@aztec/bb.js 0.85.0-nightly.20250417 → 0.85.0-nightly.20250418
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/dest/browser/barretenberg/backend.d.ts +5 -6
- package/dest/browser/barretenberg/backend.d.ts.map +1 -1
- package/dest/browser/barretenberg-threads.js +1 -1
- package/dest/browser/barretenberg.js +1 -1
- package/dest/browser/barretenberg_api/index.d.ts +15 -27
- package/dest/browser/barretenberg_api/index.d.ts.map +1 -1
- package/dest/browser/index.js +2149 -198
- package/dest/node/barretenberg/backend.d.ts +5 -6
- package/dest/node/barretenberg/backend.d.ts.map +1 -1
- package/dest/node/barretenberg/backend.js +49 -10
- package/dest/node/barretenberg_api/index.d.ts +15 -27
- package/dest/node/barretenberg_api/index.d.ts.map +1 -1
- package/dest/node/barretenberg_api/index.js +93 -194
- package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
- package/dest/node/bindgen/mappings.d.ts.map +1 -1
- package/dest/node/bindgen/mappings.js +2 -1
- package/dest/node/bindgen/typescript.d.ts.map +1 -1
- package/dest/node/bindgen/typescript.js +3 -2
- package/dest/node/main.d.ts +0 -1
- package/dest/node/main.d.ts.map +1 -1
- package/dest/node/main.js +1 -35
- package/dest/node-cjs/barretenberg/backend.d.ts +5 -6
- package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
- package/dest/node-cjs/barretenberg/backend.js +49 -10
- package/dest/node-cjs/barretenberg_api/index.d.ts +15 -27
- package/dest/node-cjs/barretenberg_api/index.d.ts.map +1 -1
- package/dest/node-cjs/barretenberg_api/index.js +92 -193
- package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
- package/dest/node-cjs/bindgen/mappings.d.ts.map +1 -1
- package/dest/node-cjs/bindgen/mappings.js +2 -1
- package/dest/node-cjs/bindgen/typescript.d.ts.map +1 -1
- package/dest/node-cjs/bindgen/typescript.js +3 -2
- package/dest/node-cjs/main.d.ts +0 -1
- package/dest/node-cjs/main.d.ts.map +1 -1
- package/dest/node-cjs/main.js +2 -37
- package/package.json +2 -2
- package/src/barretenberg/backend.ts +64 -11
- package/src/barretenberg_api/index.ts +152 -355
- package/src/bindgen/mappings.ts +1 -0
- package/src/bindgen/typescript.ts +2 -1
- package/src/main.ts +0 -39
- package/dest/node/barretenberg/schnorr.test.d.ts +0 -2
- package/dest/node/barretenberg/schnorr.test.d.ts.map +0 -1
- package/dest/node/barretenberg/schnorr.test.js +0 -113
- package/dest/node-cjs/barretenberg/schnorr.test.d.ts +0 -2
- package/dest/node-cjs/barretenberg/schnorr.test.d.ts.map +0 -1
- package/dest/node-cjs/barretenberg/schnorr.test.js +0 -115
- package/src/barretenberg/schnorr.test.ts +0 -182
package/dest/browser/index.js
CHANGED
|
@@ -3384,21 +3384,6 @@ var __webpack_exports__ = {};
|
|
|
3384
3384
|
}
|
|
3385
3385
|
}
|
|
3386
3386
|
Buffer128.SIZE_IN_BYTES = 128;
|
|
3387
|
-
function parseBigEndianU32Array(buffer, hasSizePrefix = false) {
|
|
3388
|
-
const dv = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3389
|
-
let offset = 0;
|
|
3390
|
-
let count = buffer.byteLength >>> 2;
|
|
3391
|
-
if (hasSizePrefix) {
|
|
3392
|
-
count = dv.getUint32(0, false);
|
|
3393
|
-
offset = 4;
|
|
3394
|
-
}
|
|
3395
|
-
const out = new Array(count);
|
|
3396
|
-
for (let i = 0; i < count; i++) {
|
|
3397
|
-
out[i] = dv.getUint32(offset, false);
|
|
3398
|
-
offset += 4;
|
|
3399
|
-
}
|
|
3400
|
-
return out;
|
|
3401
|
-
}
|
|
3402
3387
|
class BarretenbergApi {
|
|
3403
3388
|
constructor(wasm) {
|
|
3404
3389
|
this.wasm = wasm;
|
|
@@ -3438,13 +3423,6 @@ var __webpack_exports__ = {};
|
|
|
3438
3423
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3439
3424
|
return out[0];
|
|
3440
3425
|
}
|
|
3441
|
-
async poseidon2HashAccumulate(inputsBuffer) {
|
|
3442
|
-
const inArgs = [ inputsBuffer ].map(serializeBufferable);
|
|
3443
|
-
const outTypes = [ Fr ];
|
|
3444
|
-
const result = await this.wasm.callWasmExport("poseidon2_hash_accumulate", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3445
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3446
|
-
return out[0];
|
|
3447
|
-
}
|
|
3448
3426
|
async poseidon2Hashes(inputsBuffer) {
|
|
3449
3427
|
const inArgs = [ inputsBuffer ].map(serializeBufferable);
|
|
3450
3428
|
const outTypes = [ Fr ];
|
|
@@ -3459,6 +3437,13 @@ var __webpack_exports__ = {};
|
|
|
3459
3437
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3460
3438
|
return out[0];
|
|
3461
3439
|
}
|
|
3440
|
+
async poseidon2HashAccumulate(inputsBuffer) {
|
|
3441
|
+
const inArgs = [ inputsBuffer ].map(serializeBufferable);
|
|
3442
|
+
const outTypes = [ Fr ];
|
|
3443
|
+
const result = await this.wasm.callWasmExport("poseidon2_hash_accumulate", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3444
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3445
|
+
return out[0];
|
|
3446
|
+
}
|
|
3462
3447
|
async blake2s(data) {
|
|
3463
3448
|
const inArgs = [ data ].map(serializeBufferable);
|
|
3464
3449
|
const outTypes = [ Buffer32 ];
|
|
@@ -3473,69 +3458,6 @@ var __webpack_exports__ = {};
|
|
|
3473
3458
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3474
3459
|
return out[0];
|
|
3475
3460
|
}
|
|
3476
|
-
async schnorrComputePublicKey(privateKey) {
|
|
3477
|
-
const inArgs = [ privateKey ].map(serializeBufferable);
|
|
3478
|
-
const outTypes = [ Point ];
|
|
3479
|
-
const result = await this.wasm.callWasmExport("schnorr_compute_public_key", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3480
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3481
|
-
return out[0];
|
|
3482
|
-
}
|
|
3483
|
-
async schnorrNegatePublicKey(publicKeyBuffer) {
|
|
3484
|
-
const inArgs = [ publicKeyBuffer ].map(serializeBufferable);
|
|
3485
|
-
const outTypes = [ Point ];
|
|
3486
|
-
const result = await this.wasm.callWasmExport("schnorr_negate_public_key", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3487
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3488
|
-
return out[0];
|
|
3489
|
-
}
|
|
3490
|
-
async schnorrConstructSignature(message, privateKey) {
|
|
3491
|
-
const inArgs = [ message, privateKey ].map(serializeBufferable);
|
|
3492
|
-
const outTypes = [ Buffer32, Buffer32 ];
|
|
3493
|
-
const result = await this.wasm.callWasmExport("schnorr_construct_signature", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3494
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3495
|
-
return out;
|
|
3496
|
-
}
|
|
3497
|
-
async schnorrVerifySignature(message, pubKey, sigS, sigE) {
|
|
3498
|
-
const inArgs = [ message, pubKey, sigS, sigE ].map(serializeBufferable);
|
|
3499
|
-
const outTypes = [ BoolDeserializer() ];
|
|
3500
|
-
const result = await this.wasm.callWasmExport("schnorr_verify_signature", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3501
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3502
|
-
return out[0];
|
|
3503
|
-
}
|
|
3504
|
-
async schnorrMultisigCreateMultisigPublicKey(privateKey) {
|
|
3505
|
-
const inArgs = [ privateKey ].map(serializeBufferable);
|
|
3506
|
-
const outTypes = [ Buffer128 ];
|
|
3507
|
-
const result = await this.wasm.callWasmExport("schnorr_multisig_create_multisig_public_key", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3508
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3509
|
-
return out[0];
|
|
3510
|
-
}
|
|
3511
|
-
async schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf) {
|
|
3512
|
-
const inArgs = [ signerPubkeyBuf ].map(serializeBufferable);
|
|
3513
|
-
const outTypes = [ Point, BoolDeserializer() ];
|
|
3514
|
-
const result = await this.wasm.callWasmExport("schnorr_multisig_validate_and_combine_signer_pubkeys", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3515
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3516
|
-
return out;
|
|
3517
|
-
}
|
|
3518
|
-
async schnorrMultisigConstructSignatureRound1() {
|
|
3519
|
-
const inArgs = [].map(serializeBufferable);
|
|
3520
|
-
const outTypes = [ Buffer128, Buffer128 ];
|
|
3521
|
-
const result = await this.wasm.callWasmExport("schnorr_multisig_construct_signature_round_1", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3522
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3523
|
-
return out;
|
|
3524
|
-
}
|
|
3525
|
-
async schnorrMultisigConstructSignatureRound2(message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf) {
|
|
3526
|
-
const inArgs = [ message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf ].map(serializeBufferable);
|
|
3527
|
-
const outTypes = [ Fq, BoolDeserializer() ];
|
|
3528
|
-
const result = await this.wasm.callWasmExport("schnorr_multisig_construct_signature_round_2", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3529
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3530
|
-
return out;
|
|
3531
|
-
}
|
|
3532
|
-
async schnorrMultisigCombineSignatures(message, signerPubkeysBuf, roundOneBuf, roundTwoBuf) {
|
|
3533
|
-
const inArgs = [ message, signerPubkeysBuf, roundOneBuf, roundTwoBuf ].map(serializeBufferable);
|
|
3534
|
-
const outTypes = [ Buffer32, Buffer32, BoolDeserializer() ];
|
|
3535
|
-
const result = await this.wasm.callWasmExport("schnorr_multisig_combine_signatures", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3536
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3537
|
-
return out;
|
|
3538
|
-
}
|
|
3539
3461
|
async aesEncryptBufferCbc(input, iv, key, length) {
|
|
3540
3462
|
const inArgs = [ input, iv, key, length ].map(serializeBufferable);
|
|
3541
3463
|
const outTypes = [ BufferDeserializer() ];
|
|
@@ -3592,12 +3514,6 @@ var __webpack_exports__ = {};
|
|
|
3592
3514
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3593
3515
|
return out;
|
|
3594
3516
|
}
|
|
3595
|
-
async acirGatesAztecClient(acirVec) {
|
|
3596
|
-
const inArgs = [ acirVec ].map(serializeBufferable);
|
|
3597
|
-
const outTypes = [ BufferDeserializer() ];
|
|
3598
|
-
const resultBuffer = await this.wasm.callWasmExport("acir_gates_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3599
|
-
return parseBigEndianU32Array(resultBuffer[0], true);
|
|
3600
|
-
}
|
|
3601
3517
|
async acirNewAcirComposer(sizeHint) {
|
|
3602
3518
|
const inArgs = [ sizeHint ].map(serializeBufferable);
|
|
3603
3519
|
const outTypes = [ Ptr ];
|
|
@@ -3640,6 +3556,20 @@ var __webpack_exports__ = {};
|
|
|
3640
3556
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3641
3557
|
return out[0];
|
|
3642
3558
|
}
|
|
3559
|
+
async acirProveAztecClient(ivcInputsBuf) {
|
|
3560
|
+
const inArgs = [ ivcInputsBuf ].map(serializeBufferable);
|
|
3561
|
+
const outTypes = [ BufferDeserializer(), BufferDeserializer() ];
|
|
3562
|
+
const result = await this.wasm.callWasmExport("acir_prove_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3563
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3564
|
+
return out;
|
|
3565
|
+
}
|
|
3566
|
+
async acirVerifyAztecClient(proofBuf, vkBuf) {
|
|
3567
|
+
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
3568
|
+
const outTypes = [ BoolDeserializer() ];
|
|
3569
|
+
const result = await this.wasm.callWasmExport("acir_verify_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3570
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3571
|
+
return out[0];
|
|
3572
|
+
}
|
|
3643
3573
|
async acirLoadVerificationKey(acirComposerPtr, vkBuf) {
|
|
3644
3574
|
const inArgs = [ acirComposerPtr, vkBuf ].map(serializeBufferable);
|
|
3645
3575
|
const outTypes = [];
|
|
@@ -3682,6 +3612,13 @@ var __webpack_exports__ = {};
|
|
|
3682
3612
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3683
3613
|
return out[0];
|
|
3684
3614
|
}
|
|
3615
|
+
async acirHonkSolidityVerifier(proofBuf, vkBuf) {
|
|
3616
|
+
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
3617
|
+
const outTypes = [ StringDeserializer() ];
|
|
3618
|
+
const result = await this.wasm.callWasmExport("acir_honk_solidity_verifier", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3619
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3620
|
+
return out[0];
|
|
3621
|
+
}
|
|
3685
3622
|
async acirSerializeProofIntoFields(acirComposerPtr, proofBuf, numInnerPublicInputs) {
|
|
3686
3623
|
const inArgs = [ acirComposerPtr, proofBuf, numInnerPublicInputs ].map(serializeBufferable);
|
|
3687
3624
|
const outTypes = [ VectorDeserializer(Fr) ];
|
|
@@ -3696,27 +3633,6 @@ var __webpack_exports__ = {};
|
|
|
3696
3633
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3697
3634
|
return out;
|
|
3698
3635
|
}
|
|
3699
|
-
async acirProveAndVerifyAztecClient(acirVec, witnessVec) {
|
|
3700
|
-
const inArgs = [ acirVec, witnessVec ].map(serializeBufferable);
|
|
3701
|
-
const outTypes = [ BoolDeserializer() ];
|
|
3702
|
-
const result = await this.wasm.callWasmExport("acir_prove_and_verify_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3703
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3704
|
-
return out[0];
|
|
3705
|
-
}
|
|
3706
|
-
async acirProveAztecClient(acirVec, witnessVec) {
|
|
3707
|
-
const inArgs = [ acirVec, witnessVec ].map(serializeBufferable);
|
|
3708
|
-
const outTypes = [ BufferDeserializer(), BufferDeserializer() ];
|
|
3709
|
-
const result = await this.wasm.callWasmExport("acir_prove_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3710
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3711
|
-
return [ out[0], out[1] ];
|
|
3712
|
-
}
|
|
3713
|
-
async acirVerifyAztecClient(proofBuf, vkBuf) {
|
|
3714
|
-
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
3715
|
-
const outTypes = [ BoolDeserializer() ];
|
|
3716
|
-
const result = await this.wasm.callWasmExport("acir_verify_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3717
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3718
|
-
return out[0];
|
|
3719
|
-
}
|
|
3720
3636
|
async acirProveUltraHonk(acirVec, witnessVec) {
|
|
3721
3637
|
const inArgs = [ acirVec, witnessVec ].map(serializeBufferable);
|
|
3722
3638
|
const outTypes = [ BufferDeserializer() ];
|
|
@@ -3759,13 +3675,6 @@ var __webpack_exports__ = {};
|
|
|
3759
3675
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3760
3676
|
return out[0];
|
|
3761
3677
|
}
|
|
3762
|
-
async acirHonkSolidityVerifier(acirVec, vkBuf) {
|
|
3763
|
-
const inArgs = [ acirVec, vkBuf ].map(serializeBufferable);
|
|
3764
|
-
const outTypes = [ BufferDeserializer() ];
|
|
3765
|
-
const result = await this.wasm.callWasmExport("acir_honk_solidity_verifier", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3766
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3767
|
-
return out[0];
|
|
3768
|
-
}
|
|
3769
3678
|
async acirProofAsFieldsUltraHonk(proofBuf) {
|
|
3770
3679
|
const inArgs = [ proofBuf ].map(serializeBufferable);
|
|
3771
3680
|
const outTypes = [ VectorDeserializer(Fr) ];
|
|
@@ -3787,6 +3696,13 @@ var __webpack_exports__ = {};
|
|
|
3787
3696
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3788
3697
|
return out[0];
|
|
3789
3698
|
}
|
|
3699
|
+
async acirGatesAztecClient(ivcInputsBuf) {
|
|
3700
|
+
const inArgs = [ ivcInputsBuf ].map(serializeBufferable);
|
|
3701
|
+
const outTypes = [ BufferDeserializer() ];
|
|
3702
|
+
const result = await this.wasm.callWasmExport("acir_gates_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3703
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3704
|
+
return out[0];
|
|
3705
|
+
}
|
|
3790
3706
|
}
|
|
3791
3707
|
class BarretenbergApiSync {
|
|
3792
3708
|
constructor(wasm) {
|
|
@@ -3827,13 +3743,6 @@ var __webpack_exports__ = {};
|
|
|
3827
3743
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3828
3744
|
return out[0];
|
|
3829
3745
|
}
|
|
3830
|
-
poseidon2HashAccumulate(inputsBuffer) {
|
|
3831
|
-
const inArgs = [ inputsBuffer ].map(serializeBufferable);
|
|
3832
|
-
const outTypes = [ Fr ];
|
|
3833
|
-
const result = this.wasm.callWasmExport("poseidon2_hash_accumulate", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3834
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3835
|
-
return out[0];
|
|
3836
|
-
}
|
|
3837
3746
|
poseidon2Hashes(inputsBuffer) {
|
|
3838
3747
|
const inArgs = [ inputsBuffer ].map(serializeBufferable);
|
|
3839
3748
|
const outTypes = [ Fr ];
|
|
@@ -3848,6 +3757,13 @@ var __webpack_exports__ = {};
|
|
|
3848
3757
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3849
3758
|
return out[0];
|
|
3850
3759
|
}
|
|
3760
|
+
poseidon2HashAccumulate(inputsBuffer) {
|
|
3761
|
+
const inArgs = [ inputsBuffer ].map(serializeBufferable);
|
|
3762
|
+
const outTypes = [ Fr ];
|
|
3763
|
+
const result = this.wasm.callWasmExport("poseidon2_hash_accumulate", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3764
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3765
|
+
return out[0];
|
|
3766
|
+
}
|
|
3851
3767
|
blake2s(data) {
|
|
3852
3768
|
const inArgs = [ data ].map(serializeBufferable);
|
|
3853
3769
|
const outTypes = [ Buffer32 ];
|
|
@@ -3862,69 +3778,6 @@ var __webpack_exports__ = {};
|
|
|
3862
3778
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3863
3779
|
return out[0];
|
|
3864
3780
|
}
|
|
3865
|
-
schnorrComputePublicKey(privateKey) {
|
|
3866
|
-
const inArgs = [ privateKey ].map(serializeBufferable);
|
|
3867
|
-
const outTypes = [ Point ];
|
|
3868
|
-
const result = this.wasm.callWasmExport("schnorr_compute_public_key", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3869
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3870
|
-
return out[0];
|
|
3871
|
-
}
|
|
3872
|
-
schnorrNegatePublicKey(publicKeyBuffer) {
|
|
3873
|
-
const inArgs = [ publicKeyBuffer ].map(serializeBufferable);
|
|
3874
|
-
const outTypes = [ Point ];
|
|
3875
|
-
const result = this.wasm.callWasmExport("schnorr_negate_public_key", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3876
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3877
|
-
return out[0];
|
|
3878
|
-
}
|
|
3879
|
-
schnorrConstructSignature(message, privateKey) {
|
|
3880
|
-
const inArgs = [ message, privateKey ].map(serializeBufferable);
|
|
3881
|
-
const outTypes = [ Buffer32, Buffer32 ];
|
|
3882
|
-
const result = this.wasm.callWasmExport("schnorr_construct_signature", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3883
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3884
|
-
return out;
|
|
3885
|
-
}
|
|
3886
|
-
schnorrVerifySignature(message, pubKey, sigS, sigE) {
|
|
3887
|
-
const inArgs = [ message, pubKey, sigS, sigE ].map(serializeBufferable);
|
|
3888
|
-
const outTypes = [ BoolDeserializer() ];
|
|
3889
|
-
const result = this.wasm.callWasmExport("schnorr_verify_signature", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3890
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3891
|
-
return out[0];
|
|
3892
|
-
}
|
|
3893
|
-
schnorrMultisigCreateMultisigPublicKey(privateKey) {
|
|
3894
|
-
const inArgs = [ privateKey ].map(serializeBufferable);
|
|
3895
|
-
const outTypes = [ Buffer128 ];
|
|
3896
|
-
const result = this.wasm.callWasmExport("schnorr_multisig_create_multisig_public_key", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3897
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3898
|
-
return out[0];
|
|
3899
|
-
}
|
|
3900
|
-
schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf) {
|
|
3901
|
-
const inArgs = [ signerPubkeyBuf ].map(serializeBufferable);
|
|
3902
|
-
const outTypes = [ Point, BoolDeserializer() ];
|
|
3903
|
-
const result = this.wasm.callWasmExport("schnorr_multisig_validate_and_combine_signer_pubkeys", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3904
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3905
|
-
return out;
|
|
3906
|
-
}
|
|
3907
|
-
schnorrMultisigConstructSignatureRound1() {
|
|
3908
|
-
const inArgs = [].map(serializeBufferable);
|
|
3909
|
-
const outTypes = [ Buffer128, Buffer128 ];
|
|
3910
|
-
const result = this.wasm.callWasmExport("schnorr_multisig_construct_signature_round_1", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3911
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3912
|
-
return out;
|
|
3913
|
-
}
|
|
3914
|
-
schnorrMultisigConstructSignatureRound2(message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf) {
|
|
3915
|
-
const inArgs = [ message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf ].map(serializeBufferable);
|
|
3916
|
-
const outTypes = [ Fq, BoolDeserializer() ];
|
|
3917
|
-
const result = this.wasm.callWasmExport("schnorr_multisig_construct_signature_round_2", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3918
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3919
|
-
return out;
|
|
3920
|
-
}
|
|
3921
|
-
schnorrMultisigCombineSignatures(message, signerPubkeysBuf, roundOneBuf, roundTwoBuf) {
|
|
3922
|
-
const inArgs = [ message, signerPubkeysBuf, roundOneBuf, roundTwoBuf ].map(serializeBufferable);
|
|
3923
|
-
const outTypes = [ Buffer32, Buffer32, BoolDeserializer() ];
|
|
3924
|
-
const result = this.wasm.callWasmExport("schnorr_multisig_combine_signatures", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3925
|
-
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3926
|
-
return out;
|
|
3927
|
-
}
|
|
3928
3781
|
aesEncryptBufferCbc(input, iv, key, length) {
|
|
3929
3782
|
const inArgs = [ input, iv, key, length ].map(serializeBufferable);
|
|
3930
3783
|
const outTypes = [ BufferDeserializer() ];
|
|
@@ -4023,6 +3876,20 @@ var __webpack_exports__ = {};
|
|
|
4023
3876
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4024
3877
|
return out[0];
|
|
4025
3878
|
}
|
|
3879
|
+
acirProveAztecClient(ivcInputsBuf) {
|
|
3880
|
+
const inArgs = [ ivcInputsBuf ].map(serializeBufferable);
|
|
3881
|
+
const outTypes = [ BufferDeserializer(), BufferDeserializer() ];
|
|
3882
|
+
const result = this.wasm.callWasmExport("acir_prove_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3883
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3884
|
+
return out;
|
|
3885
|
+
}
|
|
3886
|
+
acirVerifyAztecClient(proofBuf, vkBuf) {
|
|
3887
|
+
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
3888
|
+
const outTypes = [ BoolDeserializer() ];
|
|
3889
|
+
const result = this.wasm.callWasmExport("acir_verify_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3890
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3891
|
+
return out[0];
|
|
3892
|
+
}
|
|
4026
3893
|
acirLoadVerificationKey(acirComposerPtr, vkBuf) {
|
|
4027
3894
|
const inArgs = [ acirComposerPtr, vkBuf ].map(serializeBufferable);
|
|
4028
3895
|
const outTypes = [];
|
|
@@ -4065,6 +3932,13 @@ var __webpack_exports__ = {};
|
|
|
4065
3932
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4066
3933
|
return out[0];
|
|
4067
3934
|
}
|
|
3935
|
+
acirHonkSolidityVerifier(proofBuf, vkBuf) {
|
|
3936
|
+
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
3937
|
+
const outTypes = [ StringDeserializer() ];
|
|
3938
|
+
const result = this.wasm.callWasmExport("acir_honk_solidity_verifier", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3939
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3940
|
+
return out[0];
|
|
3941
|
+
}
|
|
4068
3942
|
acirSerializeProofIntoFields(acirComposerPtr, proofBuf, numInnerPublicInputs) {
|
|
4069
3943
|
const inArgs = [ acirComposerPtr, proofBuf, numInnerPublicInputs ].map(serializeBufferable);
|
|
4070
3944
|
const outTypes = [ VectorDeserializer(Fr) ];
|
|
@@ -4086,6 +3960,13 @@ var __webpack_exports__ = {};
|
|
|
4086
3960
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4087
3961
|
return out[0];
|
|
4088
3962
|
}
|
|
3963
|
+
acirProveUltraKeccakHonk(acirVec, witnessVec) {
|
|
3964
|
+
const inArgs = [ acirVec, witnessVec ].map(serializeBufferable);
|
|
3965
|
+
const outTypes = [ BufferDeserializer() ];
|
|
3966
|
+
const result = this.wasm.callWasmExport("acir_prove_ultra_keccak_honk", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3967
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3968
|
+
return out[0];
|
|
3969
|
+
}
|
|
4089
3970
|
acirVerifyUltraHonk(proofBuf, vkBuf) {
|
|
4090
3971
|
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
4091
3972
|
const outTypes = [ BoolDeserializer() ];
|
|
@@ -4093,6 +3974,13 @@ var __webpack_exports__ = {};
|
|
|
4093
3974
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4094
3975
|
return out[0];
|
|
4095
3976
|
}
|
|
3977
|
+
acirVerifyUltraKeccakHonk(proofBuf, vkBuf) {
|
|
3978
|
+
const inArgs = [ proofBuf, vkBuf ].map(serializeBufferable);
|
|
3979
|
+
const outTypes = [ BoolDeserializer() ];
|
|
3980
|
+
const result = this.wasm.callWasmExport("acir_verify_ultra_keccak_honk", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3981
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3982
|
+
return out[0];
|
|
3983
|
+
}
|
|
4096
3984
|
acirWriteVkUltraHonk(acirVec) {
|
|
4097
3985
|
const inArgs = [ acirVec ].map(serializeBufferable);
|
|
4098
3986
|
const outTypes = [ BufferDeserializer() ];
|
|
@@ -4100,6 +3988,13 @@ var __webpack_exports__ = {};
|
|
|
4100
3988
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4101
3989
|
return out[0];
|
|
4102
3990
|
}
|
|
3991
|
+
acirWriteVkUltraKeccakHonk(acirVec) {
|
|
3992
|
+
const inArgs = [ acirVec ].map(serializeBufferable);
|
|
3993
|
+
const outTypes = [ BufferDeserializer() ];
|
|
3994
|
+
const result = this.wasm.callWasmExport("acir_write_vk_ultra_keccak_honk", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
3995
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
3996
|
+
return out[0];
|
|
3997
|
+
}
|
|
4103
3998
|
acirProofAsFieldsUltraHonk(proofBuf) {
|
|
4104
3999
|
const inArgs = [ proofBuf ].map(serializeBufferable);
|
|
4105
4000
|
const outTypes = [ VectorDeserializer(Fr) ];
|
|
@@ -4121,6 +4016,13 @@ var __webpack_exports__ = {};
|
|
|
4121
4016
|
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4122
4017
|
return out[0];
|
|
4123
4018
|
}
|
|
4019
|
+
acirGatesAztecClient(ivcInputsBuf) {
|
|
4020
|
+
const inArgs = [ ivcInputsBuf ].map(serializeBufferable);
|
|
4021
|
+
const outTypes = [ BufferDeserializer() ];
|
|
4022
|
+
const result = this.wasm.callWasmExport("acir_gates_aztec_client", inArgs, outTypes.map((t => t.SIZE_IN_BYTES)));
|
|
4023
|
+
const out = result.map(((r, i) => outTypes[i].fromBuffer(r)));
|
|
4024
|
+
return out[0];
|
|
4025
|
+
}
|
|
4124
4026
|
}
|
|
4125
4027
|
var browser = __webpack_require__(227);
|
|
4126
4028
|
var browser_default = __webpack_require__.n(browser);
|
|
@@ -10381,12 +10283,2038 @@ var __webpack_exports__ = {};
|
|
|
10381
10283
|
}
|
|
10382
10284
|
return files;
|
|
10383
10285
|
}
|
|
10286
|
+
var unpack_Buffer = __webpack_require__(764)["lW"];
|
|
10287
|
+
var decoder;
|
|
10288
|
+
try {
|
|
10289
|
+
decoder = new TextDecoder;
|
|
10290
|
+
} catch (error) {}
|
|
10291
|
+
var src;
|
|
10292
|
+
var srcEnd;
|
|
10293
|
+
var position = 0;
|
|
10294
|
+
var alreadySet;
|
|
10295
|
+
const EMPTY_ARRAY = [];
|
|
10296
|
+
var unpack_strings = EMPTY_ARRAY;
|
|
10297
|
+
var stringPosition = 0;
|
|
10298
|
+
var currentUnpackr = {};
|
|
10299
|
+
var currentStructures;
|
|
10300
|
+
var srcString;
|
|
10301
|
+
var srcStringStart = 0;
|
|
10302
|
+
var srcStringEnd = 0;
|
|
10303
|
+
var bundledStrings;
|
|
10304
|
+
var referenceMap;
|
|
10305
|
+
var currentExtensions = [];
|
|
10306
|
+
var dataView;
|
|
10307
|
+
var defaultOptions = {
|
|
10308
|
+
useRecords: false,
|
|
10309
|
+
mapsAsObjects: true
|
|
10310
|
+
};
|
|
10311
|
+
class C1Type {}
|
|
10312
|
+
const C1 = new C1Type;
|
|
10313
|
+
C1.name = "MessagePack 0xC1";
|
|
10314
|
+
var sequentialMode = false;
|
|
10315
|
+
var inlineObjectReadThreshold = 2;
|
|
10316
|
+
var readStruct, onLoadedStructures, onSaveState;
|
|
10317
|
+
var BlockedFunction;
|
|
10318
|
+
try {
|
|
10319
|
+
new Function("");
|
|
10320
|
+
} catch (error) {
|
|
10321
|
+
inlineObjectReadThreshold = Infinity;
|
|
10322
|
+
}
|
|
10323
|
+
class Unpackr {
|
|
10324
|
+
constructor(options) {
|
|
10325
|
+
if (options) {
|
|
10326
|
+
if (options.useRecords === false && options.mapsAsObjects === undefined) options.mapsAsObjects = true;
|
|
10327
|
+
if (options.sequential && options.trusted !== false) {
|
|
10328
|
+
options.trusted = true;
|
|
10329
|
+
if (!options.structures && options.useRecords != false) {
|
|
10330
|
+
options.structures = [];
|
|
10331
|
+
if (!options.maxSharedStructures) options.maxSharedStructures = 0;
|
|
10332
|
+
}
|
|
10333
|
+
}
|
|
10334
|
+
if (options.structures) options.structures.sharedLength = options.structures.length; else if (options.getStructures) {
|
|
10335
|
+
(options.structures = []).uninitialized = true;
|
|
10336
|
+
options.structures.sharedLength = 0;
|
|
10337
|
+
}
|
|
10338
|
+
if (options.int64AsNumber) {
|
|
10339
|
+
options.int64AsType = "number";
|
|
10340
|
+
}
|
|
10341
|
+
}
|
|
10342
|
+
Object.assign(this, options);
|
|
10343
|
+
}
|
|
10344
|
+
unpack(source, options) {
|
|
10345
|
+
if (src) {
|
|
10346
|
+
return saveState((() => {
|
|
10347
|
+
clearSource();
|
|
10348
|
+
return this ? this.unpack(source, options) : Unpackr.prototype.unpack.call(defaultOptions, source, options);
|
|
10349
|
+
}));
|
|
10350
|
+
}
|
|
10351
|
+
if (!source.buffer && source.constructor === ArrayBuffer) source = typeof unpack_Buffer !== "undefined" ? unpack_Buffer.from(source) : new Uint8Array(source);
|
|
10352
|
+
if (typeof options === "object") {
|
|
10353
|
+
srcEnd = options.end || source.length;
|
|
10354
|
+
position = options.start || 0;
|
|
10355
|
+
} else {
|
|
10356
|
+
position = 0;
|
|
10357
|
+
srcEnd = options > -1 ? options : source.length;
|
|
10358
|
+
}
|
|
10359
|
+
stringPosition = 0;
|
|
10360
|
+
srcStringEnd = 0;
|
|
10361
|
+
srcString = null;
|
|
10362
|
+
unpack_strings = EMPTY_ARRAY;
|
|
10363
|
+
bundledStrings = null;
|
|
10364
|
+
src = source;
|
|
10365
|
+
try {
|
|
10366
|
+
dataView = source.dataView || (source.dataView = new DataView(source.buffer, source.byteOffset, source.byteLength));
|
|
10367
|
+
} catch (error) {
|
|
10368
|
+
src = null;
|
|
10369
|
+
if (source instanceof Uint8Array) throw error;
|
|
10370
|
+
throw new Error("Source must be a Uint8Array or Buffer but was a " + (source && typeof source == "object" ? source.constructor.name : typeof source));
|
|
10371
|
+
}
|
|
10372
|
+
if (this instanceof Unpackr) {
|
|
10373
|
+
currentUnpackr = this;
|
|
10374
|
+
if (this.structures) {
|
|
10375
|
+
currentStructures = this.structures;
|
|
10376
|
+
return checkedRead(options);
|
|
10377
|
+
} else if (!currentStructures || currentStructures.length > 0) {
|
|
10378
|
+
currentStructures = [];
|
|
10379
|
+
}
|
|
10380
|
+
} else {
|
|
10381
|
+
currentUnpackr = defaultOptions;
|
|
10382
|
+
if (!currentStructures || currentStructures.length > 0) currentStructures = [];
|
|
10383
|
+
}
|
|
10384
|
+
return checkedRead(options);
|
|
10385
|
+
}
|
|
10386
|
+
unpackMultiple(source, forEach) {
|
|
10387
|
+
let values, lastPosition = 0;
|
|
10388
|
+
try {
|
|
10389
|
+
sequentialMode = true;
|
|
10390
|
+
let size = source.length;
|
|
10391
|
+
let value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size);
|
|
10392
|
+
if (forEach) {
|
|
10393
|
+
if (forEach(value, lastPosition, position) === false) return;
|
|
10394
|
+
while (position < size) {
|
|
10395
|
+
lastPosition = position;
|
|
10396
|
+
if (forEach(checkedRead(), lastPosition, position) === false) {
|
|
10397
|
+
return;
|
|
10398
|
+
}
|
|
10399
|
+
}
|
|
10400
|
+
} else {
|
|
10401
|
+
values = [ value ];
|
|
10402
|
+
while (position < size) {
|
|
10403
|
+
lastPosition = position;
|
|
10404
|
+
values.push(checkedRead());
|
|
10405
|
+
}
|
|
10406
|
+
return values;
|
|
10407
|
+
}
|
|
10408
|
+
} catch (error) {
|
|
10409
|
+
error.lastPosition = lastPosition;
|
|
10410
|
+
error.values = values;
|
|
10411
|
+
throw error;
|
|
10412
|
+
} finally {
|
|
10413
|
+
sequentialMode = false;
|
|
10414
|
+
clearSource();
|
|
10415
|
+
}
|
|
10416
|
+
}
|
|
10417
|
+
_mergeStructures(loadedStructures, existingStructures) {
|
|
10418
|
+
if (onLoadedStructures) loadedStructures = onLoadedStructures.call(this, loadedStructures);
|
|
10419
|
+
loadedStructures = loadedStructures || [];
|
|
10420
|
+
if (Object.isFrozen(loadedStructures)) loadedStructures = loadedStructures.map((structure => structure.slice(0)));
|
|
10421
|
+
for (let i = 0, l = loadedStructures.length; i < l; i++) {
|
|
10422
|
+
let structure = loadedStructures[i];
|
|
10423
|
+
if (structure) {
|
|
10424
|
+
structure.isShared = true;
|
|
10425
|
+
if (i >= 32) structure.highByte = i - 32 >> 5;
|
|
10426
|
+
}
|
|
10427
|
+
}
|
|
10428
|
+
loadedStructures.sharedLength = loadedStructures.length;
|
|
10429
|
+
for (let id in existingStructures || []) {
|
|
10430
|
+
if (id >= 0) {
|
|
10431
|
+
let structure = loadedStructures[id];
|
|
10432
|
+
let existing = existingStructures[id];
|
|
10433
|
+
if (existing) {
|
|
10434
|
+
if (structure) (loadedStructures.restoreStructures || (loadedStructures.restoreStructures = []))[id] = structure;
|
|
10435
|
+
loadedStructures[id] = existing;
|
|
10436
|
+
}
|
|
10437
|
+
}
|
|
10438
|
+
}
|
|
10439
|
+
return this.structures = loadedStructures;
|
|
10440
|
+
}
|
|
10441
|
+
decode(source, options) {
|
|
10442
|
+
return this.unpack(source, options);
|
|
10443
|
+
}
|
|
10444
|
+
}
|
|
10445
|
+
function getPosition() {
|
|
10446
|
+
return position;
|
|
10447
|
+
}
|
|
10448
|
+
function checkedRead(options) {
|
|
10449
|
+
try {
|
|
10450
|
+
if (!currentUnpackr.trusted && !sequentialMode) {
|
|
10451
|
+
let sharedLength = currentStructures.sharedLength || 0;
|
|
10452
|
+
if (sharedLength < currentStructures.length) currentStructures.length = sharedLength;
|
|
10453
|
+
}
|
|
10454
|
+
let result;
|
|
10455
|
+
if (currentUnpackr.randomAccessStructure && src[position] < 64 && src[position] >= 32 && readStruct) {
|
|
10456
|
+
result = readStruct(src, position, srcEnd, currentUnpackr);
|
|
10457
|
+
src = null;
|
|
10458
|
+
if (!(options && options.lazy) && result) result = result.toJSON();
|
|
10459
|
+
position = srcEnd;
|
|
10460
|
+
} else result = read();
|
|
10461
|
+
if (bundledStrings) {
|
|
10462
|
+
position = bundledStrings.postBundlePosition;
|
|
10463
|
+
bundledStrings = null;
|
|
10464
|
+
}
|
|
10465
|
+
if (sequentialMode) currentStructures.restoreStructures = null;
|
|
10466
|
+
if (position == srcEnd) {
|
|
10467
|
+
if (currentStructures && currentStructures.restoreStructures) restoreStructures();
|
|
10468
|
+
currentStructures = null;
|
|
10469
|
+
src = null;
|
|
10470
|
+
if (referenceMap) referenceMap = null;
|
|
10471
|
+
} else if (position > srcEnd) {
|
|
10472
|
+
throw new Error("Unexpected end of MessagePack data");
|
|
10473
|
+
} else if (!sequentialMode) {
|
|
10474
|
+
let jsonView;
|
|
10475
|
+
try {
|
|
10476
|
+
jsonView = JSON.stringify(result, ((_, value) => typeof value === "bigint" ? `${value}n` : value)).slice(0, 100);
|
|
10477
|
+
} catch (error) {
|
|
10478
|
+
jsonView = "(JSON view not available " + error + ")";
|
|
10479
|
+
}
|
|
10480
|
+
throw new Error("Data read, but end of buffer not reached " + jsonView);
|
|
10481
|
+
}
|
|
10482
|
+
return result;
|
|
10483
|
+
} catch (error) {
|
|
10484
|
+
if (currentStructures && currentStructures.restoreStructures) restoreStructures();
|
|
10485
|
+
clearSource();
|
|
10486
|
+
if (error instanceof RangeError || error.message.startsWith("Unexpected end of buffer") || position > srcEnd) {
|
|
10487
|
+
error.incomplete = true;
|
|
10488
|
+
}
|
|
10489
|
+
throw error;
|
|
10490
|
+
}
|
|
10491
|
+
}
|
|
10492
|
+
function restoreStructures() {
|
|
10493
|
+
for (let id in currentStructures.restoreStructures) {
|
|
10494
|
+
currentStructures[id] = currentStructures.restoreStructures[id];
|
|
10495
|
+
}
|
|
10496
|
+
currentStructures.restoreStructures = null;
|
|
10497
|
+
}
|
|
10498
|
+
function read() {
|
|
10499
|
+
let token = src[position++];
|
|
10500
|
+
if (token < 160) {
|
|
10501
|
+
if (token < 128) {
|
|
10502
|
+
if (token < 64) return token; else {
|
|
10503
|
+
let structure = currentStructures[token & 63] || currentUnpackr.getStructures && loadStructures()[token & 63];
|
|
10504
|
+
if (structure) {
|
|
10505
|
+
if (!structure.read) {
|
|
10506
|
+
structure.read = createStructureReader(structure, token & 63);
|
|
10507
|
+
}
|
|
10508
|
+
return structure.read();
|
|
10509
|
+
} else return token;
|
|
10510
|
+
}
|
|
10511
|
+
} else if (token < 144) {
|
|
10512
|
+
token -= 128;
|
|
10513
|
+
if (currentUnpackr.mapsAsObjects) {
|
|
10514
|
+
let object = {};
|
|
10515
|
+
for (let i = 0; i < token; i++) {
|
|
10516
|
+
let key = readKey();
|
|
10517
|
+
if (key === "__proto__") key = "__proto_";
|
|
10518
|
+
object[key] = read();
|
|
10519
|
+
}
|
|
10520
|
+
return object;
|
|
10521
|
+
} else {
|
|
10522
|
+
let map = new Map;
|
|
10523
|
+
for (let i = 0; i < token; i++) {
|
|
10524
|
+
map.set(read(), read());
|
|
10525
|
+
}
|
|
10526
|
+
return map;
|
|
10527
|
+
}
|
|
10528
|
+
} else {
|
|
10529
|
+
token -= 144;
|
|
10530
|
+
let array = new Array(token);
|
|
10531
|
+
for (let i = 0; i < token; i++) {
|
|
10532
|
+
array[i] = read();
|
|
10533
|
+
}
|
|
10534
|
+
if (currentUnpackr.freezeData) return Object.freeze(array);
|
|
10535
|
+
return array;
|
|
10536
|
+
}
|
|
10537
|
+
} else if (token < 192) {
|
|
10538
|
+
let length = token - 160;
|
|
10539
|
+
if (srcStringEnd >= position) {
|
|
10540
|
+
return srcString.slice(position - srcStringStart, (position += length) - srcStringStart);
|
|
10541
|
+
}
|
|
10542
|
+
if (srcStringEnd == 0 && srcEnd < 140) {
|
|
10543
|
+
let string = length < 16 ? shortStringInJS(length) : longStringInJS(length);
|
|
10544
|
+
if (string != null) return string;
|
|
10545
|
+
}
|
|
10546
|
+
return readFixedString(length);
|
|
10547
|
+
} else {
|
|
10548
|
+
let value;
|
|
10549
|
+
switch (token) {
|
|
10550
|
+
case 192:
|
|
10551
|
+
return null;
|
|
10552
|
+
|
|
10553
|
+
case 193:
|
|
10554
|
+
if (bundledStrings) {
|
|
10555
|
+
value = read();
|
|
10556
|
+
if (value > 0) return bundledStrings[1].slice(bundledStrings.position1, bundledStrings.position1 += value); else return bundledStrings[0].slice(bundledStrings.position0, bundledStrings.position0 -= value);
|
|
10557
|
+
}
|
|
10558
|
+
return C1;
|
|
10559
|
+
|
|
10560
|
+
case 194:
|
|
10561
|
+
return false;
|
|
10562
|
+
|
|
10563
|
+
case 195:
|
|
10564
|
+
return true;
|
|
10565
|
+
|
|
10566
|
+
case 196:
|
|
10567
|
+
value = src[position++];
|
|
10568
|
+
if (value === undefined) throw new Error("Unexpected end of buffer");
|
|
10569
|
+
return readBin(value);
|
|
10570
|
+
|
|
10571
|
+
case 197:
|
|
10572
|
+
value = dataView.getUint16(position);
|
|
10573
|
+
position += 2;
|
|
10574
|
+
return readBin(value);
|
|
10575
|
+
|
|
10576
|
+
case 198:
|
|
10577
|
+
value = dataView.getUint32(position);
|
|
10578
|
+
position += 4;
|
|
10579
|
+
return readBin(value);
|
|
10580
|
+
|
|
10581
|
+
case 199:
|
|
10582
|
+
return readExt(src[position++]);
|
|
10583
|
+
|
|
10584
|
+
case 200:
|
|
10585
|
+
value = dataView.getUint16(position);
|
|
10586
|
+
position += 2;
|
|
10587
|
+
return readExt(value);
|
|
10588
|
+
|
|
10589
|
+
case 201:
|
|
10590
|
+
value = dataView.getUint32(position);
|
|
10591
|
+
position += 4;
|
|
10592
|
+
return readExt(value);
|
|
10593
|
+
|
|
10594
|
+
case 202:
|
|
10595
|
+
value = dataView.getFloat32(position);
|
|
10596
|
+
if (currentUnpackr.useFloat32 > 2) {
|
|
10597
|
+
let multiplier = mult10[(src[position] & 127) << 1 | src[position + 1] >> 7];
|
|
10598
|
+
position += 4;
|
|
10599
|
+
return (multiplier * value + (value > 0 ? .5 : -.5) >> 0) / multiplier;
|
|
10600
|
+
}
|
|
10601
|
+
position += 4;
|
|
10602
|
+
return value;
|
|
10603
|
+
|
|
10604
|
+
case 203:
|
|
10605
|
+
value = dataView.getFloat64(position);
|
|
10606
|
+
position += 8;
|
|
10607
|
+
return value;
|
|
10608
|
+
|
|
10609
|
+
case 204:
|
|
10610
|
+
return src[position++];
|
|
10611
|
+
|
|
10612
|
+
case 205:
|
|
10613
|
+
value = dataView.getUint16(position);
|
|
10614
|
+
position += 2;
|
|
10615
|
+
return value;
|
|
10616
|
+
|
|
10617
|
+
case 206:
|
|
10618
|
+
value = dataView.getUint32(position);
|
|
10619
|
+
position += 4;
|
|
10620
|
+
return value;
|
|
10621
|
+
|
|
10622
|
+
case 207:
|
|
10623
|
+
if (currentUnpackr.int64AsType === "number") {
|
|
10624
|
+
value = dataView.getUint32(position) * 4294967296;
|
|
10625
|
+
value += dataView.getUint32(position + 4);
|
|
10626
|
+
} else if (currentUnpackr.int64AsType === "string") {
|
|
10627
|
+
value = dataView.getBigUint64(position).toString();
|
|
10628
|
+
} else if (currentUnpackr.int64AsType === "auto") {
|
|
10629
|
+
value = dataView.getBigUint64(position);
|
|
10630
|
+
if (value <= BigInt(2) << BigInt(52)) value = Number(value);
|
|
10631
|
+
} else value = dataView.getBigUint64(position);
|
|
10632
|
+
position += 8;
|
|
10633
|
+
return value;
|
|
10634
|
+
|
|
10635
|
+
case 208:
|
|
10636
|
+
return dataView.getInt8(position++);
|
|
10637
|
+
|
|
10638
|
+
case 209:
|
|
10639
|
+
value = dataView.getInt16(position);
|
|
10640
|
+
position += 2;
|
|
10641
|
+
return value;
|
|
10642
|
+
|
|
10643
|
+
case 210:
|
|
10644
|
+
value = dataView.getInt32(position);
|
|
10645
|
+
position += 4;
|
|
10646
|
+
return value;
|
|
10647
|
+
|
|
10648
|
+
case 211:
|
|
10649
|
+
if (currentUnpackr.int64AsType === "number") {
|
|
10650
|
+
value = dataView.getInt32(position) * 4294967296;
|
|
10651
|
+
value += dataView.getUint32(position + 4);
|
|
10652
|
+
} else if (currentUnpackr.int64AsType === "string") {
|
|
10653
|
+
value = dataView.getBigInt64(position).toString();
|
|
10654
|
+
} else if (currentUnpackr.int64AsType === "auto") {
|
|
10655
|
+
value = dataView.getBigInt64(position);
|
|
10656
|
+
if (value >= BigInt(-2) << BigInt(52) && value <= BigInt(2) << BigInt(52)) value = Number(value);
|
|
10657
|
+
} else value = dataView.getBigInt64(position);
|
|
10658
|
+
position += 8;
|
|
10659
|
+
return value;
|
|
10660
|
+
|
|
10661
|
+
case 212:
|
|
10662
|
+
value = src[position++];
|
|
10663
|
+
if (value == 114) {
|
|
10664
|
+
return recordDefinition(src[position++] & 63);
|
|
10665
|
+
} else {
|
|
10666
|
+
let extension = currentExtensions[value];
|
|
10667
|
+
if (extension) {
|
|
10668
|
+
if (extension.read) {
|
|
10669
|
+
position++;
|
|
10670
|
+
return extension.read(read());
|
|
10671
|
+
} else if (extension.noBuffer) {
|
|
10672
|
+
position++;
|
|
10673
|
+
return extension();
|
|
10674
|
+
} else return extension(src.subarray(position, ++position));
|
|
10675
|
+
} else throw new Error("Unknown extension " + value);
|
|
10676
|
+
}
|
|
10677
|
+
|
|
10678
|
+
case 213:
|
|
10679
|
+
value = src[position];
|
|
10680
|
+
if (value == 114) {
|
|
10681
|
+
position++;
|
|
10682
|
+
return recordDefinition(src[position++] & 63, src[position++]);
|
|
10683
|
+
} else return readExt(2);
|
|
10684
|
+
|
|
10685
|
+
case 214:
|
|
10686
|
+
return readExt(4);
|
|
10687
|
+
|
|
10688
|
+
case 215:
|
|
10689
|
+
return readExt(8);
|
|
10690
|
+
|
|
10691
|
+
case 216:
|
|
10692
|
+
return readExt(16);
|
|
10693
|
+
|
|
10694
|
+
case 217:
|
|
10695
|
+
value = src[position++];
|
|
10696
|
+
if (srcStringEnd >= position) {
|
|
10697
|
+
return srcString.slice(position - srcStringStart, (position += value) - srcStringStart);
|
|
10698
|
+
}
|
|
10699
|
+
return readString8(value);
|
|
10700
|
+
|
|
10701
|
+
case 218:
|
|
10702
|
+
value = dataView.getUint16(position);
|
|
10703
|
+
position += 2;
|
|
10704
|
+
if (srcStringEnd >= position) {
|
|
10705
|
+
return srcString.slice(position - srcStringStart, (position += value) - srcStringStart);
|
|
10706
|
+
}
|
|
10707
|
+
return readString16(value);
|
|
10708
|
+
|
|
10709
|
+
case 219:
|
|
10710
|
+
value = dataView.getUint32(position);
|
|
10711
|
+
position += 4;
|
|
10712
|
+
if (srcStringEnd >= position) {
|
|
10713
|
+
return srcString.slice(position - srcStringStart, (position += value) - srcStringStart);
|
|
10714
|
+
}
|
|
10715
|
+
return readString32(value);
|
|
10716
|
+
|
|
10717
|
+
case 220:
|
|
10718
|
+
value = dataView.getUint16(position);
|
|
10719
|
+
position += 2;
|
|
10720
|
+
return readArray(value);
|
|
10721
|
+
|
|
10722
|
+
case 221:
|
|
10723
|
+
value = dataView.getUint32(position);
|
|
10724
|
+
position += 4;
|
|
10725
|
+
return readArray(value);
|
|
10726
|
+
|
|
10727
|
+
case 222:
|
|
10728
|
+
value = dataView.getUint16(position);
|
|
10729
|
+
position += 2;
|
|
10730
|
+
return readMap(value);
|
|
10731
|
+
|
|
10732
|
+
case 223:
|
|
10733
|
+
value = dataView.getUint32(position);
|
|
10734
|
+
position += 4;
|
|
10735
|
+
return readMap(value);
|
|
10736
|
+
|
|
10737
|
+
default:
|
|
10738
|
+
if (token >= 224) return token - 256;
|
|
10739
|
+
if (token === undefined) {
|
|
10740
|
+
let error = new Error("Unexpected end of MessagePack data");
|
|
10741
|
+
error.incomplete = true;
|
|
10742
|
+
throw error;
|
|
10743
|
+
}
|
|
10744
|
+
throw new Error("Unknown MessagePack token " + token);
|
|
10745
|
+
}
|
|
10746
|
+
}
|
|
10747
|
+
}
|
|
10748
|
+
const validName = /^[a-zA-Z_$][a-zA-Z\d_$]*$/;
|
|
10749
|
+
function createStructureReader(structure, firstId) {
|
|
10750
|
+
function readObject() {
|
|
10751
|
+
if (readObject.count++ > inlineObjectReadThreshold) {
|
|
10752
|
+
let readObject = structure.read = new Function("r", "return function(){return " + (currentUnpackr.freezeData ? "Object.freeze" : "") + "({" + structure.map((key => key === "__proto__" ? "__proto_:r()" : validName.test(key) ? key + ":r()" : "[" + JSON.stringify(key) + "]:r()")).join(",") + "})}")(read);
|
|
10753
|
+
if (structure.highByte === 0) structure.read = createSecondByteReader(firstId, structure.read);
|
|
10754
|
+
return readObject();
|
|
10755
|
+
}
|
|
10756
|
+
let object = {};
|
|
10757
|
+
for (let i = 0, l = structure.length; i < l; i++) {
|
|
10758
|
+
let key = structure[i];
|
|
10759
|
+
if (key === "__proto__") key = "__proto_";
|
|
10760
|
+
object[key] = read();
|
|
10761
|
+
}
|
|
10762
|
+
if (currentUnpackr.freezeData) return Object.freeze(object);
|
|
10763
|
+
return object;
|
|
10764
|
+
}
|
|
10765
|
+
readObject.count = 0;
|
|
10766
|
+
if (structure.highByte === 0) {
|
|
10767
|
+
return createSecondByteReader(firstId, readObject);
|
|
10768
|
+
}
|
|
10769
|
+
return readObject;
|
|
10770
|
+
}
|
|
10771
|
+
const createSecondByteReader = (firstId, read0) => function() {
|
|
10772
|
+
let highByte = src[position++];
|
|
10773
|
+
if (highByte === 0) return read0();
|
|
10774
|
+
let id = firstId < 32 ? -(firstId + (highByte << 5)) : firstId + (highByte << 5);
|
|
10775
|
+
let structure = currentStructures[id] || loadStructures()[id];
|
|
10776
|
+
if (!structure) {
|
|
10777
|
+
throw new Error("Record id is not defined for " + id);
|
|
10778
|
+
}
|
|
10779
|
+
if (!structure.read) structure.read = createStructureReader(structure, firstId);
|
|
10780
|
+
return structure.read();
|
|
10781
|
+
};
|
|
10782
|
+
function loadStructures() {
|
|
10783
|
+
let loadedStructures = saveState((() => {
|
|
10784
|
+
src = null;
|
|
10785
|
+
return currentUnpackr.getStructures();
|
|
10786
|
+
}));
|
|
10787
|
+
return currentStructures = currentUnpackr._mergeStructures(loadedStructures, currentStructures);
|
|
10788
|
+
}
|
|
10789
|
+
var readFixedString = readStringJS;
|
|
10790
|
+
var readString8 = readStringJS;
|
|
10791
|
+
var readString16 = readStringJS;
|
|
10792
|
+
var readString32 = readStringJS;
|
|
10793
|
+
let isNativeAccelerationEnabled = false;
|
|
10794
|
+
function setExtractor(extractStrings) {
|
|
10795
|
+
isNativeAccelerationEnabled = true;
|
|
10796
|
+
readFixedString = readString(1);
|
|
10797
|
+
readString8 = readString(2);
|
|
10798
|
+
readString16 = readString(3);
|
|
10799
|
+
readString32 = readString(5);
|
|
10800
|
+
function readString(headerLength) {
|
|
10801
|
+
return function readString(length) {
|
|
10802
|
+
let string = unpack_strings[stringPosition++];
|
|
10803
|
+
if (string == null) {
|
|
10804
|
+
if (bundledStrings) return readStringJS(length);
|
|
10805
|
+
let byteOffset = src.byteOffset;
|
|
10806
|
+
let extraction = extractStrings(position - headerLength + byteOffset, srcEnd + byteOffset, src.buffer);
|
|
10807
|
+
if (typeof extraction == "string") {
|
|
10808
|
+
string = extraction;
|
|
10809
|
+
unpack_strings = EMPTY_ARRAY;
|
|
10810
|
+
} else {
|
|
10811
|
+
unpack_strings = extraction;
|
|
10812
|
+
stringPosition = 1;
|
|
10813
|
+
srcStringEnd = 1;
|
|
10814
|
+
string = unpack_strings[0];
|
|
10815
|
+
if (string === undefined) throw new Error("Unexpected end of buffer");
|
|
10816
|
+
}
|
|
10817
|
+
}
|
|
10818
|
+
let srcStringLength = string.length;
|
|
10819
|
+
if (srcStringLength <= length) {
|
|
10820
|
+
position += length;
|
|
10821
|
+
return string;
|
|
10822
|
+
}
|
|
10823
|
+
srcString = string;
|
|
10824
|
+
srcStringStart = position;
|
|
10825
|
+
srcStringEnd = position + srcStringLength;
|
|
10826
|
+
position += length;
|
|
10827
|
+
return string.slice(0, length);
|
|
10828
|
+
};
|
|
10829
|
+
}
|
|
10830
|
+
}
|
|
10831
|
+
function readStringJS(length) {
|
|
10832
|
+
let result;
|
|
10833
|
+
if (length < 16) {
|
|
10834
|
+
if (result = shortStringInJS(length)) return result;
|
|
10835
|
+
}
|
|
10836
|
+
if (length > 64 && decoder) return decoder.decode(src.subarray(position, position += length));
|
|
10837
|
+
const end = position + length;
|
|
10838
|
+
const units = [];
|
|
10839
|
+
result = "";
|
|
10840
|
+
while (position < end) {
|
|
10841
|
+
const byte1 = src[position++];
|
|
10842
|
+
if ((byte1 & 128) === 0) {
|
|
10843
|
+
units.push(byte1);
|
|
10844
|
+
} else if ((byte1 & 224) === 192) {
|
|
10845
|
+
const byte2 = src[position++] & 63;
|
|
10846
|
+
units.push((byte1 & 31) << 6 | byte2);
|
|
10847
|
+
} else if ((byte1 & 240) === 224) {
|
|
10848
|
+
const byte2 = src[position++] & 63;
|
|
10849
|
+
const byte3 = src[position++] & 63;
|
|
10850
|
+
units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
|
|
10851
|
+
} else if ((byte1 & 248) === 240) {
|
|
10852
|
+
const byte2 = src[position++] & 63;
|
|
10853
|
+
const byte3 = src[position++] & 63;
|
|
10854
|
+
const byte4 = src[position++] & 63;
|
|
10855
|
+
let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
|
|
10856
|
+
if (unit > 65535) {
|
|
10857
|
+
unit -= 65536;
|
|
10858
|
+
units.push(unit >>> 10 & 1023 | 55296);
|
|
10859
|
+
unit = 56320 | unit & 1023;
|
|
10860
|
+
}
|
|
10861
|
+
units.push(unit);
|
|
10862
|
+
} else {
|
|
10863
|
+
units.push(byte1);
|
|
10864
|
+
}
|
|
10865
|
+
if (units.length >= 4096) {
|
|
10866
|
+
result += fromCharCode.apply(String, units);
|
|
10867
|
+
units.length = 0;
|
|
10868
|
+
}
|
|
10869
|
+
}
|
|
10870
|
+
if (units.length > 0) {
|
|
10871
|
+
result += fromCharCode.apply(String, units);
|
|
10872
|
+
}
|
|
10873
|
+
return result;
|
|
10874
|
+
}
|
|
10875
|
+
function readString(source, start, length) {
|
|
10876
|
+
let existingSrc = src;
|
|
10877
|
+
src = source;
|
|
10878
|
+
position = start;
|
|
10879
|
+
try {
|
|
10880
|
+
return readStringJS(length);
|
|
10881
|
+
} finally {
|
|
10882
|
+
src = existingSrc;
|
|
10883
|
+
}
|
|
10884
|
+
}
|
|
10885
|
+
function readArray(length) {
|
|
10886
|
+
let array = new Array(length);
|
|
10887
|
+
for (let i = 0; i < length; i++) {
|
|
10888
|
+
array[i] = read();
|
|
10889
|
+
}
|
|
10890
|
+
if (currentUnpackr.freezeData) return Object.freeze(array);
|
|
10891
|
+
return array;
|
|
10892
|
+
}
|
|
10893
|
+
function readMap(length) {
|
|
10894
|
+
if (currentUnpackr.mapsAsObjects) {
|
|
10895
|
+
let object = {};
|
|
10896
|
+
for (let i = 0; i < length; i++) {
|
|
10897
|
+
let key = readKey();
|
|
10898
|
+
if (key === "__proto__") key = "__proto_";
|
|
10899
|
+
object[key] = read();
|
|
10900
|
+
}
|
|
10901
|
+
return object;
|
|
10902
|
+
} else {
|
|
10903
|
+
let map = new Map;
|
|
10904
|
+
for (let i = 0; i < length; i++) {
|
|
10905
|
+
map.set(read(), read());
|
|
10906
|
+
}
|
|
10907
|
+
return map;
|
|
10908
|
+
}
|
|
10909
|
+
}
|
|
10910
|
+
var fromCharCode = String.fromCharCode;
|
|
10911
|
+
function longStringInJS(length) {
|
|
10912
|
+
let start = position;
|
|
10913
|
+
let bytes = new Array(length);
|
|
10914
|
+
for (let i = 0; i < length; i++) {
|
|
10915
|
+
const byte = src[position++];
|
|
10916
|
+
if ((byte & 128) > 0) {
|
|
10917
|
+
position = start;
|
|
10918
|
+
return;
|
|
10919
|
+
}
|
|
10920
|
+
bytes[i] = byte;
|
|
10921
|
+
}
|
|
10922
|
+
return fromCharCode.apply(String, bytes);
|
|
10923
|
+
}
|
|
10924
|
+
function shortStringInJS(length) {
|
|
10925
|
+
if (length < 4) {
|
|
10926
|
+
if (length < 2) {
|
|
10927
|
+
if (length === 0) return ""; else {
|
|
10928
|
+
let a = src[position++];
|
|
10929
|
+
if ((a & 128) > 1) {
|
|
10930
|
+
position -= 1;
|
|
10931
|
+
return;
|
|
10932
|
+
}
|
|
10933
|
+
return fromCharCode(a);
|
|
10934
|
+
}
|
|
10935
|
+
} else {
|
|
10936
|
+
let a = src[position++];
|
|
10937
|
+
let b = src[position++];
|
|
10938
|
+
if ((a & 128) > 0 || (b & 128) > 0) {
|
|
10939
|
+
position -= 2;
|
|
10940
|
+
return;
|
|
10941
|
+
}
|
|
10942
|
+
if (length < 3) return fromCharCode(a, b);
|
|
10943
|
+
let c = src[position++];
|
|
10944
|
+
if ((c & 128) > 0) {
|
|
10945
|
+
position -= 3;
|
|
10946
|
+
return;
|
|
10947
|
+
}
|
|
10948
|
+
return fromCharCode(a, b, c);
|
|
10949
|
+
}
|
|
10950
|
+
} else {
|
|
10951
|
+
let a = src[position++];
|
|
10952
|
+
let b = src[position++];
|
|
10953
|
+
let c = src[position++];
|
|
10954
|
+
let d = src[position++];
|
|
10955
|
+
if ((a & 128) > 0 || (b & 128) > 0 || (c & 128) > 0 || (d & 128) > 0) {
|
|
10956
|
+
position -= 4;
|
|
10957
|
+
return;
|
|
10958
|
+
}
|
|
10959
|
+
if (length < 6) {
|
|
10960
|
+
if (length === 4) return fromCharCode(a, b, c, d); else {
|
|
10961
|
+
let e = src[position++];
|
|
10962
|
+
if ((e & 128) > 0) {
|
|
10963
|
+
position -= 5;
|
|
10964
|
+
return;
|
|
10965
|
+
}
|
|
10966
|
+
return fromCharCode(a, b, c, d, e);
|
|
10967
|
+
}
|
|
10968
|
+
} else if (length < 8) {
|
|
10969
|
+
let e = src[position++];
|
|
10970
|
+
let f = src[position++];
|
|
10971
|
+
if ((e & 128) > 0 || (f & 128) > 0) {
|
|
10972
|
+
position -= 6;
|
|
10973
|
+
return;
|
|
10974
|
+
}
|
|
10975
|
+
if (length < 7) return fromCharCode(a, b, c, d, e, f);
|
|
10976
|
+
let g = src[position++];
|
|
10977
|
+
if ((g & 128) > 0) {
|
|
10978
|
+
position -= 7;
|
|
10979
|
+
return;
|
|
10980
|
+
}
|
|
10981
|
+
return fromCharCode(a, b, c, d, e, f, g);
|
|
10982
|
+
} else {
|
|
10983
|
+
let e = src[position++];
|
|
10984
|
+
let f = src[position++];
|
|
10985
|
+
let g = src[position++];
|
|
10986
|
+
let h = src[position++];
|
|
10987
|
+
if ((e & 128) > 0 || (f & 128) > 0 || (g & 128) > 0 || (h & 128) > 0) {
|
|
10988
|
+
position -= 8;
|
|
10989
|
+
return;
|
|
10990
|
+
}
|
|
10991
|
+
if (length < 10) {
|
|
10992
|
+
if (length === 8) return fromCharCode(a, b, c, d, e, f, g, h); else {
|
|
10993
|
+
let i = src[position++];
|
|
10994
|
+
if ((i & 128) > 0) {
|
|
10995
|
+
position -= 9;
|
|
10996
|
+
return;
|
|
10997
|
+
}
|
|
10998
|
+
return fromCharCode(a, b, c, d, e, f, g, h, i);
|
|
10999
|
+
}
|
|
11000
|
+
} else if (length < 12) {
|
|
11001
|
+
let i = src[position++];
|
|
11002
|
+
let j = src[position++];
|
|
11003
|
+
if ((i & 128) > 0 || (j & 128) > 0) {
|
|
11004
|
+
position -= 10;
|
|
11005
|
+
return;
|
|
11006
|
+
}
|
|
11007
|
+
if (length < 11) return fromCharCode(a, b, c, d, e, f, g, h, i, j);
|
|
11008
|
+
let k = src[position++];
|
|
11009
|
+
if ((k & 128) > 0) {
|
|
11010
|
+
position -= 11;
|
|
11011
|
+
return;
|
|
11012
|
+
}
|
|
11013
|
+
return fromCharCode(a, b, c, d, e, f, g, h, i, j, k);
|
|
11014
|
+
} else {
|
|
11015
|
+
let i = src[position++];
|
|
11016
|
+
let j = src[position++];
|
|
11017
|
+
let k = src[position++];
|
|
11018
|
+
let l = src[position++];
|
|
11019
|
+
if ((i & 128) > 0 || (j & 128) > 0 || (k & 128) > 0 || (l & 128) > 0) {
|
|
11020
|
+
position -= 12;
|
|
11021
|
+
return;
|
|
11022
|
+
}
|
|
11023
|
+
if (length < 14) {
|
|
11024
|
+
if (length === 12) return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l); else {
|
|
11025
|
+
let m = src[position++];
|
|
11026
|
+
if ((m & 128) > 0) {
|
|
11027
|
+
position -= 13;
|
|
11028
|
+
return;
|
|
11029
|
+
}
|
|
11030
|
+
return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m);
|
|
11031
|
+
}
|
|
11032
|
+
} else {
|
|
11033
|
+
let m = src[position++];
|
|
11034
|
+
let n = src[position++];
|
|
11035
|
+
if ((m & 128) > 0 || (n & 128) > 0) {
|
|
11036
|
+
position -= 14;
|
|
11037
|
+
return;
|
|
11038
|
+
}
|
|
11039
|
+
if (length < 15) return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
|
|
11040
|
+
let o = src[position++];
|
|
11041
|
+
if ((o & 128) > 0) {
|
|
11042
|
+
position -= 15;
|
|
11043
|
+
return;
|
|
11044
|
+
}
|
|
11045
|
+
return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
|
|
11046
|
+
}
|
|
11047
|
+
}
|
|
11048
|
+
}
|
|
11049
|
+
}
|
|
11050
|
+
}
|
|
11051
|
+
function readOnlyJSString() {
|
|
11052
|
+
let token = src[position++];
|
|
11053
|
+
let length;
|
|
11054
|
+
if (token < 192) {
|
|
11055
|
+
length = token - 160;
|
|
11056
|
+
} else {
|
|
11057
|
+
switch (token) {
|
|
11058
|
+
case 217:
|
|
11059
|
+
length = src[position++];
|
|
11060
|
+
break;
|
|
11061
|
+
|
|
11062
|
+
case 218:
|
|
11063
|
+
length = dataView.getUint16(position);
|
|
11064
|
+
position += 2;
|
|
11065
|
+
break;
|
|
11066
|
+
|
|
11067
|
+
case 219:
|
|
11068
|
+
length = dataView.getUint32(position);
|
|
11069
|
+
position += 4;
|
|
11070
|
+
break;
|
|
11071
|
+
|
|
11072
|
+
default:
|
|
11073
|
+
throw new Error("Expected string");
|
|
11074
|
+
}
|
|
11075
|
+
}
|
|
11076
|
+
return readStringJS(length);
|
|
11077
|
+
}
|
|
11078
|
+
function readBin(length) {
|
|
11079
|
+
return currentUnpackr.copyBuffers ? Uint8Array.prototype.slice.call(src, position, position += length) : src.subarray(position, position += length);
|
|
11080
|
+
}
|
|
11081
|
+
function readExt(length) {
|
|
11082
|
+
let type = src[position++];
|
|
11083
|
+
if (currentExtensions[type]) {
|
|
11084
|
+
let end;
|
|
11085
|
+
return currentExtensions[type](src.subarray(position, end = position += length), (readPosition => {
|
|
11086
|
+
position = readPosition;
|
|
11087
|
+
try {
|
|
11088
|
+
return read();
|
|
11089
|
+
} finally {
|
|
11090
|
+
position = end;
|
|
11091
|
+
}
|
|
11092
|
+
}));
|
|
11093
|
+
} else throw new Error("Unknown extension type " + type);
|
|
11094
|
+
}
|
|
11095
|
+
var keyCache = new Array(4096);
|
|
11096
|
+
function readKey() {
|
|
11097
|
+
let length = src[position++];
|
|
11098
|
+
if (length >= 160 && length < 192) {
|
|
11099
|
+
length = length - 160;
|
|
11100
|
+
if (srcStringEnd >= position) return srcString.slice(position - srcStringStart, (position += length) - srcStringStart); else if (!(srcStringEnd == 0 && srcEnd < 180)) return readFixedString(length);
|
|
11101
|
+
} else {
|
|
11102
|
+
position--;
|
|
11103
|
+
return asSafeString(read());
|
|
11104
|
+
}
|
|
11105
|
+
let key = (length << 5 ^ (length > 1 ? dataView.getUint16(position) : length > 0 ? src[position] : 0)) & 4095;
|
|
11106
|
+
let entry = keyCache[key];
|
|
11107
|
+
let checkPosition = position;
|
|
11108
|
+
let end = position + length - 3;
|
|
11109
|
+
let chunk;
|
|
11110
|
+
let i = 0;
|
|
11111
|
+
if (entry && entry.bytes == length) {
|
|
11112
|
+
while (checkPosition < end) {
|
|
11113
|
+
chunk = dataView.getUint32(checkPosition);
|
|
11114
|
+
if (chunk != entry[i++]) {
|
|
11115
|
+
checkPosition = 1879048192;
|
|
11116
|
+
break;
|
|
11117
|
+
}
|
|
11118
|
+
checkPosition += 4;
|
|
11119
|
+
}
|
|
11120
|
+
end += 3;
|
|
11121
|
+
while (checkPosition < end) {
|
|
11122
|
+
chunk = src[checkPosition++];
|
|
11123
|
+
if (chunk != entry[i++]) {
|
|
11124
|
+
checkPosition = 1879048192;
|
|
11125
|
+
break;
|
|
11126
|
+
}
|
|
11127
|
+
}
|
|
11128
|
+
if (checkPosition === end) {
|
|
11129
|
+
position = checkPosition;
|
|
11130
|
+
return entry.string;
|
|
11131
|
+
}
|
|
11132
|
+
end -= 3;
|
|
11133
|
+
checkPosition = position;
|
|
11134
|
+
}
|
|
11135
|
+
entry = [];
|
|
11136
|
+
keyCache[key] = entry;
|
|
11137
|
+
entry.bytes = length;
|
|
11138
|
+
while (checkPosition < end) {
|
|
11139
|
+
chunk = dataView.getUint32(checkPosition);
|
|
11140
|
+
entry.push(chunk);
|
|
11141
|
+
checkPosition += 4;
|
|
11142
|
+
}
|
|
11143
|
+
end += 3;
|
|
11144
|
+
while (checkPosition < end) {
|
|
11145
|
+
chunk = src[checkPosition++];
|
|
11146
|
+
entry.push(chunk);
|
|
11147
|
+
}
|
|
11148
|
+
let string = length < 16 ? shortStringInJS(length) : longStringInJS(length);
|
|
11149
|
+
if (string != null) return entry.string = string;
|
|
11150
|
+
return entry.string = readFixedString(length);
|
|
11151
|
+
}
|
|
11152
|
+
function asSafeString(property) {
|
|
11153
|
+
if (typeof property === "string") return property;
|
|
11154
|
+
if (typeof property === "number" || typeof property === "boolean" || typeof property === "bigint") return property.toString();
|
|
11155
|
+
if (property == null) return property + "";
|
|
11156
|
+
throw new Error("Invalid property type for record", typeof property);
|
|
11157
|
+
}
|
|
11158
|
+
const recordDefinition = (id, highByte) => {
|
|
11159
|
+
let structure = read().map(asSafeString);
|
|
11160
|
+
let firstByte = id;
|
|
11161
|
+
if (highByte !== undefined) {
|
|
11162
|
+
id = id < 32 ? -((highByte << 5) + id) : (highByte << 5) + id;
|
|
11163
|
+
structure.highByte = highByte;
|
|
11164
|
+
}
|
|
11165
|
+
let existingStructure = currentStructures[id];
|
|
11166
|
+
if (existingStructure && (existingStructure.isShared || sequentialMode)) {
|
|
11167
|
+
(currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure;
|
|
11168
|
+
}
|
|
11169
|
+
currentStructures[id] = structure;
|
|
11170
|
+
structure.read = createStructureReader(structure, firstByte);
|
|
11171
|
+
return structure.read();
|
|
11172
|
+
};
|
|
11173
|
+
currentExtensions[0] = () => {};
|
|
11174
|
+
currentExtensions[0].noBuffer = true;
|
|
11175
|
+
currentExtensions[66] = data => {
|
|
11176
|
+
let length = data.length;
|
|
11177
|
+
let value = BigInt(data[0] & 128 ? data[0] - 256 : data[0]);
|
|
11178
|
+
for (let i = 1; i < length; i++) {
|
|
11179
|
+
value <<= BigInt(8);
|
|
11180
|
+
value += BigInt(data[i]);
|
|
11181
|
+
}
|
|
11182
|
+
return value;
|
|
11183
|
+
};
|
|
11184
|
+
let errors = {
|
|
11185
|
+
Error,
|
|
11186
|
+
TypeError,
|
|
11187
|
+
ReferenceError
|
|
11188
|
+
};
|
|
11189
|
+
currentExtensions[101] = () => {
|
|
11190
|
+
let data = read();
|
|
11191
|
+
return (errors[data[0]] || Error)(data[1], {
|
|
11192
|
+
cause: data[2]
|
|
11193
|
+
});
|
|
11194
|
+
};
|
|
11195
|
+
currentExtensions[105] = data => {
|
|
11196
|
+
if (currentUnpackr.structuredClone === false) throw new Error("Structured clone extension is disabled");
|
|
11197
|
+
let id = dataView.getUint32(position - 4);
|
|
11198
|
+
if (!referenceMap) referenceMap = new Map;
|
|
11199
|
+
let token = src[position];
|
|
11200
|
+
let target;
|
|
11201
|
+
if (token >= 144 && token < 160 || token == 220 || token == 221) target = []; else target = {};
|
|
11202
|
+
let refEntry = {
|
|
11203
|
+
target
|
|
11204
|
+
};
|
|
11205
|
+
referenceMap.set(id, refEntry);
|
|
11206
|
+
let targetProperties = read();
|
|
11207
|
+
if (refEntry.used) return Object.assign(target, targetProperties);
|
|
11208
|
+
refEntry.target = targetProperties;
|
|
11209
|
+
return targetProperties;
|
|
11210
|
+
};
|
|
11211
|
+
currentExtensions[112] = data => {
|
|
11212
|
+
if (currentUnpackr.structuredClone === false) throw new Error("Structured clone extension is disabled");
|
|
11213
|
+
let id = dataView.getUint32(position - 4);
|
|
11214
|
+
let refEntry = referenceMap.get(id);
|
|
11215
|
+
refEntry.used = true;
|
|
11216
|
+
return refEntry.target;
|
|
11217
|
+
};
|
|
11218
|
+
currentExtensions[115] = () => new Set(read());
|
|
11219
|
+
const typedArrays = [ "Int8", "Uint8", "Uint8Clamped", "Int16", "Uint16", "Int32", "Uint32", "Float32", "Float64", "BigInt64", "BigUint64" ].map((type => type + "Array"));
|
|
11220
|
+
let glbl = typeof globalThis === "object" ? globalThis : window;
|
|
11221
|
+
currentExtensions[116] = data => {
|
|
11222
|
+
let typeCode = data[0];
|
|
11223
|
+
let typedArrayName = typedArrays[typeCode];
|
|
11224
|
+
if (!typedArrayName) {
|
|
11225
|
+
if (typeCode === 16) {
|
|
11226
|
+
let ab = new ArrayBuffer(data.length - 1);
|
|
11227
|
+
let u8 = new Uint8Array(ab);
|
|
11228
|
+
u8.set(data.subarray(1));
|
|
11229
|
+
return ab;
|
|
11230
|
+
}
|
|
11231
|
+
throw new Error("Could not find typed array for code " + typeCode);
|
|
11232
|
+
}
|
|
11233
|
+
return new glbl[typedArrayName](Uint8Array.prototype.slice.call(data, 1).buffer);
|
|
11234
|
+
};
|
|
11235
|
+
currentExtensions[120] = () => {
|
|
11236
|
+
let data = read();
|
|
11237
|
+
return new RegExp(data[0], data[1]);
|
|
11238
|
+
};
|
|
11239
|
+
const TEMP_BUNDLE = [];
|
|
11240
|
+
currentExtensions[98] = data => {
|
|
11241
|
+
let dataSize = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
|
|
11242
|
+
let dataPosition = position;
|
|
11243
|
+
position += dataSize - data.length;
|
|
11244
|
+
bundledStrings = TEMP_BUNDLE;
|
|
11245
|
+
bundledStrings = [ readOnlyJSString(), readOnlyJSString() ];
|
|
11246
|
+
bundledStrings.position0 = 0;
|
|
11247
|
+
bundledStrings.position1 = 0;
|
|
11248
|
+
bundledStrings.postBundlePosition = position;
|
|
11249
|
+
position = dataPosition;
|
|
11250
|
+
return read();
|
|
11251
|
+
};
|
|
11252
|
+
currentExtensions[255] = data => {
|
|
11253
|
+
if (data.length == 4) return new Date((data[0] * 16777216 + (data[1] << 16) + (data[2] << 8) + data[3]) * 1e3); else if (data.length == 8) return new Date(((data[0] << 22) + (data[1] << 14) + (data[2] << 6) + (data[3] >> 2)) / 1e6 + ((data[3] & 3) * 4294967296 + data[4] * 16777216 + (data[5] << 16) + (data[6] << 8) + data[7]) * 1e3); else if (data.length == 12) return new Date(((data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]) / 1e6 + ((data[4] & 128 ? -281474976710656 : 0) + data[6] * 1099511627776 + data[7] * 4294967296 + data[8] * 16777216 + (data[9] << 16) + (data[10] << 8) + data[11]) * 1e3); else return new Date("invalid");
|
|
11254
|
+
};
|
|
11255
|
+
function saveState(callback) {
|
|
11256
|
+
if (onSaveState) onSaveState();
|
|
11257
|
+
let savedSrcEnd = srcEnd;
|
|
11258
|
+
let savedPosition = position;
|
|
11259
|
+
let savedStringPosition = stringPosition;
|
|
11260
|
+
let savedSrcStringStart = srcStringStart;
|
|
11261
|
+
let savedSrcStringEnd = srcStringEnd;
|
|
11262
|
+
let savedSrcString = srcString;
|
|
11263
|
+
let savedStrings = unpack_strings;
|
|
11264
|
+
let savedReferenceMap = referenceMap;
|
|
11265
|
+
let savedBundledStrings = bundledStrings;
|
|
11266
|
+
let savedSrc = new Uint8Array(src.slice(0, srcEnd));
|
|
11267
|
+
let savedStructures = currentStructures;
|
|
11268
|
+
let savedStructuresContents = currentStructures.slice(0, currentStructures.length);
|
|
11269
|
+
let savedPackr = currentUnpackr;
|
|
11270
|
+
let savedSequentialMode = sequentialMode;
|
|
11271
|
+
let value = callback();
|
|
11272
|
+
srcEnd = savedSrcEnd;
|
|
11273
|
+
position = savedPosition;
|
|
11274
|
+
stringPosition = savedStringPosition;
|
|
11275
|
+
srcStringStart = savedSrcStringStart;
|
|
11276
|
+
srcStringEnd = savedSrcStringEnd;
|
|
11277
|
+
srcString = savedSrcString;
|
|
11278
|
+
unpack_strings = savedStrings;
|
|
11279
|
+
referenceMap = savedReferenceMap;
|
|
11280
|
+
bundledStrings = savedBundledStrings;
|
|
11281
|
+
src = savedSrc;
|
|
11282
|
+
sequentialMode = savedSequentialMode;
|
|
11283
|
+
currentStructures = savedStructures;
|
|
11284
|
+
currentStructures.splice(0, currentStructures.length, ...savedStructuresContents);
|
|
11285
|
+
currentUnpackr = savedPackr;
|
|
11286
|
+
dataView = new DataView(src.buffer, src.byteOffset, src.byteLength);
|
|
11287
|
+
return value;
|
|
11288
|
+
}
|
|
11289
|
+
function clearSource() {
|
|
11290
|
+
src = null;
|
|
11291
|
+
referenceMap = null;
|
|
11292
|
+
currentStructures = null;
|
|
11293
|
+
}
|
|
11294
|
+
function addExtension(extension) {
|
|
11295
|
+
if (extension.unpack) currentExtensions[extension.type] = extension.unpack; else currentExtensions[extension.type] = extension;
|
|
11296
|
+
}
|
|
11297
|
+
const mult10 = new Array(147);
|
|
11298
|
+
for (let i = 0; i < 256; i++) {
|
|
11299
|
+
mult10[i] = +("1e" + Math.floor(45.15 - i * .30103));
|
|
11300
|
+
}
|
|
11301
|
+
const Decoder = null && Unpackr;
|
|
11302
|
+
var defaultUnpackr = new Unpackr({
|
|
11303
|
+
useRecords: false
|
|
11304
|
+
});
|
|
11305
|
+
const unpack = defaultUnpackr.unpack;
|
|
11306
|
+
const unpackMultiple = defaultUnpackr.unpackMultiple;
|
|
11307
|
+
const decode = defaultUnpackr.unpack;
|
|
11308
|
+
const FLOAT32_OPTIONS = {
|
|
11309
|
+
NEVER: 0,
|
|
11310
|
+
ALWAYS: 1,
|
|
11311
|
+
DECIMAL_ROUND: 3,
|
|
11312
|
+
DECIMAL_FIT: 4
|
|
11313
|
+
};
|
|
11314
|
+
let f32Array = new Float32Array(1);
|
|
11315
|
+
let u8Array = new Uint8Array(f32Array.buffer, 0, 4);
|
|
11316
|
+
function roundFloat32(float32Number) {
|
|
11317
|
+
f32Array[0] = float32Number;
|
|
11318
|
+
let multiplier = mult10[(u8Array[3] & 127) << 1 | u8Array[2] >> 7];
|
|
11319
|
+
return (multiplier * float32Number + (float32Number > 0 ? .5 : -.5) >> 0) / multiplier;
|
|
11320
|
+
}
|
|
11321
|
+
function setReadStruct(updatedReadStruct, loadedStructs, saveState) {
|
|
11322
|
+
readStruct = updatedReadStruct;
|
|
11323
|
+
onLoadedStructures = loadedStructs;
|
|
11324
|
+
onSaveState = saveState;
|
|
11325
|
+
}
|
|
11326
|
+
var pack_Buffer = __webpack_require__(764)["lW"];
|
|
11327
|
+
let textEncoder;
|
|
11328
|
+
try {
|
|
11329
|
+
textEncoder = new TextEncoder;
|
|
11330
|
+
} catch (error) {}
|
|
11331
|
+
let extensions, extensionClasses;
|
|
11332
|
+
const hasNodeBuffer = typeof pack_Buffer !== "undefined";
|
|
11333
|
+
const ByteArrayAllocate = hasNodeBuffer ? function(length) {
|
|
11334
|
+
return pack_Buffer.allocUnsafeSlow(length);
|
|
11335
|
+
} : Uint8Array;
|
|
11336
|
+
const ByteArray = hasNodeBuffer ? pack_Buffer : Uint8Array;
|
|
11337
|
+
const MAX_BUFFER_SIZE = hasNodeBuffer ? 4294967296 : 2144337920;
|
|
11338
|
+
let target, keysTarget;
|
|
11339
|
+
let targetView;
|
|
11340
|
+
let pack_position = 0;
|
|
11341
|
+
let safeEnd;
|
|
11342
|
+
let pack_bundledStrings = null;
|
|
11343
|
+
let writeStructSlots;
|
|
11344
|
+
const MAX_BUNDLE_SIZE = 21760;
|
|
11345
|
+
const hasNonLatin = /[\u0080-\uFFFF]/;
|
|
11346
|
+
const RECORD_SYMBOL = Symbol("record-id");
|
|
11347
|
+
class Packr extends Unpackr {
|
|
11348
|
+
constructor(options) {
|
|
11349
|
+
super(options);
|
|
11350
|
+
this.offset = 0;
|
|
11351
|
+
let typeBuffer;
|
|
11352
|
+
let start;
|
|
11353
|
+
let hasSharedUpdate;
|
|
11354
|
+
let structures;
|
|
11355
|
+
let referenceMap;
|
|
11356
|
+
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) {
|
|
11357
|
+
return target.utf8Write(string, position, target.byteLength - position);
|
|
11358
|
+
} : textEncoder && textEncoder.encodeInto ? function(string, position) {
|
|
11359
|
+
return textEncoder.encodeInto(string, target.subarray(position)).written;
|
|
11360
|
+
} : false;
|
|
11361
|
+
let packr = this;
|
|
11362
|
+
if (!options) options = {};
|
|
11363
|
+
let isSequential = options && options.sequential;
|
|
11364
|
+
let hasSharedStructures = options.structures || options.saveStructures;
|
|
11365
|
+
let maxSharedStructures = options.maxSharedStructures;
|
|
11366
|
+
if (maxSharedStructures == null) maxSharedStructures = hasSharedStructures ? 32 : 0;
|
|
11367
|
+
if (maxSharedStructures > 8160) throw new Error("Maximum maxSharedStructure is 8160");
|
|
11368
|
+
if (options.structuredClone && options.moreTypes == undefined) {
|
|
11369
|
+
this.moreTypes = true;
|
|
11370
|
+
}
|
|
11371
|
+
let maxOwnStructures = options.maxOwnStructures;
|
|
11372
|
+
if (maxOwnStructures == null) maxOwnStructures = hasSharedStructures ? 32 : 64;
|
|
11373
|
+
if (!this.structures && options.useRecords != false) this.structures = [];
|
|
11374
|
+
let useTwoByteRecords = maxSharedStructures > 32 || maxOwnStructures + maxSharedStructures > 64;
|
|
11375
|
+
let sharedLimitId = maxSharedStructures + 64;
|
|
11376
|
+
let maxStructureId = maxSharedStructures + maxOwnStructures + 64;
|
|
11377
|
+
if (maxStructureId > 8256) {
|
|
11378
|
+
throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");
|
|
11379
|
+
}
|
|
11380
|
+
let recordIdsToRemove = [];
|
|
11381
|
+
let transitionsCount = 0;
|
|
11382
|
+
let serializationsSinceTransitionRebuild = 0;
|
|
11383
|
+
this.pack = this.encode = function(value, encodeOptions) {
|
|
11384
|
+
if (!target) {
|
|
11385
|
+
target = new ByteArrayAllocate(8192);
|
|
11386
|
+
targetView = target.dataView || (target.dataView = new DataView(target.buffer, 0, 8192));
|
|
11387
|
+
pack_position = 0;
|
|
11388
|
+
}
|
|
11389
|
+
safeEnd = target.length - 10;
|
|
11390
|
+
if (safeEnd - pack_position < 2048) {
|
|
11391
|
+
target = new ByteArrayAllocate(target.length);
|
|
11392
|
+
targetView = target.dataView || (target.dataView = new DataView(target.buffer, 0, target.length));
|
|
11393
|
+
safeEnd = target.length - 10;
|
|
11394
|
+
pack_position = 0;
|
|
11395
|
+
} else pack_position = pack_position + 7 & 2147483640;
|
|
11396
|
+
start = pack_position;
|
|
11397
|
+
if (encodeOptions & RESERVE_START_SPACE) pack_position += encodeOptions & 255;
|
|
11398
|
+
referenceMap = packr.structuredClone ? new Map : null;
|
|
11399
|
+
if (packr.bundleStrings && typeof value !== "string") {
|
|
11400
|
+
pack_bundledStrings = [];
|
|
11401
|
+
pack_bundledStrings.size = Infinity;
|
|
11402
|
+
} else pack_bundledStrings = null;
|
|
11403
|
+
structures = packr.structures;
|
|
11404
|
+
if (structures) {
|
|
11405
|
+
if (structures.uninitialized) structures = packr._mergeStructures(packr.getStructures());
|
|
11406
|
+
let sharedLength = structures.sharedLength || 0;
|
|
11407
|
+
if (sharedLength > maxSharedStructures) {
|
|
11408
|
+
throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to " + structures.sharedLength);
|
|
11409
|
+
}
|
|
11410
|
+
if (!structures.transitions) {
|
|
11411
|
+
structures.transitions = Object.create(null);
|
|
11412
|
+
for (let i = 0; i < sharedLength; i++) {
|
|
11413
|
+
let keys = structures[i];
|
|
11414
|
+
if (!keys) continue;
|
|
11415
|
+
let nextTransition, transition = structures.transitions;
|
|
11416
|
+
for (let j = 0, l = keys.length; j < l; j++) {
|
|
11417
|
+
let key = keys[j];
|
|
11418
|
+
nextTransition = transition[key];
|
|
11419
|
+
if (!nextTransition) {
|
|
11420
|
+
nextTransition = transition[key] = Object.create(null);
|
|
11421
|
+
}
|
|
11422
|
+
transition = nextTransition;
|
|
11423
|
+
}
|
|
11424
|
+
transition[RECORD_SYMBOL] = i + 64;
|
|
11425
|
+
}
|
|
11426
|
+
this.lastNamedStructuresLength = sharedLength;
|
|
11427
|
+
}
|
|
11428
|
+
if (!isSequential) {
|
|
11429
|
+
structures.nextId = sharedLength + 64;
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
if (hasSharedUpdate) hasSharedUpdate = false;
|
|
11433
|
+
let encodingError;
|
|
11434
|
+
try {
|
|
11435
|
+
if (packr.randomAccessStructure && value && value.constructor && value.constructor === Object) writeStruct(value); else pack(value);
|
|
11436
|
+
let lastBundle = pack_bundledStrings;
|
|
11437
|
+
if (pack_bundledStrings) writeBundles(start, pack, 0);
|
|
11438
|
+
if (referenceMap && referenceMap.idsToInsert) {
|
|
11439
|
+
let idsToInsert = referenceMap.idsToInsert.sort(((a, b) => a.offset > b.offset ? 1 : -1));
|
|
11440
|
+
let i = idsToInsert.length;
|
|
11441
|
+
let incrementPosition = -1;
|
|
11442
|
+
while (lastBundle && i > 0) {
|
|
11443
|
+
let insertionPoint = idsToInsert[--i].offset + start;
|
|
11444
|
+
if (insertionPoint < lastBundle.stringsPosition + start && incrementPosition === -1) incrementPosition = 0;
|
|
11445
|
+
if (insertionPoint > lastBundle.position + start) {
|
|
11446
|
+
if (incrementPosition >= 0) incrementPosition += 6;
|
|
11447
|
+
} else {
|
|
11448
|
+
if (incrementPosition >= 0) {
|
|
11449
|
+
targetView.setUint32(lastBundle.position + start, targetView.getUint32(lastBundle.position + start) + incrementPosition);
|
|
11450
|
+
incrementPosition = -1;
|
|
11451
|
+
}
|
|
11452
|
+
lastBundle = lastBundle.previous;
|
|
11453
|
+
i++;
|
|
11454
|
+
}
|
|
11455
|
+
}
|
|
11456
|
+
if (incrementPosition >= 0 && lastBundle) {
|
|
11457
|
+
targetView.setUint32(lastBundle.position + start, targetView.getUint32(lastBundle.position + start) + incrementPosition);
|
|
11458
|
+
}
|
|
11459
|
+
pack_position += idsToInsert.length * 6;
|
|
11460
|
+
if (pack_position > safeEnd) makeRoom(pack_position);
|
|
11461
|
+
packr.offset = pack_position;
|
|
11462
|
+
let serialized = insertIds(target.subarray(start, pack_position), idsToInsert);
|
|
11463
|
+
referenceMap = null;
|
|
11464
|
+
return serialized;
|
|
11465
|
+
}
|
|
11466
|
+
packr.offset = pack_position;
|
|
11467
|
+
if (encodeOptions & REUSE_BUFFER_MODE) {
|
|
11468
|
+
target.start = start;
|
|
11469
|
+
target.end = pack_position;
|
|
11470
|
+
return target;
|
|
11471
|
+
}
|
|
11472
|
+
return target.subarray(start, pack_position);
|
|
11473
|
+
} catch (error) {
|
|
11474
|
+
encodingError = error;
|
|
11475
|
+
throw error;
|
|
11476
|
+
} finally {
|
|
11477
|
+
if (structures) {
|
|
11478
|
+
resetStructures();
|
|
11479
|
+
if (hasSharedUpdate && packr.saveStructures) {
|
|
11480
|
+
let sharedLength = structures.sharedLength || 0;
|
|
11481
|
+
let returnBuffer = target.subarray(start, pack_position);
|
|
11482
|
+
let newSharedData = prepareStructures(structures, packr);
|
|
11483
|
+
if (!encodingError) {
|
|
11484
|
+
if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
|
|
11485
|
+
return packr.pack(value, encodeOptions);
|
|
11486
|
+
}
|
|
11487
|
+
packr.lastNamedStructuresLength = sharedLength;
|
|
11488
|
+
if (target.length > 1073741824) target = null;
|
|
11489
|
+
return returnBuffer;
|
|
11490
|
+
}
|
|
11491
|
+
}
|
|
11492
|
+
}
|
|
11493
|
+
if (target.length > 1073741824) target = null;
|
|
11494
|
+
if (encodeOptions & RESET_BUFFER_MODE) pack_position = start;
|
|
11495
|
+
}
|
|
11496
|
+
};
|
|
11497
|
+
const resetStructures = () => {
|
|
11498
|
+
if (serializationsSinceTransitionRebuild < 10) serializationsSinceTransitionRebuild++;
|
|
11499
|
+
let sharedLength = structures.sharedLength || 0;
|
|
11500
|
+
if (structures.length > sharedLength && !isSequential) structures.length = sharedLength;
|
|
11501
|
+
if (transitionsCount > 1e4) {
|
|
11502
|
+
structures.transitions = null;
|
|
11503
|
+
serializationsSinceTransitionRebuild = 0;
|
|
11504
|
+
transitionsCount = 0;
|
|
11505
|
+
if (recordIdsToRemove.length > 0) recordIdsToRemove = [];
|
|
11506
|
+
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
11507
|
+
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
11508
|
+
recordIdsToRemove[i][RECORD_SYMBOL] = 0;
|
|
11509
|
+
}
|
|
11510
|
+
recordIdsToRemove = [];
|
|
11511
|
+
}
|
|
11512
|
+
};
|
|
11513
|
+
const packArray = value => {
|
|
11514
|
+
var length = value.length;
|
|
11515
|
+
if (length < 16) {
|
|
11516
|
+
target[pack_position++] = 144 | length;
|
|
11517
|
+
} else if (length < 65536) {
|
|
11518
|
+
target[pack_position++] = 220;
|
|
11519
|
+
target[pack_position++] = length >> 8;
|
|
11520
|
+
target[pack_position++] = length & 255;
|
|
11521
|
+
} else {
|
|
11522
|
+
target[pack_position++] = 221;
|
|
11523
|
+
targetView.setUint32(pack_position, length);
|
|
11524
|
+
pack_position += 4;
|
|
11525
|
+
}
|
|
11526
|
+
for (let i = 0; i < length; i++) {
|
|
11527
|
+
pack(value[i]);
|
|
11528
|
+
}
|
|
11529
|
+
};
|
|
11530
|
+
const pack = value => {
|
|
11531
|
+
if (pack_position > safeEnd) target = makeRoom(pack_position);
|
|
11532
|
+
var type = typeof value;
|
|
11533
|
+
var length;
|
|
11534
|
+
if (type === "string") {
|
|
11535
|
+
let strLength = value.length;
|
|
11536
|
+
if (pack_bundledStrings && strLength >= 4 && strLength < 4096) {
|
|
11537
|
+
if ((pack_bundledStrings.size += strLength) > MAX_BUNDLE_SIZE) {
|
|
11538
|
+
let extStart;
|
|
11539
|
+
let maxBytes = (pack_bundledStrings[0] ? pack_bundledStrings[0].length * 3 + pack_bundledStrings[1].length : 0) + 10;
|
|
11540
|
+
if (pack_position + maxBytes > safeEnd) target = makeRoom(pack_position + maxBytes);
|
|
11541
|
+
let lastBundle;
|
|
11542
|
+
if (pack_bundledStrings.position) {
|
|
11543
|
+
lastBundle = pack_bundledStrings;
|
|
11544
|
+
target[pack_position] = 200;
|
|
11545
|
+
pack_position += 3;
|
|
11546
|
+
target[pack_position++] = 98;
|
|
11547
|
+
extStart = pack_position - start;
|
|
11548
|
+
pack_position += 4;
|
|
11549
|
+
writeBundles(start, pack, 0);
|
|
11550
|
+
targetView.setUint16(extStart + start - 3, pack_position - start - extStart);
|
|
11551
|
+
} else {
|
|
11552
|
+
target[pack_position++] = 214;
|
|
11553
|
+
target[pack_position++] = 98;
|
|
11554
|
+
extStart = pack_position - start;
|
|
11555
|
+
pack_position += 4;
|
|
11556
|
+
}
|
|
11557
|
+
pack_bundledStrings = [ "", "" ];
|
|
11558
|
+
pack_bundledStrings.previous = lastBundle;
|
|
11559
|
+
pack_bundledStrings.size = 0;
|
|
11560
|
+
pack_bundledStrings.position = extStart;
|
|
11561
|
+
}
|
|
11562
|
+
let twoByte = hasNonLatin.test(value);
|
|
11563
|
+
pack_bundledStrings[twoByte ? 0 : 1] += value;
|
|
11564
|
+
target[pack_position++] = 193;
|
|
11565
|
+
pack(twoByte ? -strLength : strLength);
|
|
11566
|
+
return;
|
|
11567
|
+
}
|
|
11568
|
+
let headerSize;
|
|
11569
|
+
if (strLength < 32) {
|
|
11570
|
+
headerSize = 1;
|
|
11571
|
+
} else if (strLength < 256) {
|
|
11572
|
+
headerSize = 2;
|
|
11573
|
+
} else if (strLength < 65536) {
|
|
11574
|
+
headerSize = 3;
|
|
11575
|
+
} else {
|
|
11576
|
+
headerSize = 5;
|
|
11577
|
+
}
|
|
11578
|
+
let maxBytes = strLength * 3;
|
|
11579
|
+
if (pack_position + maxBytes > safeEnd) target = makeRoom(pack_position + maxBytes);
|
|
11580
|
+
if (strLength < 64 || !encodeUtf8) {
|
|
11581
|
+
let i, c1, c2, strPosition = pack_position + headerSize;
|
|
11582
|
+
for (i = 0; i < strLength; i++) {
|
|
11583
|
+
c1 = value.charCodeAt(i);
|
|
11584
|
+
if (c1 < 128) {
|
|
11585
|
+
target[strPosition++] = c1;
|
|
11586
|
+
} else if (c1 < 2048) {
|
|
11587
|
+
target[strPosition++] = c1 >> 6 | 192;
|
|
11588
|
+
target[strPosition++] = c1 & 63 | 128;
|
|
11589
|
+
} else if ((c1 & 64512) === 55296 && ((c2 = value.charCodeAt(i + 1)) & 64512) === 56320) {
|
|
11590
|
+
c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
|
|
11591
|
+
i++;
|
|
11592
|
+
target[strPosition++] = c1 >> 18 | 240;
|
|
11593
|
+
target[strPosition++] = c1 >> 12 & 63 | 128;
|
|
11594
|
+
target[strPosition++] = c1 >> 6 & 63 | 128;
|
|
11595
|
+
target[strPosition++] = c1 & 63 | 128;
|
|
11596
|
+
} else {
|
|
11597
|
+
target[strPosition++] = c1 >> 12 | 224;
|
|
11598
|
+
target[strPosition++] = c1 >> 6 & 63 | 128;
|
|
11599
|
+
target[strPosition++] = c1 & 63 | 128;
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
length = strPosition - pack_position - headerSize;
|
|
11603
|
+
} else {
|
|
11604
|
+
length = encodeUtf8(value, pack_position + headerSize);
|
|
11605
|
+
}
|
|
11606
|
+
if (length < 32) {
|
|
11607
|
+
target[pack_position++] = 160 | length;
|
|
11608
|
+
} else if (length < 256) {
|
|
11609
|
+
if (headerSize < 2) {
|
|
11610
|
+
target.copyWithin(pack_position + 2, pack_position + 1, pack_position + 1 + length);
|
|
11611
|
+
}
|
|
11612
|
+
target[pack_position++] = 217;
|
|
11613
|
+
target[pack_position++] = length;
|
|
11614
|
+
} else if (length < 65536) {
|
|
11615
|
+
if (headerSize < 3) {
|
|
11616
|
+
target.copyWithin(pack_position + 3, pack_position + 2, pack_position + 2 + length);
|
|
11617
|
+
}
|
|
11618
|
+
target[pack_position++] = 218;
|
|
11619
|
+
target[pack_position++] = length >> 8;
|
|
11620
|
+
target[pack_position++] = length & 255;
|
|
11621
|
+
} else {
|
|
11622
|
+
if (headerSize < 5) {
|
|
11623
|
+
target.copyWithin(pack_position + 5, pack_position + 3, pack_position + 3 + length);
|
|
11624
|
+
}
|
|
11625
|
+
target[pack_position++] = 219;
|
|
11626
|
+
targetView.setUint32(pack_position, length);
|
|
11627
|
+
pack_position += 4;
|
|
11628
|
+
}
|
|
11629
|
+
pack_position += length;
|
|
11630
|
+
} else if (type === "number") {
|
|
11631
|
+
if (value >>> 0 === value) {
|
|
11632
|
+
if (value < 32 || value < 128 && this.useRecords === false || value < 64 && !this.randomAccessStructure) {
|
|
11633
|
+
target[pack_position++] = value;
|
|
11634
|
+
} else if (value < 256) {
|
|
11635
|
+
target[pack_position++] = 204;
|
|
11636
|
+
target[pack_position++] = value;
|
|
11637
|
+
} else if (value < 65536) {
|
|
11638
|
+
target[pack_position++] = 205;
|
|
11639
|
+
target[pack_position++] = value >> 8;
|
|
11640
|
+
target[pack_position++] = value & 255;
|
|
11641
|
+
} else {
|
|
11642
|
+
target[pack_position++] = 206;
|
|
11643
|
+
targetView.setUint32(pack_position, value);
|
|
11644
|
+
pack_position += 4;
|
|
11645
|
+
}
|
|
11646
|
+
} else if (value >> 0 === value) {
|
|
11647
|
+
if (value >= -32) {
|
|
11648
|
+
target[pack_position++] = 256 + value;
|
|
11649
|
+
} else if (value >= -128) {
|
|
11650
|
+
target[pack_position++] = 208;
|
|
11651
|
+
target[pack_position++] = value + 256;
|
|
11652
|
+
} else if (value >= -32768) {
|
|
11653
|
+
target[pack_position++] = 209;
|
|
11654
|
+
targetView.setInt16(pack_position, value);
|
|
11655
|
+
pack_position += 2;
|
|
11656
|
+
} else {
|
|
11657
|
+
target[pack_position++] = 210;
|
|
11658
|
+
targetView.setInt32(pack_position, value);
|
|
11659
|
+
pack_position += 4;
|
|
11660
|
+
}
|
|
11661
|
+
} else {
|
|
11662
|
+
let useFloat32;
|
|
11663
|
+
if ((useFloat32 = this.useFloat32) > 0 && value < 4294967296 && value >= -2147483648) {
|
|
11664
|
+
target[pack_position++] = 202;
|
|
11665
|
+
targetView.setFloat32(pack_position, value);
|
|
11666
|
+
let xShifted;
|
|
11667
|
+
if (useFloat32 < 4 || (xShifted = value * mult10[(target[pack_position] & 127) << 1 | target[pack_position + 1] >> 7]) >> 0 === xShifted) {
|
|
11668
|
+
pack_position += 4;
|
|
11669
|
+
return;
|
|
11670
|
+
} else pack_position--;
|
|
11671
|
+
}
|
|
11672
|
+
target[pack_position++] = 203;
|
|
11673
|
+
targetView.setFloat64(pack_position, value);
|
|
11674
|
+
pack_position += 8;
|
|
11675
|
+
}
|
|
11676
|
+
} else if (type === "object" || type === "function") {
|
|
11677
|
+
if (!value) target[pack_position++] = 192; else {
|
|
11678
|
+
if (referenceMap) {
|
|
11679
|
+
let referee = referenceMap.get(value);
|
|
11680
|
+
if (referee) {
|
|
11681
|
+
if (!referee.id) {
|
|
11682
|
+
let idsToInsert = referenceMap.idsToInsert || (referenceMap.idsToInsert = []);
|
|
11683
|
+
referee.id = idsToInsert.push(referee);
|
|
11684
|
+
}
|
|
11685
|
+
target[pack_position++] = 214;
|
|
11686
|
+
target[pack_position++] = 112;
|
|
11687
|
+
targetView.setUint32(pack_position, referee.id);
|
|
11688
|
+
pack_position += 4;
|
|
11689
|
+
return;
|
|
11690
|
+
} else referenceMap.set(value, {
|
|
11691
|
+
offset: pack_position - start
|
|
11692
|
+
});
|
|
11693
|
+
}
|
|
11694
|
+
let constructor = value.constructor;
|
|
11695
|
+
if (constructor === Object) {
|
|
11696
|
+
writeObject(value);
|
|
11697
|
+
} else if (constructor === Array) {
|
|
11698
|
+
packArray(value);
|
|
11699
|
+
} else if (constructor === Map) {
|
|
11700
|
+
if (this.mapAsEmptyObject) target[pack_position++] = 128; else {
|
|
11701
|
+
length = value.size;
|
|
11702
|
+
if (length < 16) {
|
|
11703
|
+
target[pack_position++] = 128 | length;
|
|
11704
|
+
} else if (length < 65536) {
|
|
11705
|
+
target[pack_position++] = 222;
|
|
11706
|
+
target[pack_position++] = length >> 8;
|
|
11707
|
+
target[pack_position++] = length & 255;
|
|
11708
|
+
} else {
|
|
11709
|
+
target[pack_position++] = 223;
|
|
11710
|
+
targetView.setUint32(pack_position, length);
|
|
11711
|
+
pack_position += 4;
|
|
11712
|
+
}
|
|
11713
|
+
for (let [key, entryValue] of value) {
|
|
11714
|
+
pack(key);
|
|
11715
|
+
pack(entryValue);
|
|
11716
|
+
}
|
|
11717
|
+
}
|
|
11718
|
+
} else {
|
|
11719
|
+
for (let i = 0, l = extensions.length; i < l; i++) {
|
|
11720
|
+
let extensionClass = extensionClasses[i];
|
|
11721
|
+
if (value instanceof extensionClass) {
|
|
11722
|
+
let extension = extensions[i];
|
|
11723
|
+
if (extension.write) {
|
|
11724
|
+
if (extension.type) {
|
|
11725
|
+
target[pack_position++] = 212;
|
|
11726
|
+
target[pack_position++] = extension.type;
|
|
11727
|
+
target[pack_position++] = 0;
|
|
11728
|
+
}
|
|
11729
|
+
let writeResult = extension.write.call(this, value);
|
|
11730
|
+
if (writeResult === value) {
|
|
11731
|
+
if (Array.isArray(value)) {
|
|
11732
|
+
packArray(value);
|
|
11733
|
+
} else {
|
|
11734
|
+
writeObject(value);
|
|
11735
|
+
}
|
|
11736
|
+
} else {
|
|
11737
|
+
pack(writeResult);
|
|
11738
|
+
}
|
|
11739
|
+
return;
|
|
11740
|
+
}
|
|
11741
|
+
let currentTarget = target;
|
|
11742
|
+
let currentTargetView = targetView;
|
|
11743
|
+
let currentPosition = pack_position;
|
|
11744
|
+
target = null;
|
|
11745
|
+
let result;
|
|
11746
|
+
try {
|
|
11747
|
+
result = extension.pack.call(this, value, (size => {
|
|
11748
|
+
target = currentTarget;
|
|
11749
|
+
currentTarget = null;
|
|
11750
|
+
pack_position += size;
|
|
11751
|
+
if (pack_position > safeEnd) makeRoom(pack_position);
|
|
11752
|
+
return {
|
|
11753
|
+
target,
|
|
11754
|
+
targetView,
|
|
11755
|
+
position: pack_position - size
|
|
11756
|
+
};
|
|
11757
|
+
}), pack);
|
|
11758
|
+
} finally {
|
|
11759
|
+
if (currentTarget) {
|
|
11760
|
+
target = currentTarget;
|
|
11761
|
+
targetView = currentTargetView;
|
|
11762
|
+
pack_position = currentPosition;
|
|
11763
|
+
safeEnd = target.length - 10;
|
|
11764
|
+
}
|
|
11765
|
+
}
|
|
11766
|
+
if (result) {
|
|
11767
|
+
if (result.length + pack_position > safeEnd) makeRoom(result.length + pack_position);
|
|
11768
|
+
pack_position = writeExtensionData(result, target, pack_position, extension.type);
|
|
11769
|
+
}
|
|
11770
|
+
return;
|
|
11771
|
+
}
|
|
11772
|
+
}
|
|
11773
|
+
if (Array.isArray(value)) {
|
|
11774
|
+
packArray(value);
|
|
11775
|
+
} else {
|
|
11776
|
+
if (value.toJSON) {
|
|
11777
|
+
const json = value.toJSON();
|
|
11778
|
+
if (json !== value) return pack(json);
|
|
11779
|
+
}
|
|
11780
|
+
if (type === "function") return pack(this.writeFunction && this.writeFunction(value));
|
|
11781
|
+
writeObject(value);
|
|
11782
|
+
}
|
|
11783
|
+
}
|
|
11784
|
+
}
|
|
11785
|
+
} else if (type === "boolean") {
|
|
11786
|
+
target[pack_position++] = value ? 195 : 194;
|
|
11787
|
+
} else if (type === "bigint") {
|
|
11788
|
+
if (value < BigInt(1) << BigInt(63) && value >= -(BigInt(1) << BigInt(63))) {
|
|
11789
|
+
target[pack_position++] = 211;
|
|
11790
|
+
targetView.setBigInt64(pack_position, value);
|
|
11791
|
+
} else if (value < BigInt(1) << BigInt(64) && value > 0) {
|
|
11792
|
+
target[pack_position++] = 207;
|
|
11793
|
+
targetView.setBigUint64(pack_position, value);
|
|
11794
|
+
} else {
|
|
11795
|
+
if (this.largeBigIntToFloat) {
|
|
11796
|
+
target[pack_position++] = 203;
|
|
11797
|
+
targetView.setFloat64(pack_position, Number(value));
|
|
11798
|
+
} else if (this.largeBigIntToString) {
|
|
11799
|
+
return pack(value.toString());
|
|
11800
|
+
} else if (this.useBigIntExtension && value < BigInt(2) ** BigInt(1023) && value > -(BigInt(2) ** BigInt(1023))) {
|
|
11801
|
+
target[pack_position++] = 199;
|
|
11802
|
+
pack_position++;
|
|
11803
|
+
target[pack_position++] = 66;
|
|
11804
|
+
let bytes = [];
|
|
11805
|
+
let alignedSign;
|
|
11806
|
+
do {
|
|
11807
|
+
let byte = value & BigInt(255);
|
|
11808
|
+
alignedSign = (byte & BigInt(128)) === (value < BigInt(0) ? BigInt(128) : BigInt(0));
|
|
11809
|
+
bytes.push(byte);
|
|
11810
|
+
value >>= BigInt(8);
|
|
11811
|
+
} while (!((value === BigInt(0) || value === BigInt(-1)) && alignedSign));
|
|
11812
|
+
target[pack_position - 2] = bytes.length;
|
|
11813
|
+
for (let i = bytes.length; i > 0; ) {
|
|
11814
|
+
target[pack_position++] = Number(bytes[--i]);
|
|
11815
|
+
}
|
|
11816
|
+
return;
|
|
11817
|
+
} else {
|
|
11818
|
+
throw new RangeError(value + " was too large to fit in MessagePack 64-bit integer format, use" + " useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set" + " largeBigIntToString to convert to string");
|
|
11819
|
+
}
|
|
11820
|
+
}
|
|
11821
|
+
pack_position += 8;
|
|
11822
|
+
} else if (type === "undefined") {
|
|
11823
|
+
if (this.encodeUndefinedAsNil) target[pack_position++] = 192; else {
|
|
11824
|
+
target[pack_position++] = 212;
|
|
11825
|
+
target[pack_position++] = 0;
|
|
11826
|
+
target[pack_position++] = 0;
|
|
11827
|
+
}
|
|
11828
|
+
} else {
|
|
11829
|
+
throw new Error("Unknown type: " + type);
|
|
11830
|
+
}
|
|
11831
|
+
};
|
|
11832
|
+
const writePlainObject = this.variableMapSize || this.coercibleKeyAsNumber || this.skipValues ? object => {
|
|
11833
|
+
let keys;
|
|
11834
|
+
if (this.skipValues) {
|
|
11835
|
+
keys = [];
|
|
11836
|
+
for (let key in object) {
|
|
11837
|
+
if ((typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) && !this.skipValues.includes(object[key])) keys.push(key);
|
|
11838
|
+
}
|
|
11839
|
+
} else {
|
|
11840
|
+
keys = Object.keys(object);
|
|
11841
|
+
}
|
|
11842
|
+
let length = keys.length;
|
|
11843
|
+
if (length < 16) {
|
|
11844
|
+
target[pack_position++] = 128 | length;
|
|
11845
|
+
} else if (length < 65536) {
|
|
11846
|
+
target[pack_position++] = 222;
|
|
11847
|
+
target[pack_position++] = length >> 8;
|
|
11848
|
+
target[pack_position++] = length & 255;
|
|
11849
|
+
} else {
|
|
11850
|
+
target[pack_position++] = 223;
|
|
11851
|
+
targetView.setUint32(pack_position, length);
|
|
11852
|
+
pack_position += 4;
|
|
11853
|
+
}
|
|
11854
|
+
let key;
|
|
11855
|
+
if (this.coercibleKeyAsNumber) {
|
|
11856
|
+
for (let i = 0; i < length; i++) {
|
|
11857
|
+
key = keys[i];
|
|
11858
|
+
let num = Number(key);
|
|
11859
|
+
pack(isNaN(num) ? key : num);
|
|
11860
|
+
pack(object[key]);
|
|
11861
|
+
}
|
|
11862
|
+
} else {
|
|
11863
|
+
for (let i = 0; i < length; i++) {
|
|
11864
|
+
pack(key = keys[i]);
|
|
11865
|
+
pack(object[key]);
|
|
11866
|
+
}
|
|
11867
|
+
}
|
|
11868
|
+
} : object => {
|
|
11869
|
+
target[pack_position++] = 222;
|
|
11870
|
+
let objectOffset = pack_position - start;
|
|
11871
|
+
pack_position += 2;
|
|
11872
|
+
let size = 0;
|
|
11873
|
+
for (let key in object) {
|
|
11874
|
+
if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
|
|
11875
|
+
pack(key);
|
|
11876
|
+
pack(object[key]);
|
|
11877
|
+
size++;
|
|
11878
|
+
}
|
|
11879
|
+
}
|
|
11880
|
+
if (size > 65535) {
|
|
11881
|
+
throw new Error("Object is too large to serialize with fast 16-bit map size," + ' use the "variableMapSize" option to serialize this object');
|
|
11882
|
+
}
|
|
11883
|
+
target[objectOffset++ + start] = size >> 8;
|
|
11884
|
+
target[objectOffset + start] = size & 255;
|
|
11885
|
+
};
|
|
11886
|
+
const writeRecord = this.useRecords === false ? writePlainObject : options.progressiveRecords && !useTwoByteRecords ? object => {
|
|
11887
|
+
let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null));
|
|
11888
|
+
let objectOffset = pack_position++ - start;
|
|
11889
|
+
let wroteKeys;
|
|
11890
|
+
for (let key in object) {
|
|
11891
|
+
if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
|
|
11892
|
+
nextTransition = transition[key];
|
|
11893
|
+
if (nextTransition) transition = nextTransition; else {
|
|
11894
|
+
let keys = Object.keys(object);
|
|
11895
|
+
let lastTransition = transition;
|
|
11896
|
+
transition = structures.transitions;
|
|
11897
|
+
let newTransitions = 0;
|
|
11898
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
11899
|
+
let key = keys[i];
|
|
11900
|
+
nextTransition = transition[key];
|
|
11901
|
+
if (!nextTransition) {
|
|
11902
|
+
nextTransition = transition[key] = Object.create(null);
|
|
11903
|
+
newTransitions++;
|
|
11904
|
+
}
|
|
11905
|
+
transition = nextTransition;
|
|
11906
|
+
}
|
|
11907
|
+
if (objectOffset + start + 1 == pack_position) {
|
|
11908
|
+
pack_position--;
|
|
11909
|
+
newRecord(transition, keys, newTransitions);
|
|
11910
|
+
} else insertNewRecord(transition, keys, objectOffset, newTransitions);
|
|
11911
|
+
wroteKeys = true;
|
|
11912
|
+
transition = lastTransition[key];
|
|
11913
|
+
}
|
|
11914
|
+
pack(object[key]);
|
|
11915
|
+
}
|
|
11916
|
+
}
|
|
11917
|
+
if (!wroteKeys) {
|
|
11918
|
+
let recordId = transition[RECORD_SYMBOL];
|
|
11919
|
+
if (recordId) target[objectOffset + start] = recordId; else insertNewRecord(transition, Object.keys(object), objectOffset, 0);
|
|
11920
|
+
}
|
|
11921
|
+
} : object => {
|
|
11922
|
+
let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null));
|
|
11923
|
+
let newTransitions = 0;
|
|
11924
|
+
for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
|
|
11925
|
+
nextTransition = transition[key];
|
|
11926
|
+
if (!nextTransition) {
|
|
11927
|
+
nextTransition = transition[key] = Object.create(null);
|
|
11928
|
+
newTransitions++;
|
|
11929
|
+
}
|
|
11930
|
+
transition = nextTransition;
|
|
11931
|
+
}
|
|
11932
|
+
let recordId = transition[RECORD_SYMBOL];
|
|
11933
|
+
if (recordId) {
|
|
11934
|
+
if (recordId >= 96 && useTwoByteRecords) {
|
|
11935
|
+
target[pack_position++] = ((recordId -= 96) & 31) + 96;
|
|
11936
|
+
target[pack_position++] = recordId >> 5;
|
|
11937
|
+
} else target[pack_position++] = recordId;
|
|
11938
|
+
} else {
|
|
11939
|
+
newRecord(transition, transition.__keys__ || Object.keys(object), newTransitions);
|
|
11940
|
+
}
|
|
11941
|
+
for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
|
|
11942
|
+
pack(object[key]);
|
|
11943
|
+
}
|
|
11944
|
+
};
|
|
11945
|
+
const checkUseRecords = typeof this.useRecords == "function" && this.useRecords;
|
|
11946
|
+
const writeObject = checkUseRecords ? object => {
|
|
11947
|
+
checkUseRecords(object) ? writeRecord(object) : writePlainObject(object);
|
|
11948
|
+
} : writeRecord;
|
|
11949
|
+
const makeRoom = end => {
|
|
11950
|
+
let newSize;
|
|
11951
|
+
if (end > 16777216) {
|
|
11952
|
+
if (end - start > MAX_BUFFER_SIZE) throw new Error("Packed buffer would be larger than maximum buffer size");
|
|
11953
|
+
newSize = Math.min(MAX_BUFFER_SIZE, Math.round(Math.max((end - start) * (end > 67108864 ? 1.25 : 2), 4194304) / 4096) * 4096);
|
|
11954
|
+
} else newSize = (Math.max(end - start << 2, target.length - 1) >> 12) + 1 << 12;
|
|
11955
|
+
let newBuffer = new ByteArrayAllocate(newSize);
|
|
11956
|
+
targetView = newBuffer.dataView || (newBuffer.dataView = new DataView(newBuffer.buffer, 0, newSize));
|
|
11957
|
+
end = Math.min(end, target.length);
|
|
11958
|
+
if (target.copy) target.copy(newBuffer, 0, start, end); else newBuffer.set(target.slice(start, end));
|
|
11959
|
+
pack_position -= start;
|
|
11960
|
+
start = 0;
|
|
11961
|
+
safeEnd = newBuffer.length - 10;
|
|
11962
|
+
return target = newBuffer;
|
|
11963
|
+
};
|
|
11964
|
+
const newRecord = (transition, keys, newTransitions) => {
|
|
11965
|
+
let recordId = structures.nextId;
|
|
11966
|
+
if (!recordId) recordId = 64;
|
|
11967
|
+
if (recordId < sharedLimitId && this.shouldShareStructure && !this.shouldShareStructure(keys)) {
|
|
11968
|
+
recordId = structures.nextOwnId;
|
|
11969
|
+
if (!(recordId < maxStructureId)) recordId = sharedLimitId;
|
|
11970
|
+
structures.nextOwnId = recordId + 1;
|
|
11971
|
+
} else {
|
|
11972
|
+
if (recordId >= maxStructureId) recordId = sharedLimitId;
|
|
11973
|
+
structures.nextId = recordId + 1;
|
|
11974
|
+
}
|
|
11975
|
+
let highByte = keys.highByte = recordId >= 96 && useTwoByteRecords ? recordId - 96 >> 5 : -1;
|
|
11976
|
+
transition[RECORD_SYMBOL] = recordId;
|
|
11977
|
+
transition.__keys__ = keys;
|
|
11978
|
+
structures[recordId - 64] = keys;
|
|
11979
|
+
if (recordId < sharedLimitId) {
|
|
11980
|
+
keys.isShared = true;
|
|
11981
|
+
structures.sharedLength = recordId - 63;
|
|
11982
|
+
hasSharedUpdate = true;
|
|
11983
|
+
if (highByte >= 0) {
|
|
11984
|
+
target[pack_position++] = (recordId & 31) + 96;
|
|
11985
|
+
target[pack_position++] = highByte;
|
|
11986
|
+
} else {
|
|
11987
|
+
target[pack_position++] = recordId;
|
|
11988
|
+
}
|
|
11989
|
+
} else {
|
|
11990
|
+
if (highByte >= 0) {
|
|
11991
|
+
target[pack_position++] = 213;
|
|
11992
|
+
target[pack_position++] = 114;
|
|
11993
|
+
target[pack_position++] = (recordId & 31) + 96;
|
|
11994
|
+
target[pack_position++] = highByte;
|
|
11995
|
+
} else {
|
|
11996
|
+
target[pack_position++] = 212;
|
|
11997
|
+
target[pack_position++] = 114;
|
|
11998
|
+
target[pack_position++] = recordId;
|
|
11999
|
+
}
|
|
12000
|
+
if (newTransitions) transitionsCount += serializationsSinceTransitionRebuild * newTransitions;
|
|
12001
|
+
if (recordIdsToRemove.length >= maxOwnStructures) recordIdsToRemove.shift()[RECORD_SYMBOL] = 0;
|
|
12002
|
+
recordIdsToRemove.push(transition);
|
|
12003
|
+
pack(keys);
|
|
12004
|
+
}
|
|
12005
|
+
};
|
|
12006
|
+
const insertNewRecord = (transition, keys, insertionOffset, newTransitions) => {
|
|
12007
|
+
let mainTarget = target;
|
|
12008
|
+
let mainPosition = pack_position;
|
|
12009
|
+
let mainSafeEnd = safeEnd;
|
|
12010
|
+
let mainStart = start;
|
|
12011
|
+
target = keysTarget;
|
|
12012
|
+
pack_position = 0;
|
|
12013
|
+
start = 0;
|
|
12014
|
+
if (!target) keysTarget = target = new ByteArrayAllocate(8192);
|
|
12015
|
+
safeEnd = target.length - 10;
|
|
12016
|
+
newRecord(transition, keys, newTransitions);
|
|
12017
|
+
keysTarget = target;
|
|
12018
|
+
let keysPosition = pack_position;
|
|
12019
|
+
target = mainTarget;
|
|
12020
|
+
pack_position = mainPosition;
|
|
12021
|
+
safeEnd = mainSafeEnd;
|
|
12022
|
+
start = mainStart;
|
|
12023
|
+
if (keysPosition > 1) {
|
|
12024
|
+
let newEnd = pack_position + keysPosition - 1;
|
|
12025
|
+
if (newEnd > safeEnd) makeRoom(newEnd);
|
|
12026
|
+
let insertionPosition = insertionOffset + start;
|
|
12027
|
+
target.copyWithin(insertionPosition + keysPosition, insertionPosition + 1, pack_position);
|
|
12028
|
+
target.set(keysTarget.slice(0, keysPosition), insertionPosition);
|
|
12029
|
+
pack_position = newEnd;
|
|
12030
|
+
} else {
|
|
12031
|
+
target[insertionOffset + start] = keysTarget[0];
|
|
12032
|
+
}
|
|
12033
|
+
};
|
|
12034
|
+
const writeStruct = object => {
|
|
12035
|
+
let newPosition = writeStructSlots(object, target, start, pack_position, structures, makeRoom, ((value, newPosition, notifySharedUpdate) => {
|
|
12036
|
+
if (notifySharedUpdate) return hasSharedUpdate = true;
|
|
12037
|
+
pack_position = newPosition;
|
|
12038
|
+
let startTarget = target;
|
|
12039
|
+
pack(value);
|
|
12040
|
+
resetStructures();
|
|
12041
|
+
if (startTarget !== target) {
|
|
12042
|
+
return {
|
|
12043
|
+
position: pack_position,
|
|
12044
|
+
targetView,
|
|
12045
|
+
target
|
|
12046
|
+
};
|
|
12047
|
+
}
|
|
12048
|
+
return pack_position;
|
|
12049
|
+
}), this);
|
|
12050
|
+
if (newPosition === 0) return writeObject(object);
|
|
12051
|
+
pack_position = newPosition;
|
|
12052
|
+
};
|
|
12053
|
+
}
|
|
12054
|
+
useBuffer(buffer) {
|
|
12055
|
+
target = buffer;
|
|
12056
|
+
target.dataView || (target.dataView = new DataView(target.buffer, target.byteOffset, target.byteLength));
|
|
12057
|
+
pack_position = 0;
|
|
12058
|
+
}
|
|
12059
|
+
set position(value) {
|
|
12060
|
+
pack_position = value;
|
|
12061
|
+
}
|
|
12062
|
+
get position() {
|
|
12063
|
+
return pack_position;
|
|
12064
|
+
}
|
|
12065
|
+
clearSharedData() {
|
|
12066
|
+
if (this.structures) this.structures = [];
|
|
12067
|
+
if (this.typedStructs) this.typedStructs = [];
|
|
12068
|
+
}
|
|
12069
|
+
}
|
|
12070
|
+
extensionClasses = [ Date, Set, Error, RegExp, ArrayBuffer, Object.getPrototypeOf(Uint8Array.prototype).constructor, C1Type ];
|
|
12071
|
+
extensions = [ {
|
|
12072
|
+
pack(date, allocateForWrite, pack) {
|
|
12073
|
+
let seconds = date.getTime() / 1e3;
|
|
12074
|
+
if ((this.useTimestamp32 || date.getMilliseconds() === 0) && seconds >= 0 && seconds < 4294967296) {
|
|
12075
|
+
let {target, targetView, position} = allocateForWrite(6);
|
|
12076
|
+
target[position++] = 214;
|
|
12077
|
+
target[position++] = 255;
|
|
12078
|
+
targetView.setUint32(position, seconds);
|
|
12079
|
+
} else if (seconds > 0 && seconds < 4294967296) {
|
|
12080
|
+
let {target, targetView, position} = allocateForWrite(10);
|
|
12081
|
+
target[position++] = 215;
|
|
12082
|
+
target[position++] = 255;
|
|
12083
|
+
targetView.setUint32(position, date.getMilliseconds() * 4e6 + (seconds / 1e3 / 4294967296 >> 0));
|
|
12084
|
+
targetView.setUint32(position + 4, seconds);
|
|
12085
|
+
} else if (isNaN(seconds)) {
|
|
12086
|
+
if (this.onInvalidDate) {
|
|
12087
|
+
allocateForWrite(0);
|
|
12088
|
+
return pack(this.onInvalidDate());
|
|
12089
|
+
}
|
|
12090
|
+
let {target, targetView, position} = allocateForWrite(3);
|
|
12091
|
+
target[position++] = 212;
|
|
12092
|
+
target[position++] = 255;
|
|
12093
|
+
target[position++] = 255;
|
|
12094
|
+
} else {
|
|
12095
|
+
let {target, targetView, position} = allocateForWrite(15);
|
|
12096
|
+
target[position++] = 199;
|
|
12097
|
+
target[position++] = 12;
|
|
12098
|
+
target[position++] = 255;
|
|
12099
|
+
targetView.setUint32(position, date.getMilliseconds() * 1e6);
|
|
12100
|
+
targetView.setBigInt64(position + 4, BigInt(Math.floor(seconds)));
|
|
12101
|
+
}
|
|
12102
|
+
}
|
|
12103
|
+
}, {
|
|
12104
|
+
pack(set, allocateForWrite, pack) {
|
|
12105
|
+
if (this.setAsEmptyObject) {
|
|
12106
|
+
allocateForWrite(0);
|
|
12107
|
+
return pack({});
|
|
12108
|
+
}
|
|
12109
|
+
let array = Array.from(set);
|
|
12110
|
+
let {target, position} = allocateForWrite(this.moreTypes ? 3 : 0);
|
|
12111
|
+
if (this.moreTypes) {
|
|
12112
|
+
target[position++] = 212;
|
|
12113
|
+
target[position++] = 115;
|
|
12114
|
+
target[position++] = 0;
|
|
12115
|
+
}
|
|
12116
|
+
pack(array);
|
|
12117
|
+
}
|
|
12118
|
+
}, {
|
|
12119
|
+
pack(error, allocateForWrite, pack) {
|
|
12120
|
+
let {target, position} = allocateForWrite(this.moreTypes ? 3 : 0);
|
|
12121
|
+
if (this.moreTypes) {
|
|
12122
|
+
target[position++] = 212;
|
|
12123
|
+
target[position++] = 101;
|
|
12124
|
+
target[position++] = 0;
|
|
12125
|
+
}
|
|
12126
|
+
pack([ error.name, error.message, error.cause ]);
|
|
12127
|
+
}
|
|
12128
|
+
}, {
|
|
12129
|
+
pack(regex, allocateForWrite, pack) {
|
|
12130
|
+
let {target, position} = allocateForWrite(this.moreTypes ? 3 : 0);
|
|
12131
|
+
if (this.moreTypes) {
|
|
12132
|
+
target[position++] = 212;
|
|
12133
|
+
target[position++] = 120;
|
|
12134
|
+
target[position++] = 0;
|
|
12135
|
+
}
|
|
12136
|
+
pack([ regex.source, regex.flags ]);
|
|
12137
|
+
}
|
|
12138
|
+
}, {
|
|
12139
|
+
pack(arrayBuffer, allocateForWrite) {
|
|
12140
|
+
if (this.moreTypes) writeExtBuffer(arrayBuffer, 16, allocateForWrite); else writeBuffer(hasNodeBuffer ? pack_Buffer.from(arrayBuffer) : new Uint8Array(arrayBuffer), allocateForWrite);
|
|
12141
|
+
}
|
|
12142
|
+
}, {
|
|
12143
|
+
pack(typedArray, allocateForWrite) {
|
|
12144
|
+
let constructor = typedArray.constructor;
|
|
12145
|
+
if (constructor !== ByteArray && this.moreTypes) writeExtBuffer(typedArray, typedArrays.indexOf(constructor.name), allocateForWrite); else writeBuffer(typedArray, allocateForWrite);
|
|
12146
|
+
}
|
|
12147
|
+
}, {
|
|
12148
|
+
pack(c1, allocateForWrite) {
|
|
12149
|
+
let {target, position} = allocateForWrite(1);
|
|
12150
|
+
target[position] = 193;
|
|
12151
|
+
}
|
|
12152
|
+
} ];
|
|
12153
|
+
function writeExtBuffer(typedArray, type, allocateForWrite, encode) {
|
|
12154
|
+
let length = typedArray.byteLength;
|
|
12155
|
+
if (length + 1 < 256) {
|
|
12156
|
+
var {target, position} = allocateForWrite(4 + length);
|
|
12157
|
+
target[position++] = 199;
|
|
12158
|
+
target[position++] = length + 1;
|
|
12159
|
+
} else if (length + 1 < 65536) {
|
|
12160
|
+
var {target, position} = allocateForWrite(5 + length);
|
|
12161
|
+
target[position++] = 200;
|
|
12162
|
+
target[position++] = length + 1 >> 8;
|
|
12163
|
+
target[position++] = length + 1 & 255;
|
|
12164
|
+
} else {
|
|
12165
|
+
var {target, position, targetView} = allocateForWrite(7 + length);
|
|
12166
|
+
target[position++] = 201;
|
|
12167
|
+
targetView.setUint32(position, length + 1);
|
|
12168
|
+
position += 4;
|
|
12169
|
+
}
|
|
12170
|
+
target[position++] = 116;
|
|
12171
|
+
target[position++] = type;
|
|
12172
|
+
if (!typedArray.buffer) typedArray = new Uint8Array(typedArray);
|
|
12173
|
+
target.set(new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength), position);
|
|
12174
|
+
}
|
|
12175
|
+
function writeBuffer(buffer, allocateForWrite) {
|
|
12176
|
+
let length = buffer.byteLength;
|
|
12177
|
+
var target, position;
|
|
12178
|
+
if (length < 256) {
|
|
12179
|
+
var {target, position} = allocateForWrite(length + 2);
|
|
12180
|
+
target[position++] = 196;
|
|
12181
|
+
target[position++] = length;
|
|
12182
|
+
} else if (length < 65536) {
|
|
12183
|
+
var {target, position} = allocateForWrite(length + 3);
|
|
12184
|
+
target[position++] = 197;
|
|
12185
|
+
target[position++] = length >> 8;
|
|
12186
|
+
target[position++] = length & 255;
|
|
12187
|
+
} else {
|
|
12188
|
+
var {target, position, targetView} = allocateForWrite(length + 5);
|
|
12189
|
+
target[position++] = 198;
|
|
12190
|
+
targetView.setUint32(position, length);
|
|
12191
|
+
position += 4;
|
|
12192
|
+
}
|
|
12193
|
+
target.set(buffer, position);
|
|
12194
|
+
}
|
|
12195
|
+
function writeExtensionData(result, target, position, type) {
|
|
12196
|
+
let length = result.length;
|
|
12197
|
+
switch (length) {
|
|
12198
|
+
case 1:
|
|
12199
|
+
target[position++] = 212;
|
|
12200
|
+
break;
|
|
12201
|
+
|
|
12202
|
+
case 2:
|
|
12203
|
+
target[position++] = 213;
|
|
12204
|
+
break;
|
|
12205
|
+
|
|
12206
|
+
case 4:
|
|
12207
|
+
target[position++] = 214;
|
|
12208
|
+
break;
|
|
12209
|
+
|
|
12210
|
+
case 8:
|
|
12211
|
+
target[position++] = 215;
|
|
12212
|
+
break;
|
|
12213
|
+
|
|
12214
|
+
case 16:
|
|
12215
|
+
target[position++] = 216;
|
|
12216
|
+
break;
|
|
12217
|
+
|
|
12218
|
+
default:
|
|
12219
|
+
if (length < 256) {
|
|
12220
|
+
target[position++] = 199;
|
|
12221
|
+
target[position++] = length;
|
|
12222
|
+
} else if (length < 65536) {
|
|
12223
|
+
target[position++] = 200;
|
|
12224
|
+
target[position++] = length >> 8;
|
|
12225
|
+
target[position++] = length & 255;
|
|
12226
|
+
} else {
|
|
12227
|
+
target[position++] = 201;
|
|
12228
|
+
target[position++] = length >> 24;
|
|
12229
|
+
target[position++] = length >> 16 & 255;
|
|
12230
|
+
target[position++] = length >> 8 & 255;
|
|
12231
|
+
target[position++] = length & 255;
|
|
12232
|
+
}
|
|
12233
|
+
}
|
|
12234
|
+
target[position++] = type;
|
|
12235
|
+
target.set(result, position);
|
|
12236
|
+
position += length;
|
|
12237
|
+
return position;
|
|
12238
|
+
}
|
|
12239
|
+
function insertIds(serialized, idsToInsert) {
|
|
12240
|
+
let nextId;
|
|
12241
|
+
let distanceToMove = idsToInsert.length * 6;
|
|
12242
|
+
let lastEnd = serialized.length - distanceToMove;
|
|
12243
|
+
while (nextId = idsToInsert.pop()) {
|
|
12244
|
+
let offset = nextId.offset;
|
|
12245
|
+
let id = nextId.id;
|
|
12246
|
+
serialized.copyWithin(offset + distanceToMove, offset, lastEnd);
|
|
12247
|
+
distanceToMove -= 6;
|
|
12248
|
+
let position = offset + distanceToMove;
|
|
12249
|
+
serialized[position++] = 214;
|
|
12250
|
+
serialized[position++] = 105;
|
|
12251
|
+
serialized[position++] = id >> 24;
|
|
12252
|
+
serialized[position++] = id >> 16 & 255;
|
|
12253
|
+
serialized[position++] = id >> 8 & 255;
|
|
12254
|
+
serialized[position++] = id & 255;
|
|
12255
|
+
lastEnd = offset;
|
|
12256
|
+
}
|
|
12257
|
+
return serialized;
|
|
12258
|
+
}
|
|
12259
|
+
function writeBundles(start, pack, incrementPosition) {
|
|
12260
|
+
if (pack_bundledStrings.length > 0) {
|
|
12261
|
+
targetView.setUint32(pack_bundledStrings.position + start, pack_position + incrementPosition - pack_bundledStrings.position - start);
|
|
12262
|
+
pack_bundledStrings.stringsPosition = pack_position - start;
|
|
12263
|
+
let writeStrings = pack_bundledStrings;
|
|
12264
|
+
pack_bundledStrings = null;
|
|
12265
|
+
pack(writeStrings[0]);
|
|
12266
|
+
pack(writeStrings[1]);
|
|
12267
|
+
}
|
|
12268
|
+
}
|
|
12269
|
+
function pack_addExtension(extension) {
|
|
12270
|
+
if (extension.Class) {
|
|
12271
|
+
if (!extension.pack && !extension.write) throw new Error("Extension has no pack or write function");
|
|
12272
|
+
if (extension.pack && !extension.type) throw new Error("Extension has no type (numeric code to identify the extension)");
|
|
12273
|
+
extensionClasses.unshift(extension.Class);
|
|
12274
|
+
extensions.unshift(extension);
|
|
12275
|
+
}
|
|
12276
|
+
unpackAddExtension(extension);
|
|
12277
|
+
}
|
|
12278
|
+
function prepareStructures(structures, packr) {
|
|
12279
|
+
structures.isCompatible = existingStructures => {
|
|
12280
|
+
let compatible = !existingStructures || (packr.lastNamedStructuresLength || 0) === existingStructures.length;
|
|
12281
|
+
if (!compatible) packr._mergeStructures(existingStructures);
|
|
12282
|
+
return compatible;
|
|
12283
|
+
};
|
|
12284
|
+
return structures;
|
|
12285
|
+
}
|
|
12286
|
+
function setWriteStructSlots(writeSlots, makeStructures) {
|
|
12287
|
+
writeStructSlots = writeSlots;
|
|
12288
|
+
prepareStructures = makeStructures;
|
|
12289
|
+
}
|
|
12290
|
+
let defaultPackr = new Packr({
|
|
12291
|
+
useRecords: false
|
|
12292
|
+
});
|
|
12293
|
+
const pack = defaultPackr.pack;
|
|
12294
|
+
const encode = defaultPackr.pack;
|
|
12295
|
+
const Encoder = Packr;
|
|
12296
|
+
const {NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT} = FLOAT32_OPTIONS;
|
|
12297
|
+
const REUSE_BUFFER_MODE = 512;
|
|
12298
|
+
const RESET_BUFFER_MODE = 1024;
|
|
12299
|
+
const RESERVE_START_SPACE = 2048;
|
|
10384
12300
|
var backend_Buffer = __webpack_require__(764)["lW"];
|
|
10385
12301
|
class AztecClientBackendError extends Error {
|
|
10386
12302
|
constructor(message) {
|
|
10387
12303
|
super(message);
|
|
10388
12304
|
}
|
|
10389
12305
|
}
|
|
12306
|
+
function parseBigEndianU32Array(buffer) {
|
|
12307
|
+
const dv = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
12308
|
+
let offset = 0;
|
|
12309
|
+
const count = buffer.byteLength >>> 2;
|
|
12310
|
+
console.log(buffer);
|
|
12311
|
+
const out = new Array(count);
|
|
12312
|
+
for (let i = 0; i < count; i++) {
|
|
12313
|
+
out[i] = dv.getUint32(offset, false);
|
|
12314
|
+
offset += 4;
|
|
12315
|
+
}
|
|
12316
|
+
return out;
|
|
12317
|
+
}
|
|
10390
12318
|
class UltraPlonkBackend {
|
|
10391
12319
|
constructor(acirBytecode, backendOptions = {
|
|
10392
12320
|
threads: 1
|
|
@@ -10524,11 +12452,29 @@ var __webpack_exports__ = {};
|
|
|
10524
12452
|
await this.api.destroy();
|
|
10525
12453
|
}
|
|
10526
12454
|
}
|
|
12455
|
+
function serializeAztecClientExecutionSteps(acirBuf, witnessBuf, vksBuf) {
|
|
12456
|
+
const steps = [];
|
|
12457
|
+
for (let i = 0; i < acirBuf.length; i++) {
|
|
12458
|
+
const bytecode = acirBuf[i];
|
|
12459
|
+
const witness = witnessBuf[i] || backend_Buffer.from([]);
|
|
12460
|
+
const vk = vksBuf[i] || backend_Buffer.from([]);
|
|
12461
|
+
const functionName = `unknown_wasm_${i}`;
|
|
12462
|
+
steps.push({
|
|
12463
|
+
bytecode,
|
|
12464
|
+
witness,
|
|
12465
|
+
vk,
|
|
12466
|
+
functionName
|
|
12467
|
+
});
|
|
12468
|
+
}
|
|
12469
|
+
return new Encoder({
|
|
12470
|
+
useRecords: false
|
|
12471
|
+
}).pack(steps);
|
|
12472
|
+
}
|
|
10527
12473
|
class AztecClientBackend {
|
|
10528
|
-
constructor(
|
|
12474
|
+
constructor(acirBuf, options = {
|
|
10529
12475
|
threads: 1
|
|
10530
12476
|
}) {
|
|
10531
|
-
this.
|
|
12477
|
+
this.acirBuf = acirBuf;
|
|
10532
12478
|
this.options = options;
|
|
10533
12479
|
}
|
|
10534
12480
|
async instantiate() {
|
|
@@ -10538,9 +12484,16 @@ var __webpack_exports__ = {};
|
|
|
10538
12484
|
this.api = api;
|
|
10539
12485
|
}
|
|
10540
12486
|
}
|
|
10541
|
-
async prove(
|
|
12487
|
+
async prove(witnessBuf, vksBuf = []) {
|
|
12488
|
+
if (vksBuf.length !== 0 && this.acirBuf.length !== witnessBuf.length) {
|
|
12489
|
+
throw new AztecClientBackendError("Witness and bytecodes must have the same stack depth!");
|
|
12490
|
+
}
|
|
12491
|
+
if (vksBuf.length !== 0 && vksBuf.length !== witnessBuf.length) {
|
|
12492
|
+
throw new AztecClientBackendError("Witness and VKs must have the same stack depth!");
|
|
12493
|
+
}
|
|
10542
12494
|
await this.instantiate();
|
|
10543
|
-
const
|
|
12495
|
+
const ivcInputsBuf = serializeAztecClientExecutionSteps(this.acirBuf, witnessBuf, vksBuf);
|
|
12496
|
+
const proofAndVk = await this.api.acirProveAztecClient(ivcInputsBuf);
|
|
10544
12497
|
const [proof, vk] = proofAndVk;
|
|
10545
12498
|
if (!await this.verify(proof, vk)) {
|
|
10546
12499
|
throw new AztecClientBackendError("Failed to verify the private (ClientIVC) transaction proof!");
|
|
@@ -10551,13 +12504,11 @@ var __webpack_exports__ = {};
|
|
|
10551
12504
|
await this.instantiate();
|
|
10552
12505
|
return this.api.acirVerifyAztecClient(proof, vk);
|
|
10553
12506
|
}
|
|
10554
|
-
async proveAndVerify(witnessMsgpack) {
|
|
10555
|
-
await this.instantiate();
|
|
10556
|
-
return this.api.acirProveAndVerifyAztecClient(this.acirMsgpack, witnessMsgpack);
|
|
10557
|
-
}
|
|
10558
12507
|
async gates() {
|
|
10559
12508
|
await this.instantiate();
|
|
10560
|
-
|
|
12509
|
+
const ivcInputsBuf = serializeAztecClientExecutionSteps(this.acirBuf, [], []);
|
|
12510
|
+
const resultBuffer = await this.api.acirGatesAztecClient(ivcInputsBuf);
|
|
12511
|
+
return parseBigEndianU32Array(resultBuffer);
|
|
10561
12512
|
}
|
|
10562
12513
|
async destroy() {
|
|
10563
12514
|
if (!this.api) {
|