Commit Graph
8 Commits
Author SHA1 Message Date
john-okeefe 3242b6f7aa build: configure Rollup to automate ML/CV library vendoring
Set up build system to automatically download and copy ML/CV libraries
during npm run build, eliminating manual file management.

Changes to package.json:
- Add devDependencies:
  * @techstark/opencv-js: OpenCV.js for edge detection
  * @tensorflow-models/coco-ssd: ML model for panel detection
  * @rollup/plugin-terser: Minification plugin (already used)

Changes to rollup.config.js:
- Add custom downloadTensorFlow plugin:
  * Downloads TensorFlow UMD build from unpkg.com during build
  * Saves to vendor/tfjs/tf.min.js (1.5MB)
  * Only runs during build, not in watch mode

- Add copy plugins for ML/CV libraries:
  * Copy OpenCV.js from node_modules to vendor/opencv/opencv.js
  * Copy COCO-SSD from node_modules to vendor/coco-ssd/coco-ssd.min.js

This automated approach ensures:
1. All vendored libraries are updated when npm install is run
2. No manual file downloads or copy operations needed
3. Reproducible builds across different environments
4. Version tracking via package.json

Build workflow: npm install → npm run build → all ML/CV libraries ready
2026-04-13 19:14:59 -04:00
john-okeefe 89543d0df7 Deps: move panel detection libs to devDependencies
Move OpenCV, TensorFlow.js, and COCO-SSD from optionalDependencies
to devDependencies. These libraries are now bundled into the vendor
directory during build instead of being optional runtime dependencies.

Also upgrade @rollup/plugin-terser from 0.4.4 to 1.0.0 which
requires Node.js 20+ and includes updated dependencies.

Related changes:
- Move @techstark/opencv-js to devDependencies
- Move @tensorflow/tfjs to devDependencies
- Move @tensorflow-models/coco-ssd to devDependencies
- Update @rollup/plugin-terser to 1.0.0
2026-04-13 18:50:23 -04:00
john-okeefe 2a9a11adb3 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".
2026-04-13 17:00:45 -04:00
john-okeefe 1684204e75 Add panel detection dependencies
Add ML and computer vision libraries for manga/comic panel detection:
- @techstark/opencv-js: OpenCV.js for edge detection and contour analysis
- @tensorflow/tfjs: TensorFlow.js for ML-based detection fallback
- @tensorflow-models/coco-ssd: Pre-trained COCO-SSD model for object detection

These libraries enable a multi-tier panel detection pipeline:
1. OpenCV edge detection (fast, ~80% accuracy)
2. ML-based detection with COCO-SSD (handles irregular layouts)
3. Grid-based fallback (always works)

All libraries are lazy-loaded on-demand to minimize initial bundle size.
2026-04-13 16:43:20 -04:00
John Factotum 1217096245 Update PDF.js to 5.5.207
Fixes https://github.com/johnfactotum/foliate-js/issues/85
2026-03-05 15:52:38 +08:00
John Factotum ae61c5e85f Make zip.js, fflate, and PDF.js dev dependencies
Previously, zip.js and fflate were built from the main Foliate repo.
And PDF.js files were copied manually. Now they all build here.

Unfortunately, two CSS files still need to be copied manually.
2024-10-12 07:44:33 +08:00
John Factotum 7372c658cf Fix package.json 2024-04-27 16:51:04 +08:00
John Factotum 5600b6c0dc Migrate to ESLint 9 and fix linting issues 2024-04-23 12:59:31 +08:00