@apocaliss92/scrypted-reolink-native 0.4.28 → 0.4.30

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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(python3:*)",
5
+ "Bash(git push:*)",
6
+ "WebFetch(domain:pastebin.com)",
7
+ "Bash(curl:*)",
8
+ "Bash(npx tsc:*)",
9
+ "mcp__ide__getDiagnostics"
10
+ ]
11
+ }
12
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,75 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ Scrypted plugin for Reolink IP cameras using the proprietary Baichuan binary protocol (TCP port 9000 / UDP). Supports regular cameras, battery cameras, NVRs, and multifocal (dual-lens) cameras. The repo contains two components:
8
+
9
+ - **Plugin** (`src/`) — Scrypted DeviceProvider plugin, bundled by `scrypted-webpack`
10
+ - **Library** (`reolink-baichuan-js/`) — Baichuan protocol implementation, consumed as a local file dependency (`file:./reolink-baichuan-js`)
11
+
12
+ ## Build Commands
13
+
14
+ ### Plugin (root)
15
+ ```bash
16
+ npm run build # scrypted-webpack → dist/main.nodejs.js + dist/plugin.zip
17
+ npm run scrypted-deploy-debug # build + deploy to debug Scrypted instance
18
+ ```
19
+
20
+ ### Library (reolink-baichuan-js/)
21
+ ```bash
22
+ cd reolink-baichuan-js
23
+ npm run build # tsup (ESM+CJS) + tsc declarations + api-extractor rollup
24
+ npm run typecheck # tsc --noEmit
25
+ npm run lint # eslint .
26
+ ```
27
+
28
+ ### Rebuild library and reinstall in plugin
29
+ ```bash
30
+ ./build-lib.sh # builds library then runs npm install at root
31
+ ```
32
+
33
+ After modifying `reolink-baichuan-js/`, always run `./build-lib.sh` from the root before building/deploying the plugin.
34
+
35
+ ## Architecture
36
+
37
+ ### Plugin Entry Point
38
+ `src/main.ts` — `ReolinkNativePlugin` is the root `DeviceProvider` and `DeviceCreator`. It manages device lifecycle and serves video clips/thumbnails via `HttpRequestHandler` webhooks.
39
+
40
+ ### Device Hierarchy
41
+ - `BaseBaichuanClass` (`baichuan-base.ts`) — abstract base managing Baichuan API lifecycle (connection, reconnection with backoff, ping keepalive, event subscription)
42
+ - `ReolinkCamera` (`camera.ts`) — extends base, implements Scrypted interfaces (VideoCamera, Camera, Settings, ObjectDetector, PanTiltZoom, Intercom, etc.)
43
+ - `ReolinkNativeNvrDevice` (`nvr.ts`) — NVR support with DeviceDiscovery for channels
44
+ - `ReolinkNativeMultiFocalDevice` (`multiFocal.ts`) — dual-lens PIP stream support
45
+ - Accessories (`accessories/`) — sub-devices for siren, floodlight, PIR sensor, autotracking (separate ScryptedDeviceBase instances)
46
+
47
+ ### Device Identification
48
+ Device type is encoded in the `nativeId` suffix: `-cam`, `-battery-cam`, `-nvr`, `-multifocal`, `-battery-multifocal`, `-udp-cam`, etc. The `createCamera()` factory in `main.ts` switches on these.
49
+
50
+ ### Transport
51
+ TCP (regular cameras) or UDP/BCUDP (battery/WiFi cameras). Transport selection happens in `connect.ts` via `createBaichuanApi()`.
52
+
53
+ ### API Lifecycle
54
+ The Baichuan API is lazily instantiated on first use via `ensureClientPromise` with automatic reconnection on disconnect.
55
+
56
+ ## TypeScript Configuration
57
+
58
+ - **Plugin**: `module: Node16`, `target: ES2021`, no strict mode
59
+ - **Library**: `strict: true`, `noUncheckedIndexedAccess: true`, `exactOptionalPropertyTypes: true`, `target: ES2022`, `moduleResolution: Bundler`
60
+
61
+ ## Linting
62
+
63
+ Only the library has ESLint configured (flat config). `@typescript-eslint/no-explicit-any` is off. Unused vars prefixed with `_` are ignored.
64
+
65
+ ## Debugging
66
+
67
+ VS Code launch config attaches to a Scrypted instance on port 10081 (configured via `scrypted.debugHost`). Pre-launch task runs `npm run scrypted-vscode-launch`.
68
+
69
+ ## Key Local Dependencies
70
+
71
+ The plugin references sibling local repos via `file:` paths:
72
+ - `@scrypted/common` → `../../scrypted/common`
73
+ - `@scrypted/rtsp` → `../../scrypted/plugins/rtsp`
74
+
75
+ These must exist on disk for `npm install` to succeed.