You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Downloads platform-specific go2rtc binary to `resources/bin/`
168
+
169
+
**pkg Bundling**: Production builds use `@yao-pkg/pkg` to create standalone executables with embedded assets (`dist/webui/**/*`, `resources/bin/**/*`)
170
+
171
+
**Why @yao-pkg/pkg instead of official pkg?** The official `pkg` package is no longer maintained and lacks support for newer Node.js versions and ARMv7 targets. We use `@yao-pkg/pkg` (a community-maintained fork) specifically because:
172
+
- It supports `node20-linuxstatic-armv7` target for Raspberry Pi 4 (32-bit OS)
173
+
- The original pkg dropped ARMv7 support, leaving no path for 32-bit Pi builds
174
+
- It maintains API compatibility with the original pkg configuration
156
175
157
-
**pkg Bundling**: Production builds use `pkg` to create standalone executables with embedded assets (`dist/webui/**/*`)
176
+
**Why esbuild instead of tsc for backend?** The build process bundles the backend with esbuild before pkg packaging because:
177
+
- pkg requires CJS format and has issues with dynamic imports/ESM interop
178
+
- esbuild produces a single bundled file that pkg can reliably package
179
+
- The `packages: 'external'` option keeps node_modules outside the bundle so pkg can include them as bytecode
158
180
159
181
## Dependencies
160
182
@@ -164,17 +186,21 @@ Default config values are in `ConfigManager.ts`.
164
186
-`express` - HTTP server
165
187
-`ws` - WebSocket server
166
188
-`zod` - Schema validation
189
+
-`axios` - HTTP client (for go2rtc API calls)
190
+
-`form-data` - Multipart form handling
167
191
168
192
**Frontend**:
169
193
-`gridstack` - Dashboard layout system
170
-
-`@cycjimmy/jsmpeg-player` - Video streaming
171
194
-`lucide` - Icon library
195
+
-`video-rtc` - go2rtc video player (WebRTC/MSE/MJPEG) - bundled in static
172
196
173
197
**Dev**:
174
198
- TypeScript 5.7, Biome 2 for linting and formatting
- Connect to printers (creates contexts + backends)
205
231
- Start WebUI server
206
232
- Setup event forwarding (polling data → WebUI)
@@ -269,14 +295,16 @@ class Service extends EventEmitter<EventMap> {
269
295
270
296
## Gotchas
271
297
272
-
1.**Dual Build System**: Backend and frontend have separate `tsconfig.json` files with different module systems (CommonJS vs ES modules)
298
+
1.**Dual Build System**: Backend uses esbuild bundling, frontend uses tsc with separate tsconfig
273
299
2.**Data Directory**: Not in git but can be manually accessed for debugging. Default location is `<project>/data/`
274
-
3.**Camera Streams**: go2rtc manages camera streams per context; there is no user-facing global `CameraProxyPort` setting anymore
275
-
4.**Polling Frequency**: All contexts poll at 3 seconds (changed from 30s for inactive contexts to prevent TCP keep-alive failures)
276
-
5.**Context IDs**: UUID-based, generated during connection. Not tied to IP or serial number
277
-
6.**Backend Lifecycle**: Backends are created per context, not shared. Each context has its own TCP connection
278
-
7.**Graceful Shutdown**: SIGINT/SIGTERM handlers stop polling, disconnect contexts, and stop WebUI before exit
279
-
8.**Windows Compatibility**: Special handling for Ctrl+C via readline interface (see `index.ts`)
300
+
3.**Camera Streams**: go2rtc manages camera streams per context; there is no user-facing global `CameraProxyPort` setting
301
+
4.**go2rtc Binary**: Downloaded at `npm install` time via postinstall script. The binary lives in `resources/bin/` and is platform-specific. If binary download fails, camera streaming won't work
302
+
5.**Polling Frequency**: All contexts poll at 3 seconds (changed from 30s for inactive contexts to prevent TCP keep-alive failures)
303
+
6.**Context IDs**: UUID-based, generated during connection. Not tied to IP or serial number
304
+
7.**Backend Lifecycle**: Backends are created per context, not shared. Each context has its own TCP connection
305
+
8.**Graceful Shutdown**: SIGINT/SIGTERM handlers stop polling, disconnect contexts, and stop WebUI before exit
306
+
9.**Windows Compatibility**: Special handling for Ctrl+C via readline interface (see `index.ts`)
307
+
10.**ARMv7 Builds**: Target `node20-linuxstatic-armv7` for Raspberry Pi 4 with 32-bit OS. This requires `@yao-pkg/pkg` as the official pkg lacks ARMv7 support.
280
308
281
309
## Testing Notes
282
310
@@ -288,9 +316,9 @@ Core functionality has been tested and verified:
0 commit comments