変更履歴 — Hapbeat JavaScript SDK
This content is not available in your language yet.
All notable changes to @hapbeat/sdk are documented here.
The format follows Keep a Changelog, and this
project adheres to Semantic Versioning.
0.2.0 - 2026-06-29
Section titled “0.2.0 - 2026-06-29”- React Native transport — a third
connect()build resolved via the packageexports"react-native"condition (dist/react-native.js). It opens a real UDP socket through the optional peer dependencyreact-native-udpand broadcasts straight from the phone over Wi-Fi — nohapbeat-helperneeded (a phone is not sandboxed like a browser). Same wire format as Node.react-native-udpis an optional peer dependency; install it in the app.- Needs a
TextDecoderpolyfill (fast-text-encoding): RN Hermes — incl. 0.86 — shipsTextEncoderbut notTextDecoder. Seeexamples/react-native/. - Verified on a physical Android device (RN 0.86, Hermes / New Architecture): UDP socket binds, a Hapbeat is discovered, command + streaming both fire — no helper.
examples/react-native/— a minimal Android demo: button taps send a command (play) and a 1 s synthesized streaming buffer.
Changed
Section titled “Changed”- Internal: Node and React Native transports now share
UdpTransportBase(all protocol/keepalive/discovery logic); only the socket plumbing differs. No public API change for the Node/Browser builds.
src/index.tsre-exports the wire layer asimport * as protocol; export { protocol }instead ofexport * as protocol, so React Native’s Metro bundles it without the@babel/plugin-transform-export-namespace-fromplugin.
0.1.0 - 2026-06-25
Section titled “0.1.0 - 2026-06-25”Initial public release. One API, two transports.
connect(options?)— Node (@hapbeat/sdk→dist/node.js, direct UDP broadcast) and Browser (dist/browser.js, via thehapbeat-helperWebSocket atws://localhost:7703). The bundler/runtime picks the build automatically through the packageexportsmap.Hapbeatfacade — the level‑1 “fire” surface:play(eventId, opts?)— theEventMap(kit manifest) decides the mode: command (events) plays the device’s installed clip; clip (stream_events) streams the event’s WAV from the host.streamPcm(pcm, opts?)— stream an ad‑hoc PCM16 buffer (stereo for L/R directional haptics).openStream(opts?)→LiveStream— a persistent stream for continuously‑modulated haptics (STREAM_BEGINonce, thenhandle.write()chunks,handle.close()), with no per‑chunk teardown.preloadClips(),stop(),stopAll(),ping(),discover(),close().
EventMap— the orthogonal tuning side.fromManifest()(kit manifest schema 2.0.0),fromGains(), plusget/gainFor/has/ids/size.parseWav,ClipStreamer,LiveStreamas named exports for advanced use, andprotocol.*(Layer‑1 wire builders/parsers).- Device discovery (broadcast PING/PONG) and target addressing
(
"player_1/chest","*/chest", or""= broadcast). - Examples:
examples/node-minimal.mjs,examples/browser-minimal.html, and a browser haptic‑demo arcade underexamples/games/.