@arcships/light-ocr-runtime 0.1.3 → 0.1.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/package.json CHANGED
@@ -28,12 +28,12 @@
28
28
  "module": "./src/index.mjs",
29
29
  "name": "@arcships/light-ocr-runtime",
30
30
  "optionalDependencies": {
31
- "@arcships/light-ocr-darwin-arm64": "0.5.3",
32
- "@arcships/light-ocr-darwin-x64": "0.5.3",
33
- "@arcships/light-ocr-linux-arm64-gnu": "0.5.3",
34
- "@arcships/light-ocr-linux-x64-gnu": "0.5.3",
35
- "@arcships/light-ocr-win32-arm64": "0.5.3",
36
- "@arcships/light-ocr-win32-x64": "0.5.3"
31
+ "@arcships/light-ocr-darwin-arm64": "0.5.5",
32
+ "@arcships/light-ocr-darwin-x64": "0.5.5",
33
+ "@arcships/light-ocr-linux-arm64-gnu": "0.5.5",
34
+ "@arcships/light-ocr-linux-x64-gnu": "0.5.5",
35
+ "@arcships/light-ocr-win32-arm64": "0.5.5",
36
+ "@arcships/light-ocr-win32-x64": "0.5.5"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",
@@ -45,5 +45,5 @@
45
45
  },
46
46
  "type": "commonjs",
47
47
  "types": "./src/index.d.ts",
48
- "version": "0.1.3"
48
+ "version": "0.1.5"
49
49
  }
package/src/cli.cjs CHANGED
@@ -12,14 +12,13 @@
12
12
  // stdout = machine results only; stderr = logs/warnings/usage (cli-design.md §5).
13
13
  // Exit codes are a stable surface (cli-design.md §10, D106).
14
14
 
15
- const crypto = require('node:crypto');
16
15
  const fs = require('node:fs');
17
16
  const os = require('node:os');
18
17
  const path = require('node:path');
19
18
 
20
19
  const { parseExifOrientation } = require('./exif.cjs');
21
20
 
22
- const SUBCOMMANDS = new Set(['recognize', 'detect', 'info', 'document', 'doctor']);
21
+ const SUBCOMMANDS = new Set(['recognize', 'detect', 'info', 'doctor']);
23
22
  const EXIT = {
24
23
  success: 0,
25
24
  usage: 64,
@@ -514,7 +513,6 @@ async function runDoctor(rest, flags, stdout, stderr, config) {
514
513
  platform: process.platform,
515
514
  arch: process.arch,
516
515
  release: os.release(),
517
- hostHash: crypto.createHash('sha256').update(os.hostname()).digest('hex').slice(0, 16),
518
516
  cpuModel: os.cpus()[0]?.model || 'unknown',
519
517
  cpuCores: os.cpus().length,
520
518
  totalMemoryGB: +(os.totalmem() / (1024 ** 3)).toFixed(1),
@@ -523,7 +521,6 @@ async function runDoctor(rest, flags, stdout, stderr, config) {
523
521
  modules: {
524
522
  runtime: safeRequireResolve('@arcships/light-ocr-runtime') !== undefined,
525
523
  model: safeRequireResolve(config.modelProfile.model ? `@arcships/light-ocr-model-${config.modelProfile.model}` : '@arcships/light-ocr-model-ppocrv6-small') !== undefined,
526
- pdfium: false,
527
524
  },
528
525
  };
529
526
 
@@ -554,106 +551,9 @@ async function runDoctor(rest, flags, stdout, stderr, config) {
554
551
  if (gpuInfo) info.gpu = gpuInfo;
555
552
  }
556
553
 
557
- // PDF support
558
- if (typeof config.hasPdfSupport === 'function') {
559
- info.modules.pdfium = config.hasPdfSupport();
560
- }
561
-
562
554
  stdout.write(JSON.stringify(info, null, 2) + '\n');
563
555
  }
564
556
 
565
- // --- document subcommand (PDF and multi-page support) ---
566
- function parsePageRange(rangeStr) {
567
- if (!rangeStr) return undefined;
568
- const match = String(rangeStr).match(/^(\d+)(?:-(\d+))?$/);
569
- if (!match) {
570
- throw { code: EXIT.invalid_argument, message: `--pages expects N or N-M (got ${rangeStr})` };
571
- }
572
- return {
573
- start: parseInt(match[1]),
574
- end: match[2] ? parseInt(match[2]) : parseInt(match[1])
575
- };
576
- }
577
-
578
- async function runDocument(rest, flags, stdout, stderr, config) {
579
- const format = resolveFormat(flags, 'recognize');
580
- const provider = resolveProvider(flags);
581
-
582
- if (rest.length === 0) {
583
- throw { code: EXIT.usage, message: 'expected a PDF or image file path' };
584
- }
585
-
586
- // Parse document-specific flags
587
- const pageRange = parsePageRange(flags.pages);
588
- const dpi = flags.dpi ? parseInt(flags.dpi) : 150;
589
- const maxPages = flags['max-pages'] ? parseInt(flags['max-pages']) : 100;
590
- const quiet = flags.quiet === true;
591
-
592
- // Check if recognizeDocument is available
593
- if (typeof config.recognizeDocument !== 'function') {
594
- throw { code: EXIT.unsupported_capability, message: 'PDF/document support not available' };
595
- }
596
-
597
- const source = rest.length === 1 ? rest[0] : rest;
598
-
599
- const pages = [];
600
- let pageCount = 0;
601
-
602
- try {
603
- for await (const page of config.recognizeDocument(source, {
604
- pageRange,
605
- dpi,
606
- maxPages,
607
- engine: undefined // Will use default
608
- })) {
609
- pages.push(page);
610
- pageCount++;
611
-
612
- // Output JSONL as we go
613
- if (format === 'jsonl') {
614
- stdout.write(JSON.stringify({
615
- schemaVersion: SUPPORTED_SCHEMA_VERSION,
616
- source: { kind: page.source.kind },
617
- pageIndex: page.index,
618
- status: 'ok',
619
- page
620
- }) + '\n');
621
- }
622
-
623
- // Progress output
624
- if (!quiet) {
625
- stderr.write(`\rProcessed page ${pageCount}...`);
626
- }
627
- }
628
-
629
- if (!quiet && pageCount > 0) {
630
- stderr.write('\n');
631
- }
632
-
633
- // Output final result for non-JSONL formats
634
- if (format === 'json') {
635
- const result = {
636
- schemaVersion: SUPPORTED_SCHEMA_VERSION,
637
- source: {
638
- kind: Array.isArray(source) ? 'page-images' :
639
- (typeof source === 'string' && source.endsWith('.pdf') ? 'pdf' : 'image'),
640
- mediaType: typeof source === 'string' && source.endsWith('.pdf') ? 'application/pdf' : 'image/*',
641
- identity: { files: Array.isArray(source) ? source : [source] },
642
- pageCount: pages.length
643
- },
644
- pages
645
- };
646
- stdout.write(JSON.stringify(result, null, 2) + '\n');
647
- } else if (format === 'text') {
648
- for (const page of pages) {
649
- stdout.write(page.lines.map(l => l.text).join('\n') + '\n');
650
- }
651
- }
652
- } catch (e) {
653
- throw e;
654
- }
655
- }
656
-
657
557
  // --- help ---
658
558
  function printHelp(stdout, verbose, config) {
659
559
  const command = config.commandName;
@@ -661,7 +561,6 @@ function printHelp(stdout, verbose, config) {
661
561
  stdout.write('Usage:\n');
662
562
  stdout.write(` ${command} recognize <path|--stdin> [flags] Recognize text in an image (default)\n`);
663
563
  stdout.write(` ${command} detect <path|--stdin> [flags] Detect text regions only\n`);
664
- stdout.write(` ${command} document <path|paths...> [flags] Process PDF or multiple images\n`);
665
564
  stdout.write(` ${command} info --model-info | --version Show engine/version info\n`);
666
565
  stdout.write(` ${command} doctor [--json] System diagnostics\n`);
667
566
  stdout.write(` ${command} <image> [flags] Implicit recognize\n\n`);
@@ -704,18 +603,6 @@ function printSubcommandHelp(stdout, subcommand, config) {
704
603
  stdout.write(' --version Print npm/core/model version triple\n');
705
604
  return;
706
605
  }
707
- if (subcommand === 'document') {
708
- stdout.write(`${command} document — process PDF or multiple images\n\n`);
709
- stdout.write(`Usage:\n ${command} document <file.pdf> [flags]\n ${command} document <img1.png> <img2.jpg> [flags]\n\n`);
710
- stdout.write('Flags:\n');
711
- stdout.write(' --format json|jsonl|text Output format (default: json)\n');
712
- stdout.write(' --pages N-M Page range for PDF (e.g., 1-5 or 3)\n');
713
- stdout.write(' --dpi <n> PDF raster DPI (default: 150)\n');
714
- stdout.write(' --max-pages <n> Maximum pages to process (default: 100)\n');
715
- stdout.write(' --provider auto|cpu|apple|webgpu Execution provider (default: auto)\n');
716
- stdout.write(' --quiet Suppress progress output\n');
717
- return;
718
- }
719
606
  if (subcommand === 'doctor') {
720
607
  stdout.write(`${command} doctor — system diagnostics for troubleshooting\n\n`);
721
608
  stdout.write(`Usage:\n ${command} doctor [--json]\n\n`);
@@ -772,8 +659,6 @@ async function main(argv, config) {
772
659
  };
773
660
  }
774
661
  await runDetect(rest, parsed.flags, stdout, stderr, config);
775
- } else if (subcommand === 'document') {
776
- await runDocument(rest, parsed.flags, stdout, stderr, config);
777
662
  } else {
778
663
  die(stderr, config.commandName, `unknown subcommand: ${subcommand}`);
779
664
  return EXIT.usage;
package/src/metadata.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = Object.freeze({ coreVersion: '0.5.3' });
3
+ module.exports = Object.freeze({ coreVersion: '0.5.5' });