ota-hub-reactjs 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # OTA Hub ReactJS
2
+
3
+ **ReactJS tools for interacting with MCUs such as ESP32 over OTA.**
4
+
5
+ `ota-hub-reactjs` provides a set of React-friendly utilities to:
6
+
7
+ - Flash firmware to microcontrollers (ESP32 and similar)
8
+ - Read from multiple MCUs over serial **in parallel**
9
+ - Connect to MCUs via wireless transport stacks such as WebSockets for real-time streaming
10
+ - Handle Protobuf and other message layer wrappers
11
+
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install ota-hub-reactjs
17
+ # or
18
+ yarn add ota-hub-reactjs
19
+ ```
20
+
21
+ Peer dependencies:
22
+
23
+ ```bash
24
+ npm install react react-dom
25
+ ```
26
+
27
+ # Features
28
+
29
+ ## Transport layers
30
+
31
+ - All transport layers are designed to support multiple connections (thus devices) in parallel
32
+ - You can mix and match tranport layers within your applications
33
+ - All ConnectionStates are extendible, e.g.
34
+ ```ts
35
+ export type EnhancedSerialConnectionState = SerialConnectionState & {
36
+ dataPoints: DataPoint[];
37
+ isRecording: boolean;
38
+ edgeModelVersion: string;
39
+ wifiSignal: number;
40
+ wifiSSID: string;
41
+ batteryLevel: number;
42
+ };
43
+ ```
44
+
45
+ ### Serial Communication
46
+ Read and write to multiple MCUs concurrently over serial connections.
47
+
48
+ ```tsx
49
+ import { SerialMultiDeviceWhisperer, SerialConnectionState } from "ota-hub-reactjs";
50
+
51
+ const serialDeviceWhisperer = new SerialMultiDeviceWhisperer<EnhancedSerialConnectionState>();
52
+ serialDeviceWhisperer.addConnection(); // Web browser will prompt for which Serial COM to use.
53
+
54
+ <YourLoggingComponent logs={
55
+ serialDeviceWhisperer.connections.map(
56
+ (c) => c..logs || []
57
+ )
58
+ }/>
59
+ ```
60
+
61
+ ## WebSocket Streaming
62
+ Connect to MCUs that expose WebSocket interfaces for live data streaming.<br />
63
+ _Currently this is for a server that allows multiple devices as clients to connect through, rather than one device as a server itself_
64
+
65
+ ```tsx
66
+ import { WebsocketMultiDeviceWhisperer } from "ota-hub-reactjs";
67
+
68
+ const websocketDeviceWhisperer = new WebsocketMultiDeviceWhisperer<EnhancedWebsocketConnectionState>("ws://192.168.1.100:8080");
69
+
70
+ // then as Serial
71
+ ```
72
+
73
+ ## Flash Firmware
74
+ Flash multiple MCUs with firmware images using esptool-js under the hood. - Currently only implemented in Serial, more to come!
75
+
76
+ ```ts
77
+ await Promise.all(
78
+ serialDeviceWhisperer.connections
79
+ .map(c => serialDeviceWhisperer.handleFlashFirmware({ uuid: c.uuid, firmwareBlob: blobToFlash! }))
80
+ );
81
+ ```
82
+
83
+ # Message Layer Wrappers
84
+ Supports Protobuf and other custom message layers for structured communication.
85
+
86
+ ```ts
87
+ import { ProtobufMultiDeviceWhisperer } from "ota-hub-reactjs";
88
+
89
+
90
+ const protobufSerialDeviceWhisperer = ProtobufMultiDeviceWhisperer<EnhancedSerialConnectionState, TXType, TXFromESP, RXToESP>({
91
+ transportLayer: serialDeviceWhisperer,
92
+ encodeRX: (msg) => RXToESP.encode(msg).finish(),
93
+ decodeTX: (bytes) => TXFromESP.decode(bytes),
94
+ messageTypeField: "txType",
95
+ rxTopicHandlerMap: logHandlerMap
96
+ });
97
+ ```
98
+ # Contributing
99
+ Contributions are welcome! Please submit issues or pull requests via the GitHub repository.
100
+
101
+ # License
102
+ MIT License © 2025 OTA Hub
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "@/base/device-whisperer.js";
2
- export * from "@/message_layers/protobuf-wrapper.js";
3
- export * from "@/transport_layers/serial-device-whisperer.js";
4
- export * from "@/transport_layers/websocket-device-whisperer.js";
1
+ export * from "./base/device-whisperer.js";
2
+ export * from "./message_layers/protobuf-wrapper.js";
3
+ export * from "./transport_layers/serial-device-whisperer.js";
4
+ export * from "./transport_layers/websocket-device-whisperer.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Re-export core types/classes
2
- export * from "@/base/device-whisperer.js";
2
+ export * from "./base/device-whisperer.js";
3
3
  // Message layer exports
4
- export * from "@/message_layers/protobuf-wrapper.js";
4
+ export * from "./message_layers/protobuf-wrapper.js";
5
5
  // Transport layers
6
- export * from "@/transport_layers/serial-device-whisperer.js";
7
- export * from "@/transport_layers/websocket-device-whisperer.js";
6
+ export * from "./transport_layers/serial-device-whisperer.js";
7
+ export * from "./transport_layers/websocket-device-whisperer.js";
@@ -1,4 +1,4 @@
1
- import { AddConnectionProps, DeviceConnectionState, MultiDeviceWhisperer } from "@/base/device-whisperer.js";
1
+ import { AddConnectionProps, DeviceConnectionState, MultiDeviceWhisperer } from "../base/device-whisperer.js";
2
2
  export type TopicHandlerContext<AppLayer extends DeviceConnectionState> = {
3
3
  base: ReturnType<typeof MultiDeviceWhisperer<AppLayer>>;
4
4
  uuid: string;
@@ -27,5 +27,5 @@ export declare function ProtobufMultiDeviceWhisperer<AppLayer extends DeviceConn
27
27
  updateConnection: (uuid: string, updater: (c: AppLayer) => AppLayer) => void;
28
28
  reconnectAll: () => void;
29
29
  updateConnectionName: (uuid: string, name: string) => void;
30
- appendLog: (uuid: string, log: import("@/base/device-whisperer.js").LogLine) => void;
30
+ appendLog: (uuid: string, log: import("../base/device-whisperer.js").LogLine) => void;
31
31
  };
@@ -1,5 +1,5 @@
1
1
  import { FlashOptions, Transport } from "esptool-js";
2
- import { DeviceConnectionState, AddConnectionProps } from "@/base/device-whisperer.js";
2
+ import { DeviceConnectionState, AddConnectionProps } from "../base/device-whisperer.js";
3
3
  export type SerialConnectionState = DeviceConnectionState & {
4
4
  port?: SerialPort;
5
5
  baudrate?: number;
@@ -27,5 +27,5 @@ export declare function SerialMultiDeviceWhisperer<AppOrMessageLayer extends Ser
27
27
  connectionsRef: import("react").RefObject<AppOrMessageLayer[]>;
28
28
  updateConnection: (uuid: string, updater: (c: AppOrMessageLayer) => AppOrMessageLayer) => void;
29
29
  updateConnectionName: (uuid: string, name: string) => void;
30
- appendLog: (uuid: string, log: import("@/base/device-whisperer.js").LogLine) => void;
30
+ appendLog: (uuid: string, log: import("../base/device-whisperer.js").LogLine) => void;
31
31
  };
@@ -1,5 +1,5 @@
1
1
  import { ESPLoader, Transport } from "esptool-js";
2
- import { MultiDeviceWhisperer } from "@/base/device-whisperer.js";
2
+ import { MultiDeviceWhisperer } from "../base/device-whisperer.js";
3
3
  export function SerialMultiDeviceWhisperer({ ...props } = {}) {
4
4
  const base = MultiDeviceWhisperer(props);
5
5
  const defaultOnReceive = (uuid, data) => {
@@ -1,4 +1,4 @@
1
- import { DeviceConnectionState, AddConnectionProps } from "@/base/device-whisperer.js";
1
+ import { DeviceConnectionState, AddConnectionProps } from "../base/device-whisperer.js";
2
2
  export type WebsocketConnectionState = DeviceConnectionState & {
3
3
  ws?: WebSocket;
4
4
  };
@@ -20,5 +20,5 @@ export declare function WebsocketMultiDeviceWhisperer<AppOrMessageLayer extends
20
20
  connectionsRef: import("react").RefObject<AppOrMessageLayer[]>;
21
21
  updateConnection: (uuid: string, updater: (c: AppOrMessageLayer) => AppOrMessageLayer) => void;
22
22
  updateConnectionName: (uuid: string, name: string) => void;
23
- appendLog: (uuid: string, log: import("@/base/device-whisperer.js").LogLine) => void;
23
+ appendLog: (uuid: string, log: import("../base/device-whisperer.js").LogLine) => void;
24
24
  };
@@ -1,4 +1,4 @@
1
- import { MultiDeviceWhisperer } from "@/base/device-whisperer.js";
1
+ import { MultiDeviceWhisperer } from "../base/device-whisperer.js";
2
2
  export function WebsocketMultiDeviceWhisperer(server_url, server_port, { ...props } = {}) {
3
3
  const defaultOnReceive = (uuid, data) => {
4
4
  const conn = base.connectionsRef.current.find((c) => c.uuid === uuid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ota-hub-reactjs",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "ReactJS tools for building web apps to flash MCU devices such as esp32, brought to you by OTA Hub.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",