h3-print 1.0.0 → 2.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.
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'expo.modules.h3print'
4
- version = '1.0.0'
4
+ version = '2.0.0'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  if (expoModulesCorePlugin.exists()) {
@@ -26,7 +26,7 @@ android {
26
26
  minSdkVersion safeExtGet("minSdkVersion", 24)
27
27
  targetSdkVersion safeExtGet("targetSdkVersion", 34)
28
28
  versionCode 1
29
- versionName "1.0.0"
29
+ versionName "2.0.0"
30
30
  }
31
31
 
32
32
  buildTypes {
@@ -1,22 +1,20 @@
1
- import { NativeModule } from 'expo';
2
- import type { H3PrintModuleEvents, PrintResult, PrintServiceStatus, PrintPackageInfo, PdfOptions, CleanupResult, ModuleInfo } from './H3Print.types';
3
- /**
4
- * Native module interface declaration
5
- */
6
- declare class H3PrintModuleType extends NativeModule<H3PrintModuleEvents> {
7
- printHtmlAsPdf(html: string, options?: PdfOptions | null): Promise<PrintResult>;
8
- generatePdfFromHtml(html: string, options?: PdfOptions | null): Promise<PrintResult>;
9
- printPdf(filePath: string, packageName?: string | null): Promise<PrintResult>;
10
- printText(text: string, packageName?: string | null): Promise<PrintResult>;
11
- printRaw(data: number[], packageName?: string | null): Promise<PrintResult>;
12
- printFileByPath(filePath: string, mimeType?: string | null, packageName?: string | null): Promise<PrintResult>;
13
- printFileByUri(filePath: string, mimeType?: string | null, packageName?: string | null): Promise<PrintResult>;
14
- isPrintServiceAvailable(packageName?: string | null): Promise<PrintServiceStatus>;
15
- listPrintPackages(): Promise<PrintPackageInfo[]>;
16
- getAllPrintCapablePackages(): Promise<PrintPackageInfo[]>;
17
- cleanupTempFiles(): Promise<CleanupResult>;
18
- getModuleInfo(): ModuleInfo;
1
+ import type { H3PrintModuleEvents } from './H3Print.types';
2
+ interface H3PrintModuleInterface {
3
+ printHtmlAsPdf(html: string, options?: Record<string, unknown> | null): Promise<import('./H3Print.types').PrintResult>;
4
+ generatePdfFromHtml(html: string, options?: Record<string, unknown> | null): Promise<import('./H3Print.types').PrintResult>;
5
+ printPdf(filePath: string, packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;
6
+ printText(text: string, packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;
7
+ printRaw(data: number[], packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;
8
+ printFileByPath(filePath: string, mimeType?: string | null, packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;
9
+ printFileByUri(filePath: string, mimeType?: string | null, packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;
10
+ isPrintServiceAvailable(packageName?: string | null): Promise<import('./H3Print.types').PrintServiceStatus>;
11
+ listPrintPackages(): Promise<import('./H3Print.types').PrintPackageInfo[]>;
12
+ getAllPrintCapablePackages(): Promise<import('./H3Print.types').PrintPackageInfo[]>;
13
+ cleanupTempFiles(): Promise<import('./H3Print.types').CleanupResult>;
14
+ getModuleInfo(): import('./H3Print.types').ModuleInfo;
15
+ addListener(eventName: keyof H3PrintModuleEvents, listener: (...args: unknown[]) => void): void;
16
+ removeListeners(count: number): void;
19
17
  }
20
- declare const _default: H3PrintModuleType;
18
+ declare const _default: H3PrintModuleInterface;
21
19
  export default _default;
22
20
  //# sourceMappingURL=H3PrintModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"H3PrintModule.d.ts","sourceRoot":"","sources":["../src/H3PrintModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AACzD,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,UAAU,EACX,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,OAAO,OAAO,iB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CAAC,CAAC;IAGlD,uBAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;IAG5G,iBAAiB,IAAI,OAAO,CAAC,OAAO,iBAAiB,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAG3E,0BAA0B,IAAI,OAAO,CAAC,OAAO,iBAAiB,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAGpF,gBAAgB,IAAI,OAAO,CAAC,OAAO,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAGrE,aAAa,IAAI,OAAO,iBAAiB,EAAE,UAAU,CAAC;IAGtD,WAAW,CAAC,SAAS,EAAE,MAAM,mBAAmB,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAChG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAGD,wBAAsE"}
@@ -1 +1 @@
1
- {"version":3,"file":"H3PrintModule.js","sourceRoot":"","sources":["../src/H3PrintModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA4DzD,2BAA2B;AAC3B,eAAe,mBAAmB,CAAoB,SAAS,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\nimport type {\n H3PrintModuleEvents,\n PrintResult,\n PrintServiceStatus,\n PrintPackageInfo,\n PdfOptions,\n CleanupResult,\n ModuleInfo,\n} from './H3Print.types';\n\n/**\n * Native module interface declaration\n */\ndeclare class H3PrintModuleType extends NativeModule<H3PrintModuleEvents> {\n // Main HTML to PDF printing\n printHtmlAsPdf(html: string, options?: PdfOptions | null): Promise<PrintResult>;\n\n // Generate PDF without printing\n generatePdfFromHtml(html: string, options?: PdfOptions | null): Promise<PrintResult>;\n\n // Print existing PDF file\n printPdf(filePath: string, packageName?: string | null): Promise<PrintResult>;\n\n // Print plain text\n printText(text: string, packageName?: string | null): Promise<PrintResult>;\n\n // Print raw bytes (ESC/POS)\n printRaw(data: number[], packageName?: string | null): Promise<PrintResult>;\n\n // Print file using path (your discovered intent pattern)\n printFileByPath(\n filePath: string,\n mimeType?: string | null,\n packageName?: string | null\n ): Promise<PrintResult>;\n\n // Print file using URI\n printFileByUri(\n filePath: string,\n mimeType?: string | null,\n packageName?: string | null\n ): Promise<PrintResult>;\n\n // Check print service availability\n isPrintServiceAvailable(packageName?: string | null): Promise<PrintServiceStatus>;\n\n // List print packages\n listPrintPackages(): Promise<PrintPackageInfo[]>;\n\n // Get all print-capable packages\n getAllPrintCapablePackages(): Promise<PrintPackageInfo[]>;\n\n // Cleanup temporary files\n cleanupTempFiles(): Promise<CleanupResult>;\n\n // Get module info (synchronous)\n getModuleInfo(): ModuleInfo;\n}\n\n// Export the native module\nexport default requireNativeModule<H3PrintModuleType>('H3Print');"]}
1
+ {"version":3,"file":"H3PrintModule.js","sourceRoot":"","sources":["../src/H3PrintModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAsD3C,2BAA2B;AAC3B,eAAe,mBAAmB,CAAyB,SAAS,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo';\nimport type { H3PrintModuleEvents } from './H3Print.types';\n\n// Define the module interface without extending NativeModule\ninterface H3PrintModuleInterface {\n // Main HTML to PDF printing\n printHtmlAsPdf(html: string, options?: Record<string, unknown> | null): Promise<import('./H3Print.types').PrintResult>;\n\n // Generate PDF without printing\n generatePdfFromHtml(html: string, options?: Record<string, unknown> | null): Promise<import('./H3Print.types').PrintResult>;\n\n // Print existing PDF file\n printPdf(filePath: string, packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;\n\n // Print plain text\n printText(text: string, packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;\n\n // Print raw bytes (ESC/POS)\n printRaw(data: number[], packageName?: string | null): Promise<import('./H3Print.types').PrintResult>;\n\n // Print file using path\n printFileByPath(\n filePath: string,\n mimeType?: string | null,\n packageName?: string | null\n ): Promise<import('./H3Print.types').PrintResult>;\n\n // Print file using URI\n printFileByUri(\n filePath: string,\n mimeType?: string | null,\n packageName?: string | null\n ): Promise<import('./H3Print.types').PrintResult>;\n\n // Check print service availability\n isPrintServiceAvailable(packageName?: string | null): Promise<import('./H3Print.types').PrintServiceStatus>;\n\n // List print packages\n listPrintPackages(): Promise<import('./H3Print.types').PrintPackageInfo[]>;\n\n // Get all print-capable packages\n getAllPrintCapablePackages(): Promise<import('./H3Print.types').PrintPackageInfo[]>;\n\n // Cleanup temporary files\n cleanupTempFiles(): Promise<import('./H3Print.types').CleanupResult>;\n\n // Get module info (synchronous)\n getModuleInfo(): import('./H3Print.types').ModuleInfo;\n\n // Event emitter methods (provided by native module)\n addListener(eventName: keyof H3PrintModuleEvents, listener: (...args: unknown[]) => void): void;\n removeListeners(count: number): void;\n}\n\n// Export the native module\nexport default requireNativeModule<H3PrintModuleInterface>('H3Print');"]}
package/build/index.d.ts CHANGED
@@ -1,3 +1,220 @@
1
- export { default } from './H3PrintModule';
2
- export * from './H3Print.types';
1
+ import { type Subscription } from 'expo-modules-core';
2
+ import type { PrintResult, PrintServiceStatus, PrintPackageInfo, PdfOptions, PrintHtmlOptions, CleanupResult, ModuleInfo, EscPosCommand, ReceiptTemplateData } from './H3Print.types';
3
+ export type { PrintResult, PrintServiceStatus, PrintPackageInfo, PdfOptions, PrintHtmlOptions, CleanupResult, ModuleInfo, EscPosCommand, ReceiptTemplateData, };
4
+ /**
5
+ * Subscribe to print success events
6
+ */
7
+ export declare function addPrintSuccessListener(listener: (event: {
8
+ pdfPath: string;
9
+ }) => void): Subscription;
10
+ /**
11
+ * Subscribe to print error events
12
+ */
13
+ export declare function addPrintErrorListener(listener: (event: {
14
+ error: string;
15
+ }) => void): Subscription;
16
+ /**
17
+ * Subscribe to PDF generation events
18
+ */
19
+ export declare function addPdfGeneratedListener(listener: (event: {
20
+ pdfPath: string;
21
+ }) => void): Subscription;
22
+ /**
23
+ * Print HTML content as PDF (RECOMMENDED)
24
+ * Converts HTML to PDF and sends to the silent print service
25
+ *
26
+ * @param html - HTML string to print
27
+ * @param options - Print options
28
+ * @returns Promise with print result
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const result = await printHtmlAsPdf('<h1>Hello</h1>', {
33
+ * pageWidth: 384,
34
+ * packageName: 'com.bld.settings.print'
35
+ * });
36
+ * ```
37
+ */
38
+ export declare function printHtmlAsPdf(html: string, options?: PrintHtmlOptions): Promise<PrintResult>;
39
+ /**
40
+ * Generate PDF from HTML without printing
41
+ * Useful for preview or saving
42
+ *
43
+ * @param html - HTML string to convert
44
+ * @param options - PDF generation options
45
+ * @returns Promise with PDF file path
46
+ */
47
+ export declare function generatePdfFromHtml(html: string, options?: PdfOptions): Promise<PrintResult>;
48
+ /**
49
+ * Print an existing PDF file
50
+ *
51
+ * @param filePath - Path to the PDF file
52
+ * @param packageName - Optional print package name
53
+ */
54
+ export declare function printPdf(filePath: string, packageName?: string): Promise<PrintResult>;
55
+ /**
56
+ * Print plain text
57
+ *
58
+ * @param text - Text to print
59
+ * @param packageName - Optional print package name
60
+ */
61
+ export declare function printText(text: string, packageName?: string): Promise<PrintResult>;
62
+ /**
63
+ * Print raw bytes (ESC/POS commands for thermal printers)
64
+ *
65
+ * @param data - Array of byte values
66
+ * @param packageName - Optional print package name
67
+ */
68
+ export declare function printRaw(data: number[], packageName?: string): Promise<PrintResult>;
69
+ /**
70
+ * Print file using file path in EXTRA_TEXT
71
+ * Uses the intent pattern you discovered
72
+ *
73
+ * @param filePath - Absolute path to the file
74
+ * @param mimeType - MIME type (default: application/pdf)
75
+ * @param packageName - Optional print package name
76
+ */
77
+ export declare function printFileByPath(filePath: string, mimeType?: string, packageName?: string): Promise<PrintResult>;
78
+ /**
79
+ * Print file using FileProvider URI
80
+ *
81
+ * @param filePath - Path to the file
82
+ * @param mimeType - MIME type
83
+ * @param packageName - Optional print package name
84
+ */
85
+ export declare function printFileByUri(filePath: string, mimeType?: string, packageName?: string): Promise<PrintResult>;
86
+ /**
87
+ * Check if the print service is available
88
+ *
89
+ * @param packageName - Package name to check (defaults to com.bld.settings.print)
90
+ */
91
+ export declare function isPrintServiceAvailable(packageName?: string): Promise<PrintServiceStatus>;
92
+ /**
93
+ * List available print-related packages
94
+ */
95
+ export declare function listPrintPackages(): Promise<PrintPackageInfo[]>;
96
+ /**
97
+ * Get all packages capable of handling print intents
98
+ */
99
+ export declare function getAllPrintCapablePackages(): Promise<PrintPackageInfo[]>;
100
+ /**
101
+ * Clean up temporary print files
102
+ */
103
+ export declare function cleanupTempFiles(): Promise<CleanupResult>;
104
+ /**
105
+ * Get module information
106
+ */
107
+ export declare function getModuleInfo(): ModuleInfo;
108
+ export declare const ESC_POS: {
109
+ INIT: EscPosCommand;
110
+ LF: EscPosCommand;
111
+ CR: EscPosCommand;
112
+ CUT_FULL: EscPosCommand;
113
+ CUT_PARTIAL: EscPosCommand;
114
+ FEED_AND_CUT: EscPosCommand;
115
+ BOLD_ON: EscPosCommand;
116
+ BOLD_OFF: EscPosCommand;
117
+ UNDERLINE_ON: EscPosCommand;
118
+ UNDERLINE_ON_2: EscPosCommand;
119
+ UNDERLINE_OFF: EscPosCommand;
120
+ ALIGN_LEFT: EscPosCommand;
121
+ ALIGN_CENTER: EscPosCommand;
122
+ ALIGN_RIGHT: EscPosCommand;
123
+ DOUBLE_HEIGHT_ON: EscPosCommand;
124
+ DOUBLE_WIDTH_ON: EscPosCommand;
125
+ DOUBLE_SIZE_ON: EscPosCommand;
126
+ NORMAL_SIZE: EscPosCommand;
127
+ FONT_A: EscPosCommand;
128
+ FONT_B: EscPosCommand;
129
+ INVERT_ON: EscPosCommand;
130
+ INVERT_OFF: EscPosCommand;
131
+ lineSpacing: (n: number) => EscPosCommand;
132
+ LINE_SPACING_DEFAULT: EscPosCommand;
133
+ feedLines: (n: number) => EscPosCommand;
134
+ setCharSize: (width: number, height: number) => EscPosCommand;
135
+ textToBytes: (text: string) => number[];
136
+ buildCommand: (...commands: (EscPosCommand | number[])[]) => number[];
137
+ horizontalLine: (char?: string, width?: number) => number[];
138
+ formattedLine: (left: string, right: string, totalWidth?: number, fillChar?: string) => number[];
139
+ centerText: (text: string, width?: number) => number[];
140
+ };
141
+ /**
142
+ * Print a receipt from template data
143
+ * This is a convenience function that handles the full flow
144
+ *
145
+ * @param templateData - Receipt data
146
+ * @param generateHtml - Function to generate HTML from template data
147
+ * @param options - Print options
148
+ */
149
+ export declare function printReceipt<T>(templateData: T, generateHtml: (data: T) => string, options?: PrintHtmlOptions): Promise<PrintResult>;
150
+ /**
151
+ * Print with automatic fallback
152
+ * Tries different methods until one succeeds
153
+ *
154
+ * @param html - HTML to print
155
+ * @param options - Print options
156
+ */
157
+ export declare function printWithFallback(html: string, options?: PrintHtmlOptions): Promise<PrintResult>;
158
+ /**
159
+ * Discover available print services on the device
160
+ */
161
+ export declare function discoverPrintServices(): Promise<{
162
+ defaultAvailable: boolean;
163
+ defaultPackage: string;
164
+ allPackages: PrintPackageInfo[];
165
+ }>;
166
+ declare const _default: {
167
+ printHtmlAsPdf: typeof printHtmlAsPdf;
168
+ generatePdfFromHtml: typeof generatePdfFromHtml;
169
+ printPdf: typeof printPdf;
170
+ printText: typeof printText;
171
+ printRaw: typeof printRaw;
172
+ printFileByPath: typeof printFileByPath;
173
+ printFileByUri: typeof printFileByUri;
174
+ isPrintServiceAvailable: typeof isPrintServiceAvailable;
175
+ listPrintPackages: typeof listPrintPackages;
176
+ getAllPrintCapablePackages: typeof getAllPrintCapablePackages;
177
+ cleanupTempFiles: typeof cleanupTempFiles;
178
+ getModuleInfo: typeof getModuleInfo;
179
+ printReceipt: typeof printReceipt;
180
+ printWithFallback: typeof printWithFallback;
181
+ discoverPrintServices: typeof discoverPrintServices;
182
+ addPrintSuccessListener: typeof addPrintSuccessListener;
183
+ addPrintErrorListener: typeof addPrintErrorListener;
184
+ addPdfGeneratedListener: typeof addPdfGeneratedListener;
185
+ ESC_POS: {
186
+ INIT: EscPosCommand;
187
+ LF: EscPosCommand;
188
+ CR: EscPosCommand;
189
+ CUT_FULL: EscPosCommand;
190
+ CUT_PARTIAL: EscPosCommand;
191
+ FEED_AND_CUT: EscPosCommand;
192
+ BOLD_ON: EscPosCommand;
193
+ BOLD_OFF: EscPosCommand;
194
+ UNDERLINE_ON: EscPosCommand;
195
+ UNDERLINE_ON_2: EscPosCommand;
196
+ UNDERLINE_OFF: EscPosCommand;
197
+ ALIGN_LEFT: EscPosCommand;
198
+ ALIGN_CENTER: EscPosCommand;
199
+ ALIGN_RIGHT: EscPosCommand;
200
+ DOUBLE_HEIGHT_ON: EscPosCommand;
201
+ DOUBLE_WIDTH_ON: EscPosCommand;
202
+ DOUBLE_SIZE_ON: EscPosCommand;
203
+ NORMAL_SIZE: EscPosCommand;
204
+ FONT_A: EscPosCommand;
205
+ FONT_B: EscPosCommand;
206
+ INVERT_ON: EscPosCommand;
207
+ INVERT_OFF: EscPosCommand;
208
+ lineSpacing: (n: number) => EscPosCommand;
209
+ LINE_SPACING_DEFAULT: EscPosCommand;
210
+ feedLines: (n: number) => EscPosCommand;
211
+ setCharSize: (width: number, height: number) => EscPosCommand;
212
+ textToBytes: (text: string) => number[];
213
+ buildCommand: (...commands: (EscPosCommand | number[])[]) => number[];
214
+ horizontalLine: (char?: string, width?: number) => number[];
215
+ formattedLine: (left: string, right: string, totalWidth?: number, fillChar?: string) => number[];
216
+ centerText: (text: string, width?: number) => number[];
217
+ };
218
+ };
219
+ export default _default;
3
220
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,cAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO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AG,aAAa;6BAGhB,MAAM,UAAU,MAAM,KAAG,aAAa;4BAOvC,MAAM,KAAG,MAAM,EAAE;oCAeT,CAAC,aAAa,GAAG,MAAM,EAAE,CAAC,EAAE,KAAG,MAAM,EAAE;gCAK5C,MAAM,UAAe,MAAM,KAAQ,MAAM,EAAE;8BAM1D,MAAM,SACL,MAAM,eACD,MAAM,aACR,MAAM,KACf,MAAM,EAAE;2BAMQ,MAAM,UAAS,MAAM,KAAQ,MAAM,EAAE;;;AAyG1D,wBA6BE"}
package/build/index.js CHANGED
@@ -1,5 +1,337 @@
1
- // Reexport the native module. On web, it will be resolved to H3PrintModule.web.ts
2
- // and on native platforms to H3PrintModule.ts
3
- export { default } from './H3PrintModule';
4
- export * from './H3Print.types';
1
+ import { EventEmitter } from 'expo-modules-core';
2
+ import H3PrintModule from './H3PrintModule';
3
+ // ============================================================
4
+ // Event Emitter Setup
5
+ // ============================================================
6
+ const emitter = new EventEmitter(H3PrintModule);
7
+ /**
8
+ * Subscribe to print success events
9
+ */
10
+ export function addPrintSuccessListener(listener) {
11
+ return emitter.addListener('onPrintSuccess', listener);
12
+ }
13
+ /**
14
+ * Subscribe to print error events
15
+ */
16
+ export function addPrintErrorListener(listener) {
17
+ return emitter.addListener('onPrintError', listener);
18
+ }
19
+ /**
20
+ * Subscribe to PDF generation events
21
+ */
22
+ export function addPdfGeneratedListener(listener) {
23
+ return emitter.addListener('onPdfGenerated', listener);
24
+ }
25
+ // ============================================================
26
+ // Main Print Functions
27
+ // ============================================================
28
+ /**
29
+ * Print HTML content as PDF (RECOMMENDED)
30
+ * Converts HTML to PDF and sends to the silent print service
31
+ *
32
+ * @param html - HTML string to print
33
+ * @param options - Print options
34
+ * @returns Promise with print result
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const result = await printHtmlAsPdf('<h1>Hello</h1>', {
39
+ * pageWidth: 384,
40
+ * packageName: 'com.bld.settings.print'
41
+ * });
42
+ * ```
43
+ */
44
+ export async function printHtmlAsPdf(html, options) {
45
+ return H3PrintModule.printHtmlAsPdf(html, options ?? null);
46
+ }
47
+ /**
48
+ * Generate PDF from HTML without printing
49
+ * Useful for preview or saving
50
+ *
51
+ * @param html - HTML string to convert
52
+ * @param options - PDF generation options
53
+ * @returns Promise with PDF file path
54
+ */
55
+ export async function generatePdfFromHtml(html, options) {
56
+ return H3PrintModule.generatePdfFromHtml(html, options ?? null);
57
+ }
58
+ /**
59
+ * Print an existing PDF file
60
+ *
61
+ * @param filePath - Path to the PDF file
62
+ * @param packageName - Optional print package name
63
+ */
64
+ export async function printPdf(filePath, packageName) {
65
+ return H3PrintModule.printPdf(filePath, packageName ?? null);
66
+ }
67
+ /**
68
+ * Print plain text
69
+ *
70
+ * @param text - Text to print
71
+ * @param packageName - Optional print package name
72
+ */
73
+ export async function printText(text, packageName) {
74
+ return H3PrintModule.printText(text, packageName ?? null);
75
+ }
76
+ /**
77
+ * Print raw bytes (ESC/POS commands for thermal printers)
78
+ *
79
+ * @param data - Array of byte values
80
+ * @param packageName - Optional print package name
81
+ */
82
+ export async function printRaw(data, packageName) {
83
+ return H3PrintModule.printRaw(data, packageName ?? null);
84
+ }
85
+ /**
86
+ * Print file using file path in EXTRA_TEXT
87
+ * Uses the intent pattern you discovered
88
+ *
89
+ * @param filePath - Absolute path to the file
90
+ * @param mimeType - MIME type (default: application/pdf)
91
+ * @param packageName - Optional print package name
92
+ */
93
+ export async function printFileByPath(filePath, mimeType, packageName) {
94
+ return H3PrintModule.printFileByPath(filePath, mimeType ?? null, packageName ?? null);
95
+ }
96
+ /**
97
+ * Print file using FileProvider URI
98
+ *
99
+ * @param filePath - Path to the file
100
+ * @param mimeType - MIME type
101
+ * @param packageName - Optional print package name
102
+ */
103
+ export async function printFileByUri(filePath, mimeType, packageName) {
104
+ return H3PrintModule.printFileByUri(filePath, mimeType ?? null, packageName ?? null);
105
+ }
106
+ // ============================================================
107
+ // Utility Functions
108
+ // ============================================================
109
+ /**
110
+ * Check if the print service is available
111
+ *
112
+ * @param packageName - Package name to check (defaults to com.bld.settings.print)
113
+ */
114
+ export async function isPrintServiceAvailable(packageName) {
115
+ return H3PrintModule.isPrintServiceAvailable(packageName ?? null);
116
+ }
117
+ /**
118
+ * List available print-related packages
119
+ */
120
+ export async function listPrintPackages() {
121
+ return H3PrintModule.listPrintPackages();
122
+ }
123
+ /**
124
+ * Get all packages capable of handling print intents
125
+ */
126
+ export async function getAllPrintCapablePackages() {
127
+ return H3PrintModule.getAllPrintCapablePackages();
128
+ }
129
+ /**
130
+ * Clean up temporary print files
131
+ */
132
+ export async function cleanupTempFiles() {
133
+ return H3PrintModule.cleanupTempFiles();
134
+ }
135
+ /**
136
+ * Get module information
137
+ */
138
+ export function getModuleInfo() {
139
+ return H3PrintModule.getModuleInfo();
140
+ }
141
+ // ============================================================
142
+ // ESC/POS Commands for Thermal Printers
143
+ // ============================================================
144
+ export const ESC_POS = {
145
+ // Initialize printer
146
+ INIT: [0x1b, 0x40],
147
+ // Line feed
148
+ LF: [0x0a],
149
+ // Carriage return
150
+ CR: [0x0d],
151
+ // Cut paper (full cut)
152
+ CUT_FULL: [0x1d, 0x56, 0x00],
153
+ // Cut paper (partial cut)
154
+ CUT_PARTIAL: [0x1d, 0x56, 0x01],
155
+ // Feed and cut
156
+ FEED_AND_CUT: [0x1d, 0x56, 0x42, 0x00],
157
+ // Bold on
158
+ BOLD_ON: [0x1b, 0x45, 0x01],
159
+ // Bold off
160
+ BOLD_OFF: [0x1b, 0x45, 0x00],
161
+ // Underline on (1 dot)
162
+ UNDERLINE_ON: [0x1b, 0x2d, 0x01],
163
+ // Underline on (2 dots)
164
+ UNDERLINE_ON_2: [0x1b, 0x2d, 0x02],
165
+ // Underline off
166
+ UNDERLINE_OFF: [0x1b, 0x2d, 0x00],
167
+ // Align left
168
+ ALIGN_LEFT: [0x1b, 0x61, 0x00],
169
+ // Align center
170
+ ALIGN_CENTER: [0x1b, 0x61, 0x01],
171
+ // Align right
172
+ ALIGN_RIGHT: [0x1b, 0x61, 0x02],
173
+ // Double height on
174
+ DOUBLE_HEIGHT_ON: [0x1b, 0x21, 0x10],
175
+ // Double width on
176
+ DOUBLE_WIDTH_ON: [0x1b, 0x21, 0x20],
177
+ // Double height and width on
178
+ DOUBLE_SIZE_ON: [0x1b, 0x21, 0x30],
179
+ // Normal size
180
+ NORMAL_SIZE: [0x1b, 0x21, 0x00],
181
+ // Font A (12x24)
182
+ FONT_A: [0x1b, 0x4d, 0x00],
183
+ // Font B (9x17)
184
+ FONT_B: [0x1b, 0x4d, 0x01],
185
+ // Invert on (white on black)
186
+ INVERT_ON: [0x1d, 0x42, 0x01],
187
+ // Invert off
188
+ INVERT_OFF: [0x1d, 0x42, 0x00],
189
+ // Set line spacing (n/180 inch)
190
+ lineSpacing: (n) => [0x1b, 0x33, n],
191
+ // Default line spacing
192
+ LINE_SPACING_DEFAULT: [0x1b, 0x32],
193
+ // Feed n lines
194
+ feedLines: (n) => [0x1b, 0x64, n],
195
+ // Set character size (0-7 for width, 0-7 for height)
196
+ setCharSize: (width, height) => [
197
+ 0x1d,
198
+ 0x21,
199
+ ((width & 0x07) << 4) | (height & 0x07),
200
+ ],
201
+ // Convert text to bytes
202
+ textToBytes: (text) => {
203
+ const bytes = [];
204
+ for (let i = 0; i < text.length; i++) {
205
+ const charCode = text.charCodeAt(i);
206
+ if (charCode < 256) {
207
+ bytes.push(charCode);
208
+ }
209
+ else {
210
+ // Handle multi-byte characters (simplified - just use ?)
211
+ bytes.push(0x3f);
212
+ }
213
+ }
214
+ return bytes;
215
+ },
216
+ // Build command sequence from multiple commands
217
+ buildCommand: (...commands) => {
218
+ return commands.flat();
219
+ },
220
+ // Create horizontal line
221
+ horizontalLine: (char = '-', width = 32) => {
222
+ return ESC_POS.textToBytes(char.repeat(width) + '\n');
223
+ },
224
+ // Create formatted line (left text + right text)
225
+ formattedLine: (left, right, totalWidth = 32, fillChar = ' ') => {
226
+ const spaces = Math.max(1, totalWidth - left.length - right.length);
227
+ return ESC_POS.textToBytes(left + fillChar.repeat(spaces) + right + '\n');
228
+ },
229
+ // Center text
230
+ centerText: (text, width = 32) => {
231
+ const padding = Math.max(0, Math.floor((width - text.length) / 2));
232
+ return ESC_POS.textToBytes(' '.repeat(padding) + text + '\n');
233
+ },
234
+ };
235
+ // ============================================================
236
+ // High-Level Helper Functions
237
+ // ============================================================
238
+ /**
239
+ * Print a receipt from template data
240
+ * This is a convenience function that handles the full flow
241
+ *
242
+ * @param templateData - Receipt data
243
+ * @param generateHtml - Function to generate HTML from template data
244
+ * @param options - Print options
245
+ */
246
+ export async function printReceipt(templateData, generateHtml, options) {
247
+ const html = generateHtml(templateData);
248
+ return printHtmlAsPdf(html, options);
249
+ }
250
+ /**
251
+ * Print with automatic fallback
252
+ * Tries different methods until one succeeds
253
+ *
254
+ * @param html - HTML to print
255
+ * @param options - Print options
256
+ */
257
+ export async function printWithFallback(html, options) {
258
+ // Try 1: HTML to PDF
259
+ try {
260
+ const result = await printHtmlAsPdf(html, options);
261
+ if (result.success)
262
+ return result;
263
+ }
264
+ catch (e) {
265
+ console.log('HTML to PDF failed, trying alternatives...');
266
+ }
267
+ // Try 2: Generate PDF first, then print by path
268
+ try {
269
+ const pdfResult = await generatePdfFromHtml(html, options);
270
+ if (pdfResult.success && pdfResult.pdfPath) {
271
+ const printResult = await printFileByPath(pdfResult.pdfPath, 'application/pdf', options?.packageName);
272
+ if (printResult.success)
273
+ return printResult;
274
+ }
275
+ }
276
+ catch (e) {
277
+ console.log('Generate + print by path failed...');
278
+ }
279
+ // Try 3: Generate PDF and print by URI
280
+ try {
281
+ const pdfResult = await generatePdfFromHtml(html, options);
282
+ if (pdfResult.success && pdfResult.pdfPath) {
283
+ return await printFileByUri(pdfResult.pdfPath, 'application/pdf', options?.packageName);
284
+ }
285
+ }
286
+ catch (e) {
287
+ console.log('Generate + print by URI failed...');
288
+ }
289
+ return {
290
+ success: false,
291
+ message: 'All print methods failed',
292
+ };
293
+ }
294
+ /**
295
+ * Discover available print services on the device
296
+ */
297
+ export async function discoverPrintServices() {
298
+ const [status, packages] = await Promise.all([
299
+ isPrintServiceAvailable(),
300
+ getAllPrintCapablePackages(),
301
+ ]);
302
+ return {
303
+ defaultAvailable: status.available,
304
+ defaultPackage: status.packageName,
305
+ allPackages: packages,
306
+ };
307
+ }
308
+ // ============================================================
309
+ // Default Export
310
+ // ============================================================
311
+ export default {
312
+ // Main functions
313
+ printHtmlAsPdf,
314
+ generatePdfFromHtml,
315
+ printPdf,
316
+ printText,
317
+ printRaw,
318
+ printFileByPath,
319
+ printFileByUri,
320
+ // Utility functions
321
+ isPrintServiceAvailable,
322
+ listPrintPackages,
323
+ getAllPrintCapablePackages,
324
+ cleanupTempFiles,
325
+ getModuleInfo,
326
+ // Helper functions
327
+ printReceipt,
328
+ printWithFallback,
329
+ discoverPrintServices,
330
+ // Event listeners
331
+ addPrintSuccessListener,
332
+ addPrintErrorListener,
333
+ addPdfGeneratedListener,
334
+ // ESC/POS commands
335
+ ESC_POS,
336
+ };
5
337
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,8CAA8C;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,cAAe,iBAAiB,CAAC","sourcesContent":["// Reexport the native module. On web, it will be resolved to H3PrintModule.web.ts\n// and on native platforms to H3PrintModule.ts\nexport { default } from './H3PrintModule';\nexport * from './H3Print.types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AACpE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AA0B5C,+DAA+D;AAC/D,sBAAsB;AACtB,+DAA+D;AAE/D,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,aAAoB,CAAC,CAAC;AAEvD;;GAEG;AACH,MAAM,UAA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EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,0BAA0B;KACpC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IAKzC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC3C,uBAAuB,EAAE;QACzB,0BAA0B,EAAE;KAC7B,CAAC,CAAC;IAEH,OAAO;QACL,gBAAgB,EAAE,MAAM,CAAC,SAAS;QAClC,cAAc,EAAE,MAAM,CAAC,WAAW;QAClC,WAAW,EAAE,QAAQ;KACtB,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,iBAAiB;AACjB,+DAA+D;AAE/D,eAAe;IACb,iBAAiB;IACjB,cAAc;IACd,mBAAmB;IACnB,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,eAAe;IACf,cAAc;IAEd,oBAAoB;IACpB,uBAAuB;IACvB,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,aAAa;IAEb,mBAAmB;IACnB,YAAY;IACZ,iBAAiB;IACjB,qBAAqB;IAErB,kBAAkB;IAClB,uBAAuB;IACvB,qBAAqB;IACrB,uBAAuB;IAEvB,mBAAmB;IACnB,OAAO;CACR,CAAC","sourcesContent":["import { EventEmitter, type Subscription } from 'expo-modules-core';\nimport H3PrintModule from './H3PrintModule';\nimport type {\n PrintResult,\n PrintServiceStatus,\n PrintPackageInfo,\n PdfOptions,\n PrintHtmlOptions,\n CleanupResult,\n ModuleInfo,\n EscPosCommand,\n ReceiptTemplateData,\n} from './H3Print.types';\n\n// Re-export types\nexport type {\n PrintResult,\n PrintServiceStatus,\n PrintPackageInfo,\n PdfOptions,\n PrintHtmlOptions,\n CleanupResult,\n ModuleInfo,\n EscPosCommand,\n ReceiptTemplateData,\n};\n\n// ============================================================\n// Event Emitter Setup\n// ============================================================\n\nconst emitter = new EventEmitter(H3PrintModule as any);\n\n/**\n * Subscribe to print success events\n */\nexport function addPrintSuccessListener(\n listener: (event: { pdfPath: string }) => void\n): Subscription {\n return emitter.addListener('onPrintSuccess', listener);\n}\n\n/**\n * Subscribe to print error events\n */\nexport function addPrintErrorListener(\n listener: (event: { error: string }) => void\n): Subscription {\n return emitter.addListener('onPrintError', listener);\n}\n\n/**\n * Subscribe to PDF generation events\n */\nexport function addPdfGeneratedListener(\n listener: (event: { pdfPath: string }) => void\n): Subscription {\n return emitter.addListener('onPdfGenerated', listener);\n}\n\n// ============================================================\n// Main Print Functions\n// ============================================================\n\n/**\n * Print HTML content as PDF (RECOMMENDED)\n * Converts HTML to PDF and sends to the silent print service\n *\n * @param html - HTML string to print\n * @param options - Print options\n * @returns Promise with print result\n *\n * @example\n * ```typescript\n * const result = await printHtmlAsPdf('<h1>Hello</h1>', {\n * pageWidth: 384,\n * packageName: 'com.bld.settings.print'\n * });\n * ```\n */\nexport async function printHtmlAsPdf(\n html: string,\n options?: PrintHtmlOptions\n): Promise<PrintResult> {\n return H3PrintModule.printHtmlAsPdf(html, options ?? null);\n}\n\n/**\n * Generate PDF from HTML without printing\n * Useful for preview or saving\n *\n * @param html - HTML string to convert\n * @param options - PDF generation options\n * @returns Promise with PDF file path\n */\nexport async function generatePdfFromHtml(\n html: string,\n options?: PdfOptions\n): Promise<PrintResult> {\n return H3PrintModule.generatePdfFromHtml(html, options ?? null);\n}\n\n/**\n * Print an existing PDF file\n *\n * @param filePath - Path to the PDF file\n * @param packageName - Optional print package name\n */\nexport async function printPdf(\n filePath: string,\n packageName?: string\n): Promise<PrintResult> {\n return H3PrintModule.printPdf(filePath, packageName ?? null);\n}\n\n/**\n * Print plain text\n *\n * @param text - Text to print\n * @param packageName - Optional print package name\n */\nexport async function printText(\n text: string,\n packageName?: string\n): Promise<PrintResult> {\n return H3PrintModule.printText(text, packageName ?? null);\n}\n\n/**\n * Print raw bytes (ESC/POS commands for thermal printers)\n *\n * @param data - Array of byte values\n * @param packageName - Optional print package name\n */\nexport async function printRaw(\n data: number[],\n packageName?: string\n): Promise<PrintResult> {\n return H3PrintModule.printRaw(data, packageName ?? null);\n}\n\n/**\n * Print file using file path in EXTRA_TEXT\n * Uses the intent pattern you discovered\n *\n * @param filePath - Absolute path to the file\n * @param mimeType - MIME type (default: application/pdf)\n * @param packageName - Optional print package name\n */\nexport async function printFileByPath(\n filePath: string,\n mimeType?: string,\n packageName?: string\n): Promise<PrintResult> {\n return H3PrintModule.printFileByPath(\n filePath,\n mimeType ?? null,\n packageName ?? null\n );\n}\n\n/**\n * Print file using FileProvider URI\n *\n * @param filePath - Path to the file\n * @param mimeType - MIME type\n * @param packageName - Optional print package name\n */\nexport async function printFileByUri(\n filePath: string,\n mimeType?: string,\n packageName?: string\n): Promise<PrintResult> {\n return H3PrintModule.printFileByUri(\n filePath,\n mimeType ?? null,\n packageName ?? null\n );\n}\n\n// ============================================================\n// Utility Functions\n// ============================================================\n\n/**\n * Check if the print service is available\n *\n * @param packageName - Package name to check (defaults to com.bld.settings.print)\n */\nexport async function isPrintServiceAvailable(\n packageName?: string\n): Promise<PrintServiceStatus> {\n return H3PrintModule.isPrintServiceAvailable(packageName ?? null);\n}\n\n/**\n * List available print-related packages\n */\nexport async function listPrintPackages(): Promise<PrintPackageInfo[]> {\n return H3PrintModule.listPrintPackages();\n}\n\n/**\n * Get all packages capable of handling print intents\n */\nexport async function getAllPrintCapablePackages(): Promise<PrintPackageInfo[]> {\n return H3PrintModule.getAllPrintCapablePackages();\n}\n\n/**\n * Clean up temporary print files\n */\nexport async function cleanupTempFiles(): Promise<CleanupResult> {\n return H3PrintModule.cleanupTempFiles();\n}\n\n/**\n * Get module information\n */\nexport function getModuleInfo(): ModuleInfo {\n return H3PrintModule.getModuleInfo();\n}\n\n// ============================================================\n// ESC/POS Commands for Thermal Printers\n// ============================================================\n\nexport const ESC_POS = {\n // Initialize printer\n INIT: [0x1b, 0x40] as EscPosCommand,\n\n // Line feed\n LF: [0x0a] as EscPosCommand,\n\n // Carriage return\n CR: [0x0d] as EscPosCommand,\n\n // Cut paper (full cut)\n CUT_FULL: [0x1d, 0x56, 0x00] as EscPosCommand,\n\n // Cut paper (partial cut)\n CUT_PARTIAL: [0x1d, 0x56, 0x01] as EscPosCommand,\n\n // Feed and cut\n FEED_AND_CUT: [0x1d, 0x56, 0x42, 0x00] as EscPosCommand,\n\n // Bold on\n BOLD_ON: [0x1b, 0x45, 0x01] as EscPosCommand,\n\n // Bold off\n BOLD_OFF: [0x1b, 0x45, 0x00] as EscPosCommand,\n\n // Underline on (1 dot)\n UNDERLINE_ON: [0x1b, 0x2d, 0x01] as EscPosCommand,\n\n // Underline on (2 dots)\n UNDERLINE_ON_2: [0x1b, 0x2d, 0x02] as EscPosCommand,\n\n // Underline off\n UNDERLINE_OFF: [0x1b, 0x2d, 0x00] as EscPosCommand,\n\n // Align left\n ALIGN_LEFT: [0x1b, 0x61, 0x00] as EscPosCommand,\n\n // Align center\n ALIGN_CENTER: [0x1b, 0x61, 0x01] as EscPosCommand,\n\n // Align right\n ALIGN_RIGHT: [0x1b, 0x61, 0x02] as EscPosCommand,\n\n // Double height on\n DOUBLE_HEIGHT_ON: [0x1b, 0x21, 0x10] as EscPosCommand,\n\n // Double width on\n DOUBLE_WIDTH_ON: [0x1b, 0x21, 0x20] as EscPosCommand,\n\n // Double height and width on\n DOUBLE_SIZE_ON: [0x1b, 0x21, 0x30] as EscPosCommand,\n\n // Normal size\n NORMAL_SIZE: [0x1b, 0x21, 0x00] as EscPosCommand,\n\n // Font A (12x24)\n FONT_A: [0x1b, 0x4d, 0x00] as EscPosCommand,\n\n // Font B (9x17)\n FONT_B: [0x1b, 0x4d, 0x01] as EscPosCommand,\n\n // Invert on (white on black)\n INVERT_ON: [0x1d, 0x42, 0x01] as EscPosCommand,\n\n // Invert off\n INVERT_OFF: [0x1d, 0x42, 0x00] as EscPosCommand,\n\n // Set line spacing (n/180 inch)\n lineSpacing: (n: number): EscPosCommand => [0x1b, 0x33, n],\n\n // Default line spacing\n LINE_SPACING_DEFAULT: [0x1b, 0x32] as EscPosCommand,\n\n // Feed n lines\n feedLines: (n: number): EscPosCommand => [0x1b, 0x64, n],\n\n // Set character size (0-7 for width, 0-7 for height)\n setCharSize: (width: number, height: number): EscPosCommand => [\n 0x1d,\n 0x21,\n ((width & 0x07) << 4) | (height & 0x07),\n ],\n\n // Convert text to bytes\n textToBytes: (text: string): number[] => {\n const bytes: number[] = [];\n for (let i = 0; i < text.length; i++) {\n const charCode = text.charCodeAt(i);\n if (charCode < 256) {\n bytes.push(charCode);\n } else {\n // Handle multi-byte characters (simplified - just use ?)\n bytes.push(0x3f);\n }\n }\n return bytes;\n },\n\n // Build command sequence from multiple commands\n buildCommand: (...commands: (EscPosCommand | number[])[]): number[] => {\n return commands.flat();\n },\n\n // Create horizontal line\n horizontalLine: (char: string = '-', width: number = 32): number[] => {\n return ESC_POS.textToBytes(char.repeat(width) + '\\n');\n },\n\n // Create formatted line (left text + right text)\n formattedLine: (\n left: string,\n right: string,\n totalWidth: number = 32,\n fillChar: string = ' '\n ): number[] => {\n const spaces = Math.max(1, totalWidth - left.length - right.length);\n return ESC_POS.textToBytes(left + fillChar.repeat(spaces) + right + '\\n');\n },\n\n // Center text\n centerText: (text: string, width: number = 32): number[] => {\n const padding = Math.max(0, Math.floor((width - text.length) / 2));\n return ESC_POS.textToBytes(' '.repeat(padding) + text + '\\n');\n },\n};\n\n// ============================================================\n// High-Level Helper Functions\n// ============================================================\n\n/**\n * Print a receipt from template data\n * This is a convenience function that handles the full flow\n *\n * @param templateData - Receipt data\n * @param generateHtml - Function to generate HTML from template data\n * @param options - Print options\n */\nexport async function printReceipt<T>(\n templateData: T,\n generateHtml: (data: T) => string,\n options?: PrintHtmlOptions\n): Promise<PrintResult> {\n const html = generateHtml(templateData);\n return printHtmlAsPdf(html, options);\n}\n\n/**\n * Print with automatic fallback\n * Tries different methods until one succeeds\n *\n * @param html - HTML to print\n * @param options - Print options\n */\nexport async function printWithFallback(\n html: string,\n options?: PrintHtmlOptions\n): Promise<PrintResult> {\n // Try 1: HTML to PDF\n try {\n const result = await printHtmlAsPdf(html, options);\n if (result.success) return result;\n } catch (e) {\n console.log('HTML to PDF failed, trying alternatives...');\n }\n\n // Try 2: Generate PDF first, then print by path\n try {\n const pdfResult = await generatePdfFromHtml(html, options);\n if (pdfResult.success && pdfResult.pdfPath) {\n const printResult = await printFileByPath(\n pdfResult.pdfPath,\n 'application/pdf',\n options?.packageName\n );\n if (printResult.success) return printResult;\n }\n } catch (e) {\n console.log('Generate + print by path failed...');\n }\n\n // Try 3: Generate PDF and print by URI\n try {\n const pdfResult = await generatePdfFromHtml(html, options);\n if (pdfResult.success && pdfResult.pdfPath) {\n return await printFileByUri(\n pdfResult.pdfPath,\n 'application/pdf',\n options?.packageName\n );\n }\n } catch (e) {\n console.log('Generate + print by URI failed...');\n }\n\n return {\n success: false,\n message: 'All print methods failed',\n };\n}\n\n/**\n * Discover available print services on the device\n */\nexport async function discoverPrintServices(): Promise<{\n defaultAvailable: boolean;\n defaultPackage: string;\n allPackages: PrintPackageInfo[];\n}> {\n const [status, packages] = await Promise.all([\n isPrintServiceAvailable(),\n getAllPrintCapablePackages(),\n ]);\n\n return {\n defaultAvailable: status.available,\n defaultPackage: status.packageName,\n allPackages: packages,\n };\n}\n\n// ============================================================\n// Default Export\n// ============================================================\n\nexport default {\n // Main functions\n printHtmlAsPdf,\n generatePdfFromHtml,\n printPdf,\n printText,\n printRaw,\n printFileByPath,\n printFileByUri,\n\n // Utility functions\n isPrintServiceAvailable,\n listPrintPackages,\n getAllPrintCapablePackages,\n cleanupTempFiles,\n getModuleInfo,\n\n // Helper functions\n printReceipt,\n printWithFallback,\n discoverPrintServices,\n\n // Event listeners\n addPrintSuccessListener,\n addPrintErrorListener,\n addPdfGeneratedListener,\n\n // ESC/POS commands\n ESC_POS,\n};"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h3-print",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Silent printing module for Expo Android - supports HTML to PDF conversion and direct thermal printing",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,6 +42,7 @@
42
42
  "devDependencies": {
43
43
  "@types/react": "~19.1.0",
44
44
  "expo-module-scripts": "^5.0.8",
45
+ "expo-modules-core": "^1.12.0",
45
46
  "expo": "^54.0.27",
46
47
  "react-native": "0.81.5",
47
48
  "typescript": "^5.3.0"
@@ -51,4 +52,4 @@
51
52
  "react": "*",
52
53
  "react-native": "*"
53
54
  }
54
- }
55
+ }