@0dotxyz/p0-ts-sdk 2.2.0-beta.0 → 2.2.0-beta.2
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/dist/index.cjs +23 -1454
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -10
- package/dist/index.d.ts +4 -10
- package/dist/index.js +21 -1452
- package/dist/index.js.map +1 -1
- package/dist/vendor.cjs +3 -1434
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.js +1 -1432
- package/dist/vendor.js.map +1 -1
- package/package.json +2 -7
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { deserialize } from 'borsh';
|
|
|
11
11
|
import * as borsh from '@coral-xyz/borsh';
|
|
12
12
|
import { struct as struct$1, bool as bool$1, publicKey as publicKey$1, array as array$1, u64 as u64$1, u8 as u8$1, u32 as u32$1, u128 } from '@coral-xyz/borsh';
|
|
13
13
|
import WebSocket from 'ws';
|
|
14
|
+
import { Encoder, Decoder } from '@msgpack/msgpack';
|
|
14
15
|
import { SwapApi, Configuration, createJupiterApiClient } from '@jup-ag/api';
|
|
15
16
|
import { AnchorUtils, PullFeed } from '@switchboard-xyz/on-demand';
|
|
16
17
|
import { CrossbarClient } from '@switchboard-xyz/common';
|
|
@@ -16158,7 +16159,7 @@ function parseEmodeSettingsRaw(emodeSettingsRaw) {
|
|
|
16158
16159
|
};
|
|
16159
16160
|
return emodeSettings;
|
|
16160
16161
|
}
|
|
16161
|
-
function parseBankRaw(address, accountParsed, bankMetadata
|
|
16162
|
+
function parseBankRaw(address, accountParsed, bankMetadata) {
|
|
16162
16163
|
const flags = accountParsed.flags.toNumber();
|
|
16163
16164
|
const mint = accountParsed.mint;
|
|
16164
16165
|
const mintDecimals = accountParsed.mintDecimals;
|
|
@@ -16257,8 +16258,6 @@ function parseBankRaw(address, accountParsed, bankMetadata, mintData) {
|
|
|
16257
16258
|
borrowingPositionCount,
|
|
16258
16259
|
emode,
|
|
16259
16260
|
tokenSymbol,
|
|
16260
|
-
mintRate: mintData?.mintRate ?? null,
|
|
16261
|
-
mintPrice: mintData?.mintPrice ?? 0,
|
|
16262
16261
|
kaminoIntegrationAccounts,
|
|
16263
16262
|
driftIntegrationAccounts,
|
|
16264
16263
|
solendIntegrationAccounts,
|
|
@@ -16299,9 +16298,6 @@ function dtoToBank(bankDto) {
|
|
|
16299
16298
|
feesDestinationAccount: bankDto.feesDestinationAccount ? new PublicKey(bankDto.feesDestinationAccount) : void 0,
|
|
16300
16299
|
lendingPositionCount: bankDto.lendingPositionCount ? new BigNumber3(bankDto.lendingPositionCount) : void 0,
|
|
16301
16300
|
borrowingPositionCount: bankDto.borrowingPositionCount ? new BigNumber3(bankDto.borrowingPositionCount) : void 0,
|
|
16302
|
-
mintRate: null,
|
|
16303
|
-
// TODO: move these out
|
|
16304
|
-
mintPrice: 0,
|
|
16305
16301
|
kaminoIntegrationAccounts: bankDto.kaminoIntegrationAccounts ? {
|
|
16306
16302
|
kaminoReserve: new PublicKey(bankDto.kaminoIntegrationAccounts.kaminoReserve),
|
|
16307
16303
|
kaminoObligation: new PublicKey(bankDto.kaminoIntegrationAccounts.kaminoObligation)
|
|
@@ -44079,1438 +44075,6 @@ function makeUpdateJupLendRate({ lendingState }) {
|
|
|
44079
44075
|
lendingState.rewardsRateModel
|
|
44080
44076
|
);
|
|
44081
44077
|
}
|
|
44082
|
-
|
|
44083
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
|
|
44084
|
-
function utf8Count(str) {
|
|
44085
|
-
const strLength = str.length;
|
|
44086
|
-
let byteLength = 0;
|
|
44087
|
-
let pos = 0;
|
|
44088
|
-
while (pos < strLength) {
|
|
44089
|
-
let value = str.charCodeAt(pos++);
|
|
44090
|
-
if ((value & 4294967168) === 0) {
|
|
44091
|
-
byteLength++;
|
|
44092
|
-
continue;
|
|
44093
|
-
} else if ((value & 4294965248) === 0) {
|
|
44094
|
-
byteLength += 2;
|
|
44095
|
-
} else {
|
|
44096
|
-
if (value >= 55296 && value <= 56319) {
|
|
44097
|
-
if (pos < strLength) {
|
|
44098
|
-
const extra = str.charCodeAt(pos);
|
|
44099
|
-
if ((extra & 64512) === 56320) {
|
|
44100
|
-
++pos;
|
|
44101
|
-
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
44102
|
-
}
|
|
44103
|
-
}
|
|
44104
|
-
}
|
|
44105
|
-
if ((value & 4294901760) === 0) {
|
|
44106
|
-
byteLength += 3;
|
|
44107
|
-
} else {
|
|
44108
|
-
byteLength += 4;
|
|
44109
|
-
}
|
|
44110
|
-
}
|
|
44111
|
-
}
|
|
44112
|
-
return byteLength;
|
|
44113
|
-
}
|
|
44114
|
-
function utf8EncodeJs(str, output, outputOffset) {
|
|
44115
|
-
const strLength = str.length;
|
|
44116
|
-
let offset = outputOffset;
|
|
44117
|
-
let pos = 0;
|
|
44118
|
-
while (pos < strLength) {
|
|
44119
|
-
let value = str.charCodeAt(pos++);
|
|
44120
|
-
if ((value & 4294967168) === 0) {
|
|
44121
|
-
output[offset++] = value;
|
|
44122
|
-
continue;
|
|
44123
|
-
} else if ((value & 4294965248) === 0) {
|
|
44124
|
-
output[offset++] = value >> 6 & 31 | 192;
|
|
44125
|
-
} else {
|
|
44126
|
-
if (value >= 55296 && value <= 56319) {
|
|
44127
|
-
if (pos < strLength) {
|
|
44128
|
-
const extra = str.charCodeAt(pos);
|
|
44129
|
-
if ((extra & 64512) === 56320) {
|
|
44130
|
-
++pos;
|
|
44131
|
-
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
44132
|
-
}
|
|
44133
|
-
}
|
|
44134
|
-
}
|
|
44135
|
-
if ((value & 4294901760) === 0) {
|
|
44136
|
-
output[offset++] = value >> 12 & 15 | 224;
|
|
44137
|
-
output[offset++] = value >> 6 & 63 | 128;
|
|
44138
|
-
} else {
|
|
44139
|
-
output[offset++] = value >> 18 & 7 | 240;
|
|
44140
|
-
output[offset++] = value >> 12 & 63 | 128;
|
|
44141
|
-
output[offset++] = value >> 6 & 63 | 128;
|
|
44142
|
-
}
|
|
44143
|
-
}
|
|
44144
|
-
output[offset++] = value & 63 | 128;
|
|
44145
|
-
}
|
|
44146
|
-
}
|
|
44147
|
-
var sharedTextEncoder = new TextEncoder();
|
|
44148
|
-
var TEXT_ENCODER_THRESHOLD = 50;
|
|
44149
|
-
function utf8EncodeTE(str, output, outputOffset) {
|
|
44150
|
-
sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
|
|
44151
|
-
}
|
|
44152
|
-
function utf8Encode(str, output, outputOffset) {
|
|
44153
|
-
if (str.length > TEXT_ENCODER_THRESHOLD) {
|
|
44154
|
-
utf8EncodeTE(str, output, outputOffset);
|
|
44155
|
-
} else {
|
|
44156
|
-
utf8EncodeJs(str, output, outputOffset);
|
|
44157
|
-
}
|
|
44158
|
-
}
|
|
44159
|
-
var CHUNK_SIZE = 4096;
|
|
44160
|
-
function utf8DecodeJs(bytes, inputOffset, byteLength) {
|
|
44161
|
-
let offset = inputOffset;
|
|
44162
|
-
const end = offset + byteLength;
|
|
44163
|
-
const units = [];
|
|
44164
|
-
let result = "";
|
|
44165
|
-
while (offset < end) {
|
|
44166
|
-
const byte1 = bytes[offset++];
|
|
44167
|
-
if ((byte1 & 128) === 0) {
|
|
44168
|
-
units.push(byte1);
|
|
44169
|
-
} else if ((byte1 & 224) === 192) {
|
|
44170
|
-
const byte2 = bytes[offset++] & 63;
|
|
44171
|
-
units.push((byte1 & 31) << 6 | byte2);
|
|
44172
|
-
} else if ((byte1 & 240) === 224) {
|
|
44173
|
-
const byte2 = bytes[offset++] & 63;
|
|
44174
|
-
const byte3 = bytes[offset++] & 63;
|
|
44175
|
-
units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
|
|
44176
|
-
} else if ((byte1 & 248) === 240) {
|
|
44177
|
-
const byte2 = bytes[offset++] & 63;
|
|
44178
|
-
const byte3 = bytes[offset++] & 63;
|
|
44179
|
-
const byte4 = bytes[offset++] & 63;
|
|
44180
|
-
let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
|
|
44181
|
-
if (unit > 65535) {
|
|
44182
|
-
unit -= 65536;
|
|
44183
|
-
units.push(unit >>> 10 & 1023 | 55296);
|
|
44184
|
-
unit = 56320 | unit & 1023;
|
|
44185
|
-
}
|
|
44186
|
-
units.push(unit);
|
|
44187
|
-
} else {
|
|
44188
|
-
units.push(byte1);
|
|
44189
|
-
}
|
|
44190
|
-
if (units.length >= CHUNK_SIZE) {
|
|
44191
|
-
result += String.fromCharCode(...units);
|
|
44192
|
-
units.length = 0;
|
|
44193
|
-
}
|
|
44194
|
-
}
|
|
44195
|
-
if (units.length > 0) {
|
|
44196
|
-
result += String.fromCharCode(...units);
|
|
44197
|
-
}
|
|
44198
|
-
return result;
|
|
44199
|
-
}
|
|
44200
|
-
var sharedTextDecoder = new TextDecoder();
|
|
44201
|
-
var TEXT_DECODER_THRESHOLD = 200;
|
|
44202
|
-
function utf8DecodeTD(bytes, inputOffset, byteLength) {
|
|
44203
|
-
const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
|
|
44204
|
-
return sharedTextDecoder.decode(stringBytes);
|
|
44205
|
-
}
|
|
44206
|
-
function utf8Decode(bytes, inputOffset, byteLength) {
|
|
44207
|
-
if (byteLength > TEXT_DECODER_THRESHOLD) {
|
|
44208
|
-
return utf8DecodeTD(bytes, inputOffset, byteLength);
|
|
44209
|
-
} else {
|
|
44210
|
-
return utf8DecodeJs(bytes, inputOffset, byteLength);
|
|
44211
|
-
}
|
|
44212
|
-
}
|
|
44213
|
-
|
|
44214
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs
|
|
44215
|
-
var ExtData = class {
|
|
44216
|
-
type;
|
|
44217
|
-
data;
|
|
44218
|
-
constructor(type, data) {
|
|
44219
|
-
this.type = type;
|
|
44220
|
-
this.data = data;
|
|
44221
|
-
}
|
|
44222
|
-
};
|
|
44223
|
-
|
|
44224
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs
|
|
44225
|
-
var DecodeError = class _DecodeError extends Error {
|
|
44226
|
-
constructor(message) {
|
|
44227
|
-
super(message);
|
|
44228
|
-
const proto = Object.create(_DecodeError.prototype);
|
|
44229
|
-
Object.setPrototypeOf(this, proto);
|
|
44230
|
-
Object.defineProperty(this, "name", {
|
|
44231
|
-
configurable: true,
|
|
44232
|
-
enumerable: false,
|
|
44233
|
-
value: _DecodeError.name
|
|
44234
|
-
});
|
|
44235
|
-
}
|
|
44236
|
-
};
|
|
44237
|
-
|
|
44238
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs
|
|
44239
|
-
var UINT32_MAX = 4294967295;
|
|
44240
|
-
function setUint64(view, offset, value) {
|
|
44241
|
-
const high = value / 4294967296;
|
|
44242
|
-
const low = value;
|
|
44243
|
-
view.setUint32(offset, high);
|
|
44244
|
-
view.setUint32(offset + 4, low);
|
|
44245
|
-
}
|
|
44246
|
-
function setInt64(view, offset, value) {
|
|
44247
|
-
const high = Math.floor(value / 4294967296);
|
|
44248
|
-
const low = value;
|
|
44249
|
-
view.setUint32(offset, high);
|
|
44250
|
-
view.setUint32(offset + 4, low);
|
|
44251
|
-
}
|
|
44252
|
-
function getInt64(view, offset) {
|
|
44253
|
-
const high = view.getInt32(offset);
|
|
44254
|
-
const low = view.getUint32(offset + 4);
|
|
44255
|
-
return high * 4294967296 + low;
|
|
44256
|
-
}
|
|
44257
|
-
function getUint64(view, offset) {
|
|
44258
|
-
const high = view.getUint32(offset);
|
|
44259
|
-
const low = view.getUint32(offset + 4);
|
|
44260
|
-
return high * 4294967296 + low;
|
|
44261
|
-
}
|
|
44262
|
-
|
|
44263
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs
|
|
44264
|
-
var EXT_TIMESTAMP = -1;
|
|
44265
|
-
var TIMESTAMP32_MAX_SEC = 4294967296 - 1;
|
|
44266
|
-
var TIMESTAMP64_MAX_SEC = 17179869184 - 1;
|
|
44267
|
-
function encodeTimeSpecToTimestamp({ sec, nsec }) {
|
|
44268
|
-
if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
|
|
44269
|
-
if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
|
|
44270
|
-
const rv = new Uint8Array(4);
|
|
44271
|
-
const view = new DataView(rv.buffer);
|
|
44272
|
-
view.setUint32(0, sec);
|
|
44273
|
-
return rv;
|
|
44274
|
-
} else {
|
|
44275
|
-
const secHigh = sec / 4294967296;
|
|
44276
|
-
const secLow = sec & 4294967295;
|
|
44277
|
-
const rv = new Uint8Array(8);
|
|
44278
|
-
const view = new DataView(rv.buffer);
|
|
44279
|
-
view.setUint32(0, nsec << 2 | secHigh & 3);
|
|
44280
|
-
view.setUint32(4, secLow);
|
|
44281
|
-
return rv;
|
|
44282
|
-
}
|
|
44283
|
-
} else {
|
|
44284
|
-
const rv = new Uint8Array(12);
|
|
44285
|
-
const view = new DataView(rv.buffer);
|
|
44286
|
-
view.setUint32(0, nsec);
|
|
44287
|
-
setInt64(view, 4, sec);
|
|
44288
|
-
return rv;
|
|
44289
|
-
}
|
|
44290
|
-
}
|
|
44291
|
-
function encodeDateToTimeSpec(date) {
|
|
44292
|
-
const msec = date.getTime();
|
|
44293
|
-
const sec = Math.floor(msec / 1e3);
|
|
44294
|
-
const nsec = (msec - sec * 1e3) * 1e6;
|
|
44295
|
-
const nsecInSec = Math.floor(nsec / 1e9);
|
|
44296
|
-
return {
|
|
44297
|
-
sec: sec + nsecInSec,
|
|
44298
|
-
nsec: nsec - nsecInSec * 1e9
|
|
44299
|
-
};
|
|
44300
|
-
}
|
|
44301
|
-
function encodeTimestampExtension(object2) {
|
|
44302
|
-
if (object2 instanceof Date) {
|
|
44303
|
-
const timeSpec = encodeDateToTimeSpec(object2);
|
|
44304
|
-
return encodeTimeSpecToTimestamp(timeSpec);
|
|
44305
|
-
} else {
|
|
44306
|
-
return null;
|
|
44307
|
-
}
|
|
44308
|
-
}
|
|
44309
|
-
function decodeTimestampToTimeSpec(data) {
|
|
44310
|
-
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
44311
|
-
switch (data.byteLength) {
|
|
44312
|
-
case 4: {
|
|
44313
|
-
const sec = view.getUint32(0);
|
|
44314
|
-
const nsec = 0;
|
|
44315
|
-
return { sec, nsec };
|
|
44316
|
-
}
|
|
44317
|
-
case 8: {
|
|
44318
|
-
const nsec30AndSecHigh2 = view.getUint32(0);
|
|
44319
|
-
const secLow32 = view.getUint32(4);
|
|
44320
|
-
const sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
|
|
44321
|
-
const nsec = nsec30AndSecHigh2 >>> 2;
|
|
44322
|
-
return { sec, nsec };
|
|
44323
|
-
}
|
|
44324
|
-
case 12: {
|
|
44325
|
-
const sec = getInt64(view, 4);
|
|
44326
|
-
const nsec = view.getUint32(0);
|
|
44327
|
-
return { sec, nsec };
|
|
44328
|
-
}
|
|
44329
|
-
default:
|
|
44330
|
-
throw new DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
|
|
44331
|
-
}
|
|
44332
|
-
}
|
|
44333
|
-
function decodeTimestampExtension(data) {
|
|
44334
|
-
const timeSpec = decodeTimestampToTimeSpec(data);
|
|
44335
|
-
return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
|
|
44336
|
-
}
|
|
44337
|
-
var timestampExtension = {
|
|
44338
|
-
type: EXT_TIMESTAMP,
|
|
44339
|
-
encode: encodeTimestampExtension,
|
|
44340
|
-
decode: decodeTimestampExtension
|
|
44341
|
-
};
|
|
44342
|
-
|
|
44343
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs
|
|
44344
|
-
var ExtensionCodec = class _ExtensionCodec {
|
|
44345
|
-
static defaultCodec = new _ExtensionCodec();
|
|
44346
|
-
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
|
44347
|
-
// this will make type errors a lot more clear
|
|
44348
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
44349
|
-
__brand;
|
|
44350
|
-
// built-in extensions
|
|
44351
|
-
builtInEncoders = [];
|
|
44352
|
-
builtInDecoders = [];
|
|
44353
|
-
// custom extensions
|
|
44354
|
-
encoders = [];
|
|
44355
|
-
decoders = [];
|
|
44356
|
-
constructor() {
|
|
44357
|
-
this.register(timestampExtension);
|
|
44358
|
-
}
|
|
44359
|
-
register({ type, encode, decode }) {
|
|
44360
|
-
if (type >= 0) {
|
|
44361
|
-
this.encoders[type] = encode;
|
|
44362
|
-
this.decoders[type] = decode;
|
|
44363
|
-
} else {
|
|
44364
|
-
const index = -1 - type;
|
|
44365
|
-
this.builtInEncoders[index] = encode;
|
|
44366
|
-
this.builtInDecoders[index] = decode;
|
|
44367
|
-
}
|
|
44368
|
-
}
|
|
44369
|
-
tryToEncode(object2, context) {
|
|
44370
|
-
for (let i = 0; i < this.builtInEncoders.length; i++) {
|
|
44371
|
-
const encodeExt = this.builtInEncoders[i];
|
|
44372
|
-
if (encodeExt != null) {
|
|
44373
|
-
const data = encodeExt(object2, context);
|
|
44374
|
-
if (data != null) {
|
|
44375
|
-
const type = -1 - i;
|
|
44376
|
-
return new ExtData(type, data);
|
|
44377
|
-
}
|
|
44378
|
-
}
|
|
44379
|
-
}
|
|
44380
|
-
for (let i = 0; i < this.encoders.length; i++) {
|
|
44381
|
-
const encodeExt = this.encoders[i];
|
|
44382
|
-
if (encodeExt != null) {
|
|
44383
|
-
const data = encodeExt(object2, context);
|
|
44384
|
-
if (data != null) {
|
|
44385
|
-
const type = i;
|
|
44386
|
-
return new ExtData(type, data);
|
|
44387
|
-
}
|
|
44388
|
-
}
|
|
44389
|
-
}
|
|
44390
|
-
if (object2 instanceof ExtData) {
|
|
44391
|
-
return object2;
|
|
44392
|
-
}
|
|
44393
|
-
return null;
|
|
44394
|
-
}
|
|
44395
|
-
decode(data, type, context) {
|
|
44396
|
-
const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
|
44397
|
-
if (decodeExt) {
|
|
44398
|
-
return decodeExt(data, type, context);
|
|
44399
|
-
} else {
|
|
44400
|
-
return new ExtData(type, data);
|
|
44401
|
-
}
|
|
44402
|
-
}
|
|
44403
|
-
};
|
|
44404
|
-
|
|
44405
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs
|
|
44406
|
-
function isArrayBufferLike(buffer) {
|
|
44407
|
-
return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
|
|
44408
|
-
}
|
|
44409
|
-
function ensureUint8Array(buffer) {
|
|
44410
|
-
if (buffer instanceof Uint8Array) {
|
|
44411
|
-
return buffer;
|
|
44412
|
-
} else if (ArrayBuffer.isView(buffer)) {
|
|
44413
|
-
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
44414
|
-
} else if (isArrayBufferLike(buffer)) {
|
|
44415
|
-
return new Uint8Array(buffer);
|
|
44416
|
-
} else {
|
|
44417
|
-
return Uint8Array.from(buffer);
|
|
44418
|
-
}
|
|
44419
|
-
}
|
|
44420
|
-
|
|
44421
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs
|
|
44422
|
-
var DEFAULT_MAX_DEPTH = 100;
|
|
44423
|
-
var DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
|
44424
|
-
var Encoder = class _Encoder {
|
|
44425
|
-
extensionCodec;
|
|
44426
|
-
context;
|
|
44427
|
-
useBigInt64;
|
|
44428
|
-
maxDepth;
|
|
44429
|
-
initialBufferSize;
|
|
44430
|
-
sortKeys;
|
|
44431
|
-
forceFloat32;
|
|
44432
|
-
ignoreUndefined;
|
|
44433
|
-
forceIntegerToFloat;
|
|
44434
|
-
pos;
|
|
44435
|
-
view;
|
|
44436
|
-
bytes;
|
|
44437
|
-
entered = false;
|
|
44438
|
-
constructor(options) {
|
|
44439
|
-
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
|
|
44440
|
-
this.context = options?.context;
|
|
44441
|
-
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
44442
|
-
this.maxDepth = options?.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
44443
|
-
this.initialBufferSize = options?.initialBufferSize ?? DEFAULT_INITIAL_BUFFER_SIZE;
|
|
44444
|
-
this.sortKeys = options?.sortKeys ?? false;
|
|
44445
|
-
this.forceFloat32 = options?.forceFloat32 ?? false;
|
|
44446
|
-
this.ignoreUndefined = options?.ignoreUndefined ?? false;
|
|
44447
|
-
this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
|
|
44448
|
-
this.pos = 0;
|
|
44449
|
-
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
|
44450
|
-
this.bytes = new Uint8Array(this.view.buffer);
|
|
44451
|
-
}
|
|
44452
|
-
clone() {
|
|
44453
|
-
return new _Encoder({
|
|
44454
|
-
extensionCodec: this.extensionCodec,
|
|
44455
|
-
context: this.context,
|
|
44456
|
-
useBigInt64: this.useBigInt64,
|
|
44457
|
-
maxDepth: this.maxDepth,
|
|
44458
|
-
initialBufferSize: this.initialBufferSize,
|
|
44459
|
-
sortKeys: this.sortKeys,
|
|
44460
|
-
forceFloat32: this.forceFloat32,
|
|
44461
|
-
ignoreUndefined: this.ignoreUndefined,
|
|
44462
|
-
forceIntegerToFloat: this.forceIntegerToFloat
|
|
44463
|
-
});
|
|
44464
|
-
}
|
|
44465
|
-
reinitializeState() {
|
|
44466
|
-
this.pos = 0;
|
|
44467
|
-
}
|
|
44468
|
-
/**
|
|
44469
|
-
* This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
|
|
44470
|
-
*
|
|
44471
|
-
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
|
44472
|
-
*/
|
|
44473
|
-
encodeSharedRef(object2) {
|
|
44474
|
-
if (this.entered) {
|
|
44475
|
-
const instance = this.clone();
|
|
44476
|
-
return instance.encodeSharedRef(object2);
|
|
44477
|
-
}
|
|
44478
|
-
try {
|
|
44479
|
-
this.entered = true;
|
|
44480
|
-
this.reinitializeState();
|
|
44481
|
-
this.doEncode(object2, 1);
|
|
44482
|
-
return this.bytes.subarray(0, this.pos);
|
|
44483
|
-
} finally {
|
|
44484
|
-
this.entered = false;
|
|
44485
|
-
}
|
|
44486
|
-
}
|
|
44487
|
-
/**
|
|
44488
|
-
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
|
44489
|
-
*/
|
|
44490
|
-
encode(object2) {
|
|
44491
|
-
if (this.entered) {
|
|
44492
|
-
const instance = this.clone();
|
|
44493
|
-
return instance.encode(object2);
|
|
44494
|
-
}
|
|
44495
|
-
try {
|
|
44496
|
-
this.entered = true;
|
|
44497
|
-
this.reinitializeState();
|
|
44498
|
-
this.doEncode(object2, 1);
|
|
44499
|
-
return this.bytes.slice(0, this.pos);
|
|
44500
|
-
} finally {
|
|
44501
|
-
this.entered = false;
|
|
44502
|
-
}
|
|
44503
|
-
}
|
|
44504
|
-
doEncode(object2, depth) {
|
|
44505
|
-
if (depth > this.maxDepth) {
|
|
44506
|
-
throw new Error(`Too deep objects in depth ${depth}`);
|
|
44507
|
-
}
|
|
44508
|
-
if (object2 == null) {
|
|
44509
|
-
this.encodeNil();
|
|
44510
|
-
} else if (typeof object2 === "boolean") {
|
|
44511
|
-
this.encodeBoolean(object2);
|
|
44512
|
-
} else if (typeof object2 === "number") {
|
|
44513
|
-
if (!this.forceIntegerToFloat) {
|
|
44514
|
-
this.encodeNumber(object2);
|
|
44515
|
-
} else {
|
|
44516
|
-
this.encodeNumberAsFloat(object2);
|
|
44517
|
-
}
|
|
44518
|
-
} else if (typeof object2 === "string") {
|
|
44519
|
-
this.encodeString(object2);
|
|
44520
|
-
} else if (this.useBigInt64 && typeof object2 === "bigint") {
|
|
44521
|
-
this.encodeBigInt64(object2);
|
|
44522
|
-
} else {
|
|
44523
|
-
this.encodeObject(object2, depth);
|
|
44524
|
-
}
|
|
44525
|
-
}
|
|
44526
|
-
ensureBufferSizeToWrite(sizeToWrite) {
|
|
44527
|
-
const requiredSize = this.pos + sizeToWrite;
|
|
44528
|
-
if (this.view.byteLength < requiredSize) {
|
|
44529
|
-
this.resizeBuffer(requiredSize * 2);
|
|
44530
|
-
}
|
|
44531
|
-
}
|
|
44532
|
-
resizeBuffer(newSize) {
|
|
44533
|
-
const newBuffer = new ArrayBuffer(newSize);
|
|
44534
|
-
const newBytes = new Uint8Array(newBuffer);
|
|
44535
|
-
const newView = new DataView(newBuffer);
|
|
44536
|
-
newBytes.set(this.bytes);
|
|
44537
|
-
this.view = newView;
|
|
44538
|
-
this.bytes = newBytes;
|
|
44539
|
-
}
|
|
44540
|
-
encodeNil() {
|
|
44541
|
-
this.writeU8(192);
|
|
44542
|
-
}
|
|
44543
|
-
encodeBoolean(object2) {
|
|
44544
|
-
if (object2 === false) {
|
|
44545
|
-
this.writeU8(194);
|
|
44546
|
-
} else {
|
|
44547
|
-
this.writeU8(195);
|
|
44548
|
-
}
|
|
44549
|
-
}
|
|
44550
|
-
encodeNumber(object2) {
|
|
44551
|
-
if (!this.forceIntegerToFloat && Number.isSafeInteger(object2)) {
|
|
44552
|
-
if (object2 >= 0) {
|
|
44553
|
-
if (object2 < 128) {
|
|
44554
|
-
this.writeU8(object2);
|
|
44555
|
-
} else if (object2 < 256) {
|
|
44556
|
-
this.writeU8(204);
|
|
44557
|
-
this.writeU8(object2);
|
|
44558
|
-
} else if (object2 < 65536) {
|
|
44559
|
-
this.writeU8(205);
|
|
44560
|
-
this.writeU16(object2);
|
|
44561
|
-
} else if (object2 < 4294967296) {
|
|
44562
|
-
this.writeU8(206);
|
|
44563
|
-
this.writeU32(object2);
|
|
44564
|
-
} else if (!this.useBigInt64) {
|
|
44565
|
-
this.writeU8(207);
|
|
44566
|
-
this.writeU64(object2);
|
|
44567
|
-
} else {
|
|
44568
|
-
this.encodeNumberAsFloat(object2);
|
|
44569
|
-
}
|
|
44570
|
-
} else {
|
|
44571
|
-
if (object2 >= -32) {
|
|
44572
|
-
this.writeU8(224 | object2 + 32);
|
|
44573
|
-
} else if (object2 >= -128) {
|
|
44574
|
-
this.writeU8(208);
|
|
44575
|
-
this.writeI8(object2);
|
|
44576
|
-
} else if (object2 >= -32768) {
|
|
44577
|
-
this.writeU8(209);
|
|
44578
|
-
this.writeI16(object2);
|
|
44579
|
-
} else if (object2 >= -2147483648) {
|
|
44580
|
-
this.writeU8(210);
|
|
44581
|
-
this.writeI32(object2);
|
|
44582
|
-
} else if (!this.useBigInt64) {
|
|
44583
|
-
this.writeU8(211);
|
|
44584
|
-
this.writeI64(object2);
|
|
44585
|
-
} else {
|
|
44586
|
-
this.encodeNumberAsFloat(object2);
|
|
44587
|
-
}
|
|
44588
|
-
}
|
|
44589
|
-
} else {
|
|
44590
|
-
this.encodeNumberAsFloat(object2);
|
|
44591
|
-
}
|
|
44592
|
-
}
|
|
44593
|
-
encodeNumberAsFloat(object2) {
|
|
44594
|
-
if (this.forceFloat32) {
|
|
44595
|
-
this.writeU8(202);
|
|
44596
|
-
this.writeF32(object2);
|
|
44597
|
-
} else {
|
|
44598
|
-
this.writeU8(203);
|
|
44599
|
-
this.writeF64(object2);
|
|
44600
|
-
}
|
|
44601
|
-
}
|
|
44602
|
-
encodeBigInt64(object2) {
|
|
44603
|
-
if (object2 >= BigInt(0)) {
|
|
44604
|
-
this.writeU8(207);
|
|
44605
|
-
this.writeBigUint64(object2);
|
|
44606
|
-
} else {
|
|
44607
|
-
this.writeU8(211);
|
|
44608
|
-
this.writeBigInt64(object2);
|
|
44609
|
-
}
|
|
44610
|
-
}
|
|
44611
|
-
writeStringHeader(byteLength) {
|
|
44612
|
-
if (byteLength < 32) {
|
|
44613
|
-
this.writeU8(160 + byteLength);
|
|
44614
|
-
} else if (byteLength < 256) {
|
|
44615
|
-
this.writeU8(217);
|
|
44616
|
-
this.writeU8(byteLength);
|
|
44617
|
-
} else if (byteLength < 65536) {
|
|
44618
|
-
this.writeU8(218);
|
|
44619
|
-
this.writeU16(byteLength);
|
|
44620
|
-
} else if (byteLength < 4294967296) {
|
|
44621
|
-
this.writeU8(219);
|
|
44622
|
-
this.writeU32(byteLength);
|
|
44623
|
-
} else {
|
|
44624
|
-
throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
|
|
44625
|
-
}
|
|
44626
|
-
}
|
|
44627
|
-
encodeString(object2) {
|
|
44628
|
-
const maxHeaderSize = 1 + 4;
|
|
44629
|
-
const byteLength = utf8Count(object2);
|
|
44630
|
-
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
|
44631
|
-
this.writeStringHeader(byteLength);
|
|
44632
|
-
utf8Encode(object2, this.bytes, this.pos);
|
|
44633
|
-
this.pos += byteLength;
|
|
44634
|
-
}
|
|
44635
|
-
encodeObject(object2, depth) {
|
|
44636
|
-
const ext = this.extensionCodec.tryToEncode(object2, this.context);
|
|
44637
|
-
if (ext != null) {
|
|
44638
|
-
this.encodeExtension(ext);
|
|
44639
|
-
} else if (Array.isArray(object2)) {
|
|
44640
|
-
this.encodeArray(object2, depth);
|
|
44641
|
-
} else if (ArrayBuffer.isView(object2)) {
|
|
44642
|
-
this.encodeBinary(object2);
|
|
44643
|
-
} else if (typeof object2 === "object") {
|
|
44644
|
-
this.encodeMap(object2, depth);
|
|
44645
|
-
} else {
|
|
44646
|
-
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object2)}`);
|
|
44647
|
-
}
|
|
44648
|
-
}
|
|
44649
|
-
encodeBinary(object2) {
|
|
44650
|
-
const size = object2.byteLength;
|
|
44651
|
-
if (size < 256) {
|
|
44652
|
-
this.writeU8(196);
|
|
44653
|
-
this.writeU8(size);
|
|
44654
|
-
} else if (size < 65536) {
|
|
44655
|
-
this.writeU8(197);
|
|
44656
|
-
this.writeU16(size);
|
|
44657
|
-
} else if (size < 4294967296) {
|
|
44658
|
-
this.writeU8(198);
|
|
44659
|
-
this.writeU32(size);
|
|
44660
|
-
} else {
|
|
44661
|
-
throw new Error(`Too large binary: ${size}`);
|
|
44662
|
-
}
|
|
44663
|
-
const bytes = ensureUint8Array(object2);
|
|
44664
|
-
this.writeU8a(bytes);
|
|
44665
|
-
}
|
|
44666
|
-
encodeArray(object2, depth) {
|
|
44667
|
-
const size = object2.length;
|
|
44668
|
-
if (size < 16) {
|
|
44669
|
-
this.writeU8(144 + size);
|
|
44670
|
-
} else if (size < 65536) {
|
|
44671
|
-
this.writeU8(220);
|
|
44672
|
-
this.writeU16(size);
|
|
44673
|
-
} else if (size < 4294967296) {
|
|
44674
|
-
this.writeU8(221);
|
|
44675
|
-
this.writeU32(size);
|
|
44676
|
-
} else {
|
|
44677
|
-
throw new Error(`Too large array: ${size}`);
|
|
44678
|
-
}
|
|
44679
|
-
for (const item of object2) {
|
|
44680
|
-
this.doEncode(item, depth + 1);
|
|
44681
|
-
}
|
|
44682
|
-
}
|
|
44683
|
-
countWithoutUndefined(object2, keys) {
|
|
44684
|
-
let count = 0;
|
|
44685
|
-
for (const key of keys) {
|
|
44686
|
-
if (object2[key] !== void 0) {
|
|
44687
|
-
count++;
|
|
44688
|
-
}
|
|
44689
|
-
}
|
|
44690
|
-
return count;
|
|
44691
|
-
}
|
|
44692
|
-
encodeMap(object2, depth) {
|
|
44693
|
-
const keys = Object.keys(object2);
|
|
44694
|
-
if (this.sortKeys) {
|
|
44695
|
-
keys.sort();
|
|
44696
|
-
}
|
|
44697
|
-
const size = this.ignoreUndefined ? this.countWithoutUndefined(object2, keys) : keys.length;
|
|
44698
|
-
if (size < 16) {
|
|
44699
|
-
this.writeU8(128 + size);
|
|
44700
|
-
} else if (size < 65536) {
|
|
44701
|
-
this.writeU8(222);
|
|
44702
|
-
this.writeU16(size);
|
|
44703
|
-
} else if (size < 4294967296) {
|
|
44704
|
-
this.writeU8(223);
|
|
44705
|
-
this.writeU32(size);
|
|
44706
|
-
} else {
|
|
44707
|
-
throw new Error(`Too large map object: ${size}`);
|
|
44708
|
-
}
|
|
44709
|
-
for (const key of keys) {
|
|
44710
|
-
const value = object2[key];
|
|
44711
|
-
if (!(this.ignoreUndefined && value === void 0)) {
|
|
44712
|
-
this.encodeString(key);
|
|
44713
|
-
this.doEncode(value, depth + 1);
|
|
44714
|
-
}
|
|
44715
|
-
}
|
|
44716
|
-
}
|
|
44717
|
-
encodeExtension(ext) {
|
|
44718
|
-
if (typeof ext.data === "function") {
|
|
44719
|
-
const data = ext.data(this.pos + 6);
|
|
44720
|
-
const size2 = data.length;
|
|
44721
|
-
if (size2 >= 4294967296) {
|
|
44722
|
-
throw new Error(`Too large extension object: ${size2}`);
|
|
44723
|
-
}
|
|
44724
|
-
this.writeU8(201);
|
|
44725
|
-
this.writeU32(size2);
|
|
44726
|
-
this.writeI8(ext.type);
|
|
44727
|
-
this.writeU8a(data);
|
|
44728
|
-
return;
|
|
44729
|
-
}
|
|
44730
|
-
const size = ext.data.length;
|
|
44731
|
-
if (size === 1) {
|
|
44732
|
-
this.writeU8(212);
|
|
44733
|
-
} else if (size === 2) {
|
|
44734
|
-
this.writeU8(213);
|
|
44735
|
-
} else if (size === 4) {
|
|
44736
|
-
this.writeU8(214);
|
|
44737
|
-
} else if (size === 8) {
|
|
44738
|
-
this.writeU8(215);
|
|
44739
|
-
} else if (size === 16) {
|
|
44740
|
-
this.writeU8(216);
|
|
44741
|
-
} else if (size < 256) {
|
|
44742
|
-
this.writeU8(199);
|
|
44743
|
-
this.writeU8(size);
|
|
44744
|
-
} else if (size < 65536) {
|
|
44745
|
-
this.writeU8(200);
|
|
44746
|
-
this.writeU16(size);
|
|
44747
|
-
} else if (size < 4294967296) {
|
|
44748
|
-
this.writeU8(201);
|
|
44749
|
-
this.writeU32(size);
|
|
44750
|
-
} else {
|
|
44751
|
-
throw new Error(`Too large extension object: ${size}`);
|
|
44752
|
-
}
|
|
44753
|
-
this.writeI8(ext.type);
|
|
44754
|
-
this.writeU8a(ext.data);
|
|
44755
|
-
}
|
|
44756
|
-
writeU8(value) {
|
|
44757
|
-
this.ensureBufferSizeToWrite(1);
|
|
44758
|
-
this.view.setUint8(this.pos, value);
|
|
44759
|
-
this.pos++;
|
|
44760
|
-
}
|
|
44761
|
-
writeU8a(values) {
|
|
44762
|
-
const size = values.length;
|
|
44763
|
-
this.ensureBufferSizeToWrite(size);
|
|
44764
|
-
this.bytes.set(values, this.pos);
|
|
44765
|
-
this.pos += size;
|
|
44766
|
-
}
|
|
44767
|
-
writeI8(value) {
|
|
44768
|
-
this.ensureBufferSizeToWrite(1);
|
|
44769
|
-
this.view.setInt8(this.pos, value);
|
|
44770
|
-
this.pos++;
|
|
44771
|
-
}
|
|
44772
|
-
writeU16(value) {
|
|
44773
|
-
this.ensureBufferSizeToWrite(2);
|
|
44774
|
-
this.view.setUint16(this.pos, value);
|
|
44775
|
-
this.pos += 2;
|
|
44776
|
-
}
|
|
44777
|
-
writeI16(value) {
|
|
44778
|
-
this.ensureBufferSizeToWrite(2);
|
|
44779
|
-
this.view.setInt16(this.pos, value);
|
|
44780
|
-
this.pos += 2;
|
|
44781
|
-
}
|
|
44782
|
-
writeU32(value) {
|
|
44783
|
-
this.ensureBufferSizeToWrite(4);
|
|
44784
|
-
this.view.setUint32(this.pos, value);
|
|
44785
|
-
this.pos += 4;
|
|
44786
|
-
}
|
|
44787
|
-
writeI32(value) {
|
|
44788
|
-
this.ensureBufferSizeToWrite(4);
|
|
44789
|
-
this.view.setInt32(this.pos, value);
|
|
44790
|
-
this.pos += 4;
|
|
44791
|
-
}
|
|
44792
|
-
writeF32(value) {
|
|
44793
|
-
this.ensureBufferSizeToWrite(4);
|
|
44794
|
-
this.view.setFloat32(this.pos, value);
|
|
44795
|
-
this.pos += 4;
|
|
44796
|
-
}
|
|
44797
|
-
writeF64(value) {
|
|
44798
|
-
this.ensureBufferSizeToWrite(8);
|
|
44799
|
-
this.view.setFloat64(this.pos, value);
|
|
44800
|
-
this.pos += 8;
|
|
44801
|
-
}
|
|
44802
|
-
writeU64(value) {
|
|
44803
|
-
this.ensureBufferSizeToWrite(8);
|
|
44804
|
-
setUint64(this.view, this.pos, value);
|
|
44805
|
-
this.pos += 8;
|
|
44806
|
-
}
|
|
44807
|
-
writeI64(value) {
|
|
44808
|
-
this.ensureBufferSizeToWrite(8);
|
|
44809
|
-
setInt64(this.view, this.pos, value);
|
|
44810
|
-
this.pos += 8;
|
|
44811
|
-
}
|
|
44812
|
-
writeBigUint64(value) {
|
|
44813
|
-
this.ensureBufferSizeToWrite(8);
|
|
44814
|
-
this.view.setBigUint64(this.pos, value);
|
|
44815
|
-
this.pos += 8;
|
|
44816
|
-
}
|
|
44817
|
-
writeBigInt64(value) {
|
|
44818
|
-
this.ensureBufferSizeToWrite(8);
|
|
44819
|
-
this.view.setBigInt64(this.pos, value);
|
|
44820
|
-
this.pos += 8;
|
|
44821
|
-
}
|
|
44822
|
-
};
|
|
44823
|
-
|
|
44824
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs
|
|
44825
|
-
function prettyByte(byte) {
|
|
44826
|
-
return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
|
|
44827
|
-
}
|
|
44828
|
-
|
|
44829
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs
|
|
44830
|
-
var DEFAULT_MAX_KEY_LENGTH = 16;
|
|
44831
|
-
var DEFAULT_MAX_LENGTH_PER_KEY = 16;
|
|
44832
|
-
var CachedKeyDecoder = class {
|
|
44833
|
-
hit = 0;
|
|
44834
|
-
miss = 0;
|
|
44835
|
-
caches;
|
|
44836
|
-
maxKeyLength;
|
|
44837
|
-
maxLengthPerKey;
|
|
44838
|
-
constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
|
|
44839
|
-
this.maxKeyLength = maxKeyLength;
|
|
44840
|
-
this.maxLengthPerKey = maxLengthPerKey;
|
|
44841
|
-
this.caches = [];
|
|
44842
|
-
for (let i = 0; i < this.maxKeyLength; i++) {
|
|
44843
|
-
this.caches.push([]);
|
|
44844
|
-
}
|
|
44845
|
-
}
|
|
44846
|
-
canBeCached(byteLength) {
|
|
44847
|
-
return byteLength > 0 && byteLength <= this.maxKeyLength;
|
|
44848
|
-
}
|
|
44849
|
-
find(bytes, inputOffset, byteLength) {
|
|
44850
|
-
const records = this.caches[byteLength - 1];
|
|
44851
|
-
FIND_CHUNK: for (const record of records) {
|
|
44852
|
-
const recordBytes = record.bytes;
|
|
44853
|
-
for (let j = 0; j < byteLength; j++) {
|
|
44854
|
-
if (recordBytes[j] !== bytes[inputOffset + j]) {
|
|
44855
|
-
continue FIND_CHUNK;
|
|
44856
|
-
}
|
|
44857
|
-
}
|
|
44858
|
-
return record.str;
|
|
44859
|
-
}
|
|
44860
|
-
return null;
|
|
44861
|
-
}
|
|
44862
|
-
store(bytes, value) {
|
|
44863
|
-
const records = this.caches[bytes.length - 1];
|
|
44864
|
-
const record = { bytes, str: value };
|
|
44865
|
-
if (records.length >= this.maxLengthPerKey) {
|
|
44866
|
-
records[Math.random() * records.length | 0] = record;
|
|
44867
|
-
} else {
|
|
44868
|
-
records.push(record);
|
|
44869
|
-
}
|
|
44870
|
-
}
|
|
44871
|
-
decode(bytes, inputOffset, byteLength) {
|
|
44872
|
-
const cachedValue = this.find(bytes, inputOffset, byteLength);
|
|
44873
|
-
if (cachedValue != null) {
|
|
44874
|
-
this.hit++;
|
|
44875
|
-
return cachedValue;
|
|
44876
|
-
}
|
|
44877
|
-
this.miss++;
|
|
44878
|
-
const str = utf8DecodeJs(bytes, inputOffset, byteLength);
|
|
44879
|
-
const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
|
|
44880
|
-
this.store(slicedCopyOfBytes, str);
|
|
44881
|
-
return str;
|
|
44882
|
-
}
|
|
44883
|
-
};
|
|
44884
|
-
|
|
44885
|
-
// node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs
|
|
44886
|
-
var STATE_ARRAY = "array";
|
|
44887
|
-
var STATE_MAP_KEY = "map_key";
|
|
44888
|
-
var STATE_MAP_VALUE = "map_value";
|
|
44889
|
-
var mapKeyConverter = (key) => {
|
|
44890
|
-
if (typeof key === "string" || typeof key === "number") {
|
|
44891
|
-
return key;
|
|
44892
|
-
}
|
|
44893
|
-
throw new DecodeError("The type of key must be string or number but " + typeof key);
|
|
44894
|
-
};
|
|
44895
|
-
var StackPool = class {
|
|
44896
|
-
stack = [];
|
|
44897
|
-
stackHeadPosition = -1;
|
|
44898
|
-
get length() {
|
|
44899
|
-
return this.stackHeadPosition + 1;
|
|
44900
|
-
}
|
|
44901
|
-
top() {
|
|
44902
|
-
return this.stack[this.stackHeadPosition];
|
|
44903
|
-
}
|
|
44904
|
-
pushArrayState(size) {
|
|
44905
|
-
const state = this.getUninitializedStateFromPool();
|
|
44906
|
-
state.type = STATE_ARRAY;
|
|
44907
|
-
state.position = 0;
|
|
44908
|
-
state.size = size;
|
|
44909
|
-
state.array = new Array(size);
|
|
44910
|
-
}
|
|
44911
|
-
pushMapState(size) {
|
|
44912
|
-
const state = this.getUninitializedStateFromPool();
|
|
44913
|
-
state.type = STATE_MAP_KEY;
|
|
44914
|
-
state.readCount = 0;
|
|
44915
|
-
state.size = size;
|
|
44916
|
-
state.map = {};
|
|
44917
|
-
}
|
|
44918
|
-
getUninitializedStateFromPool() {
|
|
44919
|
-
this.stackHeadPosition++;
|
|
44920
|
-
if (this.stackHeadPosition === this.stack.length) {
|
|
44921
|
-
const partialState = {
|
|
44922
|
-
type: void 0,
|
|
44923
|
-
size: 0,
|
|
44924
|
-
array: void 0,
|
|
44925
|
-
position: 0,
|
|
44926
|
-
readCount: 0,
|
|
44927
|
-
map: void 0,
|
|
44928
|
-
key: null
|
|
44929
|
-
};
|
|
44930
|
-
this.stack.push(partialState);
|
|
44931
|
-
}
|
|
44932
|
-
return this.stack[this.stackHeadPosition];
|
|
44933
|
-
}
|
|
44934
|
-
release(state) {
|
|
44935
|
-
const topStackState = this.stack[this.stackHeadPosition];
|
|
44936
|
-
if (topStackState !== state) {
|
|
44937
|
-
throw new Error("Invalid stack state. Released state is not on top of the stack.");
|
|
44938
|
-
}
|
|
44939
|
-
if (state.type === STATE_ARRAY) {
|
|
44940
|
-
const partialState = state;
|
|
44941
|
-
partialState.size = 0;
|
|
44942
|
-
partialState.array = void 0;
|
|
44943
|
-
partialState.position = 0;
|
|
44944
|
-
partialState.type = void 0;
|
|
44945
|
-
}
|
|
44946
|
-
if (state.type === STATE_MAP_KEY || state.type === STATE_MAP_VALUE) {
|
|
44947
|
-
const partialState = state;
|
|
44948
|
-
partialState.size = 0;
|
|
44949
|
-
partialState.map = void 0;
|
|
44950
|
-
partialState.readCount = 0;
|
|
44951
|
-
partialState.type = void 0;
|
|
44952
|
-
}
|
|
44953
|
-
this.stackHeadPosition--;
|
|
44954
|
-
}
|
|
44955
|
-
reset() {
|
|
44956
|
-
this.stack.length = 0;
|
|
44957
|
-
this.stackHeadPosition = -1;
|
|
44958
|
-
}
|
|
44959
|
-
};
|
|
44960
|
-
var HEAD_BYTE_REQUIRED = -1;
|
|
44961
|
-
var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
|
|
44962
|
-
var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
|
|
44963
|
-
try {
|
|
44964
|
-
EMPTY_VIEW.getInt8(0);
|
|
44965
|
-
} catch (e) {
|
|
44966
|
-
if (!(e instanceof RangeError)) {
|
|
44967
|
-
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
|
|
44968
|
-
}
|
|
44969
|
-
}
|
|
44970
|
-
var MORE_DATA = new RangeError("Insufficient data");
|
|
44971
|
-
var sharedCachedKeyDecoder = new CachedKeyDecoder();
|
|
44972
|
-
var Decoder = class _Decoder {
|
|
44973
|
-
extensionCodec;
|
|
44974
|
-
context;
|
|
44975
|
-
useBigInt64;
|
|
44976
|
-
rawStrings;
|
|
44977
|
-
maxStrLength;
|
|
44978
|
-
maxBinLength;
|
|
44979
|
-
maxArrayLength;
|
|
44980
|
-
maxMapLength;
|
|
44981
|
-
maxExtLength;
|
|
44982
|
-
keyDecoder;
|
|
44983
|
-
mapKeyConverter;
|
|
44984
|
-
totalPos = 0;
|
|
44985
|
-
pos = 0;
|
|
44986
|
-
view = EMPTY_VIEW;
|
|
44987
|
-
bytes = EMPTY_BYTES;
|
|
44988
|
-
headByte = HEAD_BYTE_REQUIRED;
|
|
44989
|
-
stack = new StackPool();
|
|
44990
|
-
entered = false;
|
|
44991
|
-
constructor(options) {
|
|
44992
|
-
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
|
|
44993
|
-
this.context = options?.context;
|
|
44994
|
-
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
44995
|
-
this.rawStrings = options?.rawStrings ?? false;
|
|
44996
|
-
this.maxStrLength = options?.maxStrLength ?? UINT32_MAX;
|
|
44997
|
-
this.maxBinLength = options?.maxBinLength ?? UINT32_MAX;
|
|
44998
|
-
this.maxArrayLength = options?.maxArrayLength ?? UINT32_MAX;
|
|
44999
|
-
this.maxMapLength = options?.maxMapLength ?? UINT32_MAX;
|
|
45000
|
-
this.maxExtLength = options?.maxExtLength ?? UINT32_MAX;
|
|
45001
|
-
this.keyDecoder = options?.keyDecoder !== void 0 ? options.keyDecoder : sharedCachedKeyDecoder;
|
|
45002
|
-
this.mapKeyConverter = options?.mapKeyConverter ?? mapKeyConverter;
|
|
45003
|
-
}
|
|
45004
|
-
clone() {
|
|
45005
|
-
return new _Decoder({
|
|
45006
|
-
extensionCodec: this.extensionCodec,
|
|
45007
|
-
context: this.context,
|
|
45008
|
-
useBigInt64: this.useBigInt64,
|
|
45009
|
-
rawStrings: this.rawStrings,
|
|
45010
|
-
maxStrLength: this.maxStrLength,
|
|
45011
|
-
maxBinLength: this.maxBinLength,
|
|
45012
|
-
maxArrayLength: this.maxArrayLength,
|
|
45013
|
-
maxMapLength: this.maxMapLength,
|
|
45014
|
-
maxExtLength: this.maxExtLength,
|
|
45015
|
-
keyDecoder: this.keyDecoder
|
|
45016
|
-
});
|
|
45017
|
-
}
|
|
45018
|
-
reinitializeState() {
|
|
45019
|
-
this.totalPos = 0;
|
|
45020
|
-
this.headByte = HEAD_BYTE_REQUIRED;
|
|
45021
|
-
this.stack.reset();
|
|
45022
|
-
}
|
|
45023
|
-
setBuffer(buffer) {
|
|
45024
|
-
const bytes = ensureUint8Array(buffer);
|
|
45025
|
-
this.bytes = bytes;
|
|
45026
|
-
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
45027
|
-
this.pos = 0;
|
|
45028
|
-
}
|
|
45029
|
-
appendBuffer(buffer) {
|
|
45030
|
-
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
|
|
45031
|
-
this.setBuffer(buffer);
|
|
45032
|
-
} else {
|
|
45033
|
-
const remainingData = this.bytes.subarray(this.pos);
|
|
45034
|
-
const newData = ensureUint8Array(buffer);
|
|
45035
|
-
const newBuffer = new Uint8Array(remainingData.length + newData.length);
|
|
45036
|
-
newBuffer.set(remainingData);
|
|
45037
|
-
newBuffer.set(newData, remainingData.length);
|
|
45038
|
-
this.setBuffer(newBuffer);
|
|
45039
|
-
}
|
|
45040
|
-
}
|
|
45041
|
-
hasRemaining(size) {
|
|
45042
|
-
return this.view.byteLength - this.pos >= size;
|
|
45043
|
-
}
|
|
45044
|
-
createExtraByteError(posToShow) {
|
|
45045
|
-
const { view, pos } = this;
|
|
45046
|
-
return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
|
|
45047
|
-
}
|
|
45048
|
-
/**
|
|
45049
|
-
* @throws {@link DecodeError}
|
|
45050
|
-
* @throws {@link RangeError}
|
|
45051
|
-
*/
|
|
45052
|
-
decode(buffer) {
|
|
45053
|
-
if (this.entered) {
|
|
45054
|
-
const instance = this.clone();
|
|
45055
|
-
return instance.decode(buffer);
|
|
45056
|
-
}
|
|
45057
|
-
try {
|
|
45058
|
-
this.entered = true;
|
|
45059
|
-
this.reinitializeState();
|
|
45060
|
-
this.setBuffer(buffer);
|
|
45061
|
-
const object2 = this.doDecodeSync();
|
|
45062
|
-
if (this.hasRemaining(1)) {
|
|
45063
|
-
throw this.createExtraByteError(this.pos);
|
|
45064
|
-
}
|
|
45065
|
-
return object2;
|
|
45066
|
-
} finally {
|
|
45067
|
-
this.entered = false;
|
|
45068
|
-
}
|
|
45069
|
-
}
|
|
45070
|
-
*decodeMulti(buffer) {
|
|
45071
|
-
if (this.entered) {
|
|
45072
|
-
const instance = this.clone();
|
|
45073
|
-
yield* instance.decodeMulti(buffer);
|
|
45074
|
-
return;
|
|
45075
|
-
}
|
|
45076
|
-
try {
|
|
45077
|
-
this.entered = true;
|
|
45078
|
-
this.reinitializeState();
|
|
45079
|
-
this.setBuffer(buffer);
|
|
45080
|
-
while (this.hasRemaining(1)) {
|
|
45081
|
-
yield this.doDecodeSync();
|
|
45082
|
-
}
|
|
45083
|
-
} finally {
|
|
45084
|
-
this.entered = false;
|
|
45085
|
-
}
|
|
45086
|
-
}
|
|
45087
|
-
async decodeAsync(stream) {
|
|
45088
|
-
if (this.entered) {
|
|
45089
|
-
const instance = this.clone();
|
|
45090
|
-
return instance.decodeAsync(stream);
|
|
45091
|
-
}
|
|
45092
|
-
try {
|
|
45093
|
-
this.entered = true;
|
|
45094
|
-
let decoded = false;
|
|
45095
|
-
let object2;
|
|
45096
|
-
for await (const buffer of stream) {
|
|
45097
|
-
if (decoded) {
|
|
45098
|
-
this.entered = false;
|
|
45099
|
-
throw this.createExtraByteError(this.totalPos);
|
|
45100
|
-
}
|
|
45101
|
-
this.appendBuffer(buffer);
|
|
45102
|
-
try {
|
|
45103
|
-
object2 = this.doDecodeSync();
|
|
45104
|
-
decoded = true;
|
|
45105
|
-
} catch (e) {
|
|
45106
|
-
if (!(e instanceof RangeError)) {
|
|
45107
|
-
throw e;
|
|
45108
|
-
}
|
|
45109
|
-
}
|
|
45110
|
-
this.totalPos += this.pos;
|
|
45111
|
-
}
|
|
45112
|
-
if (decoded) {
|
|
45113
|
-
if (this.hasRemaining(1)) {
|
|
45114
|
-
throw this.createExtraByteError(this.totalPos);
|
|
45115
|
-
}
|
|
45116
|
-
return object2;
|
|
45117
|
-
}
|
|
45118
|
-
const { headByte, pos, totalPos } = this;
|
|
45119
|
-
throw new RangeError(`Insufficient data in parsing ${prettyByte(headByte)} at ${totalPos} (${pos} in the current buffer)`);
|
|
45120
|
-
} finally {
|
|
45121
|
-
this.entered = false;
|
|
45122
|
-
}
|
|
45123
|
-
}
|
|
45124
|
-
decodeArrayStream(stream) {
|
|
45125
|
-
return this.decodeMultiAsync(stream, true);
|
|
45126
|
-
}
|
|
45127
|
-
decodeStream(stream) {
|
|
45128
|
-
return this.decodeMultiAsync(stream, false);
|
|
45129
|
-
}
|
|
45130
|
-
async *decodeMultiAsync(stream, isArray) {
|
|
45131
|
-
if (this.entered) {
|
|
45132
|
-
const instance = this.clone();
|
|
45133
|
-
yield* instance.decodeMultiAsync(stream, isArray);
|
|
45134
|
-
return;
|
|
45135
|
-
}
|
|
45136
|
-
try {
|
|
45137
|
-
this.entered = true;
|
|
45138
|
-
let isArrayHeaderRequired = isArray;
|
|
45139
|
-
let arrayItemsLeft = -1;
|
|
45140
|
-
for await (const buffer of stream) {
|
|
45141
|
-
if (isArray && arrayItemsLeft === 0) {
|
|
45142
|
-
throw this.createExtraByteError(this.totalPos);
|
|
45143
|
-
}
|
|
45144
|
-
this.appendBuffer(buffer);
|
|
45145
|
-
if (isArrayHeaderRequired) {
|
|
45146
|
-
arrayItemsLeft = this.readArraySize();
|
|
45147
|
-
isArrayHeaderRequired = false;
|
|
45148
|
-
this.complete();
|
|
45149
|
-
}
|
|
45150
|
-
try {
|
|
45151
|
-
while (true) {
|
|
45152
|
-
yield this.doDecodeSync();
|
|
45153
|
-
if (--arrayItemsLeft === 0) {
|
|
45154
|
-
break;
|
|
45155
|
-
}
|
|
45156
|
-
}
|
|
45157
|
-
} catch (e) {
|
|
45158
|
-
if (!(e instanceof RangeError)) {
|
|
45159
|
-
throw e;
|
|
45160
|
-
}
|
|
45161
|
-
}
|
|
45162
|
-
this.totalPos += this.pos;
|
|
45163
|
-
}
|
|
45164
|
-
} finally {
|
|
45165
|
-
this.entered = false;
|
|
45166
|
-
}
|
|
45167
|
-
}
|
|
45168
|
-
doDecodeSync() {
|
|
45169
|
-
DECODE: while (true) {
|
|
45170
|
-
const headByte = this.readHeadByte();
|
|
45171
|
-
let object2;
|
|
45172
|
-
if (headByte >= 224) {
|
|
45173
|
-
object2 = headByte - 256;
|
|
45174
|
-
} else if (headByte < 192) {
|
|
45175
|
-
if (headByte < 128) {
|
|
45176
|
-
object2 = headByte;
|
|
45177
|
-
} else if (headByte < 144) {
|
|
45178
|
-
const size = headByte - 128;
|
|
45179
|
-
if (size !== 0) {
|
|
45180
|
-
this.pushMapState(size);
|
|
45181
|
-
this.complete();
|
|
45182
|
-
continue DECODE;
|
|
45183
|
-
} else {
|
|
45184
|
-
object2 = {};
|
|
45185
|
-
}
|
|
45186
|
-
} else if (headByte < 160) {
|
|
45187
|
-
const size = headByte - 144;
|
|
45188
|
-
if (size !== 0) {
|
|
45189
|
-
this.pushArrayState(size);
|
|
45190
|
-
this.complete();
|
|
45191
|
-
continue DECODE;
|
|
45192
|
-
} else {
|
|
45193
|
-
object2 = [];
|
|
45194
|
-
}
|
|
45195
|
-
} else {
|
|
45196
|
-
const byteLength = headByte - 160;
|
|
45197
|
-
object2 = this.decodeString(byteLength, 0);
|
|
45198
|
-
}
|
|
45199
|
-
} else if (headByte === 192) {
|
|
45200
|
-
object2 = null;
|
|
45201
|
-
} else if (headByte === 194) {
|
|
45202
|
-
object2 = false;
|
|
45203
|
-
} else if (headByte === 195) {
|
|
45204
|
-
object2 = true;
|
|
45205
|
-
} else if (headByte === 202) {
|
|
45206
|
-
object2 = this.readF32();
|
|
45207
|
-
} else if (headByte === 203) {
|
|
45208
|
-
object2 = this.readF64();
|
|
45209
|
-
} else if (headByte === 204) {
|
|
45210
|
-
object2 = this.readU8();
|
|
45211
|
-
} else if (headByte === 205) {
|
|
45212
|
-
object2 = this.readU16();
|
|
45213
|
-
} else if (headByte === 206) {
|
|
45214
|
-
object2 = this.readU32();
|
|
45215
|
-
} else if (headByte === 207) {
|
|
45216
|
-
if (this.useBigInt64) {
|
|
45217
|
-
object2 = this.readU64AsBigInt();
|
|
45218
|
-
} else {
|
|
45219
|
-
object2 = this.readU64();
|
|
45220
|
-
}
|
|
45221
|
-
} else if (headByte === 208) {
|
|
45222
|
-
object2 = this.readI8();
|
|
45223
|
-
} else if (headByte === 209) {
|
|
45224
|
-
object2 = this.readI16();
|
|
45225
|
-
} else if (headByte === 210) {
|
|
45226
|
-
object2 = this.readI32();
|
|
45227
|
-
} else if (headByte === 211) {
|
|
45228
|
-
if (this.useBigInt64) {
|
|
45229
|
-
object2 = this.readI64AsBigInt();
|
|
45230
|
-
} else {
|
|
45231
|
-
object2 = this.readI64();
|
|
45232
|
-
}
|
|
45233
|
-
} else if (headByte === 217) {
|
|
45234
|
-
const byteLength = this.lookU8();
|
|
45235
|
-
object2 = this.decodeString(byteLength, 1);
|
|
45236
|
-
} else if (headByte === 218) {
|
|
45237
|
-
const byteLength = this.lookU16();
|
|
45238
|
-
object2 = this.decodeString(byteLength, 2);
|
|
45239
|
-
} else if (headByte === 219) {
|
|
45240
|
-
const byteLength = this.lookU32();
|
|
45241
|
-
object2 = this.decodeString(byteLength, 4);
|
|
45242
|
-
} else if (headByte === 220) {
|
|
45243
|
-
const size = this.readU16();
|
|
45244
|
-
if (size !== 0) {
|
|
45245
|
-
this.pushArrayState(size);
|
|
45246
|
-
this.complete();
|
|
45247
|
-
continue DECODE;
|
|
45248
|
-
} else {
|
|
45249
|
-
object2 = [];
|
|
45250
|
-
}
|
|
45251
|
-
} else if (headByte === 221) {
|
|
45252
|
-
const size = this.readU32();
|
|
45253
|
-
if (size !== 0) {
|
|
45254
|
-
this.pushArrayState(size);
|
|
45255
|
-
this.complete();
|
|
45256
|
-
continue DECODE;
|
|
45257
|
-
} else {
|
|
45258
|
-
object2 = [];
|
|
45259
|
-
}
|
|
45260
|
-
} else if (headByte === 222) {
|
|
45261
|
-
const size = this.readU16();
|
|
45262
|
-
if (size !== 0) {
|
|
45263
|
-
this.pushMapState(size);
|
|
45264
|
-
this.complete();
|
|
45265
|
-
continue DECODE;
|
|
45266
|
-
} else {
|
|
45267
|
-
object2 = {};
|
|
45268
|
-
}
|
|
45269
|
-
} else if (headByte === 223) {
|
|
45270
|
-
const size = this.readU32();
|
|
45271
|
-
if (size !== 0) {
|
|
45272
|
-
this.pushMapState(size);
|
|
45273
|
-
this.complete();
|
|
45274
|
-
continue DECODE;
|
|
45275
|
-
} else {
|
|
45276
|
-
object2 = {};
|
|
45277
|
-
}
|
|
45278
|
-
} else if (headByte === 196) {
|
|
45279
|
-
const size = this.lookU8();
|
|
45280
|
-
object2 = this.decodeBinary(size, 1);
|
|
45281
|
-
} else if (headByte === 197) {
|
|
45282
|
-
const size = this.lookU16();
|
|
45283
|
-
object2 = this.decodeBinary(size, 2);
|
|
45284
|
-
} else if (headByte === 198) {
|
|
45285
|
-
const size = this.lookU32();
|
|
45286
|
-
object2 = this.decodeBinary(size, 4);
|
|
45287
|
-
} else if (headByte === 212) {
|
|
45288
|
-
object2 = this.decodeExtension(1, 0);
|
|
45289
|
-
} else if (headByte === 213) {
|
|
45290
|
-
object2 = this.decodeExtension(2, 0);
|
|
45291
|
-
} else if (headByte === 214) {
|
|
45292
|
-
object2 = this.decodeExtension(4, 0);
|
|
45293
|
-
} else if (headByte === 215) {
|
|
45294
|
-
object2 = this.decodeExtension(8, 0);
|
|
45295
|
-
} else if (headByte === 216) {
|
|
45296
|
-
object2 = this.decodeExtension(16, 0);
|
|
45297
|
-
} else if (headByte === 199) {
|
|
45298
|
-
const size = this.lookU8();
|
|
45299
|
-
object2 = this.decodeExtension(size, 1);
|
|
45300
|
-
} else if (headByte === 200) {
|
|
45301
|
-
const size = this.lookU16();
|
|
45302
|
-
object2 = this.decodeExtension(size, 2);
|
|
45303
|
-
} else if (headByte === 201) {
|
|
45304
|
-
const size = this.lookU32();
|
|
45305
|
-
object2 = this.decodeExtension(size, 4);
|
|
45306
|
-
} else {
|
|
45307
|
-
throw new DecodeError(`Unrecognized type byte: ${prettyByte(headByte)}`);
|
|
45308
|
-
}
|
|
45309
|
-
this.complete();
|
|
45310
|
-
const stack = this.stack;
|
|
45311
|
-
while (stack.length > 0) {
|
|
45312
|
-
const state = stack.top();
|
|
45313
|
-
if (state.type === STATE_ARRAY) {
|
|
45314
|
-
state.array[state.position] = object2;
|
|
45315
|
-
state.position++;
|
|
45316
|
-
if (state.position === state.size) {
|
|
45317
|
-
object2 = state.array;
|
|
45318
|
-
stack.release(state);
|
|
45319
|
-
} else {
|
|
45320
|
-
continue DECODE;
|
|
45321
|
-
}
|
|
45322
|
-
} else if (state.type === STATE_MAP_KEY) {
|
|
45323
|
-
if (object2 === "__proto__") {
|
|
45324
|
-
throw new DecodeError("The key __proto__ is not allowed");
|
|
45325
|
-
}
|
|
45326
|
-
state.key = this.mapKeyConverter(object2);
|
|
45327
|
-
state.type = STATE_MAP_VALUE;
|
|
45328
|
-
continue DECODE;
|
|
45329
|
-
} else {
|
|
45330
|
-
state.map[state.key] = object2;
|
|
45331
|
-
state.readCount++;
|
|
45332
|
-
if (state.readCount === state.size) {
|
|
45333
|
-
object2 = state.map;
|
|
45334
|
-
stack.release(state);
|
|
45335
|
-
} else {
|
|
45336
|
-
state.key = null;
|
|
45337
|
-
state.type = STATE_MAP_KEY;
|
|
45338
|
-
continue DECODE;
|
|
45339
|
-
}
|
|
45340
|
-
}
|
|
45341
|
-
}
|
|
45342
|
-
return object2;
|
|
45343
|
-
}
|
|
45344
|
-
}
|
|
45345
|
-
readHeadByte() {
|
|
45346
|
-
if (this.headByte === HEAD_BYTE_REQUIRED) {
|
|
45347
|
-
this.headByte = this.readU8();
|
|
45348
|
-
}
|
|
45349
|
-
return this.headByte;
|
|
45350
|
-
}
|
|
45351
|
-
complete() {
|
|
45352
|
-
this.headByte = HEAD_BYTE_REQUIRED;
|
|
45353
|
-
}
|
|
45354
|
-
readArraySize() {
|
|
45355
|
-
const headByte = this.readHeadByte();
|
|
45356
|
-
switch (headByte) {
|
|
45357
|
-
case 220:
|
|
45358
|
-
return this.readU16();
|
|
45359
|
-
case 221:
|
|
45360
|
-
return this.readU32();
|
|
45361
|
-
default: {
|
|
45362
|
-
if (headByte < 160) {
|
|
45363
|
-
return headByte - 144;
|
|
45364
|
-
} else {
|
|
45365
|
-
throw new DecodeError(`Unrecognized array type byte: ${prettyByte(headByte)}`);
|
|
45366
|
-
}
|
|
45367
|
-
}
|
|
45368
|
-
}
|
|
45369
|
-
}
|
|
45370
|
-
pushMapState(size) {
|
|
45371
|
-
if (size > this.maxMapLength) {
|
|
45372
|
-
throw new DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
|
|
45373
|
-
}
|
|
45374
|
-
this.stack.pushMapState(size);
|
|
45375
|
-
}
|
|
45376
|
-
pushArrayState(size) {
|
|
45377
|
-
if (size > this.maxArrayLength) {
|
|
45378
|
-
throw new DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
|
|
45379
|
-
}
|
|
45380
|
-
this.stack.pushArrayState(size);
|
|
45381
|
-
}
|
|
45382
|
-
decodeString(byteLength, headerOffset) {
|
|
45383
|
-
if (!this.rawStrings || this.stateIsMapKey()) {
|
|
45384
|
-
return this.decodeUtf8String(byteLength, headerOffset);
|
|
45385
|
-
}
|
|
45386
|
-
return this.decodeBinary(byteLength, headerOffset);
|
|
45387
|
-
}
|
|
45388
|
-
/**
|
|
45389
|
-
* @throws {@link RangeError}
|
|
45390
|
-
*/
|
|
45391
|
-
decodeUtf8String(byteLength, headerOffset) {
|
|
45392
|
-
if (byteLength > this.maxStrLength) {
|
|
45393
|
-
throw new DecodeError(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`);
|
|
45394
|
-
}
|
|
45395
|
-
if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
|
|
45396
|
-
throw MORE_DATA;
|
|
45397
|
-
}
|
|
45398
|
-
const offset = this.pos + headerOffset;
|
|
45399
|
-
let object2;
|
|
45400
|
-
if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) {
|
|
45401
|
-
object2 = this.keyDecoder.decode(this.bytes, offset, byteLength);
|
|
45402
|
-
} else {
|
|
45403
|
-
object2 = utf8Decode(this.bytes, offset, byteLength);
|
|
45404
|
-
}
|
|
45405
|
-
this.pos += headerOffset + byteLength;
|
|
45406
|
-
return object2;
|
|
45407
|
-
}
|
|
45408
|
-
stateIsMapKey() {
|
|
45409
|
-
if (this.stack.length > 0) {
|
|
45410
|
-
const state = this.stack.top();
|
|
45411
|
-
return state.type === STATE_MAP_KEY;
|
|
45412
|
-
}
|
|
45413
|
-
return false;
|
|
45414
|
-
}
|
|
45415
|
-
/**
|
|
45416
|
-
* @throws {@link RangeError}
|
|
45417
|
-
*/
|
|
45418
|
-
decodeBinary(byteLength, headOffset) {
|
|
45419
|
-
if (byteLength > this.maxBinLength) {
|
|
45420
|
-
throw new DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
|
|
45421
|
-
}
|
|
45422
|
-
if (!this.hasRemaining(byteLength + headOffset)) {
|
|
45423
|
-
throw MORE_DATA;
|
|
45424
|
-
}
|
|
45425
|
-
const offset = this.pos + headOffset;
|
|
45426
|
-
const object2 = this.bytes.subarray(offset, offset + byteLength);
|
|
45427
|
-
this.pos += headOffset + byteLength;
|
|
45428
|
-
return object2;
|
|
45429
|
-
}
|
|
45430
|
-
decodeExtension(size, headOffset) {
|
|
45431
|
-
if (size > this.maxExtLength) {
|
|
45432
|
-
throw new DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
|
|
45433
|
-
}
|
|
45434
|
-
const extType = this.view.getInt8(this.pos + headOffset);
|
|
45435
|
-
const data = this.decodeBinary(
|
|
45436
|
-
size,
|
|
45437
|
-
headOffset + 1
|
|
45438
|
-
/* extType */
|
|
45439
|
-
);
|
|
45440
|
-
return this.extensionCodec.decode(data, extType, this.context);
|
|
45441
|
-
}
|
|
45442
|
-
lookU8() {
|
|
45443
|
-
return this.view.getUint8(this.pos);
|
|
45444
|
-
}
|
|
45445
|
-
lookU16() {
|
|
45446
|
-
return this.view.getUint16(this.pos);
|
|
45447
|
-
}
|
|
45448
|
-
lookU32() {
|
|
45449
|
-
return this.view.getUint32(this.pos);
|
|
45450
|
-
}
|
|
45451
|
-
readU8() {
|
|
45452
|
-
const value = this.view.getUint8(this.pos);
|
|
45453
|
-
this.pos++;
|
|
45454
|
-
return value;
|
|
45455
|
-
}
|
|
45456
|
-
readI8() {
|
|
45457
|
-
const value = this.view.getInt8(this.pos);
|
|
45458
|
-
this.pos++;
|
|
45459
|
-
return value;
|
|
45460
|
-
}
|
|
45461
|
-
readU16() {
|
|
45462
|
-
const value = this.view.getUint16(this.pos);
|
|
45463
|
-
this.pos += 2;
|
|
45464
|
-
return value;
|
|
45465
|
-
}
|
|
45466
|
-
readI16() {
|
|
45467
|
-
const value = this.view.getInt16(this.pos);
|
|
45468
|
-
this.pos += 2;
|
|
45469
|
-
return value;
|
|
45470
|
-
}
|
|
45471
|
-
readU32() {
|
|
45472
|
-
const value = this.view.getUint32(this.pos);
|
|
45473
|
-
this.pos += 4;
|
|
45474
|
-
return value;
|
|
45475
|
-
}
|
|
45476
|
-
readI32() {
|
|
45477
|
-
const value = this.view.getInt32(this.pos);
|
|
45478
|
-
this.pos += 4;
|
|
45479
|
-
return value;
|
|
45480
|
-
}
|
|
45481
|
-
readU64() {
|
|
45482
|
-
const value = getUint64(this.view, this.pos);
|
|
45483
|
-
this.pos += 8;
|
|
45484
|
-
return value;
|
|
45485
|
-
}
|
|
45486
|
-
readI64() {
|
|
45487
|
-
const value = getInt64(this.view, this.pos);
|
|
45488
|
-
this.pos += 8;
|
|
45489
|
-
return value;
|
|
45490
|
-
}
|
|
45491
|
-
readU64AsBigInt() {
|
|
45492
|
-
const value = this.view.getBigUint64(this.pos);
|
|
45493
|
-
this.pos += 8;
|
|
45494
|
-
return value;
|
|
45495
|
-
}
|
|
45496
|
-
readI64AsBigInt() {
|
|
45497
|
-
const value = this.view.getBigInt64(this.pos);
|
|
45498
|
-
this.pos += 8;
|
|
45499
|
-
return value;
|
|
45500
|
-
}
|
|
45501
|
-
readF32() {
|
|
45502
|
-
const value = this.view.getFloat32(this.pos);
|
|
45503
|
-
this.pos += 4;
|
|
45504
|
-
return value;
|
|
45505
|
-
}
|
|
45506
|
-
readF64() {
|
|
45507
|
-
const value = this.view.getFloat64(this.pos);
|
|
45508
|
-
this.pos += 8;
|
|
45509
|
-
return value;
|
|
45510
|
-
}
|
|
45511
|
-
};
|
|
45512
|
-
|
|
45513
|
-
// src/vendor/titan/client.ts
|
|
45514
44078
|
var SUBPROTOCOL = "v1.api.titan.ag";
|
|
45515
44079
|
var UINT64_MAX = (1n << 64n) - 1n;
|
|
45516
44080
|
function toBigInt(value) {
|
|
@@ -50905,7 +49469,10 @@ async function getTitanSwapIxsViaWebSocket(params, feeAccount) {
|
|
|
50905
49469
|
const swapInstructions = bestRoute.instructions.map(deserializeTitanInstruction);
|
|
50906
49470
|
const lutPubkeys = bestRoute.addressLookupTables.map((lutBytes) => new PublicKey(lutBytes));
|
|
50907
49471
|
const addressLookupTableAddresses = await resolveLookupTables(connection, lutPubkeys);
|
|
50908
|
-
const quoteResponse =
|
|
49472
|
+
const quoteResponse = {
|
|
49473
|
+
...buildSwapQuoteResult(bestRoute, swapMode),
|
|
49474
|
+
provider: "TITAN" /* TITAN */
|
|
49475
|
+
};
|
|
50909
49476
|
return {
|
|
50910
49477
|
swapInstructions,
|
|
50911
49478
|
setupInstructions: [],
|
|
@@ -50982,7 +49549,10 @@ async function getTitanSwapIxsViaHttpProxy(params, feeAccount) {
|
|
|
50982
49549
|
(b64) => new PublicKey(Buffer.from(b64, "base64"))
|
|
50983
49550
|
);
|
|
50984
49551
|
const addressLookupTableAddresses = await resolveLookupTables(connection, lutPubkeys);
|
|
50985
|
-
const quoteResponse =
|
|
49552
|
+
const quoteResponse = {
|
|
49553
|
+
...buildSwapQuoteResult(bestRoute, swapMode),
|
|
49554
|
+
provider: "TITAN" /* TITAN */
|
|
49555
|
+
};
|
|
50986
49556
|
return {
|
|
50987
49557
|
swapInstructions,
|
|
50988
49558
|
setupInstructions: [],
|
|
@@ -51033,7 +49603,10 @@ async function getTitanExactOutViaWebSocket(params) {
|
|
|
51033
49603
|
if (!bestRoute) {
|
|
51034
49604
|
throw new Error(`No Titan ExactOut routes found for ${inputMint} -> ${outputMint}`);
|
|
51035
49605
|
}
|
|
51036
|
-
const quoteResult =
|
|
49606
|
+
const quoteResult = {
|
|
49607
|
+
...buildSwapQuoteResult(bestRoute, "ExactOut"),
|
|
49608
|
+
provider: "TITAN" /* TITAN */
|
|
49609
|
+
};
|
|
51037
49610
|
return {
|
|
51038
49611
|
otherAmountThreshold: quoteResult.otherAmountThreshold,
|
|
51039
49612
|
quoteResult
|
|
@@ -51074,7 +49647,8 @@ async function getTitanExactOutViaHttpProxy(params) {
|
|
|
51074
49647
|
inAmount: String(data.inAmount),
|
|
51075
49648
|
outAmount: String(data.outAmount),
|
|
51076
49649
|
otherAmountThreshold: data.otherAmountThreshold,
|
|
51077
|
-
slippageBps: data.slippageBps
|
|
49650
|
+
slippageBps: data.slippageBps,
|
|
49651
|
+
provider: "TITAN" /* TITAN */
|
|
51078
49652
|
};
|
|
51079
49653
|
return {
|
|
51080
49654
|
otherAmountThreshold: data.otherAmountThreshold,
|
|
@@ -51288,7 +49862,8 @@ function mapJupiterQuoteToSwapQuoteResult(quote) {
|
|
|
51288
49862
|
} : void 0,
|
|
51289
49863
|
priceImpactPct: quote.priceImpactPct,
|
|
51290
49864
|
contextSlot: quote.contextSlot,
|
|
51291
|
-
timeTaken: quote.timeTaken
|
|
49865
|
+
timeTaken: quote.timeTaken,
|
|
49866
|
+
provider: "JUPITER" /* JUPITER */
|
|
51292
49867
|
};
|
|
51293
49868
|
}
|
|
51294
49869
|
|
|
@@ -52608,7 +51183,7 @@ function computeMaxLeverage(depositBank, borrowBank, opts) {
|
|
|
52608
51183
|
ltv
|
|
52609
51184
|
};
|
|
52610
51185
|
}
|
|
52611
|
-
function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank,
|
|
51186
|
+
function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositPriceUsd, borrowPriceUsd, opts) {
|
|
52612
51187
|
const initialCollateral = toBigNumber(principal);
|
|
52613
51188
|
const { maxLeverage } = computeMaxLeverage(depositBank, borrowBank, opts);
|
|
52614
51189
|
let clampedLeverage = targetLeverage;
|
|
@@ -52623,7 +51198,7 @@ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank
|
|
|
52623
51198
|
}
|
|
52624
51199
|
const totalDepositAmount = initialCollateral.times(new BigNumber3(clampedLeverage));
|
|
52625
51200
|
const additionalDepositAmount = totalDepositAmount.minus(initialCollateral);
|
|
52626
|
-
const totalBorrowAmount = additionalDepositAmount.times(
|
|
51201
|
+
const totalBorrowAmount = additionalDepositAmount.times(new BigNumber3(depositPriceUsd)).div(new BigNumber3(borrowPriceUsd));
|
|
52627
51202
|
return {
|
|
52628
51203
|
totalBorrowAmount: totalBorrowAmount.decimalPlaces(
|
|
52629
51204
|
borrowBank.mintDecimals,
|
|
@@ -53669,13 +52244,11 @@ async function fetchBankIntegrationMetadata(options) {
|
|
|
53669
52244
|
return bankIntegrationMap;
|
|
53670
52245
|
}
|
|
53671
52246
|
var Bank = class _Bank {
|
|
53672
|
-
constructor(address, mint, mintDecimals, group,
|
|
52247
|
+
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, oracleKey, emode, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
53673
52248
|
this.address = address;
|
|
53674
52249
|
this.mint = mint;
|
|
53675
52250
|
this.mintDecimals = mintDecimals;
|
|
53676
52251
|
this.group = group;
|
|
53677
|
-
this.mintRate = mintRate;
|
|
53678
|
-
this.mintPrice = mintPrice;
|
|
53679
52252
|
this.assetShareValue = assetShareValue;
|
|
53680
52253
|
this.liabilityShareValue = liabilityShareValue;
|
|
53681
52254
|
this.liquidityVault = liquidityVault;
|
|
@@ -53745,8 +52318,6 @@ var Bank = class _Bank {
|
|
|
53745
52318
|
bankType.mint,
|
|
53746
52319
|
bankType.mintDecimals,
|
|
53747
52320
|
bankType.group,
|
|
53748
|
-
bankType.mintRate,
|
|
53749
|
-
bankType.mintPrice,
|
|
53750
52321
|
bankType.assetShareValue,
|
|
53751
52322
|
bankType.liabilityShareValue,
|
|
53752
52323
|
bankType.liquidityVault,
|
|
@@ -53788,8 +52359,6 @@ var Bank = class _Bank {
|
|
|
53788
52359
|
props.mint,
|
|
53789
52360
|
props.mintDecimals,
|
|
53790
52361
|
props.group,
|
|
53791
|
-
props.mintRate,
|
|
53792
|
-
props.mintPrice,
|
|
53793
52362
|
props.assetShareValue,
|
|
53794
52363
|
props.liabilityShareValue,
|
|
53795
52364
|
props.liquidityVault,
|