Paket @smash-pos/core
packages/pos-core berisi semua yang sama antara dua POS, supaya perbaikan di satu tempat berlaku di keduanya. Dikonsumsi sebagai TypeScript sumber ("main": "src/index.ts") oleh Metro; tidak ada langkah build.
flowchart TD
subgraph core["@smash-pos/core"]
CL["createPosClient<br/>sesi perangkat + staf, request"]
OB["createOutbox<br/>antrean kirim"]
GT["PosGate + usePos<br/>pairing, login PIN, shift, outbox, pengaturan"]
UI["PayModal, ReceiptModal,<br/>HistoryList, MoreScreen, StatusBanner"]
TT["computeTotals, receipt, format"]
end
APP["apps/retail atau apps/fnb"] --> CL
APP --> OB
APP --> GT
APP --> UI
UI --> TT
Pemakaian minimum
Section titled “Pemakaian minimum”export const client = createPosClient({ kind: "retail", appKey: "smash.retail" });export const outbox = createOutbox(client, { key: "smash.retail.outbox.v1", endpoint: "/v1/sales/sync", bodyKey: "sales" });<PosGate client={client} outbox={outbox} title="Smash POS Retail"> <Stack screenOptions={{ headerShown: false }} /></PosGate>Di dalam PosGate, usePos() memberi: client, session, settings, staff, staffMode, canManage, shift, outboxItems, connection, flush, openShift, closeShift, signOutStaff, unpair.
Ekspor penting
Section titled “Ekspor penting”| Ekspor | Fungsi |
|---|---|
createPosClient |
HTTP client; request(path, { body, form, staffToken }), staff.*, shifts.*, outlet.settings(), pairWithToken, startDemo |
createOutbox |
submit, flush, retry, discard, items, subscribe |
computeTotals / totalsFor |
Hitung subtotal, diskon, service, pajak |
receiptFromCart / buildReceiptText |
Susun dan render struk |
PayModal, ReceiptModal, HistoryList, MoreScreen, StatusBanner |
Layar dan komponen bersama |
confirmAction, shareText |
Konfirmasi dan berbagi lintas platform (web dan native) |
ApiError |
Error bertipe dengan kind, status, code |
pnpm test menjalankan vitest: totals (memakai fixtures/totals.json bersama dengan API), receipt, dan outbox (offline, restart, penolakan, token staf kedaluwarsa).