Search by

wielorzeczownik / pepito-client

wielorzeczownik

Pepito cat flap API client: live in and out events, current status and archive statistics. Plain PHP, with the Rust core as opt-in FFI.

Package info

github.com/wielorzeczownik/pepito-client

Homepage

Type:composer-plugin

pkg:composer/wielorzeczownik/pepito-client

Statistics

Installs: 27

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v3.2.14 2026-11-25 18:33 UTC

README

pepito-client logo

Pépito Client

Release crates.io npm Packagist License: MIT
Rust TypeScript PHP

A client for the Pepito API, the feed of a cat door that reports when Pépito goes out and comes back. It comes as a Rust crate, an npm package and a Composer package.

Package Language Default backend Opt-in backend Docs
pepito-client Rust Rust - crates/core/README.md
@wielorzeczownik/pepito-client JS / TS plain TypeScript Rust through wasm js/README.md
wielorzeczownik/pepito-client PHP 8.2+ plain PHP Rust through FFI php/README.md

The npm and Composer packages need nothing native by default. The Rust backend is there if you want it, through @wielorzeczownik/pepito-client/wasm or Client::withFfi().

All three do the same things:

  • parse the SSE stream into in/out events and track whether the cat is home
  • drop repeats that arrive again after a reconnect
  • cache the current status and know how old it is
  • watch the heartbeat and reconnect when the stream goes quiet
  • compute statistics from the Pepito-data archive

Events, status(), statistics and snapshots are the same in every backend, so a snapshot saved by one restores in any other.

How it fits together

The Rust core does no networking. Each binding brings its own transport, which is why the same core runs in wasm and behind PHP's FFI.

Path What it is
crates/core/ the core, published to crates.io. The net feature adds reqwest
crates/ffi/ C ABI over the core, JSON in and out, used by the PHP package
crates/wasm/ wasm-bindgen over the core, used by @wielorzeczownik/pepito-client/wasm
js/src/ the TypeScript port (core.ts), transport (pepito.ts), wasm wrapper
php/src/ the PHP port (Tracker, History), client, FFI wrapper (FfiTracker)

Each binding is its own crate, so building for PHP doesn't compile wasm-bindgen and the wasm build doesn't pull in reqwest. Parity tests run each port against the Rust core on the same input and fail on any difference.

Building

The default JS and PHP packages need no build step. The Rust backends do:

make wasm     # js/src/wasm/ through wasm-bindgen
make header   # php/lib/pepito.h from crates/ffi
make dylib    # php/lib/pepito.h and php/lib/libpepito.{dylib,so}

That needs cbindgen and wasm-bindgen-cli at exactly the version in crates/wasm/Cargo.toml:

cargo install cbindgen
cargo install wasm-bindgen-cli --version 0.2.130

Disclaimer

Not official and not affiliated with the Pepito API or its author. If the API changes, this will stop working until it's fixed here.

The cat in the logo is from Font Awesome Free, licensed under CC BY 4.0.