Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ PODS:
- React-cxxreact (= 0.63.2)
- React-jsi (= 0.63.2)
- React-jsinspector (0.63.2)
- react-native-esc-pos-printer (2.2.1):
- React-Core
- react-native-star-io10 (1.2.0):
- React
- React-RCTActionSheet (0.63.2):
- React-Core/RCTActionSheetHeaders (= 0.63.2)
- React-RCTAnimation (0.63.2):
Expand Down Expand Up @@ -245,8 +249,12 @@ PODS:
- React-Core (= 0.63.2)
- React-cxxreact (= 0.63.2)
- React-jsi (= 0.63.2)
- tillpos-rn-receipt-printer-utils (0.1.0):
- RNFS (2.16.6):
- React
- tillpos-rn-receipt-printer-utils (0.2.19):
- React
- react-native-esc-pos-printer
- react-native-star-io10
- Yoga (1.14.0)

DEPENDENCIES:
Expand All @@ -267,6 +275,8 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-esc-pos-printer (from `../node_modules/react-native-esc-pos-printer`)
- react-native-star-io10 (from `../node_modules/react-native-star-io10`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
Expand All @@ -277,6 +287,7 @@ DEPENDENCIES:
- React-RCTText (from `../node_modules/react-native/Libraries/Text`)
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNFS (from `../node_modules/react-native-fs`)
- tillpos-rn-receipt-printer-utils (from `../..`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -315,6 +326,10 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-esc-pos-printer:
:path: "../node_modules/react-native-esc-pos-printer"
react-native-star-io10:
:path: "../node_modules/react-native-star-io10"
React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation:
Expand All @@ -335,6 +350,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/Vibration"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNFS:
:path: "../node_modules/react-native-fs"
tillpos-rn-receipt-printer-utils:
:path: "../.."
Yoga:
Expand All @@ -357,6 +374,8 @@ SPEC CHECKSUMS:
React-jsi: 54245e1d5f4b690dec614a73a3795964eeef13a8
React-jsiexecutor: 8ca588cc921e70590820ce72b8789b02c67cce38
React-jsinspector: b14e62ebe7a66e9231e9581279909f2fc3db6606
react-native-esc-pos-printer: 699b8f2c060c36f244bbc443449fec83a40bca09
react-native-star-io10: 21afc32e6319db95ae5b46af0b7e5546298f1f04
React-RCTActionSheet: 910163b6b09685a35c4ebbc52b66d1bfbbe39fc5
React-RCTAnimation: 9a883bbe1e9d2e158d4fb53765ed64c8dc2200c6
React-RCTBlob: 39cf0ece1927996c4466510e25d2105f67010e13
Expand All @@ -367,9 +386,10 @@ SPEC CHECKSUMS:
React-RCTText: 1b6773e776e4b33f90468c20fe3b16ca3e224bb8
React-RCTVibration: 4d2e726957f4087449739b595f107c0d4b6c2d2d
ReactCommon: a0a1edbebcac5e91338371b72ffc66aa822792ce
tillpos-rn-receipt-printer-utils: dbc6561b334bc48c8d2b73163ea1bcec35178d68
RNFS: 2bd9eb49dc82fa9676382f0585b992c424cd59df
tillpos-rn-receipt-printer-utils: deb8e6f2eac4348ddef8742361906f64efa6017d
Yoga: 7740b94929bbacbddda59bf115b5317e9a161598

PODFILE CHECKSUM: f48d21d8c903ca4bae3af77aec96d015293dce33

COCOAPODS: 1.10.1
COCOAPODS: 1.11.3
22 changes: 22 additions & 0 deletions example/ios/ThermalReceiptPrinterExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
929AC738BA57C3E4D5D8B112 /* [CP] Copy Pods Resources */,
2DBB992C130D2C60BA65DAF1 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -144,6 +145,7 @@
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 5BRLH95UCS;
LastSwiftMigration = 1110;
};
};
Expand Down Expand Up @@ -194,6 +196,24 @@
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
};
2DBB992C130D2C60BA65DAF1 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ThermalReceiptPrinterExample/Pods-ThermalReceiptPrinterExample-frameworks.sh",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/react-native-star-io10/StarIO10.framework/StarIO10",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/StarIO10.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ThermalReceiptPrinterExample/Pods-ThermalReceiptPrinterExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
929AC738BA57C3E4D5D8B112 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -288,6 +308,7 @@
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 5BRLH95UCS;
INFOPLIST_FILE = ThermalReceiptPrinterExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_CFLAGS = (
Expand Down Expand Up @@ -315,6 +336,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 5BRLH95UCS;
INFOPLIST_FILE = ThermalReceiptPrinterExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_CFLAGS = (
Expand Down
6 changes: 6 additions & 0 deletions example/ios/ThermalReceiptPrinterExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocalNetworkUsageDescription</key>
<string>Would like to use Local Network for Printing</string>
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>jp.star-m.starpro</string>
</array>
<key>UIFileSharingEnabled</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
Expand Down
16 changes: 12 additions & 4 deletions example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const escape = require('escape-string-regexp');
const pak = require('../package.json');

const root = path.resolve(__dirname, '..');
const packagePath = (packageName) =>
path.dirname(require.resolve(`${packageName}/package.json`));

const modules = Object.keys({
...pak.peerDependencies,
Expand All @@ -23,10 +25,16 @@ module.exports = {
)
),

extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),
extraNodeModules: {
'@babel/runtime': packagePath('@babel/runtime'),
...modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),
'stream': require.resolve('readable-stream'),
'zlib': require.resolve('browserify-zlib'),
'fs': require.resolve('react-native-fs'),
},
},

transformer: {
Expand Down
10 changes: 9 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@
"start": "react-native start"
},
"dependencies": {
"@tillpos/xml-escpos-helper": "^0.2.7",
"browserify-zlib": "0.2.0",
"buffer": "^6.0.3",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-esc-pos-printer": "^2.2.1"
"react-native-esc-pos-printer": "^2.2.1",
"react-native-fs": "2.16.6",
"react-native-star-io10": "^1.2.0",
"readable-stream": "3.6.0",
"util": "^0.12.5"
},
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/runtime": "^7.9.6",
"@types/node": "12.20.13",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-rewrite-require": "^1.14.5",
"metro-react-native-babel-preset": "^0.59.0"
}
}
125 changes: 111 additions & 14 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,135 @@ import {
NetPrinter,
PrinterBrand,
PrinterSeries,
PrintRow,
RowAlignment,
} from '@tillpos/rn-receipt-printer-utils';
import { Buffer } from 'buffer';
import React, { Fragment, useCallback } from 'react';

interface Printer {
device_name: string;
host: string;
port: number;
brand: PrinterBrand;
series?: PrinterSeries;
}
const divider = Array.from({ length: 42 }).fill('-').join('');
const space = Array.from({ length: 32 }).fill(' ').join('');
const PRINTERS: Array<Printer> = [
{ device_name: 'P1', host: '10.15.0.101', port: 9100 },
{
device_name: 'P1',
host: '10.15.0.175',
port: 9100,
brand: PrinterBrand.STAR,
},
{
device_name: 'P2',
host: '10.15.0.101',
port: 9100,
brand: PrinterBrand.EPSON,
},
{
device_name: 'P3',
host: '10.15.0.196',
port: 9100,
brand: PrinterBrand.EPSON,
series: PrinterSeries.TM_U220,
},
];

let globalCount = 0;

export default function App() {
const testPrint = useCallback(async () => {
globalCount++;
const buffer = Buffer.from(
globalCount + ' ::: minions minions minions \n \n '
);
for (let i = 0; i < 1; i++) {
let spont: number = Math.floor(Math.random() * PRINTERS.length);
const printer = PRINTERS[spont];
const printRows: PrintRow[] = [
{
isBold: true,
alignment: RowAlignment.CENTER,
height: 4,
width: 1,
text: 'New Order \n',
feedLine: false,
},
{
isBold: false,
alignment: RowAlignment.RIGHT,
height: 0,
width: 2,
text: 'test \n',
feedLine: true,
},
{
isBold: true,
alignment: RowAlignment.CENTER,
height: 0,
width: 0,
text: divider + '\n',
feedLine: false,
},
{
isBold: false,
alignment: RowAlignment.RIGHT,
height: 0,
width: 2,
text: 'test \n',
feedLine: false,
},
{
isBold: false,
alignment: RowAlignment.RIGHT,
height: 0,
width: 2,
text: 'test \n',
feedLine: true,
},
{
isBold: false,
alignment: RowAlignment.RIGHT,
height: 0,
width: 2,
text: 'test \n',
feedLine: true,
},
{
isBold: false,
alignment: RowAlignment.RIGHT,
height: 0,
width: 2,
text: 'Hello World! \n',
feedLine: false,
},
{
isBold: false,
alignment: RowAlignment.RIGHT,
height: 0,
width: 2,
text: 'test \n',
feedLine: true,
},
{
isBold: true,
alignment: RowAlignment.CENTER,
height: 0,
width: 0,
text: divider + '\n',
feedLine: false,
},
{
isBold: true,
alignment: RowAlignment.CENTER,
height: 0,
width: 0,
text: 'Total' + space + '69.69\n',
feedLine: false,
},
];
for (var printer of PRINTERS) {
try {
console.log('sending data to;' + printer.host);
await NetPrinter.connectAndSend(
printer.host,
printer.port,
buffer,
PrinterBrand.EPSON,
PrinterSeries.TM_M30
printRows,
printer.brand,
printer.series || PrinterSeries.TM_M30
);
} catch (err) {
console.log('error', err);
Expand Down
Loading