boot-nemonic-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 (84) hide show
  1. package/.eslintrc.js +5 -0
  2. package/README.md +209 -0
  3. package/ai/example-ui-card-refactor.md +348 -0
  4. package/android/build.gradle +22 -0
  5. package/android/libs/NemonicSdk.aar +0 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/net/eventboot/nemonicprinter/BootNemonicPrinterModule.kt +509 -0
  8. package/build/BootNemonicPrinter.types.d.ts +44 -0
  9. package/build/BootNemonicPrinter.types.d.ts.map +1 -0
  10. package/build/BootNemonicPrinter.types.js +2 -0
  11. package/build/BootNemonicPrinter.types.js.map +1 -0
  12. package/build/BootNemonicPrinterModule.d.ts +36 -0
  13. package/build/BootNemonicPrinterModule.d.ts.map +1 -0
  14. package/build/BootNemonicPrinterModule.js +3 -0
  15. package/build/BootNemonicPrinterModule.js.map +1 -0
  16. package/build/constants/NBatteryStatus.d.ts +8 -0
  17. package/build/constants/NBatteryStatus.d.ts.map +1 -0
  18. package/build/constants/NBatteryStatus.js +7 -0
  19. package/build/constants/NBatteryStatus.js.map +1 -0
  20. package/build/constants/NCartridgeType.d.ts +35 -0
  21. package/build/constants/NCartridgeType.d.ts.map +1 -0
  22. package/build/constants/NCartridgeType.js +183 -0
  23. package/build/constants/NCartridgeType.js.map +1 -0
  24. package/build/constants/NConnectState.d.ts +8 -0
  25. package/build/constants/NConnectState.d.ts.map +1 -0
  26. package/build/constants/NConnectState.js +7 -0
  27. package/build/constants/NConnectState.js.map +1 -0
  28. package/build/constants/NPowerSaveMode.d.ts +6 -0
  29. package/build/constants/NPowerSaveMode.d.ts.map +1 -0
  30. package/build/constants/NPowerSaveMode.js +5 -0
  31. package/build/constants/NPowerSaveMode.js.map +1 -0
  32. package/build/constants/NPrintImageLength.d.ts +12 -0
  33. package/build/constants/NPrintImageLength.d.ts.map +1 -0
  34. package/build/constants/NPrintImageLength.js +12 -0
  35. package/build/constants/NPrintImageLength.js.map +1 -0
  36. package/build/constants/NPrintQuality.d.ts +7 -0
  37. package/build/constants/NPrintQuality.d.ts.map +1 -0
  38. package/build/constants/NPrintQuality.js +6 -0
  39. package/build/constants/NPrintQuality.js.map +1 -0
  40. package/build/constants/NPrinterStatus.d.ts +9 -0
  41. package/build/constants/NPrinterStatus.d.ts.map +1 -0
  42. package/build/constants/NPrinterStatus.js +8 -0
  43. package/build/constants/NPrinterStatus.js.map +1 -0
  44. package/build/constants/NPrinterType.d.ts +9 -0
  45. package/build/constants/NPrinterType.d.ts.map +1 -0
  46. package/build/constants/NPrinterType.js +8 -0
  47. package/build/constants/NPrinterType.js.map +1 -0
  48. package/build/constants/NResult.d.ts +51 -0
  49. package/build/constants/NResult.d.ts.map +1 -0
  50. package/build/constants/NResult.js +50 -0
  51. package/build/constants/NResult.js.map +1 -0
  52. package/build/index.d.ts +13 -0
  53. package/build/index.d.ts.map +1 -0
  54. package/build/index.js +13 -0
  55. package/build/index.js.map +1 -0
  56. package/expo-module.config.json +9 -0
  57. package/ios/BootNemonicPrinter.podspec +31 -0
  58. package/ios/BootNemonicPrinterModule.swift +257 -0
  59. package/ios/Frameworks/NemonicSdk.framework/Headers/NemonicSdk-Swift.h +797 -0
  60. package/ios/Frameworks/NemonicSdk.framework/Headers/NemonicSdk.h +18 -0
  61. package/ios/Frameworks/NemonicSdk.framework/Info.plist +0 -0
  62. package/ios/Frameworks/NemonicSdk.framework/Modules/NemonicSdk.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  63. package/ios/Frameworks/NemonicSdk.framework/Modules/NemonicSdk.swiftmodule/arm64-apple-ios.abi.json +12244 -0
  64. package/ios/Frameworks/NemonicSdk.framework/Modules/NemonicSdk.swiftmodule/arm64-apple-ios.private.swiftinterface +356 -0
  65. package/ios/Frameworks/NemonicSdk.framework/Modules/NemonicSdk.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  66. package/ios/Frameworks/NemonicSdk.framework/Modules/NemonicSdk.swiftmodule/arm64-apple-ios.swiftinterface +356 -0
  67. package/ios/Frameworks/NemonicSdk.framework/Modules/NemonicSdk.swiftmodule/arm64-apple-ios.swiftmodule +0 -0
  68. package/ios/Frameworks/NemonicSdk.framework/Modules/module.modulemap +11 -0
  69. package/ios/Frameworks/NemonicSdk.framework/NemonicSdk +0 -0
  70. package/ios/Frameworks/NemonicSdk.framework/_CodeSignature/CodeResources +237 -0
  71. package/package.json +44 -0
  72. package/src/BootNemonicPrinter.types.ts +50 -0
  73. package/src/BootNemonicPrinterModule.ts +48 -0
  74. package/src/constants/NBatteryStatus.ts +8 -0
  75. package/src/constants/NCartridgeType.ts +181 -0
  76. package/src/constants/NConnectState.ts +8 -0
  77. package/src/constants/NPowerSaveMode.ts +6 -0
  78. package/src/constants/NPrintImageLength.ts +11 -0
  79. package/src/constants/NPrintQuality.ts +7 -0
  80. package/src/constants/NPrinterStatus.ts +9 -0
  81. package/src/constants/NPrinterType.ts +9 -0
  82. package/src/constants/NResult.ts +51 -0
  83. package/src/index.ts +13 -0
  84. package/tsconfig.json +9 -0
@@ -0,0 +1,48 @@
1
+ import { NativeModule, requireNativeModule } from 'expo';
2
+
3
+ import {
4
+ BootNemonicPrinterModuleEvents,
5
+ NPrinter,
6
+ PrintOptions,
7
+ PrinterNameResult,
8
+ } from './BootNemonicPrinter.types';
9
+
10
+ declare class BootNemonicPrinterModule extends NativeModule<BootNemonicPrinterModuleEvents> {
11
+ readonly MAX_IMAGE_SIZE: number;
12
+ readonly SDK_VERSION: string;
13
+
14
+ startScan(): Promise<number>;
15
+ stopScan(): void;
16
+
17
+ getUsbPrinterList(): Promise<NPrinter[]>;
18
+ requestUsbPermission(printer: NPrinter): Promise<boolean>;
19
+
20
+ connect(printer: NPrinter & { queueLabel?: string }): Promise<number>;
21
+ disconnect(): void;
22
+ getConnectState(): Promise<number>;
23
+ cancel(): void;
24
+
25
+ setPrintTimeout(enableAuto: boolean, manualTime: number): void;
26
+ print(options: PrintOptions): Promise<number>;
27
+
28
+ setTemplate(image: number[], withPrint: boolean, enableDither: boolean): Promise<number>;
29
+ setTemplateWithUrl(imageUrl: string, withPrint: boolean, enableDither: boolean): Promise<number>;
30
+ clearTemplate(): Promise<number>;
31
+
32
+ getPrinterStatus(): Promise<number>;
33
+ getCartridgeType(): Promise<number>;
34
+ getPrinterName(): Promise<PrinterNameResult>;
35
+ getBatteryLevel(): Promise<number>;
36
+ getBatteryStatus(): Promise<number>;
37
+
38
+ getBleConnectDelayOffset(): Promise<number>;
39
+ setBleConnectDelayOffset(msec: number): void;
40
+ getBleSendRetryDelayOffset(): Promise<number>;
41
+ setBleSendRetryDelayOffset(msec: number): void;
42
+
43
+ getDefaultConnectDelay(): Promise<number>;
44
+ getConnectDelay(): Promise<number>;
45
+ setConnectDelay(msec: number): void;
46
+ }
47
+
48
+ export default requireNativeModule<BootNemonicPrinterModule>('BootNemonicPrinter');
@@ -0,0 +1,8 @@
1
+ export const NBatteryStatus = {
2
+ NO_CHARGING: 0,
3
+ LOW_NO_CHARGING: 1,
4
+ CHARGING: 2,
5
+ LOW_CHARGING: 3,
6
+ } as const;
7
+
8
+ export type NBatteryStatusCode = (typeof NBatteryStatus)[keyof typeof NBatteryStatus];
@@ -0,0 +1,181 @@
1
+ export enum NCartridgeType {
2
+ none = -1,
3
+ white = 0,
4
+ yellow = 1,
5
+ green = 2,
6
+ blue = 3,
7
+ pink = 7,
8
+ l1 = 13,
9
+ l2 = 12,
10
+ l3 = 10,
11
+ l4 = 6,
12
+ l5 = 8,
13
+ l6 = 5,
14
+ l7 = 9,
15
+ l8 = 11,
16
+ m1 = 101,
17
+ m2 = 102,
18
+ m3 = 103,
19
+ m4 = 104,
20
+ m5 = 105,
21
+ m6 = 106,
22
+ m7 = 107,
23
+ m8 = 108,
24
+ question = 4,
25
+ n = 14,
26
+ }
27
+
28
+ export namespace NCartridgeType {
29
+ export function isValidCartridge(type: NCartridgeType): boolean {
30
+ switch (type) {
31
+ case NCartridgeType.white:
32
+ case NCartridgeType.yellow:
33
+ case NCartridgeType.green:
34
+ case NCartridgeType.blue:
35
+ case NCartridgeType.pink:
36
+ case NCartridgeType.l1:
37
+ case NCartridgeType.l2:
38
+ case NCartridgeType.l3:
39
+ case NCartridgeType.l4:
40
+ case NCartridgeType.l5:
41
+ case NCartridgeType.l6:
42
+ case NCartridgeType.l7:
43
+ case NCartridgeType.l8:
44
+ case NCartridgeType.m1:
45
+ case NCartridgeType.m2:
46
+ case NCartridgeType.m3:
47
+ case NCartridgeType.m4:
48
+ case NCartridgeType.m5:
49
+ case NCartridgeType.m6:
50
+ case NCartridgeType.m7:
51
+ case NCartridgeType.m8:
52
+ case NCartridgeType.n:
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+
58
+ export function isMiniCartridge(type: NCartridgeType): boolean {
59
+ switch (type) {
60
+ case NCartridgeType.m1:
61
+ case NCartridgeType.m2:
62
+ case NCartridgeType.m3:
63
+ case NCartridgeType.m4:
64
+ case NCartridgeType.m5:
65
+ case NCartridgeType.m6:
66
+ case NCartridgeType.m7:
67
+ case NCartridgeType.m8:
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+
73
+ export function isLabelCartridge(type: NCartridgeType): boolean {
74
+ switch (type) {
75
+ case NCartridgeType.l1:
76
+ case NCartridgeType.l2:
77
+ case NCartridgeType.l3:
78
+ case NCartridgeType.l4:
79
+ case NCartridgeType.l5:
80
+ case NCartridgeType.l6:
81
+ case NCartridgeType.l7:
82
+ case NCartridgeType.l8:
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+
88
+ export function isStickyCartridge(type: NCartridgeType): boolean {
89
+ switch (type) {
90
+ case NCartridgeType.white:
91
+ case NCartridgeType.yellow:
92
+ case NCartridgeType.green:
93
+ case NCartridgeType.blue:
94
+ case NCartridgeType.pink:
95
+ case NCartridgeType.l1:
96
+ case NCartridgeType.l2:
97
+ case NCartridgeType.l3:
98
+ case NCartridgeType.l4:
99
+ case NCartridgeType.l5:
100
+ case NCartridgeType.l6:
101
+ case NCartridgeType.l7:
102
+ case NCartridgeType.l8:
103
+ case NCartridgeType.m1:
104
+ case NCartridgeType.m2:
105
+ case NCartridgeType.m3:
106
+ case NCartridgeType.m4:
107
+ case NCartridgeType.m5:
108
+ case NCartridgeType.m6:
109
+ case NCartridgeType.m7:
110
+ case NCartridgeType.m8:
111
+ case NCartridgeType.n:
112
+ return true;
113
+ }
114
+ return false;
115
+ }
116
+
117
+ export function getCartridgeName(type: NCartridgeType): string {
118
+ switch (type) {
119
+ case NCartridgeType.white: return 'W';
120
+ case NCartridgeType.yellow: return 'Y';
121
+ case NCartridgeType.green: return 'G';
122
+ case NCartridgeType.blue: return 'B';
123
+ case NCartridgeType.pink: return 'P';
124
+ case NCartridgeType.l1: return 'L1';
125
+ case NCartridgeType.l2: return 'L2';
126
+ case NCartridgeType.l3: return 'L3';
127
+ case NCartridgeType.l4: return 'L4';
128
+ case NCartridgeType.l5: return 'L5';
129
+ case NCartridgeType.l6: return 'L6';
130
+ case NCartridgeType.l7: return 'L7';
131
+ case NCartridgeType.l8: return 'L8';
132
+ case NCartridgeType.m1: return 'm1';
133
+ case NCartridgeType.m2: return 'm2';
134
+ case NCartridgeType.m3: return 'm3';
135
+ case NCartridgeType.m4: return 'm4';
136
+ case NCartridgeType.m5: return 'm5';
137
+ case NCartridgeType.m6: return 'm6';
138
+ case NCartridgeType.m7: return 'm7';
139
+ case NCartridgeType.m8: return 'm8';
140
+ case NCartridgeType.question: return '?';
141
+ case NCartridgeType.n: return 'n';
142
+ default: return 'X';
143
+ }
144
+ }
145
+
146
+ export function getCartridgeType(value: string | number): NCartridgeType {
147
+ if (typeof value === 'number') {
148
+ const result = value as NCartridgeType;
149
+ if (NCartridgeType[result] === undefined) {
150
+ return NCartridgeType.none;
151
+ }
152
+ return result;
153
+ }
154
+ switch (value) {
155
+ case 'W': return NCartridgeType.white;
156
+ case 'Y': return NCartridgeType.yellow;
157
+ case 'G': return NCartridgeType.green;
158
+ case 'B': return NCartridgeType.blue;
159
+ case 'P': return NCartridgeType.pink;
160
+ case 'L1': return NCartridgeType.l1;
161
+ case 'L2': return NCartridgeType.l2;
162
+ case 'L3': return NCartridgeType.l3;
163
+ case 'L4': return NCartridgeType.l4;
164
+ case 'L5': return NCartridgeType.l5;
165
+ case 'L6': return NCartridgeType.l6;
166
+ case 'L7': return NCartridgeType.l7;
167
+ case 'L8': return NCartridgeType.l8;
168
+ case 'm1': return NCartridgeType.m1;
169
+ case 'm2': return NCartridgeType.m2;
170
+ case 'm3': return NCartridgeType.m3;
171
+ case 'm4': return NCartridgeType.m4;
172
+ case 'm5': return NCartridgeType.m5;
173
+ case 'm6': return NCartridgeType.m6;
174
+ case 'm7': return NCartridgeType.m7;
175
+ case 'm8': return NCartridgeType.m8;
176
+ case '?': return NCartridgeType.question;
177
+ case 'N': return NCartridgeType.n;
178
+ default: return NCartridgeType.none;
179
+ }
180
+ }
181
+ }
@@ -0,0 +1,8 @@
1
+ export const NConnectState = {
2
+ DISCONNECTED: 0,
3
+ CONNECTING: 1,
4
+ CONNECTED: 2,
5
+ DISCONNECTING: 3,
6
+ } as const;
7
+
8
+ export type NConnectStateCode = (typeof NConnectState)[keyof typeof NConnectState];
@@ -0,0 +1,6 @@
1
+ export const NPowerSaveMode = {
2
+ SLEEP: 0,
3
+ POWER_OFF: 1,
4
+ } as const;
5
+
6
+ export type NPowerSaveModeCode = (typeof NPowerSaveMode)[keyof typeof NPowerSaveMode];
@@ -0,0 +1,11 @@
1
+ export const NPrintImageLength = {
2
+ PRINT_WIDTH: 576,
3
+ MAX_LENGTH: 2240,
4
+ MAX_LENGTH_MIP_201: 2000,
5
+ MAX_TEMPLATE_LENGTH: 900,
6
+ MAX_TEMPLATE_LENGTH_MIP_201: 2000,
7
+ CONTENT_1_INCH: 160,
8
+ CONTENT_2_INCH: 385,
9
+ CONTENT_3_INCH: 576,
10
+ CONTENT_4_INCH: 762,
11
+ } as const;
@@ -0,0 +1,7 @@
1
+ export const NPrintQuality = {
2
+ LOW_FAST: 0,
3
+ MIDDLE: 1,
4
+ HIGH_SLOW: 2,
5
+ } as const;
6
+
7
+ export type NPrintQualityCode = (typeof NPrintQuality)[keyof typeof NPrintQuality];
@@ -0,0 +1,9 @@
1
+ export const NPrinterStatus = {
2
+ OK: 0,
3
+ OUT_OF_PAPER: 2,
4
+ COVER_OPENED: 4,
5
+ OVERHEAT: 8,
6
+ PAPER_JAM: 16,
7
+ } as const;
8
+
9
+ export type NPrinterStatusCode = (typeof NPrinterStatus)[keyof typeof NPrinterStatus];
@@ -0,0 +1,9 @@
1
+ export const NPrinterType = {
2
+ NONE: 0,
3
+ NEMONIC: 1,
4
+ NEMONIC_LABEL: 2,
5
+ NEMONIC_MINI: 3,
6
+ NEMONIC_MIP201: 4,
7
+ } as const;
8
+
9
+ export type NPrinterTypeCode = (typeof NPrinterType)[keyof typeof NPrinterType];
@@ -0,0 +1,51 @@
1
+ export const NResult = {
2
+ OK: 0,
3
+ TIMEOUT: -64,
4
+ CANCELED: -65,
5
+ BATTERY_LOW: -70,
6
+ BATTERY_NEED_CHARGE: -71,
7
+ BATTERY_LOW_OR_NO_CHARGE: -72,
8
+ PAPER_NOT_MATCHED: -80,
9
+ UNAVAILABLE_CARTRIDGE: -81,
10
+ NEED_UPDATE_FIRMWARE: -90,
11
+ BLUETOOTH_UNSUPPORTED: -100,
12
+ BLUETOOTH_DISABLED: -101,
13
+ BLUETOOTH_NO_PERMISSION: -102,
14
+ BLUETOOTH_RESETTING: -103,
15
+ CANCELED_OR_BLUETOOTH_DISABLED: -104,
16
+ BLUETOOTH_UNKNOWN: -105,
17
+ LOCATION_NO_PERMISSION: -110,
18
+ LOCATION_DISABLED: -111,
19
+ USB_NO_PERMISSION: -120,
20
+ USB_NO_INTERFACE: -121,
21
+ USB_NO_ENDPOINT_OUT: -122,
22
+ USB_NO_ENDPOINT_IN: -123,
23
+ SCAN_FAILED: -200,
24
+ NO_SELECTED_PRINTER: -300,
25
+ NOT_CONNECTED: -301,
26
+ ALREADY_CONNECTED: -302,
27
+ NOT_FOUND: -303,
28
+ NOT_CONNECTABLE: -304,
29
+ SOCKET_ERROR: -305,
30
+ CONNECT_ERROR: -306,
31
+ CONNECT_FAILED: -307,
32
+ SESSION_ERROR: -308,
33
+ CONNECT_SERVICE_NOT_FOUND: -309,
34
+ CONNECT_UNSUPPORTED_MODE: -310,
35
+ IO_RECEIVE_ERROR: -400,
36
+ IO_SEND_ERROR: -401,
37
+ SEND_FAILED: -402,
38
+ UNKNOWN: -500,
39
+ INVALID_PARAMETER: -501,
40
+ NOT_MATCHED_PRINTER_TYPE: -502,
41
+ NO_CALLBACK: -503,
42
+ NOT_MATCHED_COMMAND_RESULT_FORMAT: -504,
43
+ INVALID_PRINTER_NAME: -505,
44
+ INVALID_PRINTER_RESULT: -506,
45
+ PRINTER_RESULT_FAILED: -507,
46
+ UNSUPPORTED_DEVICE: -508,
47
+ OPERATION_NOT_SUPPORTED: -509,
48
+ EXCEED_MAX_SIZE: -900,
49
+ } as const;
50
+
51
+ export type NResultCode = (typeof NResult)[keyof typeof NResult];
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import BootNemonicPrinter from './BootNemonicPrinterModule';
2
+
3
+ export default BootNemonicPrinter;
4
+ export * from './BootNemonicPrinter.types';
5
+ export * from './constants/NResult';
6
+ export * from './constants/NPrinterStatus';
7
+ export * from './constants/NPrinterType';
8
+ export * from './constants/NPrintQuality';
9
+ export * from './constants/NConnectState';
10
+ export * from './constants/NBatteryStatus';
11
+ export * from './constants/NPowerSaveMode';
12
+ export * from './constants/NPrintImageLength';
13
+ export * from './constants/NCartridgeType';
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ // @generated by expo-module-scripts
2
+ {
3
+ "extends": "expo-module-scripts/tsconfig.base",
4
+ "compilerOptions": {
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__rsc_tests__/*"]
9
+ }