@pradip1995/pos-common
v0.1.10
Published
Shared POS utilities for Medusa POS and Offline POS (Bluetooth print, receipts, storage, app updates).
Maintainers
Readme
@pradip1995/pos-common
Shared POS utilities for offline-pos and medusa-pos:
- Secure storage helpers (native SecureStore + web AsyncStorage)
- Receipt paper width + default print target prefs
- HTML / system receipt printing (
expo-print) - Bluetooth ESC/POS printing (address normalize, permissions,
Rs.for ₹) - Smart print routing (Bluetooth vs system)
- React Query hooks for printer settings
- App updates from the VyaparNext deployer (Windows, macOS, Android) and machine heartbeats
Install
npm install @pradip1995/pos-commonConfigure (required once per app)
// src/pos-common-setup.ts
import { configurePosCommon } from '@pradip1995/pos-common';
configurePosCommon({
storagePrefix: 'offline_pos', // or medusa_pos
appName: 'POS Lite',
printerSettingsHint: 'Open Settings → Bluetooth printer.',
receiptAccentColor: '#0D9488',
printFrameId: 'offline-pos-receipt-print-frame',
});Import that file first in your root layout:
import './pos-common-setup';Usage
Prefer subpath imports so Jest / tree-shaking stay light:
import { printReceiptSmart } from '@pradip1995/pos-common/print-smart';
import { scanBluetoothPrinters } from '@pradip1995/pos-common/bluetooth-printer';
import { useBluetoothPrinter } from '@pradip1995/pos-common/hooks';
import { escPosSafeText } from '@pradip1995/pos-common/bluetooth-printer';Or the barrel:
import { printReceiptSmart, scanBluetoothPrinters } from '@pradip1995/pos-common';App updates
The deployer publishes one latest build per product and platform. AppUpdatePrompt checks it,
asks before downloading, verifies the SHA-256, then asks before restarting to install. It also
sends a heartbeat every 5 minutes so the machine shows on the deployer dashboard.
import { AppUpdatePrompt } from '@pradip1995/pos-common/app-update';
<AppUpdatePrompt apiBase="https://app.vyaparnext.com" product="OFFLINE_POS" appVersion="1.2.0" />Android needs
expo-file-system,expo-intent-launcher, and theandroid.permission.REQUEST_INSTALL_PACKAGESpermission. The APK must be signed with the same key as the installed app.Electron main process registers the download/install IPC:
const { registerPosUpdateHandlers } = require('@pradip1995/pos-common/updates/electron-main'); registerPosUpdateHandlers({ app, ipcMain, shell });and the preload exposes
platform,arch,getAppInfo,downloadUpdate,applyUpdate, andonUpdateProgressonwindow.posDesktop. Packagenode_modules/@pradip1995/pos-common/{package.json,dist/updates/**}in electron-builder.Publishing builds:
pos-release-upload(bin) hashes an installer and uploads it through the deployer release API usingDEPLOYER_URLandDEPLOYER_RELEASE_TOKEN.
