@iscc/wasm 0.0.4 → 0.1.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 +15 -2
- package/iscc_wasm.js +45 -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
|
/**
|
|
@@ -233,8 +241,11 @@ export function gen_mixed_code_v0(codes: any, bits?: number | null): string;
|
|
|
233
241
|
* Feeds both `DataHasher` (CDC/MinHash) and `InstanceHasher` (BLAKE3) from
|
|
234
242
|
* the same byte slice, then composes the final ISCC-CODE via
|
|
235
243
|
* `gen_iscc_code_v0`. WASM-compatible alternative to the file-based core API.
|
|
244
|
+
*
|
|
245
|
+
* When `add_units` is `true`, the result includes the individual Data-Code
|
|
246
|
+
* and Instance-Code ISCC strings.
|
|
236
247
|
*/
|
|
237
|
-
export function gen_sum_code_v0(data: Uint8Array, bits?: number | null, wide?: boolean | null): WasmSumCodeResult;
|
|
248
|
+
export function gen_sum_code_v0(data: Uint8Array, bits?: number | null, wide?: boolean | null, add_units?: boolean | null): WasmSumCodeResult;
|
|
238
249
|
|
|
239
250
|
/**
|
|
240
251
|
* Generate a Text-Code from plain text content.
|
|
@@ -344,6 +355,7 @@ export interface InitOutput {
|
|
|
344
355
|
readonly __wbg_get_wasmsumcoderesult_datahash: (a: number, b: number) => void;
|
|
345
356
|
readonly __wbg_get_wasmsumcoderesult_filesize: (a: number) => number;
|
|
346
357
|
readonly __wbg_get_wasmsumcoderesult_iscc: (a: number, b: number) => void;
|
|
358
|
+
readonly __wbg_get_wasmsumcoderesult_units: (a: number, b: number) => void;
|
|
347
359
|
readonly __wbg_instancehasher_free: (a: number, b: number) => void;
|
|
348
360
|
readonly __wbg_isccdecoderesult_free: (a: number, b: number) => void;
|
|
349
361
|
readonly __wbg_set_isccdecoderesult_digest: (a: number, b: number, c: number) => void;
|
|
@@ -354,6 +366,7 @@ export interface InitOutput {
|
|
|
354
366
|
readonly __wbg_set_wasmsumcoderesult_datahash: (a: number, b: number, c: number) => void;
|
|
355
367
|
readonly __wbg_set_wasmsumcoderesult_filesize: (a: number, b: number) => void;
|
|
356
368
|
readonly __wbg_set_wasmsumcoderesult_iscc: (a: number, b: number, c: number) => void;
|
|
369
|
+
readonly __wbg_set_wasmsumcoderesult_units: (a: number, b: number, c: number) => void;
|
|
357
370
|
readonly __wbg_wasmsumcoderesult_free: (a: number, b: number) => void;
|
|
358
371
|
readonly alg_cdc_chunks: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
359
372
|
readonly alg_minhash_256: (a: number, b: number, c: number) => void;
|
|
@@ -370,7 +383,7 @@ export interface InitOutput {
|
|
|
370
383
|
readonly gen_iscc_code_v0: (a: number, b: number, c: number) => void;
|
|
371
384
|
readonly gen_meta_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
372
385
|
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;
|
|
386
|
+
readonly gen_sum_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
374
387
|
readonly gen_text_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
375
388
|
readonly gen_video_code_v0: (a: number, b: number, c: number) => void;
|
|
376
389
|
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
|
|
|
@@ -820,17 +849,21 @@ export function gen_mixed_code_v0(codes, bits) {
|
|
|
820
849
|
* Feeds both `DataHasher` (CDC/MinHash) and `InstanceHasher` (BLAKE3) from
|
|
821
850
|
* the same byte slice, then composes the final ISCC-CODE via
|
|
822
851
|
* `gen_iscc_code_v0`. WASM-compatible alternative to the file-based core API.
|
|
852
|
+
*
|
|
853
|
+
* When `add_units` is `true`, the result includes the individual Data-Code
|
|
854
|
+
* and Instance-Code ISCC strings.
|
|
823
855
|
* @param {Uint8Array} data
|
|
824
856
|
* @param {number | null} [bits]
|
|
825
857
|
* @param {boolean | null} [wide]
|
|
858
|
+
* @param {boolean | null} [add_units]
|
|
826
859
|
* @returns {WasmSumCodeResult}
|
|
827
860
|
*/
|
|
828
|
-
export function gen_sum_code_v0(data, bits, wide) {
|
|
861
|
+
export function gen_sum_code_v0(data, bits, wide, add_units) {
|
|
829
862
|
try {
|
|
830
863
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
831
864
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
832
865
|
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);
|
|
866
|
+
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
867
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
835
868
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
836
869
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1504,6 +1537,16 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
1504
1537
|
return ptr;
|
|
1505
1538
|
}
|
|
1506
1539
|
|
|
1540
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1541
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1542
|
+
const mem = getDataViewMemory0();
|
|
1543
|
+
for (let i = 0; i < array.length; i++) {
|
|
1544
|
+
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
|
|
1545
|
+
}
|
|
1546
|
+
WASM_VECTOR_LEN = array.length;
|
|
1547
|
+
return ptr;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1507
1550
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
1508
1551
|
if (realloc === undefined) {
|
|
1509
1552
|
const buf = cachedTextEncoder.encode(arg);
|
package/iscc_wasm_bg.wasm
CHANGED
|
Binary file
|