@iscc/wasm 0.0.4 → 0.2.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/README.md +0 -3
- package/iscc_wasm.d.ts +23 -2
- package/iscc_wasm.js +56 -2
- package/iscc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@iscc/wasm)
|
|
5
5
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
6
|
|
|
7
|
-
> **Experimental:** This library is in early development (v0.0.x). APIs may change without notice.
|
|
8
|
-
> Not recommended for production use yet.
|
|
9
|
-
|
|
10
7
|
Browser-compatible WebAssembly bindings for
|
|
11
8
|
[ISO 24138:2024](https://www.iso.org/standard/77899.html) -- International Standard Content Code
|
|
12
9
|
(ISCC). Built with Rust and [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/) for use in
|
package/iscc_wasm.d.ts
CHANGED
|
@@ -128,6 +128,14 @@ export class WasmSumCodeResult {
|
|
|
128
128
|
* Composite ISCC-CODE string (e.g., `"ISCC:KAC..."`).
|
|
129
129
|
*/
|
|
130
130
|
iscc: string;
|
|
131
|
+
/**
|
|
132
|
+
* Data-Code and Instance-Code ISCC strings (when `add_units` is true).
|
|
133
|
+
*/
|
|
134
|
+
get units(): string[] | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Data-Code and Instance-Code ISCC strings (when `add_units` is true).
|
|
137
|
+
*/
|
|
138
|
+
set units(value: string[] | null | undefined);
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
/**
|
|
@@ -156,6 +164,13 @@ export function alg_minhash_256(features: Uint32Array): Uint8Array;
|
|
|
156
164
|
*/
|
|
157
165
|
export function alg_simhash(hash_digests: any): Uint8Array;
|
|
158
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Run all conformance tests against vendored test vectors.
|
|
169
|
+
*
|
|
170
|
+
* Returns `true` if all tests pass, `false` if any fail.
|
|
171
|
+
*/
|
|
172
|
+
export function conformance_selftest(): boolean;
|
|
173
|
+
|
|
159
174
|
/**
|
|
160
175
|
* Encode bytes as base64url (RFC 4648 §5, no padding).
|
|
161
176
|
*
|
|
@@ -233,8 +248,11 @@ export function gen_mixed_code_v0(codes: any, bits?: number | null): string;
|
|
|
233
248
|
* Feeds both `DataHasher` (CDC/MinHash) and `InstanceHasher` (BLAKE3) from
|
|
234
249
|
* the same byte slice, then composes the final ISCC-CODE via
|
|
235
250
|
* `gen_iscc_code_v0`. WASM-compatible alternative to the file-based core API.
|
|
251
|
+
*
|
|
252
|
+
* When `add_units` is `true`, the result includes the individual Data-Code
|
|
253
|
+
* and Instance-Code ISCC strings.
|
|
236
254
|
*/
|
|
237
|
-
export function gen_sum_code_v0(data: Uint8Array, bits?: number | null, wide?: boolean | null): WasmSumCodeResult;
|
|
255
|
+
export function gen_sum_code_v0(data: Uint8Array, bits?: number | null, wide?: boolean | null, add_units?: boolean | null): WasmSumCodeResult;
|
|
238
256
|
|
|
239
257
|
/**
|
|
240
258
|
* Generate a Text-Code from plain text content.
|
|
@@ -344,6 +362,7 @@ export interface InitOutput {
|
|
|
344
362
|
readonly __wbg_get_wasmsumcoderesult_datahash: (a: number, b: number) => void;
|
|
345
363
|
readonly __wbg_get_wasmsumcoderesult_filesize: (a: number) => number;
|
|
346
364
|
readonly __wbg_get_wasmsumcoderesult_iscc: (a: number, b: number) => void;
|
|
365
|
+
readonly __wbg_get_wasmsumcoderesult_units: (a: number, b: number) => void;
|
|
347
366
|
readonly __wbg_instancehasher_free: (a: number, b: number) => void;
|
|
348
367
|
readonly __wbg_isccdecoderesult_free: (a: number, b: number) => void;
|
|
349
368
|
readonly __wbg_set_isccdecoderesult_digest: (a: number, b: number, c: number) => void;
|
|
@@ -354,10 +373,12 @@ export interface InitOutput {
|
|
|
354
373
|
readonly __wbg_set_wasmsumcoderesult_datahash: (a: number, b: number, c: number) => void;
|
|
355
374
|
readonly __wbg_set_wasmsumcoderesult_filesize: (a: number, b: number) => void;
|
|
356
375
|
readonly __wbg_set_wasmsumcoderesult_iscc: (a: number, b: number, c: number) => void;
|
|
376
|
+
readonly __wbg_set_wasmsumcoderesult_units: (a: number, b: number, c: number) => void;
|
|
357
377
|
readonly __wbg_wasmsumcoderesult_free: (a: number, b: number) => void;
|
|
358
378
|
readonly alg_cdc_chunks: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
359
379
|
readonly alg_minhash_256: (a: number, b: number, c: number) => void;
|
|
360
380
|
readonly alg_simhash: (a: number, b: number) => void;
|
|
381
|
+
readonly conformance_selftest: () => number;
|
|
361
382
|
readonly datahasher_finalize: (a: number, b: number, c: number) => void;
|
|
362
383
|
readonly datahasher_new: () => number;
|
|
363
384
|
readonly datahasher_update: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -370,7 +391,7 @@ export interface InitOutput {
|
|
|
370
391
|
readonly gen_iscc_code_v0: (a: number, b: number, c: number) => void;
|
|
371
392
|
readonly gen_meta_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
372
393
|
readonly gen_mixed_code_v0: (a: number, b: number, c: number) => void;
|
|
373
|
-
readonly gen_sum_code_v0: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
394
|
+
readonly gen_sum_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
374
395
|
readonly gen_text_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
375
396
|
readonly gen_video_code_v0: (a: number, b: number, c: number) => void;
|
|
376
397
|
readonly instancehasher_finalize: (a: number, b: number, c: number) => void;
|
package/iscc_wasm.js
CHANGED
|
@@ -386,6 +386,26 @@ export class WasmSumCodeResult {
|
|
|
386
386
|
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Data-Code and Instance-Code ISCC strings (when `add_units` is true).
|
|
391
|
+
* @returns {string[] | undefined}
|
|
392
|
+
*/
|
|
393
|
+
get units() {
|
|
394
|
+
try {
|
|
395
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
396
|
+
wasm.__wbg_get_wasmsumcoderesult_units(retptr, this.__wbg_ptr);
|
|
397
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
398
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
399
|
+
let v1;
|
|
400
|
+
if (r0 !== 0) {
|
|
401
|
+
v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
402
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
403
|
+
}
|
|
404
|
+
return v1;
|
|
405
|
+
} finally {
|
|
406
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
389
409
|
/**
|
|
390
410
|
* Hex-encoded BLAKE3 multihash (`"1e20..."`) of the data.
|
|
391
411
|
* @param {string} arg0
|
|
@@ -411,6 +431,15 @@ export class WasmSumCodeResult {
|
|
|
411
431
|
const len0 = WASM_VECTOR_LEN;
|
|
412
432
|
wasm.__wbg_set_wasmsumcoderesult_iscc(this.__wbg_ptr, ptr0, len0);
|
|
413
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Data-Code and Instance-Code ISCC strings (when `add_units` is true).
|
|
436
|
+
* @param {string[] | null} [arg0]
|
|
437
|
+
*/
|
|
438
|
+
set units(arg0) {
|
|
439
|
+
var ptr0 = isLikeNone(arg0) ? 0 : passArrayJsValueToWasm0(arg0, wasm.__wbindgen_export);
|
|
440
|
+
var len0 = WASM_VECTOR_LEN;
|
|
441
|
+
wasm.__wbg_set_wasmsumcoderesult_units(this.__wbg_ptr, ptr0, len0);
|
|
442
|
+
}
|
|
414
443
|
}
|
|
415
444
|
if (Symbol.dispose) WasmSumCodeResult.prototype[Symbol.dispose] = WasmSumCodeResult.prototype.free;
|
|
416
445
|
|
|
@@ -495,6 +524,17 @@ export function alg_simhash(hash_digests) {
|
|
|
495
524
|
}
|
|
496
525
|
}
|
|
497
526
|
|
|
527
|
+
/**
|
|
528
|
+
* Run all conformance tests against vendored test vectors.
|
|
529
|
+
*
|
|
530
|
+
* Returns `true` if all tests pass, `false` if any fail.
|
|
531
|
+
* @returns {boolean}
|
|
532
|
+
*/
|
|
533
|
+
export function conformance_selftest() {
|
|
534
|
+
const ret = wasm.conformance_selftest();
|
|
535
|
+
return ret !== 0;
|
|
536
|
+
}
|
|
537
|
+
|
|
498
538
|
/**
|
|
499
539
|
* Encode bytes as base64url (RFC 4648 §5, no padding).
|
|
500
540
|
*
|
|
@@ -820,17 +860,21 @@ export function gen_mixed_code_v0(codes, bits) {
|
|
|
820
860
|
* Feeds both `DataHasher` (CDC/MinHash) and `InstanceHasher` (BLAKE3) from
|
|
821
861
|
* the same byte slice, then composes the final ISCC-CODE via
|
|
822
862
|
* `gen_iscc_code_v0`. WASM-compatible alternative to the file-based core API.
|
|
863
|
+
*
|
|
864
|
+
* When `add_units` is `true`, the result includes the individual Data-Code
|
|
865
|
+
* and Instance-Code ISCC strings.
|
|
823
866
|
* @param {Uint8Array} data
|
|
824
867
|
* @param {number | null} [bits]
|
|
825
868
|
* @param {boolean | null} [wide]
|
|
869
|
+
* @param {boolean | null} [add_units]
|
|
826
870
|
* @returns {WasmSumCodeResult}
|
|
827
871
|
*/
|
|
828
|
-
export function gen_sum_code_v0(data, bits, wide) {
|
|
872
|
+
export function gen_sum_code_v0(data, bits, wide, add_units) {
|
|
829
873
|
try {
|
|
830
874
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
831
875
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
832
876
|
const len0 = WASM_VECTOR_LEN;
|
|
833
|
-
wasm.gen_sum_code_v0(retptr, ptr0, len0, isLikeNone(bits) ? 0x100000001 : (bits) >>> 0, isLikeNone(wide) ? 0xFFFFFF : wide ? 1 : 0);
|
|
877
|
+
wasm.gen_sum_code_v0(retptr, ptr0, len0, isLikeNone(bits) ? 0x100000001 : (bits) >>> 0, isLikeNone(wide) ? 0xFFFFFF : wide ? 1 : 0, isLikeNone(add_units) ? 0xFFFFFF : add_units ? 1 : 0);
|
|
834
878
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
835
879
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
836
880
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1504,6 +1548,16 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
1504
1548
|
return ptr;
|
|
1505
1549
|
}
|
|
1506
1550
|
|
|
1551
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1552
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1553
|
+
const mem = getDataViewMemory0();
|
|
1554
|
+
for (let i = 0; i < array.length; i++) {
|
|
1555
|
+
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
|
|
1556
|
+
}
|
|
1557
|
+
WASM_VECTOR_LEN = array.length;
|
|
1558
|
+
return ptr;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1507
1561
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
1508
1562
|
if (realloc === undefined) {
|
|
1509
1563
|
const buf = cachedTextEncoder.encode(arg);
|
package/iscc_wasm_bg.wasm
CHANGED
|
Binary file
|