@iscc/wasm 0.5.0 → 0.6.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 +7 -0
- package/iscc_wasm.d.ts +18 -0
- package/iscc_wasm.js +75 -31
- package/iscc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,13 @@ All code generators return ISCC strings directly.
|
|
|
65
65
|
- **Streaming:** `DataHasher`, `InstanceHasher` classes for incremental processing
|
|
66
66
|
- **Diagnostics:** `conformance_selftest`
|
|
67
67
|
|
|
68
|
+
## Engine Requirements
|
|
69
|
+
|
|
70
|
+
The published package is compiled with [WebAssembly SIMD](https://webassembly.org/features/)
|
|
71
|
+
(`simd128`) so BLAKE3 uses its SIMD backend. It requires an engine with WASM SIMD support: all
|
|
72
|
+
evergreen browsers (Chrome 91+, Firefox 89+, Safari 16.4+) and Node.js 16.4+. Engines without WASM
|
|
73
|
+
SIMD fail at `WebAssembly.instantiate` with a `CompileError`.
|
|
74
|
+
|
|
68
75
|
## Links
|
|
69
76
|
|
|
70
77
|
- [Documentation](https://lib.iscc.codes)
|
package/iscc_wasm.d.ts
CHANGED
|
@@ -257,6 +257,23 @@ export function gen_instance_code_v0(data: Uint8Array, bits?: number | null): st
|
|
|
257
257
|
*/
|
|
258
258
|
export function gen_iscc_code_v0(codes: any, wide?: boolean | null): string;
|
|
259
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Generate an ISCC-IDv1 from a timestamp and a HUB-ID (experimental).
|
|
262
|
+
*
|
|
263
|
+
* Packs a 52-bit microsecond UTC `timestamp` into the high bits and a 12-bit
|
|
264
|
+
* `hub_id` (0-4095) into the low bits, encoding the result as an ISCC-ID unit
|
|
265
|
+
* with `realm` (0 = testnet, 1 = mainnet) as SubType and Version `V1`.
|
|
266
|
+
*
|
|
267
|
+
* All three parameters are JS `number`s (valid `timestamp` values are `< 2^52`,
|
|
268
|
+
* exactly representable in `f64`). Throws if any parameter is non-finite,
|
|
269
|
+
* non-integral, or negative, or if `timestamp >= 2^52`, `hub_id >= 2^12`, or
|
|
270
|
+
* `realm` is not `0` or `1`.
|
|
271
|
+
*
|
|
272
|
+
* **Experimental:** the ISCC-IDv1 format is not yet part of ISO 24138 and may
|
|
273
|
+
* change. There is no dedicated decoder — use `iscc_decode` to decode.
|
|
274
|
+
*/
|
|
275
|
+
export function gen_iscc_id_v1(timestamp: number, hub_id: number, realm: number): string;
|
|
276
|
+
|
|
260
277
|
/**
|
|
261
278
|
* Generate a Meta-Code from name and optional metadata.
|
|
262
279
|
*
|
|
@@ -421,6 +438,7 @@ export interface InitOutput {
|
|
|
421
438
|
readonly gen_image_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
422
439
|
readonly gen_instance_code_v0: (a: number, b: number, c: number, d: number) => void;
|
|
423
440
|
readonly gen_iscc_code_v0: (a: number, b: number, c: number) => void;
|
|
441
|
+
readonly gen_iscc_id_v1: (a: number, b: number, c: number, d: number) => void;
|
|
424
442
|
readonly gen_meta_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
425
443
|
readonly gen_mixed_code_v0: (a: number, b: number, c: number) => void;
|
|
426
444
|
readonly gen_sum_code_v0: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
package/iscc_wasm.js
CHANGED
|
@@ -854,6 +854,50 @@ export function gen_iscc_code_v0(codes, wide) {
|
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
+
/**
|
|
858
|
+
* Generate an ISCC-IDv1 from a timestamp and a HUB-ID (experimental).
|
|
859
|
+
*
|
|
860
|
+
* Packs a 52-bit microsecond UTC `timestamp` into the high bits and a 12-bit
|
|
861
|
+
* `hub_id` (0-4095) into the low bits, encoding the result as an ISCC-ID unit
|
|
862
|
+
* with `realm` (0 = testnet, 1 = mainnet) as SubType and Version `V1`.
|
|
863
|
+
*
|
|
864
|
+
* All three parameters are JS `number`s (valid `timestamp` values are `< 2^52`,
|
|
865
|
+
* exactly representable in `f64`). Throws if any parameter is non-finite,
|
|
866
|
+
* non-integral, or negative, or if `timestamp >= 2^52`, `hub_id >= 2^12`, or
|
|
867
|
+
* `realm` is not `0` or `1`.
|
|
868
|
+
*
|
|
869
|
+
* **Experimental:** the ISCC-IDv1 format is not yet part of ISO 24138 and may
|
|
870
|
+
* change. There is no dedicated decoder — use `iscc_decode` to decode.
|
|
871
|
+
* @param {number} timestamp
|
|
872
|
+
* @param {number} hub_id
|
|
873
|
+
* @param {number} realm
|
|
874
|
+
* @returns {string}
|
|
875
|
+
*/
|
|
876
|
+
export function gen_iscc_id_v1(timestamp, hub_id, realm) {
|
|
877
|
+
let deferred2_0;
|
|
878
|
+
let deferred2_1;
|
|
879
|
+
try {
|
|
880
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
881
|
+
wasm.gen_iscc_id_v1(retptr, timestamp, hub_id, realm);
|
|
882
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
883
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
884
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
885
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
886
|
+
var ptr1 = r0;
|
|
887
|
+
var len1 = r1;
|
|
888
|
+
if (r3) {
|
|
889
|
+
ptr1 = 0; len1 = 0;
|
|
890
|
+
throw takeObject(r2);
|
|
891
|
+
}
|
|
892
|
+
deferred2_0 = ptr1;
|
|
893
|
+
deferred2_1 = len1;
|
|
894
|
+
return getStringFromWasm0(ptr1, len1);
|
|
895
|
+
} finally {
|
|
896
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
897
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
857
901
|
/**
|
|
858
902
|
* Generate a Meta-Code from name and optional metadata.
|
|
859
903
|
*
|
|
@@ -1294,11 +1338,11 @@ export function text_trim(text, nbytes) {
|
|
|
1294
1338
|
function __wbg_get_imports() {
|
|
1295
1339
|
const import0 = {
|
|
1296
1340
|
__proto__: null,
|
|
1297
|
-
|
|
1341
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
1298
1342
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1299
1343
|
return addHeapObject(ret);
|
|
1300
1344
|
},
|
|
1301
|
-
|
|
1345
|
+
__wbg_Number_9a4e0ecb0fa16705: function(arg0) {
|
|
1302
1346
|
const ret = Number(getObject(arg0));
|
|
1303
1347
|
return ret;
|
|
1304
1348
|
},
|
|
@@ -1309,38 +1353,38 @@ function __wbg_get_imports() {
|
|
|
1309
1353
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1310
1354
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1311
1355
|
},
|
|
1312
|
-
|
|
1356
|
+
__wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
|
|
1313
1357
|
const v = getObject(arg0);
|
|
1314
1358
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
1315
1359
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
1316
1360
|
},
|
|
1317
|
-
|
|
1361
|
+
__wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
|
|
1318
1362
|
const ret = debugString(getObject(arg1));
|
|
1319
1363
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1320
1364
|
const len1 = WASM_VECTOR_LEN;
|
|
1321
1365
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1322
1366
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1323
1367
|
},
|
|
1324
|
-
|
|
1368
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
1325
1369
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
1326
1370
|
return ret;
|
|
1327
1371
|
},
|
|
1328
|
-
|
|
1372
|
+
__wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
|
|
1329
1373
|
const val = getObject(arg0);
|
|
1330
1374
|
const ret = typeof(val) === 'object' && val !== null;
|
|
1331
1375
|
return ret;
|
|
1332
1376
|
},
|
|
1333
|
-
|
|
1377
|
+
__wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
|
|
1334
1378
|
const ret = getObject(arg0) == getObject(arg1);
|
|
1335
1379
|
return ret;
|
|
1336
1380
|
},
|
|
1337
|
-
|
|
1381
|
+
__wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
|
|
1338
1382
|
const obj = getObject(arg1);
|
|
1339
1383
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1340
1384
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1341
1385
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1342
1386
|
},
|
|
1343
|
-
|
|
1387
|
+
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
1344
1388
|
const obj = getObject(arg1);
|
|
1345
1389
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1346
1390
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -1348,26 +1392,26 @@ function __wbg_get_imports() {
|
|
|
1348
1392
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1349
1393
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1350
1394
|
},
|
|
1351
|
-
|
|
1395
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
1352
1396
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1353
1397
|
},
|
|
1354
|
-
|
|
1398
|
+
__wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
|
|
1355
1399
|
const ret = getObject(arg0).call(getObject(arg1));
|
|
1356
1400
|
return addHeapObject(ret);
|
|
1357
1401
|
}, arguments); },
|
|
1358
|
-
|
|
1402
|
+
__wbg_done_89b2b13e91a60321: function(arg0) {
|
|
1359
1403
|
const ret = getObject(arg0).done;
|
|
1360
1404
|
return ret;
|
|
1361
1405
|
},
|
|
1362
|
-
|
|
1406
|
+
__wbg_get_c7eb1f358a7654df: function() { return handleError(function (arg0, arg1) {
|
|
1363
1407
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
1364
1408
|
return addHeapObject(ret);
|
|
1365
1409
|
}, arguments); },
|
|
1366
|
-
|
|
1410
|
+
__wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
|
|
1367
1411
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1368
1412
|
return addHeapObject(ret);
|
|
1369
1413
|
},
|
|
1370
|
-
|
|
1414
|
+
__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
|
|
1371
1415
|
let result;
|
|
1372
1416
|
try {
|
|
1373
1417
|
result = getObject(arg0) instanceof ArrayBuffer;
|
|
@@ -1377,7 +1421,7 @@ function __wbg_get_imports() {
|
|
|
1377
1421
|
const ret = result;
|
|
1378
1422
|
return ret;
|
|
1379
1423
|
},
|
|
1380
|
-
|
|
1424
|
+
__wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
|
|
1381
1425
|
let result;
|
|
1382
1426
|
try {
|
|
1383
1427
|
result = getObject(arg0) instanceof Uint8Array;
|
|
@@ -1387,49 +1431,49 @@ function __wbg_get_imports() {
|
|
|
1387
1431
|
const ret = result;
|
|
1388
1432
|
return ret;
|
|
1389
1433
|
},
|
|
1390
|
-
|
|
1434
|
+
__wbg_isArray_0677c962b281d01a: function(arg0) {
|
|
1391
1435
|
const ret = Array.isArray(getObject(arg0));
|
|
1392
1436
|
return ret;
|
|
1393
1437
|
},
|
|
1394
|
-
|
|
1438
|
+
__wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
|
|
1395
1439
|
const ret = Number.isSafeInteger(getObject(arg0));
|
|
1396
1440
|
return ret;
|
|
1397
1441
|
},
|
|
1398
|
-
|
|
1442
|
+
__wbg_iterator_6f722e4a93058b71: function() {
|
|
1399
1443
|
const ret = Symbol.iterator;
|
|
1400
1444
|
return addHeapObject(ret);
|
|
1401
1445
|
},
|
|
1402
|
-
|
|
1446
|
+
__wbg_length_1f0964f4a5e2c6d8: function(arg0) {
|
|
1403
1447
|
const ret = getObject(arg0).length;
|
|
1404
1448
|
return ret;
|
|
1405
1449
|
},
|
|
1406
|
-
|
|
1450
|
+
__wbg_length_370319915dc99107: function(arg0) {
|
|
1407
1451
|
const ret = getObject(arg0).length;
|
|
1408
1452
|
return ret;
|
|
1409
1453
|
},
|
|
1410
|
-
|
|
1454
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
1411
1455
|
const ret = new Array();
|
|
1412
1456
|
return addHeapObject(ret);
|
|
1413
1457
|
},
|
|
1414
|
-
|
|
1458
|
+
__wbg_new_cd45aabdf6073e84: function(arg0) {
|
|
1415
1459
|
const ret = new Uint8Array(getObject(arg0));
|
|
1416
1460
|
return addHeapObject(ret);
|
|
1417
1461
|
},
|
|
1418
|
-
|
|
1419
|
-
const ret = getObject(arg0).next();
|
|
1420
|
-
return addHeapObject(ret);
|
|
1421
|
-
}, arguments); },
|
|
1422
|
-
__wbg_next_402fa10b59ab20c3: function(arg0) {
|
|
1462
|
+
__wbg_next_6dbf2c0ac8cde20f: function(arg0) {
|
|
1423
1463
|
const ret = getObject(arg0).next;
|
|
1424
1464
|
return addHeapObject(ret);
|
|
1425
1465
|
},
|
|
1426
|
-
|
|
1466
|
+
__wbg_next_71f2aa1cb3d1e37e: function() { return handleError(function (arg0) {
|
|
1467
|
+
const ret = getObject(arg0).next();
|
|
1468
|
+
return addHeapObject(ret);
|
|
1469
|
+
}, arguments); },
|
|
1470
|
+
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
1427
1471
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
1428
1472
|
},
|
|
1429
|
-
|
|
1473
|
+
__wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
|
|
1430
1474
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
1431
1475
|
},
|
|
1432
|
-
|
|
1476
|
+
__wbg_value_a5d5488a9589444a: function(arg0) {
|
|
1433
1477
|
const ret = getObject(arg0).value;
|
|
1434
1478
|
return addHeapObject(ret);
|
|
1435
1479
|
},
|
package/iscc_wasm_bg.wasm
CHANGED
|
Binary file
|