Move panel detection dependencies to optionalDependencies

Fix npm install errors and make ML/CV libraries truly optional.

Changes:
- Move dependencies from "dependencies" to "optionalDependencies"
- Fix @techstark/opencv-js version from "^4.12.0" to "4.12.0-release.1"
  - The caret syntax (^) doesn't work with suffix versions like -release.1
  - Use exact version match instead

Why optionalDependencies:
- Installation won't fail if these packages fail to install
- Users can opt-out with: npm install foliate-js --omit=optional
- Maintains the library's "no hard dependencies" philosophy
- Graceful degradation: panel detection falls back to grid-only mode

Behavior:
- Default: npm attempts to install OpenCV, TensorFlow, COCO-SSD (~4.5MB)
- With --omit=optional: skips heavy ML/CV libraries
- Either way: library works, panel detection gracefully adapts

This resolves npm install errors where "^4.12.0" couldn't be found
because the actual version is "4.12.0-release.1".
This commit is contained in:
2026-04-13 17:00:45 -04:00
parent dc894c89dd
commit 2a9a11adb3
+2 -2
View File
@@ -16,8 +16,8 @@
"exports": {
"./*.js": "./*.js"
},
"dependencies": {
"@techstark/opencv-js": "^4.12.0",
"optionalDependencies": {
"@techstark/opencv-js": "4.12.0-release.1",
"@tensorflow/tfjs": "^4.22.0",
"@tensorflow-models/coco-ssd": "^2.2.3"
},