@iscc/wasm 0.0.2 → 0.0.4
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 +1 -0
- package/iscc_wasm.d.ts +135 -0
- package/iscc_wasm.js +387 -0
- package/iscc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ Both browser and Node.js targets are supported.
|
|
|
54
54
|
| `gen_data_code_v0` | Generate a Data-Code from raw bytes |
|
|
55
55
|
| `gen_instance_code_v0` | Generate an Instance-Code from raw bytes |
|
|
56
56
|
| `gen_iscc_code_v0` | Generate a composite ISCC-CODE |
|
|
57
|
+
| `gen_sum_code_v0` | Generate an ISCC-SUM from raw bytes |
|
|
57
58
|
|
|
58
59
|
All code generators return ISCC strings directly.
|
|
59
60
|
|
package/iscc_wasm.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export class DataHasher {
|
|
|
28
28
|
update(data: Uint8Array): void;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Default read buffer size for streaming I/O (4 MB).
|
|
33
|
+
*/
|
|
34
|
+
export function IO_READ_SIZE(): number;
|
|
35
|
+
|
|
31
36
|
/**
|
|
32
37
|
* Streaming Instance-Code generator.
|
|
33
38
|
*
|
|
@@ -55,6 +60,76 @@ export class InstanceHasher {
|
|
|
55
60
|
update(data: Uint8Array): void;
|
|
56
61
|
}
|
|
57
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Result of decoding an ISCC unit string.
|
|
65
|
+
*/
|
|
66
|
+
export class IsccDecodeResult {
|
|
67
|
+
private constructor();
|
|
68
|
+
free(): void;
|
|
69
|
+
[Symbol.dispose](): void;
|
|
70
|
+
/**
|
|
71
|
+
* Raw digest bytes truncated to the encoded bit-length.
|
|
72
|
+
*/
|
|
73
|
+
digest: Uint8Array;
|
|
74
|
+
/**
|
|
75
|
+
* Length index from the header.
|
|
76
|
+
*/
|
|
77
|
+
length: number;
|
|
78
|
+
/**
|
|
79
|
+
* MainType enum value (0–7).
|
|
80
|
+
*/
|
|
81
|
+
maintype: number;
|
|
82
|
+
/**
|
|
83
|
+
* SubType enum value (0–7).
|
|
84
|
+
*/
|
|
85
|
+
subtype: number;
|
|
86
|
+
/**
|
|
87
|
+
* Version enum value.
|
|
88
|
+
*/
|
|
89
|
+
version: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Maximum byte length for the description field after trimming.
|
|
94
|
+
*/
|
|
95
|
+
export function META_TRIM_DESCRIPTION(): number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Maximum byte length for the meta field payload after decoding.
|
|
99
|
+
*/
|
|
100
|
+
export function META_TRIM_META(): number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Maximum byte length for the name field after trimming.
|
|
104
|
+
*/
|
|
105
|
+
export function META_TRIM_NAME(): number;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Sliding window width for text n-gram generation.
|
|
109
|
+
*/
|
|
110
|
+
export function TEXT_NGRAM_SIZE(): number;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Result of [`gen_sum_code_v0`], containing the composite ISCC-CODE, data hash, and file size.
|
|
114
|
+
*/
|
|
115
|
+
export class WasmSumCodeResult {
|
|
116
|
+
private constructor();
|
|
117
|
+
free(): void;
|
|
118
|
+
[Symbol.dispose](): void;
|
|
119
|
+
/**
|
|
120
|
+
* Hex-encoded BLAKE3 multihash (`"1e20..."`) of the data.
|
|
121
|
+
*/
|
|
122
|
+
datahash: string;
|
|
123
|
+
/**
|
|
124
|
+
* Byte length of the input data (as `f64` for JS `number` compatibility).
|
|
125
|
+
*/
|
|
126
|
+
filesize: number;
|
|
127
|
+
/**
|
|
128
|
+
* Composite ISCC-CODE string (e.g., `"ISCC:KAC..."`).
|
|
129
|
+
*/
|
|
130
|
+
iscc: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
58
133
|
/**
|
|
59
134
|
* Split data into content-defined chunks using gear rolling hash.
|
|
60
135
|
*
|
|
@@ -88,6 +163,14 @@ export function alg_simhash(hash_digests: any): Uint8Array;
|
|
|
88
163
|
*/
|
|
89
164
|
export function encode_base64(data: Uint8Array): string;
|
|
90
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Encode raw ISCC header components and digest into a base32 ISCC unit string.
|
|
168
|
+
*
|
|
169
|
+
* Takes integer type identifiers and a raw digest, returns a base32-encoded
|
|
170
|
+
* ISCC unit string (without "ISCC:" prefix).
|
|
171
|
+
*/
|
|
172
|
+
export function encode_component(mtype: number, stype: number, version: number, bit_length: number, digest: Uint8Array): string;
|
|
173
|
+
|
|
91
174
|
/**
|
|
92
175
|
* Generate an Audio-Code from a Chromaprint feature vector.
|
|
93
176
|
*
|
|
@@ -144,6 +227,15 @@ export function gen_meta_code_v0(name: string, description?: string | null, meta
|
|
|
144
227
|
*/
|
|
145
228
|
export function gen_mixed_code_v0(codes: any, bits?: number | null): string;
|
|
146
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Generate a composite ISCC-CODE from raw byte data in a single pass.
|
|
232
|
+
*
|
|
233
|
+
* Feeds both `DataHasher` (CDC/MinHash) and `InstanceHasher` (BLAKE3) from
|
|
234
|
+
* the same byte slice, then composes the final ISCC-CODE via
|
|
235
|
+
* `gen_iscc_code_v0`. WASM-compatible alternative to the file-based core API.
|
|
236
|
+
*/
|
|
237
|
+
export function gen_sum_code_v0(data: Uint8Array, bits?: number | null, wide?: boolean | null): WasmSumCodeResult;
|
|
238
|
+
|
|
147
239
|
/**
|
|
148
240
|
* Generate a Text-Code from plain text content.
|
|
149
241
|
*
|
|
@@ -160,6 +252,14 @@ export function gen_text_code_v0(text: string, bits?: number | null): string;
|
|
|
160
252
|
*/
|
|
161
253
|
export function gen_video_code_v0(frame_sigs: any, bits?: number | null): string;
|
|
162
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Decode an ISCC unit string into header components and raw digest.
|
|
257
|
+
*
|
|
258
|
+
* Returns an object with `maintype`, `subtype`, `version`, `length`, and
|
|
259
|
+
* `digest` fields. Strips an optional "ISCC:" prefix before decoding.
|
|
260
|
+
*/
|
|
261
|
+
export function iscc_decode(iscc: string): IsccDecodeResult;
|
|
262
|
+
|
|
163
263
|
/**
|
|
164
264
|
* Decompose a composite ISCC-CODE into individual ISCC-UNITs.
|
|
165
265
|
*
|
|
@@ -169,6 +269,14 @@ export function gen_video_code_v0(frame_sigs: any, bits?: number | null): string
|
|
|
169
269
|
*/
|
|
170
270
|
export function iscc_decompose(iscc_code: string): string[];
|
|
171
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Convert a JSON string into a `data:` URL with JCS canonicalization.
|
|
274
|
+
*
|
|
275
|
+
* Uses `application/ld+json` media type when the JSON contains an `@context`
|
|
276
|
+
* key, otherwise `application/json`.
|
|
277
|
+
*/
|
|
278
|
+
export function json_to_data_url(json: string): string;
|
|
279
|
+
|
|
172
280
|
/**
|
|
173
281
|
* Generate sliding window n-grams from a string.
|
|
174
282
|
*
|
|
@@ -222,8 +330,31 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
222
330
|
|
|
223
331
|
export interface InitOutput {
|
|
224
332
|
readonly memory: WebAssembly.Memory;
|
|
333
|
+
readonly IO_READ_SIZE: () => number;
|
|
334
|
+
readonly META_TRIM_DESCRIPTION: () => number;
|
|
335
|
+
readonly META_TRIM_META: () => number;
|
|
336
|
+
readonly META_TRIM_NAME: () => number;
|
|
337
|
+
readonly TEXT_NGRAM_SIZE: () => number;
|
|
225
338
|
readonly __wbg_datahasher_free: (a: number, b: number) => void;
|
|
339
|
+
readonly __wbg_get_isccdecoderesult_digest: (a: number, b: number) => void;
|
|
340
|
+
readonly __wbg_get_isccdecoderesult_length: (a: number) => number;
|
|
341
|
+
readonly __wbg_get_isccdecoderesult_maintype: (a: number) => number;
|
|
342
|
+
readonly __wbg_get_isccdecoderesult_subtype: (a: number) => number;
|
|
343
|
+
readonly __wbg_get_isccdecoderesult_version: (a: number) => number;
|
|
344
|
+
readonly __wbg_get_wasmsumcoderesult_datahash: (a: number, b: number) => void;
|
|
345
|
+
readonly __wbg_get_wasmsumcoderesult_filesize: (a: number) => number;
|
|
346
|
+
readonly __wbg_get_wasmsumcoderesult_iscc: (a: number, b: number) => void;
|
|
226
347
|
readonly __wbg_instancehasher_free: (a: number, b: number) => void;
|
|
348
|
+
readonly __wbg_isccdecoderesult_free: (a: number, b: number) => void;
|
|
349
|
+
readonly __wbg_set_isccdecoderesult_digest: (a: number, b: number, c: number) => void;
|
|
350
|
+
readonly __wbg_set_isccdecoderesult_length: (a: number, b: number) => void;
|
|
351
|
+
readonly __wbg_set_isccdecoderesult_maintype: (a: number, b: number) => void;
|
|
352
|
+
readonly __wbg_set_isccdecoderesult_subtype: (a: number, b: number) => void;
|
|
353
|
+
readonly __wbg_set_isccdecoderesult_version: (a: number, b: number) => void;
|
|
354
|
+
readonly __wbg_set_wasmsumcoderesult_datahash: (a: number, b: number, c: number) => void;
|
|
355
|
+
readonly __wbg_set_wasmsumcoderesult_filesize: (a: number, b: number) => void;
|
|
356
|
+
readonly __wbg_set_wasmsumcoderesult_iscc: (a: number, b: number, c: number) => void;
|
|
357
|
+
readonly __wbg_wasmsumcoderesult_free: (a: number, b: number) => void;
|
|
227
358
|
readonly alg_cdc_chunks: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
228
359
|
readonly alg_minhash_256: (a: number, b: number, c: number) => void;
|
|
229
360
|
readonly alg_simhash: (a: number, b: number) => void;
|
|
@@ -231,6 +362,7 @@ export interface InitOutput {
|
|
|
231
362
|
readonly datahasher_new: () => number;
|
|
232
363
|
readonly datahasher_update: (a: number, b: number, c: number, d: number) => void;
|
|
233
364
|
readonly encode_base64: (a: number, b: number, c: number) => void;
|
|
365
|
+
readonly encode_component: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
234
366
|
readonly gen_audio_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
235
367
|
readonly gen_data_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
236
368
|
readonly gen_image_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -238,12 +370,15 @@ export interface InitOutput {
|
|
|
238
370
|
readonly gen_iscc_code_v0: (a: number, b: number, c: number) => void;
|
|
239
371
|
readonly gen_meta_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
240
372
|
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;
|
|
241
374
|
readonly gen_text_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
242
375
|
readonly gen_video_code_v0: (a: number, b: number, c: number) => void;
|
|
243
376
|
readonly instancehasher_finalize: (a: number, b: number, c: number) => void;
|
|
244
377
|
readonly instancehasher_new: () => number;
|
|
245
378
|
readonly instancehasher_update: (a: number, b: number, c: number, d: number) => void;
|
|
379
|
+
readonly iscc_decode: (a: number, b: number, c: number) => void;
|
|
246
380
|
readonly iscc_decompose: (a: number, b: number, c: number) => void;
|
|
381
|
+
readonly json_to_data_url: (a: number, b: number, c: number) => void;
|
|
247
382
|
readonly sliding_window: (a: number, b: number, c: number, d: number) => void;
|
|
248
383
|
readonly soft_hash_video_v0: (a: number, b: number, c: number) => void;
|
|
249
384
|
readonly text_clean: (a: number, b: number, c: number) => void;
|
package/iscc_wasm.js
CHANGED
|
@@ -81,6 +81,15 @@ export class DataHasher {
|
|
|
81
81
|
}
|
|
82
82
|
if (Symbol.dispose) DataHasher.prototype[Symbol.dispose] = DataHasher.prototype.free;
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Default read buffer size for streaming I/O (4 MB).
|
|
86
|
+
* @returns {number}
|
|
87
|
+
*/
|
|
88
|
+
export function IO_READ_SIZE() {
|
|
89
|
+
const ret = wasm.IO_READ_SIZE();
|
|
90
|
+
return ret >>> 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
84
93
|
/**
|
|
85
94
|
* Streaming Instance-Code generator.
|
|
86
95
|
*
|
|
@@ -162,6 +171,249 @@ export class InstanceHasher {
|
|
|
162
171
|
}
|
|
163
172
|
if (Symbol.dispose) InstanceHasher.prototype[Symbol.dispose] = InstanceHasher.prototype.free;
|
|
164
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Result of decoding an ISCC unit string.
|
|
176
|
+
*/
|
|
177
|
+
export class IsccDecodeResult {
|
|
178
|
+
static __wrap(ptr) {
|
|
179
|
+
ptr = ptr >>> 0;
|
|
180
|
+
const obj = Object.create(IsccDecodeResult.prototype);
|
|
181
|
+
obj.__wbg_ptr = ptr;
|
|
182
|
+
IsccDecodeResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
183
|
+
return obj;
|
|
184
|
+
}
|
|
185
|
+
__destroy_into_raw() {
|
|
186
|
+
const ptr = this.__wbg_ptr;
|
|
187
|
+
this.__wbg_ptr = 0;
|
|
188
|
+
IsccDecodeResultFinalization.unregister(this);
|
|
189
|
+
return ptr;
|
|
190
|
+
}
|
|
191
|
+
free() {
|
|
192
|
+
const ptr = this.__destroy_into_raw();
|
|
193
|
+
wasm.__wbg_isccdecoderesult_free(ptr, 0);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Raw digest bytes truncated to the encoded bit-length.
|
|
197
|
+
* @returns {Uint8Array}
|
|
198
|
+
*/
|
|
199
|
+
get digest() {
|
|
200
|
+
try {
|
|
201
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
202
|
+
wasm.__wbg_get_isccdecoderesult_digest(retptr, this.__wbg_ptr);
|
|
203
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
204
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
205
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
206
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
207
|
+
return v1;
|
|
208
|
+
} finally {
|
|
209
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Length index from the header.
|
|
214
|
+
* @returns {number}
|
|
215
|
+
*/
|
|
216
|
+
get length() {
|
|
217
|
+
const ret = wasm.__wbg_get_isccdecoderesult_length(this.__wbg_ptr);
|
|
218
|
+
return ret;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* MainType enum value (0–7).
|
|
222
|
+
* @returns {number}
|
|
223
|
+
*/
|
|
224
|
+
get maintype() {
|
|
225
|
+
const ret = wasm.__wbg_get_isccdecoderesult_maintype(this.__wbg_ptr);
|
|
226
|
+
return ret;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* SubType enum value (0–7).
|
|
230
|
+
* @returns {number}
|
|
231
|
+
*/
|
|
232
|
+
get subtype() {
|
|
233
|
+
const ret = wasm.__wbg_get_isccdecoderesult_subtype(this.__wbg_ptr);
|
|
234
|
+
return ret;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Version enum value.
|
|
238
|
+
* @returns {number}
|
|
239
|
+
*/
|
|
240
|
+
get version() {
|
|
241
|
+
const ret = wasm.__wbg_get_isccdecoderesult_version(this.__wbg_ptr);
|
|
242
|
+
return ret;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Raw digest bytes truncated to the encoded bit-length.
|
|
246
|
+
* @param {Uint8Array} arg0
|
|
247
|
+
*/
|
|
248
|
+
set digest(arg0) {
|
|
249
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_export);
|
|
250
|
+
const len0 = WASM_VECTOR_LEN;
|
|
251
|
+
wasm.__wbg_set_isccdecoderesult_digest(this.__wbg_ptr, ptr0, len0);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Length index from the header.
|
|
255
|
+
* @param {number} arg0
|
|
256
|
+
*/
|
|
257
|
+
set length(arg0) {
|
|
258
|
+
wasm.__wbg_set_isccdecoderesult_length(this.__wbg_ptr, arg0);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* MainType enum value (0–7).
|
|
262
|
+
* @param {number} arg0
|
|
263
|
+
*/
|
|
264
|
+
set maintype(arg0) {
|
|
265
|
+
wasm.__wbg_set_isccdecoderesult_maintype(this.__wbg_ptr, arg0);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* SubType enum value (0–7).
|
|
269
|
+
* @param {number} arg0
|
|
270
|
+
*/
|
|
271
|
+
set subtype(arg0) {
|
|
272
|
+
wasm.__wbg_set_isccdecoderesult_subtype(this.__wbg_ptr, arg0);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Version enum value.
|
|
276
|
+
* @param {number} arg0
|
|
277
|
+
*/
|
|
278
|
+
set version(arg0) {
|
|
279
|
+
wasm.__wbg_set_isccdecoderesult_version(this.__wbg_ptr, arg0);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (Symbol.dispose) IsccDecodeResult.prototype[Symbol.dispose] = IsccDecodeResult.prototype.free;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Maximum byte length for the description field after trimming.
|
|
286
|
+
* @returns {number}
|
|
287
|
+
*/
|
|
288
|
+
export function META_TRIM_DESCRIPTION() {
|
|
289
|
+
const ret = wasm.META_TRIM_DESCRIPTION();
|
|
290
|
+
return ret >>> 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Maximum byte length for the meta field payload after decoding.
|
|
295
|
+
* @returns {number}
|
|
296
|
+
*/
|
|
297
|
+
export function META_TRIM_META() {
|
|
298
|
+
const ret = wasm.META_TRIM_META();
|
|
299
|
+
return ret >>> 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Maximum byte length for the name field after trimming.
|
|
304
|
+
* @returns {number}
|
|
305
|
+
*/
|
|
306
|
+
export function META_TRIM_NAME() {
|
|
307
|
+
const ret = wasm.META_TRIM_NAME();
|
|
308
|
+
return ret >>> 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Sliding window width for text n-gram generation.
|
|
313
|
+
* @returns {number}
|
|
314
|
+
*/
|
|
315
|
+
export function TEXT_NGRAM_SIZE() {
|
|
316
|
+
const ret = wasm.TEXT_NGRAM_SIZE();
|
|
317
|
+
return ret >>> 0;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Result of [`gen_sum_code_v0`], containing the composite ISCC-CODE, data hash, and file size.
|
|
322
|
+
*/
|
|
323
|
+
export class WasmSumCodeResult {
|
|
324
|
+
static __wrap(ptr) {
|
|
325
|
+
ptr = ptr >>> 0;
|
|
326
|
+
const obj = Object.create(WasmSumCodeResult.prototype);
|
|
327
|
+
obj.__wbg_ptr = ptr;
|
|
328
|
+
WasmSumCodeResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
329
|
+
return obj;
|
|
330
|
+
}
|
|
331
|
+
__destroy_into_raw() {
|
|
332
|
+
const ptr = this.__wbg_ptr;
|
|
333
|
+
this.__wbg_ptr = 0;
|
|
334
|
+
WasmSumCodeResultFinalization.unregister(this);
|
|
335
|
+
return ptr;
|
|
336
|
+
}
|
|
337
|
+
free() {
|
|
338
|
+
const ptr = this.__destroy_into_raw();
|
|
339
|
+
wasm.__wbg_wasmsumcoderesult_free(ptr, 0);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Hex-encoded BLAKE3 multihash (`"1e20..."`) of the data.
|
|
343
|
+
* @returns {string}
|
|
344
|
+
*/
|
|
345
|
+
get datahash() {
|
|
346
|
+
let deferred1_0;
|
|
347
|
+
let deferred1_1;
|
|
348
|
+
try {
|
|
349
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
350
|
+
wasm.__wbg_get_wasmsumcoderesult_datahash(retptr, this.__wbg_ptr);
|
|
351
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
352
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
353
|
+
deferred1_0 = r0;
|
|
354
|
+
deferred1_1 = r1;
|
|
355
|
+
return getStringFromWasm0(r0, r1);
|
|
356
|
+
} finally {
|
|
357
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
358
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Byte length of the input data (as `f64` for JS `number` compatibility).
|
|
363
|
+
* @returns {number}
|
|
364
|
+
*/
|
|
365
|
+
get filesize() {
|
|
366
|
+
const ret = wasm.__wbg_get_wasmsumcoderesult_filesize(this.__wbg_ptr);
|
|
367
|
+
return ret;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Composite ISCC-CODE string (e.g., `"ISCC:KAC..."`).
|
|
371
|
+
* @returns {string}
|
|
372
|
+
*/
|
|
373
|
+
get iscc() {
|
|
374
|
+
let deferred1_0;
|
|
375
|
+
let deferred1_1;
|
|
376
|
+
try {
|
|
377
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
378
|
+
wasm.__wbg_get_wasmsumcoderesult_iscc(retptr, this.__wbg_ptr);
|
|
379
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
380
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
381
|
+
deferred1_0 = r0;
|
|
382
|
+
deferred1_1 = r1;
|
|
383
|
+
return getStringFromWasm0(r0, r1);
|
|
384
|
+
} finally {
|
|
385
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
386
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Hex-encoded BLAKE3 multihash (`"1e20..."`) of the data.
|
|
391
|
+
* @param {string} arg0
|
|
392
|
+
*/
|
|
393
|
+
set datahash(arg0) {
|
|
394
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
395
|
+
const len0 = WASM_VECTOR_LEN;
|
|
396
|
+
wasm.__wbg_set_wasmsumcoderesult_datahash(this.__wbg_ptr, ptr0, len0);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Byte length of the input data (as `f64` for JS `number` compatibility).
|
|
400
|
+
* @param {number} arg0
|
|
401
|
+
*/
|
|
402
|
+
set filesize(arg0) {
|
|
403
|
+
wasm.__wbg_set_wasmsumcoderesult_filesize(this.__wbg_ptr, arg0);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Composite ISCC-CODE string (e.g., `"ISCC:KAC..."`).
|
|
407
|
+
* @param {string} arg0
|
|
408
|
+
*/
|
|
409
|
+
set iscc(arg0) {
|
|
410
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
411
|
+
const len0 = WASM_VECTOR_LEN;
|
|
412
|
+
wasm.__wbg_set_wasmsumcoderesult_iscc(this.__wbg_ptr, ptr0, len0);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (Symbol.dispose) WasmSumCodeResult.prototype[Symbol.dispose] = WasmSumCodeResult.prototype.free;
|
|
416
|
+
|
|
165
417
|
/**
|
|
166
418
|
* Split data into content-defined chunks using gear rolling hash.
|
|
167
419
|
*
|
|
@@ -269,6 +521,45 @@ export function encode_base64(data) {
|
|
|
269
521
|
}
|
|
270
522
|
}
|
|
271
523
|
|
|
524
|
+
/**
|
|
525
|
+
* Encode raw ISCC header components and digest into a base32 ISCC unit string.
|
|
526
|
+
*
|
|
527
|
+
* Takes integer type identifiers and a raw digest, returns a base32-encoded
|
|
528
|
+
* ISCC unit string (without "ISCC:" prefix).
|
|
529
|
+
* @param {number} mtype
|
|
530
|
+
* @param {number} stype
|
|
531
|
+
* @param {number} version
|
|
532
|
+
* @param {number} bit_length
|
|
533
|
+
* @param {Uint8Array} digest
|
|
534
|
+
* @returns {string}
|
|
535
|
+
*/
|
|
536
|
+
export function encode_component(mtype, stype, version, bit_length, digest) {
|
|
537
|
+
let deferred3_0;
|
|
538
|
+
let deferred3_1;
|
|
539
|
+
try {
|
|
540
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
541
|
+
const ptr0 = passArray8ToWasm0(digest, wasm.__wbindgen_export);
|
|
542
|
+
const len0 = WASM_VECTOR_LEN;
|
|
543
|
+
wasm.encode_component(retptr, mtype, stype, version, bit_length, ptr0, len0);
|
|
544
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
545
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
546
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
547
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
548
|
+
var ptr2 = r0;
|
|
549
|
+
var len2 = r1;
|
|
550
|
+
if (r3) {
|
|
551
|
+
ptr2 = 0; len2 = 0;
|
|
552
|
+
throw takeObject(r2);
|
|
553
|
+
}
|
|
554
|
+
deferred3_0 = ptr2;
|
|
555
|
+
deferred3_1 = len2;
|
|
556
|
+
return getStringFromWasm0(ptr2, len2);
|
|
557
|
+
} finally {
|
|
558
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
559
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
272
563
|
/**
|
|
273
564
|
* Generate an Audio-Code from a Chromaprint feature vector.
|
|
274
565
|
*
|
|
@@ -523,6 +814,35 @@ export function gen_mixed_code_v0(codes, bits) {
|
|
|
523
814
|
}
|
|
524
815
|
}
|
|
525
816
|
|
|
817
|
+
/**
|
|
818
|
+
* Generate a composite ISCC-CODE from raw byte data in a single pass.
|
|
819
|
+
*
|
|
820
|
+
* Feeds both `DataHasher` (CDC/MinHash) and `InstanceHasher` (BLAKE3) from
|
|
821
|
+
* the same byte slice, then composes the final ISCC-CODE via
|
|
822
|
+
* `gen_iscc_code_v0`. WASM-compatible alternative to the file-based core API.
|
|
823
|
+
* @param {Uint8Array} data
|
|
824
|
+
* @param {number | null} [bits]
|
|
825
|
+
* @param {boolean | null} [wide]
|
|
826
|
+
* @returns {WasmSumCodeResult}
|
|
827
|
+
*/
|
|
828
|
+
export function gen_sum_code_v0(data, bits, wide) {
|
|
829
|
+
try {
|
|
830
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
831
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
832
|
+
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);
|
|
834
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
835
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
836
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
837
|
+
if (r2) {
|
|
838
|
+
throw takeObject(r1);
|
|
839
|
+
}
|
|
840
|
+
return WasmSumCodeResult.__wrap(r0);
|
|
841
|
+
} finally {
|
|
842
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
526
846
|
/**
|
|
527
847
|
* Generate a Text-Code from plain text content.
|
|
528
848
|
*
|
|
@@ -593,6 +913,32 @@ export function gen_video_code_v0(frame_sigs, bits) {
|
|
|
593
913
|
}
|
|
594
914
|
}
|
|
595
915
|
|
|
916
|
+
/**
|
|
917
|
+
* Decode an ISCC unit string into header components and raw digest.
|
|
918
|
+
*
|
|
919
|
+
* Returns an object with `maintype`, `subtype`, `version`, `length`, and
|
|
920
|
+
* `digest` fields. Strips an optional "ISCC:" prefix before decoding.
|
|
921
|
+
* @param {string} iscc
|
|
922
|
+
* @returns {IsccDecodeResult}
|
|
923
|
+
*/
|
|
924
|
+
export function iscc_decode(iscc) {
|
|
925
|
+
try {
|
|
926
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
927
|
+
const ptr0 = passStringToWasm0(iscc, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
928
|
+
const len0 = WASM_VECTOR_LEN;
|
|
929
|
+
wasm.iscc_decode(retptr, ptr0, len0);
|
|
930
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
931
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
932
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
933
|
+
if (r2) {
|
|
934
|
+
throw takeObject(r1);
|
|
935
|
+
}
|
|
936
|
+
return IsccDecodeResult.__wrap(r0);
|
|
937
|
+
} finally {
|
|
938
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
596
942
|
/**
|
|
597
943
|
* Decompose a composite ISCC-CODE into individual ISCC-UNITs.
|
|
598
944
|
*
|
|
@@ -623,6 +969,41 @@ export function iscc_decompose(iscc_code) {
|
|
|
623
969
|
}
|
|
624
970
|
}
|
|
625
971
|
|
|
972
|
+
/**
|
|
973
|
+
* Convert a JSON string into a `data:` URL with JCS canonicalization.
|
|
974
|
+
*
|
|
975
|
+
* Uses `application/ld+json` media type when the JSON contains an `@context`
|
|
976
|
+
* key, otherwise `application/json`.
|
|
977
|
+
* @param {string} json
|
|
978
|
+
* @returns {string}
|
|
979
|
+
*/
|
|
980
|
+
export function json_to_data_url(json) {
|
|
981
|
+
let deferred3_0;
|
|
982
|
+
let deferred3_1;
|
|
983
|
+
try {
|
|
984
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
985
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
986
|
+
const len0 = WASM_VECTOR_LEN;
|
|
987
|
+
wasm.json_to_data_url(retptr, ptr0, len0);
|
|
988
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
989
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
990
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
991
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
992
|
+
var ptr2 = r0;
|
|
993
|
+
var len2 = r1;
|
|
994
|
+
if (r3) {
|
|
995
|
+
ptr2 = 0; len2 = 0;
|
|
996
|
+
throw takeObject(r2);
|
|
997
|
+
}
|
|
998
|
+
deferred3_0 = ptr2;
|
|
999
|
+
deferred3_1 = len2;
|
|
1000
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1001
|
+
} finally {
|
|
1002
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1003
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
626
1007
|
/**
|
|
627
1008
|
* Generate sliding window n-grams from a string.
|
|
628
1009
|
*
|
|
@@ -959,6 +1340,12 @@ const DataHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
959
1340
|
const InstanceHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
960
1341
|
? { register: () => {}, unregister: () => {} }
|
|
961
1342
|
: new FinalizationRegistry(ptr => wasm.__wbg_instancehasher_free(ptr >>> 0, 1));
|
|
1343
|
+
const IsccDecodeResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1344
|
+
? { register: () => {}, unregister: () => {} }
|
|
1345
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_isccdecoderesult_free(ptr >>> 0, 1));
|
|
1346
|
+
const WasmSumCodeResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1347
|
+
? { register: () => {}, unregister: () => {} }
|
|
1348
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsumcoderesult_free(ptr >>> 0, 1));
|
|
962
1349
|
|
|
963
1350
|
function addHeapObject(obj) {
|
|
964
1351
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
package/iscc_wasm_bg.wasm
CHANGED
|
Binary file
|