@iscc/lib 0.3.0 → 0.4.0
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/index.d.ts +291 -0
- package/index.js +612 -0
- package/iscc-lib.darwin-arm64.node +0 -0
- package/iscc-lib.darwin-x64.node +0 -0
- package/iscc-lib.linux-arm64-gnu.node +0 -0
- package/iscc-lib.linux-x64-gnu.node +0 -0
- package/iscc-lib.win32-x64-msvc.node +0 -0
- package/package.json +6 -6
package/index.d.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Streaming Data-Code generator.
|
|
5
|
+
*
|
|
6
|
+
* Incrementally processes data with content-defined chunking and MinHash
|
|
7
|
+
* to produce results identical to `gen_data_code_v0`. Follows the
|
|
8
|
+
* `new() → update() → finalize()` pattern.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DataHasher {
|
|
11
|
+
/** Create a new `DataHasher`. */
|
|
12
|
+
constructor()
|
|
13
|
+
/** Push data into the hasher. */
|
|
14
|
+
update(data: Buffer): void
|
|
15
|
+
/**
|
|
16
|
+
* Consume the hasher and produce a Data-Code ISCC string.
|
|
17
|
+
*
|
|
18
|
+
* After calling `finalize`, subsequent calls to `update` or `finalize`
|
|
19
|
+
* will throw. Default `bits` is 64.
|
|
20
|
+
*/
|
|
21
|
+
finalize(bits?: number | undefined | null): string
|
|
22
|
+
}
|
|
23
|
+
export type NapiDataHasher = DataHasher
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Streaming Instance-Code generator.
|
|
27
|
+
*
|
|
28
|
+
* Incrementally hashes data with BLAKE3 to produce results identical
|
|
29
|
+
* to `gen_instance_code_v0`. Follows the
|
|
30
|
+
* `new() → update() → finalize()` pattern.
|
|
31
|
+
*/
|
|
32
|
+
export declare class InstanceHasher {
|
|
33
|
+
/** Create a new `InstanceHasher`. */
|
|
34
|
+
constructor()
|
|
35
|
+
/** Push data into the hasher. */
|
|
36
|
+
update(data: Buffer): void
|
|
37
|
+
/**
|
|
38
|
+
* Consume the hasher and produce an Instance-Code ISCC string.
|
|
39
|
+
*
|
|
40
|
+
* After calling `finalize`, subsequent calls to `update` or `finalize`
|
|
41
|
+
* will throw. Default `bits` is 64.
|
|
42
|
+
*/
|
|
43
|
+
finalize(bits?: number | undefined | null): string
|
|
44
|
+
}
|
|
45
|
+
export type NapiInstanceHasher = InstanceHasher
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Split data into content-defined chunks using gear rolling hash.
|
|
49
|
+
*
|
|
50
|
+
* Returns at least one chunk (empty bytes for empty input). When `utf32`
|
|
51
|
+
* is true, aligns cut points to 4-byte boundaries. Default
|
|
52
|
+
* `avg_chunk_size` is 1024.
|
|
53
|
+
*/
|
|
54
|
+
export declare function alg_cdc_chunks(data: Buffer, utf32: boolean, avgChunkSize?: number | undefined | null): Array<Buffer>
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Compute a 256-bit MinHash digest from 32-bit integer features.
|
|
58
|
+
*
|
|
59
|
+
* Uses 64 universal hash functions with bit-interleaved compression to
|
|
60
|
+
* produce a 32-byte similarity-preserving digest.
|
|
61
|
+
*/
|
|
62
|
+
export declare function alg_minhash_256(features: Array<number>): Buffer
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Compute a SimHash from a sequence of equal-length hash digests.
|
|
66
|
+
*
|
|
67
|
+
* Returns a similarity-preserving hash as a Buffer. Each output bit is set
|
|
68
|
+
* when its frequency meets or exceeds half the input count. Returns 32
|
|
69
|
+
* zero bytes for empty input. Throws on mismatched digest lengths.
|
|
70
|
+
*/
|
|
71
|
+
export declare function alg_simhash(hashDigests: Array<Buffer>): Buffer
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Run all conformance tests against vendored test vectors.
|
|
75
|
+
*
|
|
76
|
+
* Returns `true` if all tests pass, `false` if any fail.
|
|
77
|
+
*/
|
|
78
|
+
export declare function conformance_selftest(): boolean
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Encode bytes as base64url (RFC 4648 §5, no padding).
|
|
82
|
+
*
|
|
83
|
+
* Returns a URL-safe base64 encoded string without padding characters.
|
|
84
|
+
*/
|
|
85
|
+
export declare function encode_base64(data: Buffer): string
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Encode raw ISCC header components and digest into a base32 ISCC unit string.
|
|
89
|
+
*
|
|
90
|
+
* Takes integer type identifiers and a raw digest, returns a base32-encoded
|
|
91
|
+
* ISCC unit string (without "ISCC:" prefix).
|
|
92
|
+
*/
|
|
93
|
+
export declare function encode_component(mtype: number, stype: number, version: number, bitLength: number, digest: Buffer): string
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Generate an Audio-Code from a Chromaprint feature vector.
|
|
97
|
+
*
|
|
98
|
+
* Produces an ISCC Content-Code for audio from signed integer
|
|
99
|
+
* Chromaprint fingerprint features using multi-stage SimHash.
|
|
100
|
+
*/
|
|
101
|
+
export declare function gen_audio_code_v0(cv: Array<number>, bits?: number | undefined | null): string
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Generate a Data-Code from raw byte data.
|
|
105
|
+
*
|
|
106
|
+
* Produces an ISCC Data-Code by splitting data into content-defined
|
|
107
|
+
* chunks and applying MinHash for similarity hashing.
|
|
108
|
+
*/
|
|
109
|
+
export declare function gen_data_code_v0(data: Buffer, bits?: number | undefined | null): string
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Generate an Image-Code from pixel data.
|
|
113
|
+
*
|
|
114
|
+
* Produces an ISCC Content-Code for images from 1024 grayscale pixels
|
|
115
|
+
* (32×32) using a DCT-based perceptual hash.
|
|
116
|
+
*/
|
|
117
|
+
export declare function gen_image_code_v0(pixels: Buffer, bits?: number | undefined | null): string
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Generate an Instance-Code from raw byte data.
|
|
121
|
+
*
|
|
122
|
+
* Produces an ISCC Instance-Code by hashing the complete byte stream
|
|
123
|
+
* with BLAKE3. Returns the ISCC string with "ISCC:" prefix.
|
|
124
|
+
*/
|
|
125
|
+
export declare function gen_instance_code_v0(data: Buffer, bits?: number | undefined | null): string
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Generate a composite ISCC-CODE from individual unit codes.
|
|
129
|
+
*
|
|
130
|
+
* Combines multiple ISCC unit codes into a single composite ISCC-CODE.
|
|
131
|
+
* Requires at least Data-Code and Instance-Code.
|
|
132
|
+
*/
|
|
133
|
+
export declare function gen_iscc_code_v0(codes: Array<string>, wide?: boolean | undefined | null): string
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Generate a Meta-Code from name and optional metadata.
|
|
137
|
+
*
|
|
138
|
+
* Produces an ISCC Meta-Code by hashing the provided name, description,
|
|
139
|
+
* and metadata fields using the SimHash algorithm.
|
|
140
|
+
*/
|
|
141
|
+
export declare function gen_meta_code_v0(name: string, description?: string | undefined | null, meta?: string | undefined | null, bits?: number | undefined | null): string
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generate a Mixed-Code from multiple Content-Code strings.
|
|
145
|
+
*
|
|
146
|
+
* Produces a Mixed Content-Code by combining multiple ISCC Content-Codes
|
|
147
|
+
* of different types using SimHash.
|
|
148
|
+
*/
|
|
149
|
+
export declare function gen_mixed_code_v0(codes: Array<string>, bits?: number | undefined | null): string
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Generate a composite ISCC-CODE from a file in a single pass.
|
|
153
|
+
*
|
|
154
|
+
* Reads the file at `path` and produces Data-Code + Instance-Code in one
|
|
155
|
+
* pass, then combines them into an ISCC-CODE. Returns an object with
|
|
156
|
+
* `iscc`, `datahash`, `filesize`, and optionally `units` fields.
|
|
157
|
+
*/
|
|
158
|
+
export declare function gen_sum_code_v0(path: string, bits?: number | undefined | null, wide?: boolean | undefined | null, addUnits?: boolean | undefined | null): NapiSumCodeResult
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Generate a Text-Code from plain text content.
|
|
162
|
+
*
|
|
163
|
+
* Produces an ISCC Content-Code for text using MinHash-based
|
|
164
|
+
* similarity hashing.
|
|
165
|
+
*/
|
|
166
|
+
export declare function gen_text_code_v0(text: string, bits?: number | undefined | null): string
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Generate a Video-Code from frame signature data.
|
|
170
|
+
*
|
|
171
|
+
* Produces an ISCC Content-Code for video from MPEG-7 frame
|
|
172
|
+
* signature vectors using WTA-Hash.
|
|
173
|
+
*/
|
|
174
|
+
export declare function gen_video_code_v0(frameSigs: Array<Array<number>>, bits?: number | undefined | null): string
|
|
175
|
+
|
|
176
|
+
/** Default read buffer size for streaming I/O (4 MB). */
|
|
177
|
+
export const IO_READ_SIZE: number
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Decode an ISCC unit string into header components and raw digest.
|
|
181
|
+
*
|
|
182
|
+
* Returns an object with `maintype`, `subtype`, `version`, `length`, and
|
|
183
|
+
* `digest` fields. Strips an optional "ISCC:" prefix before decoding.
|
|
184
|
+
*/
|
|
185
|
+
export declare function iscc_decode(iscc: string): IsccDecodeResult
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Decompose a composite ISCC-CODE into individual ISCC-UNITs.
|
|
189
|
+
*
|
|
190
|
+
* Accepts a normalized ISCC-CODE or concatenated ISCC-UNIT sequence.
|
|
191
|
+
* The optional "ISCC:" prefix is stripped before decoding.
|
|
192
|
+
* Returns an array of base32-encoded ISCC-UNIT strings (without prefix).
|
|
193
|
+
*/
|
|
194
|
+
export declare function iscc_decompose(isccCode: string): Array<string>
|
|
195
|
+
|
|
196
|
+
/** Result of decoding an ISCC unit string. */
|
|
197
|
+
export interface IsccDecodeResult {
|
|
198
|
+
/** MainType enum value (0–7). */
|
|
199
|
+
maintype: number
|
|
200
|
+
/** SubType enum value (0–7). */
|
|
201
|
+
subtype: number
|
|
202
|
+
/** Version enum value. */
|
|
203
|
+
version: number
|
|
204
|
+
/** Length index from the header. */
|
|
205
|
+
length: number
|
|
206
|
+
/** Raw digest bytes truncated to the encoded bit-length. */
|
|
207
|
+
digest: Buffer
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Convert a JSON string into a `data:` URL with JCS canonicalization.
|
|
212
|
+
*
|
|
213
|
+
* Uses `application/ld+json` media type when the JSON contains an `@context`
|
|
214
|
+
* key, otherwise `application/json`.
|
|
215
|
+
*/
|
|
216
|
+
export declare function json_to_data_url(json: string): string
|
|
217
|
+
|
|
218
|
+
/** Maximum byte length for the description field after trimming. */
|
|
219
|
+
export const META_TRIM_DESCRIPTION: number
|
|
220
|
+
|
|
221
|
+
/** Maximum byte length for the meta field payload after decoding. */
|
|
222
|
+
export const META_TRIM_META: number
|
|
223
|
+
|
|
224
|
+
/** Maximum byte length for the name field after trimming. */
|
|
225
|
+
export const META_TRIM_NAME: number
|
|
226
|
+
|
|
227
|
+
/** Result of generating a composite ISCC-CODE from a file in a single pass. */
|
|
228
|
+
export interface NapiSumCodeResult {
|
|
229
|
+
/** Composite ISCC-CODE string. */
|
|
230
|
+
iscc: string
|
|
231
|
+
/** Hex-encoded BLAKE3 multihash of the file. */
|
|
232
|
+
datahash: string
|
|
233
|
+
/** Byte length of the file. */
|
|
234
|
+
filesize: number
|
|
235
|
+
/** Data-Code and Instance-Code ISCC strings (when `add_units` is true). */
|
|
236
|
+
units?: Array<string>
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Generate sliding window n-grams from a string.
|
|
241
|
+
*
|
|
242
|
+
* Returns overlapping substrings of `width` Unicode characters, advancing
|
|
243
|
+
* by one character at a time. Throws if width is less than 2.
|
|
244
|
+
*/
|
|
245
|
+
export declare function sliding_window(seq: string, width: number): Array<string>
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Compute a similarity-preserving hash from video frame signatures.
|
|
249
|
+
*
|
|
250
|
+
* Returns raw bytes of length `bits / 8`. Default `bits` is 64.
|
|
251
|
+
* Throws if `frame_sigs` is empty.
|
|
252
|
+
*/
|
|
253
|
+
export declare function soft_hash_video_v0(frameSigs: Array<Array<number>>, bits?: number | undefined | null): Buffer
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Clean and normalize text for display.
|
|
257
|
+
*
|
|
258
|
+
* Applies NFKC normalization, removes control characters (except newlines),
|
|
259
|
+
* normalizes `\r
|
|
260
|
+
` to `
|
|
261
|
+
`, collapses consecutive empty lines, and strips
|
|
262
|
+
* leading/trailing whitespace.
|
|
263
|
+
*/
|
|
264
|
+
export declare function text_clean(text: string): string
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Normalize and simplify text for similarity hashing.
|
|
268
|
+
*
|
|
269
|
+
* Applies NFD normalization, lowercasing, removes whitespace and characters
|
|
270
|
+
* in Unicode categories C (control), M (mark), and P (punctuation), then
|
|
271
|
+
* recombines with NFKC normalization.
|
|
272
|
+
*/
|
|
273
|
+
export declare function text_collapse(text: string): string
|
|
274
|
+
|
|
275
|
+
/** Sliding window width for text n-gram generation. */
|
|
276
|
+
export const TEXT_NGRAM_SIZE: number
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Remove newlines and collapse whitespace to single spaces.
|
|
280
|
+
*
|
|
281
|
+
* Converts multi-line text into a single normalized line.
|
|
282
|
+
*/
|
|
283
|
+
export declare function text_remove_newlines(text: string): string
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Trim text so its UTF-8 encoded size does not exceed `nbytes`.
|
|
287
|
+
*
|
|
288
|
+
* Multi-byte characters that would be split are dropped entirely.
|
|
289
|
+
* Leading/trailing whitespace is stripped from the result.
|
|
290
|
+
*/
|
|
291
|
+
export declare function text_trim(text: string, nbytes: number): string
|
package/index.js
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { readFileSync } = require('node:fs')
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
|
+
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
let report = null
|
|
36
|
+
if (typeof process.report?.getReport === 'function') {
|
|
37
|
+
process.report.excludeNetwork = true
|
|
38
|
+
report = process.report.getReport()
|
|
39
|
+
}
|
|
40
|
+
if (!report) {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
47
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isMuslFromChildProcess = () => {
|
|
55
|
+
try {
|
|
56
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function requireNative() {
|
|
64
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
|
+
try {
|
|
66
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
loadErrors.push(err)
|
|
69
|
+
}
|
|
70
|
+
} else if (process.platform === 'android') {
|
|
71
|
+
if (process.arch === 'arm64') {
|
|
72
|
+
try {
|
|
73
|
+
return require('./iscc-lib.android-arm64.node')
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadErrors.push(e)
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const binding = require('@iscc/lib-android-arm64')
|
|
79
|
+
const bindingPackageVersion = require('@iscc/lib-android-arm64/package.json').version
|
|
80
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
|
+
}
|
|
83
|
+
return binding
|
|
84
|
+
} catch (e) {
|
|
85
|
+
loadErrors.push(e)
|
|
86
|
+
}
|
|
87
|
+
} else if (process.arch === 'arm') {
|
|
88
|
+
try {
|
|
89
|
+
return require('./iscc-lib.android-arm-eabi.node')
|
|
90
|
+
} catch (e) {
|
|
91
|
+
loadErrors.push(e)
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const binding = require('@iscc/lib-android-arm-eabi')
|
|
95
|
+
const bindingPackageVersion = require('@iscc/lib-android-arm-eabi/package.json').version
|
|
96
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
|
+
}
|
|
99
|
+
return binding
|
|
100
|
+
} catch (e) {
|
|
101
|
+
loadErrors.push(e)
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
105
|
+
}
|
|
106
|
+
} else if (process.platform === 'win32') {
|
|
107
|
+
if (process.arch === 'x64') {
|
|
108
|
+
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
109
|
+
try {
|
|
110
|
+
return require('./iscc-lib.win32-x64-gnu.node')
|
|
111
|
+
} catch (e) {
|
|
112
|
+
loadErrors.push(e)
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const binding = require('@iscc/lib-win32-x64-gnu')
|
|
116
|
+
const bindingPackageVersion = require('@iscc/lib-win32-x64-gnu/package.json').version
|
|
117
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
|
+
}
|
|
120
|
+
return binding
|
|
121
|
+
} catch (e) {
|
|
122
|
+
loadErrors.push(e)
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
try {
|
|
126
|
+
return require('./iscc-lib.win32-x64-msvc.node')
|
|
127
|
+
} catch (e) {
|
|
128
|
+
loadErrors.push(e)
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const binding = require('@iscc/lib-win32-x64-msvc')
|
|
132
|
+
const bindingPackageVersion = require('@iscc/lib-win32-x64-msvc/package.json').version
|
|
133
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
|
+
}
|
|
136
|
+
return binding
|
|
137
|
+
} catch (e) {
|
|
138
|
+
loadErrors.push(e)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else if (process.arch === 'ia32') {
|
|
142
|
+
try {
|
|
143
|
+
return require('./iscc-lib.win32-ia32-msvc.node')
|
|
144
|
+
} catch (e) {
|
|
145
|
+
loadErrors.push(e)
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const binding = require('@iscc/lib-win32-ia32-msvc')
|
|
149
|
+
const bindingPackageVersion = require('@iscc/lib-win32-ia32-msvc/package.json').version
|
|
150
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
|
+
}
|
|
153
|
+
return binding
|
|
154
|
+
} catch (e) {
|
|
155
|
+
loadErrors.push(e)
|
|
156
|
+
}
|
|
157
|
+
} else if (process.arch === 'arm64') {
|
|
158
|
+
try {
|
|
159
|
+
return require('./iscc-lib.win32-arm64-msvc.node')
|
|
160
|
+
} catch (e) {
|
|
161
|
+
loadErrors.push(e)
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const binding = require('@iscc/lib-win32-arm64-msvc')
|
|
165
|
+
const bindingPackageVersion = require('@iscc/lib-win32-arm64-msvc/package.json').version
|
|
166
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
|
+
}
|
|
169
|
+
return binding
|
|
170
|
+
} catch (e) {
|
|
171
|
+
loadErrors.push(e)
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
175
|
+
}
|
|
176
|
+
} else if (process.platform === 'darwin') {
|
|
177
|
+
try {
|
|
178
|
+
return require('./iscc-lib.darwin-universal.node')
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadErrors.push(e)
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const binding = require('@iscc/lib-darwin-universal')
|
|
184
|
+
const bindingPackageVersion = require('@iscc/lib-darwin-universal/package.json').version
|
|
185
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
|
+
}
|
|
188
|
+
return binding
|
|
189
|
+
} catch (e) {
|
|
190
|
+
loadErrors.push(e)
|
|
191
|
+
}
|
|
192
|
+
if (process.arch === 'x64') {
|
|
193
|
+
try {
|
|
194
|
+
return require('./iscc-lib.darwin-x64.node')
|
|
195
|
+
} catch (e) {
|
|
196
|
+
loadErrors.push(e)
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const binding = require('@iscc/lib-darwin-x64')
|
|
200
|
+
const bindingPackageVersion = require('@iscc/lib-darwin-x64/package.json').version
|
|
201
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
|
+
}
|
|
204
|
+
return binding
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadErrors.push(e)
|
|
207
|
+
}
|
|
208
|
+
} else if (process.arch === 'arm64') {
|
|
209
|
+
try {
|
|
210
|
+
return require('./iscc-lib.darwin-arm64.node')
|
|
211
|
+
} catch (e) {
|
|
212
|
+
loadErrors.push(e)
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const binding = require('@iscc/lib-darwin-arm64')
|
|
216
|
+
const bindingPackageVersion = require('@iscc/lib-darwin-arm64/package.json').version
|
|
217
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
|
+
}
|
|
220
|
+
return binding
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadErrors.push(e)
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
226
|
+
}
|
|
227
|
+
} else if (process.platform === 'freebsd') {
|
|
228
|
+
if (process.arch === 'x64') {
|
|
229
|
+
try {
|
|
230
|
+
return require('./iscc-lib.freebsd-x64.node')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const binding = require('@iscc/lib-freebsd-x64')
|
|
236
|
+
const bindingPackageVersion = require('@iscc/lib-freebsd-x64/package.json').version
|
|
237
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
|
+
}
|
|
240
|
+
return binding
|
|
241
|
+
} catch (e) {
|
|
242
|
+
loadErrors.push(e)
|
|
243
|
+
}
|
|
244
|
+
} else if (process.arch === 'arm64') {
|
|
245
|
+
try {
|
|
246
|
+
return require('./iscc-lib.freebsd-arm64.node')
|
|
247
|
+
} catch (e) {
|
|
248
|
+
loadErrors.push(e)
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const binding = require('@iscc/lib-freebsd-arm64')
|
|
252
|
+
const bindingPackageVersion = require('@iscc/lib-freebsd-arm64/package.json').version
|
|
253
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
|
+
}
|
|
256
|
+
return binding
|
|
257
|
+
} catch (e) {
|
|
258
|
+
loadErrors.push(e)
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
262
|
+
}
|
|
263
|
+
} else if (process.platform === 'linux') {
|
|
264
|
+
if (process.arch === 'x64') {
|
|
265
|
+
if (isMusl()) {
|
|
266
|
+
try {
|
|
267
|
+
return require('./iscc-lib.linux-x64-musl.node')
|
|
268
|
+
} catch (e) {
|
|
269
|
+
loadErrors.push(e)
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
const binding = require('@iscc/lib-linux-x64-musl')
|
|
273
|
+
const bindingPackageVersion = require('@iscc/lib-linux-x64-musl/package.json').version
|
|
274
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
|
+
}
|
|
277
|
+
return binding
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
try {
|
|
283
|
+
return require('./iscc-lib.linux-x64-gnu.node')
|
|
284
|
+
} catch (e) {
|
|
285
|
+
loadErrors.push(e)
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
const binding = require('@iscc/lib-linux-x64-gnu')
|
|
289
|
+
const bindingPackageVersion = require('@iscc/lib-linux-x64-gnu/package.json').version
|
|
290
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
|
+
}
|
|
293
|
+
return binding
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadErrors.push(e)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} else if (process.arch === 'arm64') {
|
|
299
|
+
if (isMusl()) {
|
|
300
|
+
try {
|
|
301
|
+
return require('./iscc-lib.linux-arm64-musl.node')
|
|
302
|
+
} catch (e) {
|
|
303
|
+
loadErrors.push(e)
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const binding = require('@iscc/lib-linux-arm64-musl')
|
|
307
|
+
const bindingPackageVersion = require('@iscc/lib-linux-arm64-musl/package.json').version
|
|
308
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
|
+
}
|
|
311
|
+
return binding
|
|
312
|
+
} catch (e) {
|
|
313
|
+
loadErrors.push(e)
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
try {
|
|
317
|
+
return require('./iscc-lib.linux-arm64-gnu.node')
|
|
318
|
+
} catch (e) {
|
|
319
|
+
loadErrors.push(e)
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const binding = require('@iscc/lib-linux-arm64-gnu')
|
|
323
|
+
const bindingPackageVersion = require('@iscc/lib-linux-arm64-gnu/package.json').version
|
|
324
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
|
+
}
|
|
327
|
+
return binding
|
|
328
|
+
} catch (e) {
|
|
329
|
+
loadErrors.push(e)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} else if (process.arch === 'arm') {
|
|
333
|
+
if (isMusl()) {
|
|
334
|
+
try {
|
|
335
|
+
return require('./iscc-lib.linux-arm-musleabihf.node')
|
|
336
|
+
} catch (e) {
|
|
337
|
+
loadErrors.push(e)
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
const binding = require('@iscc/lib-linux-arm-musleabihf')
|
|
341
|
+
const bindingPackageVersion = require('@iscc/lib-linux-arm-musleabihf/package.json').version
|
|
342
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
|
+
}
|
|
345
|
+
return binding
|
|
346
|
+
} catch (e) {
|
|
347
|
+
loadErrors.push(e)
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
try {
|
|
351
|
+
return require('./iscc-lib.linux-arm-gnueabihf.node')
|
|
352
|
+
} catch (e) {
|
|
353
|
+
loadErrors.push(e)
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
const binding = require('@iscc/lib-linux-arm-gnueabihf')
|
|
357
|
+
const bindingPackageVersion = require('@iscc/lib-linux-arm-gnueabihf/package.json').version
|
|
358
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
|
+
}
|
|
361
|
+
return binding
|
|
362
|
+
} catch (e) {
|
|
363
|
+
loadErrors.push(e)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else if (process.arch === 'loong64') {
|
|
367
|
+
if (isMusl()) {
|
|
368
|
+
try {
|
|
369
|
+
return require('./iscc-lib.linux-loong64-musl.node')
|
|
370
|
+
} catch (e) {
|
|
371
|
+
loadErrors.push(e)
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const binding = require('@iscc/lib-linux-loong64-musl')
|
|
375
|
+
const bindingPackageVersion = require('@iscc/lib-linux-loong64-musl/package.json').version
|
|
376
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
|
+
}
|
|
379
|
+
return binding
|
|
380
|
+
} catch (e) {
|
|
381
|
+
loadErrors.push(e)
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
try {
|
|
385
|
+
return require('./iscc-lib.linux-loong64-gnu.node')
|
|
386
|
+
} catch (e) {
|
|
387
|
+
loadErrors.push(e)
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
const binding = require('@iscc/lib-linux-loong64-gnu')
|
|
391
|
+
const bindingPackageVersion = require('@iscc/lib-linux-loong64-gnu/package.json').version
|
|
392
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
|
+
}
|
|
395
|
+
return binding
|
|
396
|
+
} catch (e) {
|
|
397
|
+
loadErrors.push(e)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} else if (process.arch === 'riscv64') {
|
|
401
|
+
if (isMusl()) {
|
|
402
|
+
try {
|
|
403
|
+
return require('./iscc-lib.linux-riscv64-musl.node')
|
|
404
|
+
} catch (e) {
|
|
405
|
+
loadErrors.push(e)
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
const binding = require('@iscc/lib-linux-riscv64-musl')
|
|
409
|
+
const bindingPackageVersion = require('@iscc/lib-linux-riscv64-musl/package.json').version
|
|
410
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
|
+
}
|
|
413
|
+
return binding
|
|
414
|
+
} catch (e) {
|
|
415
|
+
loadErrors.push(e)
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
try {
|
|
419
|
+
return require('./iscc-lib.linux-riscv64-gnu.node')
|
|
420
|
+
} catch (e) {
|
|
421
|
+
loadErrors.push(e)
|
|
422
|
+
}
|
|
423
|
+
try {
|
|
424
|
+
const binding = require('@iscc/lib-linux-riscv64-gnu')
|
|
425
|
+
const bindingPackageVersion = require('@iscc/lib-linux-riscv64-gnu/package.json').version
|
|
426
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
|
+
}
|
|
429
|
+
return binding
|
|
430
|
+
} catch (e) {
|
|
431
|
+
loadErrors.push(e)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} else if (process.arch === 'ppc64') {
|
|
435
|
+
try {
|
|
436
|
+
return require('./iscc-lib.linux-ppc64-gnu.node')
|
|
437
|
+
} catch (e) {
|
|
438
|
+
loadErrors.push(e)
|
|
439
|
+
}
|
|
440
|
+
try {
|
|
441
|
+
const binding = require('@iscc/lib-linux-ppc64-gnu')
|
|
442
|
+
const bindingPackageVersion = require('@iscc/lib-linux-ppc64-gnu/package.json').version
|
|
443
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
|
+
}
|
|
446
|
+
return binding
|
|
447
|
+
} catch (e) {
|
|
448
|
+
loadErrors.push(e)
|
|
449
|
+
}
|
|
450
|
+
} else if (process.arch === 's390x') {
|
|
451
|
+
try {
|
|
452
|
+
return require('./iscc-lib.linux-s390x-gnu.node')
|
|
453
|
+
} catch (e) {
|
|
454
|
+
loadErrors.push(e)
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
const binding = require('@iscc/lib-linux-s390x-gnu')
|
|
458
|
+
const bindingPackageVersion = require('@iscc/lib-linux-s390x-gnu/package.json').version
|
|
459
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
|
+
}
|
|
462
|
+
return binding
|
|
463
|
+
} catch (e) {
|
|
464
|
+
loadErrors.push(e)
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
468
|
+
}
|
|
469
|
+
} else if (process.platform === 'openharmony') {
|
|
470
|
+
if (process.arch === 'arm64') {
|
|
471
|
+
try {
|
|
472
|
+
return require('./iscc-lib.openharmony-arm64.node')
|
|
473
|
+
} catch (e) {
|
|
474
|
+
loadErrors.push(e)
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
const binding = require('@iscc/lib-openharmony-arm64')
|
|
478
|
+
const bindingPackageVersion = require('@iscc/lib-openharmony-arm64/package.json').version
|
|
479
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
|
+
}
|
|
482
|
+
return binding
|
|
483
|
+
} catch (e) {
|
|
484
|
+
loadErrors.push(e)
|
|
485
|
+
}
|
|
486
|
+
} else if (process.arch === 'x64') {
|
|
487
|
+
try {
|
|
488
|
+
return require('./iscc-lib.openharmony-x64.node')
|
|
489
|
+
} catch (e) {
|
|
490
|
+
loadErrors.push(e)
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
const binding = require('@iscc/lib-openharmony-x64')
|
|
494
|
+
const bindingPackageVersion = require('@iscc/lib-openharmony-x64/package.json').version
|
|
495
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
|
+
}
|
|
498
|
+
return binding
|
|
499
|
+
} catch (e) {
|
|
500
|
+
loadErrors.push(e)
|
|
501
|
+
}
|
|
502
|
+
} else if (process.arch === 'arm') {
|
|
503
|
+
try {
|
|
504
|
+
return require('./iscc-lib.openharmony-arm.node')
|
|
505
|
+
} catch (e) {
|
|
506
|
+
loadErrors.push(e)
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
const binding = require('@iscc/lib-openharmony-arm')
|
|
510
|
+
const bindingPackageVersion = require('@iscc/lib-openharmony-arm/package.json').version
|
|
511
|
+
if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
|
+
}
|
|
514
|
+
return binding
|
|
515
|
+
} catch (e) {
|
|
516
|
+
loadErrors.push(e)
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
520
|
+
}
|
|
521
|
+
} else {
|
|
522
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
nativeBinding = requireNative()
|
|
527
|
+
|
|
528
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
529
|
+
let wasiBinding = null
|
|
530
|
+
let wasiBindingError = null
|
|
531
|
+
try {
|
|
532
|
+
wasiBinding = require('./iscc-lib.wasi.cjs')
|
|
533
|
+
nativeBinding = wasiBinding
|
|
534
|
+
} catch (err) {
|
|
535
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
536
|
+
wasiBindingError = err
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
540
|
+
try {
|
|
541
|
+
wasiBinding = require('@iscc/lib-wasm32-wasi')
|
|
542
|
+
nativeBinding = wasiBinding
|
|
543
|
+
} catch (err) {
|
|
544
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
+
if (!wasiBindingError) {
|
|
546
|
+
wasiBindingError = err
|
|
547
|
+
} else {
|
|
548
|
+
wasiBindingError.cause = err
|
|
549
|
+
}
|
|
550
|
+
loadErrors.push(err)
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
555
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
556
|
+
error.cause = wasiBindingError
|
|
557
|
+
throw error
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (!nativeBinding) {
|
|
562
|
+
if (loadErrors.length > 0) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
`Cannot find native binding. ` +
|
|
565
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
566
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
567
|
+
{
|
|
568
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
569
|
+
cur.cause = err
|
|
570
|
+
return cur
|
|
571
|
+
}),
|
|
572
|
+
},
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
throw new Error(`Failed to load native binding`)
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
module.exports = nativeBinding
|
|
579
|
+
module.exports.DataHasher = nativeBinding.DataHasher
|
|
580
|
+
module.exports.NapiDataHasher = nativeBinding.NapiDataHasher
|
|
581
|
+
module.exports.InstanceHasher = nativeBinding.InstanceHasher
|
|
582
|
+
module.exports.NapiInstanceHasher = nativeBinding.NapiInstanceHasher
|
|
583
|
+
module.exports.alg_cdc_chunks = nativeBinding.alg_cdc_chunks
|
|
584
|
+
module.exports.alg_minhash_256 = nativeBinding.alg_minhash_256
|
|
585
|
+
module.exports.alg_simhash = nativeBinding.alg_simhash
|
|
586
|
+
module.exports.conformance_selftest = nativeBinding.conformance_selftest
|
|
587
|
+
module.exports.encode_base64 = nativeBinding.encode_base64
|
|
588
|
+
module.exports.encode_component = nativeBinding.encode_component
|
|
589
|
+
module.exports.gen_audio_code_v0 = nativeBinding.gen_audio_code_v0
|
|
590
|
+
module.exports.gen_data_code_v0 = nativeBinding.gen_data_code_v0
|
|
591
|
+
module.exports.gen_image_code_v0 = nativeBinding.gen_image_code_v0
|
|
592
|
+
module.exports.gen_instance_code_v0 = nativeBinding.gen_instance_code_v0
|
|
593
|
+
module.exports.gen_iscc_code_v0 = nativeBinding.gen_iscc_code_v0
|
|
594
|
+
module.exports.gen_meta_code_v0 = nativeBinding.gen_meta_code_v0
|
|
595
|
+
module.exports.gen_mixed_code_v0 = nativeBinding.gen_mixed_code_v0
|
|
596
|
+
module.exports.gen_sum_code_v0 = nativeBinding.gen_sum_code_v0
|
|
597
|
+
module.exports.gen_text_code_v0 = nativeBinding.gen_text_code_v0
|
|
598
|
+
module.exports.gen_video_code_v0 = nativeBinding.gen_video_code_v0
|
|
599
|
+
module.exports.IO_READ_SIZE = nativeBinding.IO_READ_SIZE
|
|
600
|
+
module.exports.iscc_decode = nativeBinding.iscc_decode
|
|
601
|
+
module.exports.iscc_decompose = nativeBinding.iscc_decompose
|
|
602
|
+
module.exports.json_to_data_url = nativeBinding.json_to_data_url
|
|
603
|
+
module.exports.META_TRIM_DESCRIPTION = nativeBinding.META_TRIM_DESCRIPTION
|
|
604
|
+
module.exports.META_TRIM_META = nativeBinding.META_TRIM_META
|
|
605
|
+
module.exports.META_TRIM_NAME = nativeBinding.META_TRIM_NAME
|
|
606
|
+
module.exports.sliding_window = nativeBinding.sliding_window
|
|
607
|
+
module.exports.soft_hash_video_v0 = nativeBinding.soft_hash_video_v0
|
|
608
|
+
module.exports.text_clean = nativeBinding.text_clean
|
|
609
|
+
module.exports.text_collapse = nativeBinding.text_collapse
|
|
610
|
+
module.exports.TEXT_NGRAM_SIZE = nativeBinding.TEXT_NGRAM_SIZE
|
|
611
|
+
module.exports.text_remove_newlines = nativeBinding.text_remove_newlines
|
|
612
|
+
module.exports.text_trim = nativeBinding.text_trim
|
|
Binary file
|
package/iscc-lib.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iscc/lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@napi-rs/cli": "^3"
|
|
33
33
|
},
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@iscc/lib-darwin-x64": "0.
|
|
36
|
-
"@iscc/lib-darwin-arm64": "0.
|
|
37
|
-
"@iscc/lib-win32-x64-msvc": "0.
|
|
38
|
-
"@iscc/lib-linux-x64-gnu": "0.
|
|
39
|
-
"@iscc/lib-linux-arm64-gnu": "0.
|
|
35
|
+
"@iscc/lib-darwin-x64": "0.4.0",
|
|
36
|
+
"@iscc/lib-darwin-arm64": "0.4.0",
|
|
37
|
+
"@iscc/lib-win32-x64-msvc": "0.4.0",
|
|
38
|
+
"@iscc/lib-linux-x64-gnu": "0.4.0",
|
|
39
|
+
"@iscc/lib-linux-arm64-gnu": "0.4.0"
|
|
40
40
|
}
|
|
41
41
|
}
|