@delicity/capacitor-thermal-printer 7.0.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 (100) hide show
  1. package/DelicityThermalPrinter.podspec +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +649 -0
  4. package/android/build.gradle +122 -0
  5. package/android/src/main/AndroidManifest.xml +38 -0
  6. package/android/src/main/java/com/delicity/thermalprinter/Logger.kt +50 -0
  7. package/android/src/main/java/com/delicity/thermalprinter/ThermalPrinterEngine.kt +528 -0
  8. package/android/src/main/java/com/delicity/thermalprinter/ThermalPrinterPlugin.kt +334 -0
  9. package/android/src/main/java/com/delicity/thermalprinter/adapters/BleAdapter.kt +125 -0
  10. package/android/src/main/java/com/delicity/thermalprinter/adapters/BrotherAdapter.kt +206 -0
  11. package/android/src/main/java/com/delicity/thermalprinter/adapters/EpsonAdapter.kt +384 -0
  12. package/android/src/main/java/com/delicity/thermalprinter/adapters/EscPosAdapter.kt +160 -0
  13. package/android/src/main/java/com/delicity/thermalprinter/adapters/EscPosCommands.kt +42 -0
  14. package/android/src/main/java/com/delicity/thermalprinter/adapters/EscPosTextEncoder.kt +138 -0
  15. package/android/src/main/java/com/delicity/thermalprinter/adapters/PrinterAdapter.kt +95 -0
  16. package/android/src/main/java/com/delicity/thermalprinter/adapters/RawTcpAdapter.kt +96 -0
  17. package/android/src/main/java/com/delicity/thermalprinter/adapters/SdkContract.kt +158 -0
  18. package/android/src/main/java/com/delicity/thermalprinter/adapters/SdkReflect.kt +104 -0
  19. package/android/src/main/java/com/delicity/thermalprinter/adapters/StarAdapter.kt +322 -0
  20. package/android/src/main/java/com/delicity/thermalprinter/adapters/UsbAdapter.kt +248 -0
  21. package/android/src/main/java/com/delicity/thermalprinter/adapters/ZebraAdapter.kt +207 -0
  22. package/android/src/main/java/com/delicity/thermalprinter/discovery/AdapterPriority.kt +39 -0
  23. package/android/src/main/java/com/delicity/thermalprinter/discovery/BleScanner.kt +70 -0
  24. package/android/src/main/java/com/delicity/thermalprinter/discovery/BluetoothClassicScanner.kt +112 -0
  25. package/android/src/main/java/com/delicity/thermalprinter/discovery/DiscoveryManager.kt +136 -0
  26. package/android/src/main/java/com/delicity/thermalprinter/discovery/TcpScanner.kt +96 -0
  27. package/android/src/main/java/com/delicity/thermalprinter/image/ImageCache.kt +88 -0
  28. package/android/src/main/java/com/delicity/thermalprinter/image/ImageProcessor.kt +220 -0
  29. package/android/src/main/java/com/delicity/thermalprinter/image/TextRasterizer.kt +99 -0
  30. package/android/src/main/java/com/delicity/thermalprinter/model/Models.kt +206 -0
  31. package/android/src/main/java/com/delicity/thermalprinter/model/PrintItem.kt +100 -0
  32. package/android/src/main/java/com/delicity/thermalprinter/store/PrinterStore.kt +71 -0
  33. package/android/src/main/java/com/delicity/thermalprinter/transport/BleGattClient.kt +201 -0
  34. package/android/src/main/java/com/delicity/thermalprinter/transport/BluetoothSppTransport.kt +110 -0
  35. package/android/src/main/java/com/delicity/thermalprinter/transport/ByteTransport.kt +18 -0
  36. package/android/src/main/java/com/delicity/thermalprinter/transport/TcpTransport.kt +83 -0
  37. package/dist/esm/adapters/dedup.d.ts +26 -0
  38. package/dist/esm/adapters/dedup.js +66 -0
  39. package/dist/esm/adapters/dedup.js.map +1 -0
  40. package/dist/esm/adapters/priority.d.ts +29 -0
  41. package/dist/esm/adapters/priority.js +55 -0
  42. package/dist/esm/adapters/priority.js.map +1 -0
  43. package/dist/esm/core/enums.d.ts +61 -0
  44. package/dist/esm/core/enums.js +25 -0
  45. package/dist/esm/core/enums.js.map +1 -0
  46. package/dist/esm/core/errors.d.ts +16 -0
  47. package/dist/esm/core/errors.js +53 -0
  48. package/dist/esm/core/errors.js.map +1 -0
  49. package/dist/esm/core/escpos-text.d.ts +33 -0
  50. package/dist/esm/core/escpos-text.js +239 -0
  51. package/dist/esm/core/escpos-text.js.map +1 -0
  52. package/dist/esm/core/imaging.d.ts +91 -0
  53. package/dist/esm/core/imaging.js +184 -0
  54. package/dist/esm/core/imaging.js.map +1 -0
  55. package/dist/esm/core/models.d.ts +131 -0
  56. package/dist/esm/core/models.js +2 -0
  57. package/dist/esm/core/models.js.map +1 -0
  58. package/dist/esm/core/options.d.ts +154 -0
  59. package/dist/esm/core/options.js +2 -0
  60. package/dist/esm/core/options.js.map +1 -0
  61. package/dist/esm/core/text.d.ts +138 -0
  62. package/dist/esm/core/text.js +14 -0
  63. package/dist/esm/core/text.js.map +1 -0
  64. package/dist/esm/definitions.d.ts +155 -0
  65. package/dist/esm/definitions.js +2 -0
  66. package/dist/esm/definitions.js.map +1 -0
  67. package/dist/esm/index.d.ts +15 -0
  68. package/dist/esm/index.js +18 -0
  69. package/dist/esm/index.js.map +1 -0
  70. package/dist/esm/web.d.ts +63 -0
  71. package/dist/esm/web.js +112 -0
  72. package/dist/esm/web.js.map +1 -0
  73. package/dist/plugin.cjs.js +224 -0
  74. package/dist/plugin.cjs.js.map +1 -0
  75. package/dist/plugin.js +227 -0
  76. package/dist/plugin.js.map +1 -0
  77. package/ios/Plugin/Adapters/BrotherAdapter.swift +139 -0
  78. package/ios/Plugin/Adapters/EpsonAdapter.swift +131 -0
  79. package/ios/Plugin/Adapters/EscPosAdapter.swift +106 -0
  80. package/ios/Plugin/Adapters/EscPosCommands.swift +32 -0
  81. package/ios/Plugin/Adapters/EscPosTextEncoder.swift +115 -0
  82. package/ios/Plugin/Adapters/PrinterAdapter.swift +44 -0
  83. package/ios/Plugin/Adapters/RawTcpAdapter.swift +70 -0
  84. package/ios/Plugin/Adapters/StarAdapter.swift +305 -0
  85. package/ios/Plugin/Adapters/ZebraAdapter.swift +119 -0
  86. package/ios/Plugin/Discovery/AdapterPriority.swift +21 -0
  87. package/ios/Plugin/Discovery/BonjourScanner.swift +51 -0
  88. package/ios/Plugin/Discovery/DiscoveryManager.swift +86 -0
  89. package/ios/Plugin/Image/ImageCache.swift +73 -0
  90. package/ios/Plugin/Image/ImageProcessor.swift +168 -0
  91. package/ios/Plugin/Image/TextRasterizer.swift +81 -0
  92. package/ios/Plugin/Logger.swift +33 -0
  93. package/ios/Plugin/Model/Models.swift +174 -0
  94. package/ios/Plugin/Model/PrintItem.swift +111 -0
  95. package/ios/Plugin/Store/PrinterStore.swift +51 -0
  96. package/ios/Plugin/ThermalPrinterEngine.swift +395 -0
  97. package/ios/Plugin/ThermalPrinterPlugin.m +22 -0
  98. package/ios/Plugin/ThermalPrinterPlugin.swift +258 -0
  99. package/ios/Plugin/Transport/TcpTransport.swift +89 -0
  100. package/package.json +96 -0
@@ -0,0 +1,138 @@
1
+ import type { ImageSource, PrintRenderOptions } from './options';
2
+ /**
3
+ * ============================================================================
4
+ * MODÈLE DE TEXTE STYLÉ — `printText([...])`
5
+ * ============================================================================
6
+ *
7
+ * L'app envoie un TABLEAU d'items typés. Chaque item est rendu séquentiellement.
8
+ * Le sous-ensemble de styles couvre TOUT ce que l'ESC/POS standard permet ; pour
9
+ * les adapters SDK (Epson/Star/Brother), un mapping documenté est appliqué et les
10
+ * styles non supportés sont ignorés proprement (jamais d'échec dur).
11
+ *
12
+ * Voir le tableau de correspondance complet dans le README (section "printText").
13
+ */
14
+ /** Alignement horizontal. */
15
+ export type TextAlign = 'left' | 'center' | 'right';
16
+ /** Soulignement. */
17
+ export type Underline = 'none' | 'single' | 'double';
18
+ /** Police interne ESC/POS (A ≈ 12x24, B ≈ 9x17). */
19
+ export type EscPosFont = 'A' | 'B';
20
+ /**
21
+ * Page de code pour les caractères accentués. Le défaut `WPC1252`
22
+ * (Windows-1252) couvre le français. La valeur ESC t exacte est résolue par
23
+ * `CODE_PAGE_TO_ESC_T` (surclassable via `codePageId`).
24
+ */
25
+ export type CodePage = 'CP437' | 'CP850' | 'CP858' | 'WPC1252' | 'CP852' | 'CP866';
26
+ /** Symbologies code-barres ESC/POS (GS k). */
27
+ export type BarcodeSymbology = 'UPC_A' | 'UPC_E' | 'EAN13' | 'EAN8' | 'CODE39' | 'ITF' | 'CODABAR' | 'CODE93' | 'CODE128';
28
+ /** Position du texte lisible (HRI) d'un code-barres. */
29
+ export type HriPosition = 'none' | 'above' | 'below' | 'both';
30
+ /** Niveau de correction d'erreur QR. */
31
+ export type QrErrorCorrection = 'L' | 'M' | 'Q' | 'H';
32
+ /**
33
+ * Style applicable à un item `text`. Tous les champs sont optionnels ;
34
+ * chaque imprimante repart de l'état par défaut (ESC @) entre les jobs.
35
+ */
36
+ export interface TextStyle {
37
+ align?: TextAlign;
38
+ /** Gras / emphase (ESC E). */
39
+ bold?: boolean;
40
+ /** Soulignement (ESC - n). */
41
+ underline?: Underline;
42
+ /** Police interne (ESC M). */
43
+ font?: EscPosFont;
44
+ /** Multiplicateur de largeur 1..8 (GS ! partie haute). */
45
+ widthMultiplier?: number;
46
+ /** Multiplicateur de hauteur 1..8 (GS ! partie basse). */
47
+ heightMultiplier?: number;
48
+ /** Double frappe (rendu plus dense) (ESC G). */
49
+ doubleStrike?: boolean;
50
+ /** Vidéo inverse : blanc sur noir (GS B). */
51
+ invert?: boolean;
52
+ /** Texte à l'envers (ESC { ). */
53
+ upsideDown?: boolean;
54
+ /** Rotation 90° dans le sens horaire (ESC V). */
55
+ rotate90?: boolean;
56
+ /** Espacement inter-caractères en points (ESC SP n). */
57
+ letterSpacing?: number;
58
+ /** Interligne en points (ESC 3 n). `undefined` = interligne par défaut (ESC 2). */
59
+ lineSpacing?: number;
60
+ /** Page de code pour les accents. Défaut hérité des options globales. */
61
+ codePage?: CodePage;
62
+ /** Override numérique brut de la commande ESC t (priorité sur codePage). */
63
+ codePageId?: number;
64
+ /** Ajoute un saut de ligne (LF) après le texte. Défaut `true`. */
65
+ newline?: boolean;
66
+ }
67
+ /** Item: texte stylé. */
68
+ export interface TextItem {
69
+ type: 'text';
70
+ value: string;
71
+ style?: TextStyle;
72
+ }
73
+ /** Item: avance papier de N lignes. */
74
+ export interface FeedItem {
75
+ type: 'feed';
76
+ lines?: number;
77
+ }
78
+ /** Item: coupe papier. */
79
+ export interface CutItem {
80
+ type: 'cut';
81
+ mode?: 'full' | 'partial';
82
+ /** Lignes d'avance avant la coupe. Défaut 0. */
83
+ feedBefore?: number;
84
+ }
85
+ /** Item: ligne de séparation pleine largeur (répétition d'un caractère). */
86
+ export interface DividerItem {
87
+ type: 'divider';
88
+ /** Caractère répété. Défaut '-'. */
89
+ char?: string;
90
+ /** Nombre de colonnes ; si omis, déduit de la largeur papier/police. */
91
+ columns?: number;
92
+ style?: Pick<TextStyle, 'align' | 'bold' | 'font'>;
93
+ }
94
+ /** Item: QR code natif (GS ( k). */
95
+ export interface QrCodeItem {
96
+ type: 'qrcode';
97
+ value: string;
98
+ /** Taille du module 1..16. Défaut 6. */
99
+ size?: number;
100
+ errorCorrection?: QrErrorCorrection;
101
+ align?: TextAlign;
102
+ }
103
+ /** Item: code-barres 1D natif (GS k). */
104
+ export interface BarcodeItem {
105
+ type: 'barcode';
106
+ value: string;
107
+ symbology: BarcodeSymbology;
108
+ /** Hauteur en points. Défaut 80. */
109
+ height?: number;
110
+ /** Largeur du module 2..6. Défaut 3. */
111
+ width?: number;
112
+ hri?: HriPosition;
113
+ align?: TextAlign;
114
+ }
115
+ /** Item: ouverture tiroir-caisse. */
116
+ export interface CashDrawerItem {
117
+ type: 'cashDrawer';
118
+ pin?: 2 | 5;
119
+ }
120
+ /** Item: image intercalée dans le flux texte (réutilise le pipeline image). */
121
+ export interface ImageItem {
122
+ type: 'image';
123
+ image: ImageSource;
124
+ render?: PrintRenderOptions;
125
+ }
126
+ /** Item: octets bruts (échappatoire avancée) — base64. */
127
+ export interface RawItem {
128
+ type: 'raw';
129
+ bytesBase64: string;
130
+ }
131
+ /** Union discriminée de tous les items imprimables. */
132
+ export type PrintItem = TextItem | FeedItem | CutItem | DividerItem | QrCodeItem | BarcodeItem | CashDrawerItem | ImageItem | RawItem;
133
+ /**
134
+ * Correspondance page de code -> argument de la commande ESC t (n).
135
+ * Ces valeurs sont les plus répandues ; certaines imprimantes diffèrent
136
+ * (override possible via `TextStyle.codePageId`).
137
+ */
138
+ export declare const CODE_PAGE_TO_ESC_T: Record<CodePage, number>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Correspondance page de code -> argument de la commande ESC t (n).
3
+ * Ces valeurs sont les plus répandues ; certaines imprimantes diffèrent
4
+ * (override possible via `TextStyle.codePageId`).
5
+ */
6
+ export const CODE_PAGE_TO_ESC_T = {
7
+ CP437: 0,
8
+ CP850: 2,
9
+ CP858: 19,
10
+ WPC1252: 16,
11
+ CP852: 18,
12
+ CP866: 17,
13
+ };
14
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/core/text.ts"],"names":[],"mappings":"AA0KA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA6B;IAC1D,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;CACV,CAAC","sourcesContent":["import type { ImageSource, PrintRenderOptions } from './options';\n\n/**\n * ============================================================================\n * MODÈLE DE TEXTE STYLÉ — `printText([...])`\n * ============================================================================\n *\n * L'app envoie un TABLEAU d'items typés. Chaque item est rendu séquentiellement.\n * Le sous-ensemble de styles couvre TOUT ce que l'ESC/POS standard permet ; pour\n * les adapters SDK (Epson/Star/Brother), un mapping documenté est appliqué et les\n * styles non supportés sont ignorés proprement (jamais d'échec dur).\n *\n * Voir le tableau de correspondance complet dans le README (section \"printText\").\n */\n\n/** Alignement horizontal. */\nexport type TextAlign = 'left' | 'center' | 'right';\n\n/** Soulignement. */\nexport type Underline = 'none' | 'single' | 'double';\n\n/** Police interne ESC/POS (A ≈ 12x24, B ≈ 9x17). */\nexport type EscPosFont = 'A' | 'B';\n\n/**\n * Page de code pour les caractères accentués. Le défaut `WPC1252`\n * (Windows-1252) couvre le français. La valeur ESC t exacte est résolue par\n * `CODE_PAGE_TO_ESC_T` (surclassable via `codePageId`).\n */\nexport type CodePage = 'CP437' | 'CP850' | 'CP858' | 'WPC1252' | 'CP852' | 'CP866';\n\n/** Symbologies code-barres ESC/POS (GS k). */\nexport type BarcodeSymbology =\n | 'UPC_A'\n | 'UPC_E'\n | 'EAN13'\n | 'EAN8'\n | 'CODE39'\n | 'ITF'\n | 'CODABAR'\n | 'CODE93'\n | 'CODE128';\n\n/** Position du texte lisible (HRI) d'un code-barres. */\nexport type HriPosition = 'none' | 'above' | 'below' | 'both';\n\n/** Niveau de correction d'erreur QR. */\nexport type QrErrorCorrection = 'L' | 'M' | 'Q' | 'H';\n\n/**\n * Style applicable à un item `text`. Tous les champs sont optionnels ;\n * chaque imprimante repart de l'état par défaut (ESC @) entre les jobs.\n */\nexport interface TextStyle {\n align?: TextAlign;\n /** Gras / emphase (ESC E). */\n bold?: boolean;\n /** Soulignement (ESC - n). */\n underline?: Underline;\n /** Police interne (ESC M). */\n font?: EscPosFont;\n /** Multiplicateur de largeur 1..8 (GS ! partie haute). */\n widthMultiplier?: number;\n /** Multiplicateur de hauteur 1..8 (GS ! partie basse). */\n heightMultiplier?: number;\n /** Double frappe (rendu plus dense) (ESC G). */\n doubleStrike?: boolean;\n /** Vidéo inverse : blanc sur noir (GS B). */\n invert?: boolean;\n /** Texte à l'envers (ESC { ). */\n upsideDown?: boolean;\n /** Rotation 90° dans le sens horaire (ESC V). */\n rotate90?: boolean;\n /** Espacement inter-caractères en points (ESC SP n). */\n letterSpacing?: number;\n /** Interligne en points (ESC 3 n). `undefined` = interligne par défaut (ESC 2). */\n lineSpacing?: number;\n /** Page de code pour les accents. Défaut hérité des options globales. */\n codePage?: CodePage;\n /** Override numérique brut de la commande ESC t (priorité sur codePage). */\n codePageId?: number;\n /** Ajoute un saut de ligne (LF) après le texte. Défaut `true`. */\n newline?: boolean;\n}\n\n/** Item: texte stylé. */\nexport interface TextItem {\n type: 'text';\n value: string;\n style?: TextStyle;\n}\n\n/** Item: avance papier de N lignes. */\nexport interface FeedItem {\n type: 'feed';\n lines?: number; // défaut 1\n}\n\n/** Item: coupe papier. */\nexport interface CutItem {\n type: 'cut';\n mode?: 'full' | 'partial'; // défaut 'partial'\n /** Lignes d'avance avant la coupe. Défaut 0. */\n feedBefore?: number;\n}\n\n/** Item: ligne de séparation pleine largeur (répétition d'un caractère). */\nexport interface DividerItem {\n type: 'divider';\n /** Caractère répété. Défaut '-'. */\n char?: string;\n /** Nombre de colonnes ; si omis, déduit de la largeur papier/police. */\n columns?: number;\n style?: Pick<TextStyle, 'align' | 'bold' | 'font'>;\n}\n\n/** Item: QR code natif (GS ( k). */\nexport interface QrCodeItem {\n type: 'qrcode';\n value: string;\n /** Taille du module 1..16. Défaut 6. */\n size?: number;\n errorCorrection?: QrErrorCorrection; // défaut 'M'\n align?: TextAlign; // défaut 'center'\n}\n\n/** Item: code-barres 1D natif (GS k). */\nexport interface BarcodeItem {\n type: 'barcode';\n value: string;\n symbology: BarcodeSymbology;\n /** Hauteur en points. Défaut 80. */\n height?: number;\n /** Largeur du module 2..6. Défaut 3. */\n width?: number;\n hri?: HriPosition; // défaut 'below'\n align?: TextAlign; // défaut 'center'\n}\n\n/** Item: ouverture tiroir-caisse. */\nexport interface CashDrawerItem {\n type: 'cashDrawer';\n pin?: 2 | 5; // défaut 2\n}\n\n/** Item: image intercalée dans le flux texte (réutilise le pipeline image). */\nexport interface ImageItem {\n type: 'image';\n image: ImageSource;\n render?: PrintRenderOptions;\n}\n\n/** Item: octets bruts (échappatoire avancée) — base64. */\nexport interface RawItem {\n type: 'raw';\n bytesBase64: string;\n}\n\n/** Union discriminée de tous les items imprimables. */\nexport type PrintItem =\n | TextItem\n | FeedItem\n | CutItem\n | DividerItem\n | QrCodeItem\n | BarcodeItem\n | CashDrawerItem\n | ImageItem\n | RawItem;\n\n/**\n * Correspondance page de code -> argument de la commande ESC t (n).\n * Ces valeurs sont les plus répandues ; certaines imprimantes diffèrent\n * (override possible via `TextStyle.codePageId`).\n */\nexport const CODE_PAGE_TO_ESC_T: Record<CodePage, number> = {\n CP437: 0,\n CP850: 2,\n CP858: 19,\n WPC1252: 16,\n CP852: 18,\n CP866: 17,\n};\n"]}
@@ -0,0 +1,155 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ import type { ConnectOptions, DiscoverOptions, PrintImageOptions, PrintTextOptions } from './core/options';
3
+ import type { PrinterAdapterId, PrinterTransport } from './core/enums';
4
+ import type { DiscoveredPrinter, PrinterProfile, PrinterStatus, PrintJobStatus, PrintResult } from './core/models';
5
+ /**
6
+ * État d'un adapter/SDK à l'instant présent (résultat de `getActiveSdks`).
7
+ */
8
+ export interface SdkStatus {
9
+ /** Identifiant d'adapter (marque ou intégré). */
10
+ adapter: PrinterAdapterId;
11
+ /** Libellé lisible (ex. "Star StarXpand"). */
12
+ label: string;
13
+ /**
14
+ * `true` si le SDK/binaire est détecté et utilisable MAINTENANT.
15
+ * Pour les adapters intégrés (escpos, rawTcp) : toujours `true`.
16
+ * Pour les marques (star, epson, brother, zebra) : `true` si le SDK est lié.
17
+ */
18
+ available: boolean;
19
+ /**
20
+ * `true` si l'adapter dépend d'un SDK fabricant (à fournir), `false` s'il est
21
+ * intégré au plugin (ESC/POS générique, TCP brut, BLE, USB).
22
+ */
23
+ requiresSdk: boolean;
24
+ /** Transports gérés par cet adapter quand il est disponible. */
25
+ transports: PrinterTransport[];
26
+ }
27
+ /** Payload de l'event émis pendant un scan quand une imprimante est trouvée. */
28
+ export interface PrinterFoundEvent {
29
+ printer: DiscoveredPrinter;
30
+ }
31
+ /** Payload de l'event de fin de découverte. */
32
+ export interface DiscoveryCompleteEvent {
33
+ printers: DiscoveredPrinter[];
34
+ /** Sources ayant échoué (ex: SDK manquant), pour diagnostic non bloquant. */
35
+ failedSources?: string[];
36
+ }
37
+ /** Payload de changement de statut imprimante (connexion, papier, capot). */
38
+ export interface StatusChangeEvent {
39
+ status: PrinterStatus;
40
+ }
41
+ /** Payload de changement d'état d'un job d'impression. */
42
+ export interface PrintJobStatusEvent {
43
+ job: PrintJobStatus;
44
+ }
45
+ export type ThermalPrinterEvent = 'printerFound' | 'discoveryComplete' | 'statusChange' | 'printJobStatus';
46
+ /** Entrée du journal de diagnostic (ring-buffer natif). */
47
+ export interface DebugLogEntry {
48
+ ts: number;
49
+ category: string;
50
+ message: string;
51
+ [key: string]: unknown;
52
+ }
53
+ /**
54
+ * API native exposée par le plugin. C'est le contrat strict implémenté
55
+ * par Android (Kotlin), iOS (Swift) et le fallback Web.
56
+ *
57
+ * NB: l'objet exporté par `index.ts` enrichit ce contrat avec des helpers
58
+ * ergonomiques (overloads, conversions d'erreur), mais la surface native
59
+ * reste celle-ci.
60
+ */
61
+ export interface ThermalPrinterPlugin {
62
+ /**
63
+ * Lance une découverte agrégée multi-sources et renvoie la liste
64
+ * dédoublonnée et normalisée à la fin du scan.
65
+ * Émet aussi `printerFound` au fil de l'eau si `emitPartialResults`.
66
+ */
67
+ discoverPrinters(options?: DiscoverOptions): Promise<{
68
+ printers: DiscoveredPrinter[];
69
+ }>;
70
+ /** Ouvre explicitement une connexion vers une imprimante connue/découverte. */
71
+ connectPrinter(options: ConnectOptions): Promise<{
72
+ connected: boolean;
73
+ }>;
74
+ /** Ferme la connexion active (sans supprimer le profil). */
75
+ disconnectPrinter(options: {
76
+ printerId: string;
77
+ }): Promise<void>;
78
+ /**
79
+ * Enregistre une imprimante comme imprimante par défaut et persiste son profil.
80
+ * À appeler après un test d'impression réussi.
81
+ */
82
+ setDefaultPrinter(options: {
83
+ printerId: string;
84
+ }): Promise<{
85
+ profile: PrinterProfile;
86
+ }>;
87
+ /** Retourne le profil par défaut, ou null si aucun. */
88
+ getDefaultPrinter(): Promise<{
89
+ profile: PrinterProfile | null;
90
+ }>;
91
+ /** Liste tous les profils enregistrés (persistés). */
92
+ getSavedPrinters(): Promise<{
93
+ profiles: PrinterProfile[];
94
+ }>;
95
+ /** Supprime un profil enregistré (oubli total). */
96
+ removePrinter(options: {
97
+ printerId: string;
98
+ }): Promise<void>;
99
+ /**
100
+ * Imprime une image. Gère reconnexion auto, redimensionnement, binarisation,
101
+ * dithering, conversion adapter et envoi. Voir flux détaillé dans le README.
102
+ *
103
+ * La promesse se résout quand l'impression physique est terminée (best-effort
104
+ * selon transport/SDK — voir README "Fin d'impression / await").
105
+ */
106
+ printImage(options: PrintImageOptions): Promise<PrintResult>;
107
+ /**
108
+ * Imprime un tableau d'items texte stylés (+ QR/code-barres/feed/cut/image).
109
+ * Voir les types `PrintItem` / `TextStyle` et le tableau de styles dans le README.
110
+ *
111
+ * La promesse se résout quand l'impression physique est terminée (best-effort).
112
+ */
113
+ printText(options: PrintTextOptions): Promise<PrintResult>;
114
+ /** Lit le statut temps réel (si supporté par l'adapter/transport). */
115
+ getPrinterStatus(options: {
116
+ printerId?: string;
117
+ }): Promise<PrinterStatus>;
118
+ /** Demande/vérifie les permissions natives nécessaires (Bluetooth, etc.). */
119
+ requestPermissions(): Promise<PermissionStatus>;
120
+ checkPermissions(): Promise<PermissionStatus>;
121
+ /** Active/désactive le monitoring de statut en arrière-plan pour une imprimante. */
122
+ startStatusMonitor(options: {
123
+ printerId: string;
124
+ intervalMs?: number;
125
+ }): Promise<void>;
126
+ stopStatusMonitor(options: {
127
+ printerId: string;
128
+ }): Promise<void>;
129
+ /**
130
+ * Retourne l'état, à l'instant présent, de chaque adapter/SDK : quels SDK
131
+ * fabricants sont actifs (binaire détecté) et quels adapters intégrés sont
132
+ * disponibles. Utile pour un écran de diagnostic ou pour adapter l'UI.
133
+ */
134
+ getActiveSdks(): Promise<{
135
+ sdks: SdkStatus[];
136
+ }>;
137
+ /** Récupère le journal de diagnostic en mémoire (support client). */
138
+ getDebugLog(): Promise<{
139
+ log: DebugLogEntry[];
140
+ }>;
141
+ addListener(eventName: 'printerFound', listener: (event: PrinterFoundEvent) => void): Promise<PluginListenerHandle>;
142
+ addListener(eventName: 'discoveryComplete', listener: (event: DiscoveryCompleteEvent) => void): Promise<PluginListenerHandle>;
143
+ addListener(eventName: 'statusChange', listener: (event: StatusChangeEvent) => void): Promise<PluginListenerHandle>;
144
+ addListener(eventName: 'printJobStatus', listener: (event: PrintJobStatusEvent) => void): Promise<PluginListenerHandle>;
145
+ removeAllListeners(): Promise<void>;
146
+ }
147
+ /** État des permissions natives liées au transport. */
148
+ export interface PermissionStatus {
149
+ bluetooth: PermissionState;
150
+ bluetoothScan: PermissionState;
151
+ bluetoothConnect: PermissionState;
152
+ location: PermissionState;
153
+ localNetwork: PermissionState;
154
+ }
155
+ export type PermissionState = 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale' | 'unavailable';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nimport type {\n ConnectOptions,\n DiscoverOptions,\n PrintImageOptions,\n PrintTextOptions,\n} from './core/options';\nimport type { PrinterAdapterId, PrinterTransport } from './core/enums';\nimport type {\n DiscoveredPrinter,\n PrinterProfile,\n PrinterStatus,\n PrintJobStatus,\n PrintResult,\n} from './core/models';\n\n/**\n * État d'un adapter/SDK à l'instant présent (résultat de `getActiveSdks`).\n */\nexport interface SdkStatus {\n /** Identifiant d'adapter (marque ou intégré). */\n adapter: PrinterAdapterId;\n /** Libellé lisible (ex. \"Star StarXpand\"). */\n label: string;\n /**\n * `true` si le SDK/binaire est détecté et utilisable MAINTENANT.\n * Pour les adapters intégrés (escpos, rawTcp) : toujours `true`.\n * Pour les marques (star, epson, brother, zebra) : `true` si le SDK est lié.\n */\n available: boolean;\n /**\n * `true` si l'adapter dépend d'un SDK fabricant (à fournir), `false` s'il est\n * intégré au plugin (ESC/POS générique, TCP brut, BLE, USB).\n */\n requiresSdk: boolean;\n /** Transports gérés par cet adapter quand il est disponible. */\n transports: PrinterTransport[];\n}\n\n/** Payload de l'event émis pendant un scan quand une imprimante est trouvée. */\nexport interface PrinterFoundEvent {\n printer: DiscoveredPrinter;\n}\n\n/** Payload de l'event de fin de découverte. */\nexport interface DiscoveryCompleteEvent {\n printers: DiscoveredPrinter[];\n /** Sources ayant échoué (ex: SDK manquant), pour diagnostic non bloquant. */\n failedSources?: string[];\n}\n\n/** Payload de changement de statut imprimante (connexion, papier, capot). */\nexport interface StatusChangeEvent {\n status: PrinterStatus;\n}\n\n/** Payload de changement d'état d'un job d'impression. */\nexport interface PrintJobStatusEvent {\n job: PrintJobStatus;\n}\n\nexport type ThermalPrinterEvent =\n | 'printerFound'\n | 'discoveryComplete'\n | 'statusChange'\n | 'printJobStatus';\n\n/** Entrée du journal de diagnostic (ring-buffer natif). */\nexport interface DebugLogEntry {\n ts: number;\n category: string;\n message: string;\n [key: string]: unknown;\n}\n\n/**\n * API native exposée par le plugin. C'est le contrat strict implémenté\n * par Android (Kotlin), iOS (Swift) et le fallback Web.\n *\n * NB: l'objet exporté par `index.ts` enrichit ce contrat avec des helpers\n * ergonomiques (overloads, conversions d'erreur), mais la surface native\n * reste celle-ci.\n */\nexport interface ThermalPrinterPlugin {\n /**\n * Lance une découverte agrégée multi-sources et renvoie la liste\n * dédoublonnée et normalisée à la fin du scan.\n * Émet aussi `printerFound` au fil de l'eau si `emitPartialResults`.\n */\n discoverPrinters(options?: DiscoverOptions): Promise<{ printers: DiscoveredPrinter[] }>;\n\n /** Ouvre explicitement une connexion vers une imprimante connue/découverte. */\n connectPrinter(options: ConnectOptions): Promise<{ connected: boolean }>;\n\n /** Ferme la connexion active (sans supprimer le profil). */\n disconnectPrinter(options: { printerId: string }): Promise<void>;\n\n /**\n * Enregistre une imprimante comme imprimante par défaut et persiste son profil.\n * À appeler après un test d'impression réussi.\n */\n setDefaultPrinter(options: { printerId: string }): Promise<{ profile: PrinterProfile }>;\n\n /** Retourne le profil par défaut, ou null si aucun. */\n getDefaultPrinter(): Promise<{ profile: PrinterProfile | null }>;\n\n /** Liste tous les profils enregistrés (persistés). */\n getSavedPrinters(): Promise<{ profiles: PrinterProfile[] }>;\n\n /** Supprime un profil enregistré (oubli total). */\n removePrinter(options: { printerId: string }): Promise<void>;\n\n /**\n * Imprime une image. Gère reconnexion auto, redimensionnement, binarisation,\n * dithering, conversion adapter et envoi. Voir flux détaillé dans le README.\n *\n * La promesse se résout quand l'impression physique est terminée (best-effort\n * selon transport/SDK — voir README \"Fin d'impression / await\").\n */\n printImage(options: PrintImageOptions): Promise<PrintResult>;\n\n /**\n * Imprime un tableau d'items texte stylés (+ QR/code-barres/feed/cut/image).\n * Voir les types `PrintItem` / `TextStyle` et le tableau de styles dans le README.\n *\n * La promesse se résout quand l'impression physique est terminée (best-effort).\n */\n printText(options: PrintTextOptions): Promise<PrintResult>;\n\n /** Lit le statut temps réel (si supporté par l'adapter/transport). */\n getPrinterStatus(options: { printerId?: string }): Promise<PrinterStatus>;\n\n /** Demande/vérifie les permissions natives nécessaires (Bluetooth, etc.). */\n requestPermissions(): Promise<PermissionStatus>;\n checkPermissions(): Promise<PermissionStatus>;\n\n /** Active/désactive le monitoring de statut en arrière-plan pour une imprimante. */\n startStatusMonitor(options: { printerId: string; intervalMs?: number }): Promise<void>;\n stopStatusMonitor(options: { printerId: string }): Promise<void>;\n\n /**\n * Retourne l'état, à l'instant présent, de chaque adapter/SDK : quels SDK\n * fabricants sont actifs (binaire détecté) et quels adapters intégrés sont\n * disponibles. Utile pour un écran de diagnostic ou pour adapter l'UI.\n */\n getActiveSdks(): Promise<{ sdks: SdkStatus[] }>;\n\n /** Récupère le journal de diagnostic en mémoire (support client). */\n getDebugLog(): Promise<{ log: DebugLogEntry[] }>;\n\n addListener(\n eventName: 'printerFound',\n listener: (event: PrinterFoundEvent) => void,\n ): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'discoveryComplete',\n listener: (event: DiscoveryCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'statusChange',\n listener: (event: StatusChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'printJobStatus',\n listener: (event: PrintJobStatusEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n removeAllListeners(): Promise<void>;\n}\n\n/** État des permissions natives liées au transport. */\nexport interface PermissionStatus {\n bluetooth: PermissionState;\n bluetoothScan: PermissionState;\n bluetoothConnect: PermissionState;\n location: PermissionState; // requis pour le scan BLE sur anciens Android\n localNetwork: PermissionState; // iOS Local Network usage\n}\n\nexport type PermissionState = 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale' | 'unavailable';\n"]}
@@ -0,0 +1,15 @@
1
+ import type { ThermalPrinterPlugin } from './definitions';
2
+ /**
3
+ * Point d'entrée du plugin.
4
+ *
5
+ * `registerPlugin` renvoie un proxy : sur natif il route vers Kotlin/Swift,
6
+ * sur web il charge dynamiquement l'implémentation `ThermalPrinterWeb`.
7
+ */
8
+ declare const ThermalPrinter: ThermalPrinterPlugin;
9
+ export * from './definitions';
10
+ export * from './core/enums';
11
+ export * from './core/models';
12
+ export * from './core/options';
13
+ export * from './core/text';
14
+ export * from './core/errors';
15
+ export { ThermalPrinter };
@@ -0,0 +1,18 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ /**
3
+ * Point d'entrée du plugin.
4
+ *
5
+ * `registerPlugin` renvoie un proxy : sur natif il route vers Kotlin/Swift,
6
+ * sur web il charge dynamiquement l'implémentation `ThermalPrinterWeb`.
7
+ */
8
+ const ThermalPrinter = registerPlugin('ThermalPrinter', {
9
+ web: () => import('./web').then(m => new m.ThermalPrinterWeb()),
10
+ });
11
+ export * from './definitions';
12
+ export * from './core/enums';
13
+ export * from './core/models';
14
+ export * from './core/options';
15
+ export * from './core/text';
16
+ export * from './core/errors';
17
+ export { ThermalPrinter };
18
+ //# 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;;;;;GAKG;AACH,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ThermalPrinterPlugin } from './definitions';\n\n/**\n * Point d'entrée du plugin.\n *\n * `registerPlugin` renvoie un proxy : sur natif il route vers Kotlin/Swift,\n * sur web il charge dynamiquement l'implémentation `ThermalPrinterWeb`.\n */\nconst ThermalPrinter = registerPlugin<ThermalPrinterPlugin>('ThermalPrinter', {\n web: () => import('./web').then(m => new m.ThermalPrinterWeb()),\n});\n\nexport * from './definitions';\nexport * from './core/enums';\nexport * from './core/models';\nexport * from './core/options';\nexport * from './core/text';\nexport * from './core/errors';\nexport { ThermalPrinter };\n"]}
@@ -0,0 +1,63 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { PermissionStatus, ThermalPrinterPlugin } from './definitions';
3
+ import type { ConnectOptions, DiscoverOptions, PrintImageOptions, PrintTextOptions } from './core/options';
4
+ import type { DiscoveredPrinter, PrinterProfile, PrinterStatus, PrintResult } from './core/models';
5
+ /**
6
+ * Implémentation Web (fallback navigateur / SSR).
7
+ *
8
+ * Le matériel d'impression thermique n'est pas adressable de façon fiable
9
+ * depuis un navigateur standard. On expose donc une implémentation qui :
10
+ * - persiste les profils dans localStorage (utile pour le dev UI),
11
+ * - rejette explicitement les opérations matérielles avec SDK_NOT_AVAILABLE.
12
+ *
13
+ * Cela permet de développer toute l'UI Capacitor sans device.
14
+ */
15
+ export declare class ThermalPrinterWeb extends WebPlugin implements ThermalPrinterPlugin {
16
+ private readonly storageKey;
17
+ discoverPrinters(_options?: DiscoverOptions): Promise<{
18
+ printers: DiscoveredPrinter[];
19
+ }>;
20
+ connectPrinter(_options: ConnectOptions): Promise<{
21
+ connected: boolean;
22
+ }>;
23
+ disconnectPrinter(_options: {
24
+ printerId: string;
25
+ }): Promise<void>;
26
+ setDefaultPrinter(options: {
27
+ printerId: string;
28
+ }): Promise<{
29
+ profile: PrinterProfile;
30
+ }>;
31
+ getDefaultPrinter(): Promise<{
32
+ profile: PrinterProfile | null;
33
+ }>;
34
+ getSavedPrinters(): Promise<{
35
+ profiles: PrinterProfile[];
36
+ }>;
37
+ removePrinter(options: {
38
+ printerId: string;
39
+ }): Promise<void>;
40
+ printImage(_options: PrintImageOptions): Promise<PrintResult>;
41
+ printText(_options: PrintTextOptions): Promise<PrintResult>;
42
+ getPrinterStatus(_options: {
43
+ printerId?: string;
44
+ }): Promise<PrinterStatus>;
45
+ requestPermissions(): Promise<PermissionStatus>;
46
+ checkPermissions(): Promise<PermissionStatus>;
47
+ startStatusMonitor(_options: {
48
+ printerId: string;
49
+ intervalMs?: number;
50
+ }): Promise<void>;
51
+ stopStatusMonitor(_options: {
52
+ printerId: string;
53
+ }): Promise<void>;
54
+ getActiveSdks(): Promise<{
55
+ sdks: import('./definitions').SdkStatus[];
56
+ }>;
57
+ getDebugLog(): Promise<{
58
+ log: import('./definitions').DebugLogEntry[];
59
+ }>;
60
+ private unsupported;
61
+ private readProfiles;
62
+ private writeProfiles;
63
+ }
@@ -0,0 +1,112 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import { PrintErrorCode } from './core/enums';
3
+ import { PrinterError } from './core/errors';
4
+ /**
5
+ * Implémentation Web (fallback navigateur / SSR).
6
+ *
7
+ * Le matériel d'impression thermique n'est pas adressable de façon fiable
8
+ * depuis un navigateur standard. On expose donc une implémentation qui :
9
+ * - persiste les profils dans localStorage (utile pour le dev UI),
10
+ * - rejette explicitement les opérations matérielles avec SDK_NOT_AVAILABLE.
11
+ *
12
+ * Cela permet de développer toute l'UI Capacitor sans device.
13
+ */
14
+ export class ThermalPrinterWeb extends WebPlugin {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.storageKey = 'delicity.thermalprinter.profiles';
18
+ }
19
+ async discoverPrinters(_options) {
20
+ // Aucune découverte matérielle possible sur le web.
21
+ return { printers: [] };
22
+ }
23
+ async connectPrinter(_options) {
24
+ throw this.unsupported('connectPrinter');
25
+ }
26
+ async disconnectPrinter(_options) {
27
+ return;
28
+ }
29
+ async setDefaultPrinter(options) {
30
+ const profiles = this.readProfiles();
31
+ const target = profiles.find(p => p.id === options.printerId);
32
+ if (!target)
33
+ throw new PrinterError({ code: PrintErrorCode.PRINTER_NOT_FOUND, message: 'Profil introuvable' });
34
+ profiles.forEach(p => (p.isDefault = p.id === options.printerId));
35
+ target.updatedAt = Date.now();
36
+ this.writeProfiles(profiles);
37
+ return { profile: target };
38
+ }
39
+ async getDefaultPrinter() {
40
+ var _a;
41
+ const profiles = this.readProfiles();
42
+ return { profile: (_a = profiles.find(p => p.isDefault)) !== null && _a !== void 0 ? _a : null };
43
+ }
44
+ async getSavedPrinters() {
45
+ return { profiles: this.readProfiles() };
46
+ }
47
+ async removePrinter(options) {
48
+ this.writeProfiles(this.readProfiles().filter(p => p.id !== options.printerId));
49
+ }
50
+ async printImage(_options) {
51
+ throw this.unsupported('printImage');
52
+ }
53
+ async printText(_options) {
54
+ throw this.unsupported('printText');
55
+ }
56
+ async getPrinterStatus(_options) {
57
+ throw this.unsupported('getPrinterStatus');
58
+ }
59
+ async requestPermissions() {
60
+ return this.checkPermissions();
61
+ }
62
+ async checkPermissions() {
63
+ return {
64
+ bluetooth: 'unavailable',
65
+ bluetoothScan: 'unavailable',
66
+ bluetoothConnect: 'unavailable',
67
+ location: 'unavailable',
68
+ localNetwork: 'unavailable',
69
+ };
70
+ }
71
+ async startStatusMonitor(_options) {
72
+ return;
73
+ }
74
+ async stopStatusMonitor(_options) {
75
+ return;
76
+ }
77
+ async getActiveSdks() {
78
+ // Aucun adapter natif n'est actif sur le web.
79
+ return {
80
+ sdks: [
81
+ { adapter: 'escpos', label: 'ESC/POS générique', available: false, requiresSdk: false, transports: ['wifi', 'ethernet', 'bluetooth', 'ble', 'usb'] },
82
+ { adapter: 'star', label: 'Star StarXpand', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth', 'ble', 'usb'] },
83
+ { adapter: 'epson', label: 'Epson ePOS2', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth', 'usb'] },
84
+ { adapter: 'brother', label: 'Brother', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth', 'ble'] },
85
+ { adapter: 'zebra', label: 'Zebra Link-OS', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth'] },
86
+ { adapter: 'rawTcp', label: 'TCP brut', available: false, requiresSdk: false, transports: ['wifi', 'ethernet'] },
87
+ ],
88
+ };
89
+ }
90
+ async getDebugLog() {
91
+ return { log: [] };
92
+ }
93
+ unsupported(method) {
94
+ return new PrinterError({
95
+ code: PrintErrorCode.SDK_NOT_AVAILABLE,
96
+ message: `${method} n'est pas disponible sur le web. Utilisez un device Android/iOS.`,
97
+ });
98
+ }
99
+ readProfiles() {
100
+ var _a;
101
+ try {
102
+ return JSON.parse((_a = localStorage.getItem(this.storageKey)) !== null && _a !== void 0 ? _a : '[]');
103
+ }
104
+ catch (_b) {
105
+ return [];
106
+ }
107
+ }
108
+ writeProfiles(profiles) {
109
+ localStorage.setItem(this.storageKey, JSON.stringify(profiles));
110
+ }
111
+ }
112
+ //# 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;AAM5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC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OAAO,EAAE,GAAG,MAAM,mEAAmE;SACtF,CAAC,CAAC;IACL,CAAC;IAEO,YAAY;;QAClB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAA,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,mCAAI,IAAI,CAAC,CAAC;QACnE,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,QAA0B;QAC9C,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n PermissionStatus,\n ThermalPrinterPlugin,\n} from './definitions';\nimport { PrintErrorCode } from './core/enums';\nimport { PrinterError } from './core/errors';\nimport type {\n ConnectOptions,\n DiscoverOptions,\n PrintImageOptions,\n PrintTextOptions,\n} from './core/options';\nimport type {\n DiscoveredPrinter,\n PrinterProfile,\n PrinterStatus,\n PrintResult,\n} from './core/models';\n\n/**\n * Implémentation Web (fallback navigateur / SSR).\n *\n * Le matériel d'impression thermique n'est pas adressable de façon fiable\n * depuis un navigateur standard. On expose donc une implémentation qui :\n * - persiste les profils dans localStorage (utile pour le dev UI),\n * - rejette explicitement les opérations matérielles avec SDK_NOT_AVAILABLE.\n *\n * Cela permet de développer toute l'UI Capacitor sans device.\n */\nexport class ThermalPrinterWeb extends WebPlugin implements ThermalPrinterPlugin {\n private readonly storageKey = 'delicity.thermalprinter.profiles';\n\n async discoverPrinters(_options?: DiscoverOptions): Promise<{ printers: DiscoveredPrinter[] }> {\n // Aucune découverte matérielle possible sur le web.\n return { printers: [] };\n }\n\n async connectPrinter(_options: ConnectOptions): Promise<{ connected: boolean }> {\n throw this.unsupported('connectPrinter');\n }\n\n async disconnectPrinter(_options: { printerId: string }): Promise<void> {\n return;\n }\n\n async setDefaultPrinter(options: { printerId: string }): Promise<{ profile: PrinterProfile }> {\n const profiles = this.readProfiles();\n const target = profiles.find(p => p.id === options.printerId);\n if (!target) throw new PrinterError({ code: PrintErrorCode.PRINTER_NOT_FOUND, message: 'Profil introuvable' });\n profiles.forEach(p => (p.isDefault = p.id === options.printerId));\n target.updatedAt = Date.now();\n this.writeProfiles(profiles);\n return { profile: target };\n }\n\n async getDefaultPrinter(): Promise<{ profile: PrinterProfile | null }> {\n const profiles = this.readProfiles();\n return { profile: profiles.find(p => p.isDefault) ?? null };\n }\n\n async getSavedPrinters(): Promise<{ profiles: PrinterProfile[] }> {\n return { profiles: this.readProfiles() };\n }\n\n async removePrinter(options: { printerId: string }): Promise<void> {\n this.writeProfiles(this.readProfiles().filter(p => p.id !== options.printerId));\n }\n\n async printImage(_options: PrintImageOptions): Promise<PrintResult> {\n throw this.unsupported('printImage');\n }\n\n async printText(_options: PrintTextOptions): Promise<PrintResult> {\n throw this.unsupported('printText');\n }\n\n async getPrinterStatus(_options: { printerId?: string }): Promise<PrinterStatus> {\n throw this.unsupported('getPrinterStatus');\n }\n\n async requestPermissions(): Promise<PermissionStatus> {\n return this.checkPermissions();\n }\n\n async checkPermissions(): Promise<PermissionStatus> {\n return {\n bluetooth: 'unavailable',\n bluetoothScan: 'unavailable',\n bluetoothConnect: 'unavailable',\n location: 'unavailable',\n localNetwork: 'unavailable',\n };\n }\n\n async startStatusMonitor(_options: { printerId: string; intervalMs?: number }): Promise<void> {\n return;\n }\n\n async stopStatusMonitor(_options: { printerId: string }): Promise<void> {\n return;\n }\n\n async getActiveSdks(): Promise<{ sdks: import('./definitions').SdkStatus[] }> {\n // Aucun adapter natif n'est actif sur le web.\n return {\n sdks: [\n { adapter: 'escpos', label: 'ESC/POS générique', available: false, requiresSdk: false, transports: ['wifi', 'ethernet', 'bluetooth', 'ble', 'usb'] },\n { adapter: 'star', label: 'Star StarXpand', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth', 'ble', 'usb'] },\n { adapter: 'epson', label: 'Epson ePOS2', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth', 'usb'] },\n { adapter: 'brother', label: 'Brother', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth', 'ble'] },\n { adapter: 'zebra', label: 'Zebra Link-OS', available: false, requiresSdk: true, transports: ['wifi', 'bluetooth'] },\n { adapter: 'rawTcp', label: 'TCP brut', available: false, requiresSdk: false, transports: ['wifi', 'ethernet'] },\n ],\n };\n }\n\n async getDebugLog(): Promise<{ log: import('./definitions').DebugLogEntry[] }> {\n return { log: [] };\n }\n\n private unsupported(method: string): PrinterError {\n return new PrinterError({\n code: PrintErrorCode.SDK_NOT_AVAILABLE,\n message: `${method} n'est pas disponible sur le web. Utilisez un device Android/iOS.`,\n });\n }\n\n private readProfiles(): PrinterProfile[] {\n try {\n return JSON.parse(localStorage.getItem(this.storageKey) ?? '[]');\n } catch {\n return [];\n }\n }\n\n private writeProfiles(profiles: PrinterProfile[]): void {\n localStorage.setItem(this.storageKey, JSON.stringify(profiles));\n }\n}\n"]}