@arcships/light-ocr-runtime 0.1.7 → 0.1.8

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
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "description": "Model-free Node.js runtime for light-ocr",
6
6
  "engines": {
7
- "node": "^22.0.0 || ^24.0.0"
7
+ "node": ">=22.0.0"
8
8
  },
9
9
  "exports": {
10
10
  ".": {
@@ -28,12 +28,14 @@
28
28
  "module": "./src/index.mjs",
29
29
  "name": "@arcships/light-ocr-runtime",
30
30
  "optionalDependencies": {
31
- "@arcships/light-ocr-darwin-arm64": "0.5.7",
32
- "@arcships/light-ocr-darwin-x64": "0.5.7",
33
- "@arcships/light-ocr-linux-arm64-gnu": "0.5.7",
34
- "@arcships/light-ocr-linux-x64-gnu": "0.5.7",
35
- "@arcships/light-ocr-win32-arm64": "0.5.7",
36
- "@arcships/light-ocr-win32-x64": "0.5.7"
31
+ "@arcships/light-ocr-darwin-arm64": "0.5.8",
32
+ "@arcships/light-ocr-darwin-x64": "0.5.8",
33
+ "@arcships/light-ocr-linux-arm64-gnu": "0.5.8",
34
+ "@arcships/light-ocr-linux-arm64-musl": "0.5.8",
35
+ "@arcships/light-ocr-linux-x64-gnu": "0.5.8",
36
+ "@arcships/light-ocr-linux-x64-musl": "0.5.8",
37
+ "@arcships/light-ocr-win32-arm64": "0.5.8",
38
+ "@arcships/light-ocr-win32-x64": "0.5.8"
37
39
  },
38
40
  "publishConfig": {
39
41
  "access": "public",
@@ -45,5 +47,5 @@
45
47
  },
46
48
  "type": "commonjs",
47
49
  "types": "./src/index.d.ts",
48
- "version": "0.1.7"
50
+ "version": "0.1.8"
49
51
  }
package/src/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { loadNative } = require('./load-native.cjs');
3
+ const { loadNative, platformIdentity } = require('./load-native.cjs');
4
4
 
5
5
  class OcrError extends Error {
6
6
  constructor(code, message, detail) {
@@ -174,4 +174,4 @@ async function createEngine(options) {
174
174
  }
175
175
  }
176
176
 
177
- module.exports = { createEngine, OcrError, loadNative };
177
+ module.exports = { createEngine, OcrError, loadNative, platformIdentity };
package/src/index.d.ts CHANGED
@@ -289,4 +289,15 @@ export interface DetectionResult {
289
289
  readonly timingUs: TimingUs;
290
290
  }
291
291
 
292
+ /** Resolved host platform identity used to select the native package. */
293
+ export interface PlatformIdentity {
294
+ readonly id: string;
295
+ readonly os: string;
296
+ readonly architecture: string;
297
+ /** Present for Linux hosts; `"glibc"` or `"musl"`. */
298
+ readonly libc?: 'glibc' | 'musl';
299
+ }
300
+
301
+ export function platformIdentity(): PlatformIdentity;
302
+
292
303
  export function createEngine(options: CreateEngineOptions): Promise<OcrEngine>;
package/src/index.mjs CHANGED
@@ -2,3 +2,4 @@ import cjs from './index.cjs';
2
2
 
3
3
  export const createEngine = cjs.createEngine;
4
4
  export const OcrError = cjs.OcrError;
5
+ export const platformIdentity = cjs.platformIdentity;
@@ -104,6 +104,22 @@ function adapterError(code, message, detail, cause) {
104
104
  return error;
105
105
  }
106
106
 
107
+ // Detect musl Linux (Alpine and friends). Only reached when the host does not
108
+ // report glibcVersionRuntime through process.report. The musl dynamic linker
109
+ // path is the primary signal; the ldd output check covers hosts with a
110
+ // non-standard loader location.
111
+ function isMuslLinux() {
112
+ if (process.platform !== 'linux') return false;
113
+ const loader = process.arch === 'arm64'
114
+ ? '/lib/ld-musl-aarch64.so.1'
115
+ : '/lib/ld-musl-x86_64.so.1';
116
+ if (fs.existsSync(loader)) return true;
117
+ const ldd = spawnSync('ldd', ['--version'], { encoding: 'utf8', timeout: 5000 });
118
+ if (ldd.error) return false;
119
+ const output = `${ldd.stdout || ''}${ldd.stderr || ''}`;
120
+ return output.toLowerCase().includes('musl');
121
+ }
122
+
107
123
  function platformIdentity() {
108
124
  const key = `${process.platform}-${process.arch}`;
109
125
  const identities = {
@@ -117,9 +133,12 @@ function platformIdentity() {
117
133
  if (report?.header?.glibcVersionRuntime) {
118
134
  return { id: 'linux-x64', os: 'linux', architecture: 'x86_64', libc: 'glibc' };
119
135
  }
136
+ if (isMuslLinux()) {
137
+ return { id: 'linux-x64-musl', os: 'linux', architecture: 'x86_64', libc: 'musl' };
138
+ }
120
139
  throw adapterError(
121
140
  'unsupported_platform',
122
- 'light-ocr currently supports Linux x64 with glibc only',
141
+ 'light-ocr currently supports Linux x64 with glibc or musl only',
123
142
  key,
124
143
  );
125
144
  }
@@ -128,9 +147,12 @@ function platformIdentity() {
128
147
  if (report?.header?.glibcVersionRuntime) {
129
148
  return { id: 'linux-arm64', os: 'linux', architecture: 'arm64', libc: 'glibc' };
130
149
  }
150
+ if (isMuslLinux()) {
151
+ return { id: 'linux-arm64-musl', os: 'linux', architecture: 'arm64', libc: 'musl' };
152
+ }
131
153
  throw adapterError(
132
154
  'unsupported_platform',
133
- 'light-ocr currently supports Linux arm64 with glibc only',
155
+ 'light-ocr currently supports Linux arm64 with glibc or musl only',
134
156
  key,
135
157
  );
136
158
  }
@@ -149,6 +171,8 @@ function platformPackage() {
149
171
  'windows-x64': '@arcships/light-ocr-win32-x64',
150
172
  'linux-x64': '@arcships/light-ocr-linux-x64-gnu',
151
173
  'linux-arm64': '@arcships/light-ocr-linux-arm64-gnu',
174
+ 'linux-x64-musl': '@arcships/light-ocr-linux-x64-musl',
175
+ 'linux-arm64-musl': '@arcships/light-ocr-linux-arm64-musl',
152
176
  };
153
177
  return packages[platformIdentity().id];
154
178
  }
@@ -606,4 +630,4 @@ const macOSSignature = Object.freeze({
606
630
  signerMatchesHost,
607
631
  });
608
632
 
609
- module.exports = { loadNative, validateRuntimeDescriptor, macOSSignature };
633
+ module.exports = { loadNative, validateRuntimeDescriptor, macOSSignature, platformIdentity };
package/src/metadata.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = Object.freeze({ coreVersion: '0.5.7' });
3
+ module.exports = Object.freeze({ coreVersion: '0.5.8' });