Skip to content

Commit 13c2894

Browse files
committed
docs(update): update documentations, extract package
1 parent 78563e4 commit 13c2894

File tree

196 files changed

+255
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+255
-213
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 100 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,119 @@
1-
# EPSON ePOS SDK for React Native
2-
3-
_An unofficial React Native library for printing on an EPSON TM printer with the <strong>Epson ePOS SDK for iOS</strong> and <strong>Epson ePOS SDK for Android</strong>_
4-
5-
6-
<p align="center">
7-
<img src="./assets/printer.png"
1+
<p align="center" style="margin: -40px -40px 0 -40px;">
2+
<img src="./docs/assets/printer.png"
83
alt="Printer"
94
/>
105
</p>
116

127
| [![npm version](https://badge.fury.io/js/react-native-esc-pos-printer.svg)](https://badge.fury.io/js/react-native-esc-pos-printer) |
138
|---|
149

15-
1. [Installation](./docs/INSTALLATION.md)
16-
2. [API](./docs/API.md)
10+
## Features
11+
- Supports **BLE, LAN, USB** and **Wi-Fi** connection methods
12+
- Print receipts natively and from React Native views
13+
- Compatible with the **new architecture**
14+
- Build-in **queue mechanism**
15+
- **Clear errors descriptions**
16+
- Proxy-like API makes it **easy to add new commands**
17+
18+
19+
## Installation
20+
21+
### React Native
22+
23+
```sh
24+
yarn add react-native-esc-pos-printer
25+
```
26+
27+
### Expo
28+
29+
```sh
30+
npx expo install react-native-esc-pos-printer
31+
npx expo prebuild
32+
```
33+
34+
35+
36+
### Also complete [this required steps](./docs/INSTALLATION.md)
37+
38+
## Usage
39+
40+
### Discover printers
41+
42+
```tsx
43+
import { usePrintersDiscovery } from 'react-native-esc-pos-printer';
44+
45+
function App() {
46+
const { start, isDiscovering, printers } =
47+
usePrintersDiscovery();
48+
49+
useEffect(() => {
50+
start();
51+
}, []);
52+
}
53+
```
54+
55+
### Print
56+
57+
```tsx
58+
import { Printer } from 'react-native-esc-pos-printer';
59+
60+
function App() {
61+
const { start, isDiscovering, printers } =
62+
usePrintersDiscovery();
63+
64+
useEffect(() => {
65+
start();
66+
}, []);
67+
68+
const print = () => {
69+
// printing on all discovered printers
70+
printers.forEach(printersData => {
71+
const printerInstance = new Printer({
72+
target: printersData.target,
73+
deviceName: printersData.deviceName,
74+
});
75+
76+
const res = await printerInstance.addQueueTask(async () => {
77+
await Printer.tryToConnectUntil(
78+
printerInstance,
79+
(status) => status.online.statusCode === PrinterConstants.TRUE
80+
);
81+
await printerInstance.addText('DUDE!');
82+
await printerInstance.addFeedLine();
83+
await printerInstance.addCut();
84+
const result = await printerInstance.sendData();
85+
await printerInstance.disconnect();
86+
return result;
87+
})
88+
})
89+
}
90+
91+
return <Button title="Print" onPress={print} />;
92+
}
93+
94+
```
95+
96+
## Documentation
97+
1. [Discovery API](./docs/discovery/discovery.md)
98+
2. [Printer API](./docs/printer/Printer.md)
1799
3. [Examples](./docs/QUICK_START.md)
18100
4. [Supported devices](./docs/SUPPORTED_DEVICES.md)
19101
5. [SDK information (v2.27.0)](./docs/SDK.md)
20102

21-
## Sponsoring
22-
I'm working on the lib at my free time. If you like the lib and want to support me, you can [buy me a cofee](https://buymeacoffee.com/tr3v3r
23-
). Thanks!
103+
## Sponsor this project
104+
If you like what I'm doing and want to support me, you can:
24105

106+
<p align="left" style="overflow: hidden; max-width: 500px;">
107+
<a style="display: block; margin-top: -20px; margin-bottom: -30px" href="https://buymeacoffee.com/tr3v3r" target="_blank">
108+
<img src="./docs/assets/coffee.png" alt="Buy me a coffee" />
109+
</a>
110+
</p>
25111

26112
## Known issues
27113

28-
1. For now it's not possible to print and discover on Android simulator. But you can always use real device.
29-
30-
2. If you have an issue with using Flipper on iOS real device, please [try this](./docs/flipperWorkaround.md) workaround.
114+
1. It's not possible to print and discover on Android simulator.
31115

32-
## Roadmap
33-
- [x] Add new architecture support
34-
- [x] Add expo example
35-
- [x] Add print from react View example
36-
- [x] Reimplement discovering to have implementation close to native SDK
37-
- [x] Reimplement printing to have implementation close to native SDK
38-
- [x] Add queue mechanism for quick print
116+
2. If you have an issue with using Flipper on iOS real device, [try this](./docs/flipperWorkaround.md) workaround.
39117

40118
## License
41119

β€Žassets/printer.pngβ€Ž

-58.7 KB
Binary file not shown.

β€Ždocs/API.mdβ€Ž

Lines changed: 0 additions & 51 deletions
This file was deleted.

β€Ždocs/INSTALLATION.mdβ€Ž

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,7 @@
55
- [Expo](#expo)
66

77

8-
## Bare React Native
9-
10-
```sh
11-
npm install react-native-esc-pos-printer
12-
```
13-
14-
or
15-
16-
```sh
17-
yarn add react-native-esc-pos-printer
18-
```
8+
## React Native
199

2010
### Android
2111
Add the following permissions to `android/app/src/main/AndroidManifest.xml`
@@ -56,7 +46,7 @@ For iOS13 or later, add Privacy-Bluetooth Always Usage Description.
5646
3. Select "Privacy-Bluetooth Always Usage Description".
5747
4. Enter the intended use of Bluetooth in the "Value" field. (Example: Use this to communicate with the printer.)
5848

59-
<img src="../assets/ios-install-0.png"
49+
<img src="./assets/ios-install-0.png"
6050
alt="Indoor Building Map Android"
6151
height="300"
6252
/>
@@ -69,19 +59,14 @@ For iOS13 or later, add Privacy-Bluetooth Always Usage Description.
6959
4. Expand the items added in Step 3.
7060
5. Enter com.epson.escpos as the Value for Item 0.
7161

72-
<img src="../assets/ios-install.png"
62+
<img src="./assets/ios-install.png"
7363
alt="Indoor Building Map Android"
7464
height="300"
7565
/>
7666

7767
---
7868
## Expo
7969

80-
```sh
81-
npx expo install react-native-esc-pos-printer
82-
npx expo prebuild
83-
```
84-
8570
Modify `app.json`:
8671

8772
### Android

β€Ždocs/QUICK_START.mdβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33

44
## 1) Simple print
55

6-
<img src="../assets/quickprint.png"
6+
<img src="./assets/quickprint.png"
77
alt="Receipt`"
88
height="300"
99
/>
1010

11-
Please find full code [here](https://github.com/tr3v3r/react-native-esc-pos-printer/tree/main/example/src/screens/SimplePrint.tsx).
11+
Please find full code [here](https://github.com/tr3v3r/react-native-esc-pos-printer/tree/main/package/example/src/screens/SimplePrint.tsx).
1212

1313
## 2) Print from React Native View
1414

15-
<img src="../assets/viewShotCode.jpg"
15+
<img src="./assets/viewShotCode.jpg"
1616
alt="Receipt`"
1717
width="300"
1818
/>
1919

20-
<img src="../assets/viewShotResult.jpg"
20+
<img src="./assets/viewShotResult.jpg"
2121
alt="Receipt`"
2222
height="300"
2323
/>
2424

25-
Please find full code [here](https://github.com/tr3v3r/react-native-esc-pos-printer/tree/main/example/src/screens/PrintFromView.tsx).
25+
Please find full code [here](https://github.com/tr3v3r/react-native-esc-pos-printer/tree/main/package/example/src/screens/PrintFromView.tsx).

β€Ždocs/assets/coffee.pngβ€Ž

2.48 MB
Loading
File renamed without changes.
File renamed without changes.

β€Ždocs/assets/printer.pngβ€Ž

1.99 MB
Loading
File renamed without changes.

0 commit comments

Comments
Β (0)