Skip to content

Latest commit

 

History

History
74 lines (49 loc) · 2.9 KB

CLAUDE.md

File metadata and controls

74 lines (49 loc) · 2.9 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

# Install dependencies
yarn

# Build the library
yarn prepare

# Type checking
yarn typecheck

# Linting
yarn lint
yarn lint --fix

# Tests
yarn test

# Run a single test file
yarn test src/__tests__/index.test.tsx

# Clean build artifacts
yarn clean

# Example app
yarn example start
yarn example android
yarn example ios

Architecture

This is a React Native TurboModule library (New Architecture) for thermal receipt printing over Bluetooth, scaffolded with create-react-native-library.

Structure

  • src/ — TypeScript source; index.tsx exports the public API, NativeReceiptPrinter.ts defines the Spec interface and retrieves the native module via TurboModuleRegistry.getEnforcing
  • android/src/main/java/com/receiptprinter/ — Kotlin TurboModule implementation (ReceiptPrinterModule.kt) and package registration (ReceiptPrinterPackage.kt)
  • ios/ — Objective-C++ implementation (ReceiptPrinter.mm / ReceiptPrinter.h) with JSI bridge
  • example/ — Standalone demo app (Yarn workspace) for testing against real devices/simulators
  • lib/ — Compiled output (generated by yarn prepare; do not edit manually)

TurboModule pattern

The JS–native bridge works as follows:

  1. src/NativeReceiptPrinter.ts defines the Spec interface (method signatures)
  2. codegenConfig in package.json drives codegen to produce native specs
  3. Native classes (ReceiptPrinterModule on Android, ReceiptPrinter on iOS) implement the generated spec
  4. src/index.tsx wraps the native module and exposes the public API

Monorepo / tooling

  • Yarn v4 workspaces — root + example/ app
  • Turbo (turbo.json) — build:android and build:ios tasks with caching
  • Lefthook — pre-commit runs ESLint + tsc --noEmit on staged files; commit-msg enforces Conventional Commits (Angular preset: fix, feat, refactor, docs, test, chore)
  • react-native-builder-bob — compiles src/ to lib/ (ESM + TypeScript declarations; no CommonJS target)

TypeScript

tsconfig.json uses strict mode with bundler module resolution. The path alias react-native-receipt-printer → ./src/index lets the example app import the library source directly during development.

Current implementation state

The library is scaffolded but not yet functional. All native modules currently expose only the placeholder multiply(a, b) stub from create-react-native-library. react-native-bluetooth-classic is installed as a runtime dependency but is not yet wired into any native or JS code. Actual Bluetooth discovery, connection, and ESC/POS printing logic still needs to be implemented.

Release

yarn release runs release-it — bumps the version via Conventional Commits, tags the commit (v<version>), publishes to npm, and creates a GitHub release.