@nsshunt/stsobservability 1.0.97 → 1.0.99
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/stsobservability.mjs +564 -481
- package/dist/stsobservability.mjs.map +1 -1
- package/dist/stsobservability.umd.js +564 -481
- package/dist/stsobservability.umd.js.map +1 -1
- package/package.json +14 -14
- package/types/globalServiceDefinitions.d.ts.map +1 -1
- package/types/publish/agentinstrumentcontroller.d.ts.map +1 -1
- package/types/publish/middleware/requestLoggerMiddleware.d.ts.map +1 -1
- package/types/publish/publishInstrumentController.d.ts.map +1 -1
- package/types/publish/publishers/publishTransportRESTServer.d.ts.map +1 -1
- package/types/subscribe/commonTypes.d.ts.map +1 -1
- package/types/subscribe/kafkaHelper.d.ts.map +1 -1
- package/types/subscribe/observabilitymodelutils.d.ts.map +1 -1
|
@@ -3943,11 +3943,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3943
3943
|
var sourceExports = requireSource();
|
|
3944
3944
|
const chalk = /* @__PURE__ */ getDefaultExportFromCjs(sourceExports);
|
|
3945
3945
|
function utf8Count(str) {
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3946
|
+
const strLength = str.length;
|
|
3947
|
+
let byteLength = 0;
|
|
3948
|
+
let pos = 0;
|
|
3949
3949
|
while (pos < strLength) {
|
|
3950
|
-
|
|
3950
|
+
let value = str.charCodeAt(pos++);
|
|
3951
3951
|
if ((value & 4294967168) === 0) {
|
|
3952
3952
|
byteLength++;
|
|
3953
3953
|
continue;
|
|
@@ -3956,7 +3956,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3956
3956
|
} else {
|
|
3957
3957
|
if (value >= 55296 && value <= 56319) {
|
|
3958
3958
|
if (pos < strLength) {
|
|
3959
|
-
|
|
3959
|
+
const extra = str.charCodeAt(pos);
|
|
3960
3960
|
if ((extra & 64512) === 56320) {
|
|
3961
3961
|
++pos;
|
|
3962
3962
|
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
@@ -3973,11 +3973,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3973
3973
|
return byteLength;
|
|
3974
3974
|
}
|
|
3975
3975
|
function utf8EncodeJs(str, output, outputOffset) {
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3976
|
+
const strLength = str.length;
|
|
3977
|
+
let offset = outputOffset;
|
|
3978
|
+
let pos = 0;
|
|
3979
3979
|
while (pos < strLength) {
|
|
3980
|
-
|
|
3980
|
+
let value = str.charCodeAt(pos++);
|
|
3981
3981
|
if ((value & 4294967168) === 0) {
|
|
3982
3982
|
output[offset++] = value;
|
|
3983
3983
|
continue;
|
|
@@ -3986,7 +3986,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3986
3986
|
} else {
|
|
3987
3987
|
if (value >= 55296 && value <= 56319) {
|
|
3988
3988
|
if (pos < strLength) {
|
|
3989
|
-
|
|
3989
|
+
const extra = str.charCodeAt(pos);
|
|
3990
3990
|
if ((extra & 64512) === 56320) {
|
|
3991
3991
|
++pos;
|
|
3992
3992
|
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
@@ -4005,8 +4005,8 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
4005
4005
|
output[offset++] = value & 63 | 128;
|
|
4006
4006
|
}
|
|
4007
4007
|
}
|
|
4008
|
-
|
|
4009
|
-
|
|
4008
|
+
const sharedTextEncoder = new TextEncoder();
|
|
4009
|
+
const TEXT_ENCODER_THRESHOLD = 50;
|
|
4010
4010
|
function utf8EncodeTE(str, output, outputOffset) {
|
|
4011
4011
|
sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
|
|
4012
4012
|
}
|
|
@@ -4018,103 +4018,73 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
4018
4018
|
}
|
|
4019
4019
|
}
|
|
4020
4020
|
new TextDecoder();
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
};
|
|
4040
|
-
return function(d, b) {
|
|
4041
|
-
if (typeof b !== "function" && b !== null)
|
|
4042
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
4043
|
-
extendStatics(d, b);
|
|
4044
|
-
function __() {
|
|
4045
|
-
this.constructor = d;
|
|
4046
|
-
}
|
|
4047
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4048
|
-
};
|
|
4049
|
-
}();
|
|
4050
|
-
var DecodeError = (
|
|
4051
|
-
/** @class */
|
|
4052
|
-
function(_super) {
|
|
4053
|
-
__extends(DecodeError2, _super);
|
|
4054
|
-
function DecodeError2(message) {
|
|
4055
|
-
var _this = _super.call(this, message) || this;
|
|
4056
|
-
var proto = Object.create(DecodeError2.prototype);
|
|
4057
|
-
Object.setPrototypeOf(_this, proto);
|
|
4058
|
-
Object.defineProperty(_this, "name", {
|
|
4059
|
-
configurable: true,
|
|
4060
|
-
enumerable: false,
|
|
4061
|
-
value: DecodeError2.name
|
|
4062
|
-
});
|
|
4063
|
-
return _this;
|
|
4064
|
-
}
|
|
4065
|
-
return DecodeError2;
|
|
4066
|
-
}(Error)
|
|
4067
|
-
);
|
|
4021
|
+
class ExtData {
|
|
4022
|
+
constructor(type, data) {
|
|
4023
|
+
this.type = type;
|
|
4024
|
+
this.data = data;
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
class DecodeError extends Error {
|
|
4028
|
+
constructor(message) {
|
|
4029
|
+
super(message);
|
|
4030
|
+
const proto = Object.create(DecodeError.prototype);
|
|
4031
|
+
Object.setPrototypeOf(this, proto);
|
|
4032
|
+
Object.defineProperty(this, "name", {
|
|
4033
|
+
configurable: true,
|
|
4034
|
+
enumerable: false,
|
|
4035
|
+
value: DecodeError.name
|
|
4036
|
+
});
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4068
4039
|
function setUint64(view, offset, value) {
|
|
4069
|
-
|
|
4070
|
-
|
|
4040
|
+
const high = value / 4294967296;
|
|
4041
|
+
const low = value;
|
|
4071
4042
|
view.setUint32(offset, high);
|
|
4072
4043
|
view.setUint32(offset + 4, low);
|
|
4073
4044
|
}
|
|
4074
4045
|
function setInt64(view, offset, value) {
|
|
4075
|
-
|
|
4076
|
-
|
|
4046
|
+
const high = Math.floor(value / 4294967296);
|
|
4047
|
+
const low = value;
|
|
4077
4048
|
view.setUint32(offset, high);
|
|
4078
4049
|
view.setUint32(offset + 4, low);
|
|
4079
4050
|
}
|
|
4080
4051
|
function getInt64(view, offset) {
|
|
4081
|
-
|
|
4082
|
-
|
|
4052
|
+
const high = view.getInt32(offset);
|
|
4053
|
+
const low = view.getUint32(offset + 4);
|
|
4083
4054
|
return high * 4294967296 + low;
|
|
4084
4055
|
}
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
function encodeTimeSpecToTimestamp(
|
|
4089
|
-
var sec = _a2.sec, nsec = _a2.nsec;
|
|
4056
|
+
const EXT_TIMESTAMP = -1;
|
|
4057
|
+
const TIMESTAMP32_MAX_SEC = 4294967296 - 1;
|
|
4058
|
+
const TIMESTAMP64_MAX_SEC = 17179869184 - 1;
|
|
4059
|
+
function encodeTimeSpecToTimestamp({ sec, nsec }) {
|
|
4090
4060
|
if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
|
|
4091
4061
|
if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
|
|
4092
|
-
|
|
4093
|
-
|
|
4062
|
+
const rv = new Uint8Array(4);
|
|
4063
|
+
const view = new DataView(rv.buffer);
|
|
4094
4064
|
view.setUint32(0, sec);
|
|
4095
4065
|
return rv;
|
|
4096
4066
|
} else {
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4067
|
+
const secHigh = sec / 4294967296;
|
|
4068
|
+
const secLow = sec & 4294967295;
|
|
4069
|
+
const rv = new Uint8Array(8);
|
|
4070
|
+
const view = new DataView(rv.buffer);
|
|
4101
4071
|
view.setUint32(0, nsec << 2 | secHigh & 3);
|
|
4102
4072
|
view.setUint32(4, secLow);
|
|
4103
4073
|
return rv;
|
|
4104
4074
|
}
|
|
4105
4075
|
} else {
|
|
4106
|
-
|
|
4107
|
-
|
|
4076
|
+
const rv = new Uint8Array(12);
|
|
4077
|
+
const view = new DataView(rv.buffer);
|
|
4108
4078
|
view.setUint32(0, nsec);
|
|
4109
4079
|
setInt64(view, 4, sec);
|
|
4110
4080
|
return rv;
|
|
4111
4081
|
}
|
|
4112
4082
|
}
|
|
4113
4083
|
function encodeDateToTimeSpec(date) {
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4084
|
+
const msec = date.getTime();
|
|
4085
|
+
const sec = Math.floor(msec / 1e3);
|
|
4086
|
+
const nsec = (msec - sec * 1e3) * 1e6;
|
|
4087
|
+
const nsecInSec = Math.floor(nsec / 1e9);
|
|
4118
4088
|
return {
|
|
4119
4089
|
sec: sec + nsecInSec,
|
|
4120
4090
|
nsec: nsec - nsecInSec * 1e9
|
|
@@ -4122,105 +4092,100 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
4122
4092
|
}
|
|
4123
4093
|
function encodeTimestampExtension(object) {
|
|
4124
4094
|
if (object instanceof Date) {
|
|
4125
|
-
|
|
4095
|
+
const timeSpec = encodeDateToTimeSpec(object);
|
|
4126
4096
|
return encodeTimeSpecToTimestamp(timeSpec);
|
|
4127
4097
|
} else {
|
|
4128
4098
|
return null;
|
|
4129
4099
|
}
|
|
4130
4100
|
}
|
|
4131
4101
|
function decodeTimestampToTimeSpec(data) {
|
|
4132
|
-
|
|
4102
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
4133
4103
|
switch (data.byteLength) {
|
|
4134
4104
|
case 4: {
|
|
4135
|
-
|
|
4136
|
-
|
|
4105
|
+
const sec = view.getUint32(0);
|
|
4106
|
+
const nsec = 0;
|
|
4137
4107
|
return { sec, nsec };
|
|
4138
4108
|
}
|
|
4139
4109
|
case 8: {
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4110
|
+
const nsec30AndSecHigh2 = view.getUint32(0);
|
|
4111
|
+
const secLow32 = view.getUint32(4);
|
|
4112
|
+
const sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
|
|
4113
|
+
const nsec = nsec30AndSecHigh2 >>> 2;
|
|
4144
4114
|
return { sec, nsec };
|
|
4145
4115
|
}
|
|
4146
4116
|
case 12: {
|
|
4147
|
-
|
|
4148
|
-
|
|
4117
|
+
const sec = getInt64(view, 4);
|
|
4118
|
+
const nsec = view.getUint32(0);
|
|
4149
4119
|
return { sec, nsec };
|
|
4150
4120
|
}
|
|
4151
4121
|
default:
|
|
4152
|
-
throw new DecodeError(
|
|
4122
|
+
throw new DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
|
|
4153
4123
|
}
|
|
4154
4124
|
}
|
|
4155
4125
|
function decodeTimestampExtension(data) {
|
|
4156
|
-
|
|
4126
|
+
const timeSpec = decodeTimestampToTimeSpec(data);
|
|
4157
4127
|
return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
|
|
4158
4128
|
}
|
|
4159
|
-
|
|
4129
|
+
const timestampExtension = {
|
|
4160
4130
|
type: EXT_TIMESTAMP,
|
|
4161
4131
|
encode: encodeTimestampExtension,
|
|
4162
4132
|
decode: decodeTimestampExtension
|
|
4163
4133
|
};
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
if (data != null) {
|
|
4191
|
-
var type = -1 - i;
|
|
4192
|
-
return new ExtData(type, data);
|
|
4193
|
-
}
|
|
4134
|
+
class ExtensionCodec {
|
|
4135
|
+
constructor() {
|
|
4136
|
+
this.builtInEncoders = [];
|
|
4137
|
+
this.builtInDecoders = [];
|
|
4138
|
+
this.encoders = [];
|
|
4139
|
+
this.decoders = [];
|
|
4140
|
+
this.register(timestampExtension);
|
|
4141
|
+
}
|
|
4142
|
+
register({ type, encode: encode2, decode }) {
|
|
4143
|
+
if (type >= 0) {
|
|
4144
|
+
this.encoders[type] = encode2;
|
|
4145
|
+
this.decoders[type] = decode;
|
|
4146
|
+
} else {
|
|
4147
|
+
const index = -1 - type;
|
|
4148
|
+
this.builtInEncoders[index] = encode2;
|
|
4149
|
+
this.builtInDecoders[index] = decode;
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
tryToEncode(object, context) {
|
|
4153
|
+
for (let i = 0; i < this.builtInEncoders.length; i++) {
|
|
4154
|
+
const encodeExt = this.builtInEncoders[i];
|
|
4155
|
+
if (encodeExt != null) {
|
|
4156
|
+
const data = encodeExt(object, context);
|
|
4157
|
+
if (data != null) {
|
|
4158
|
+
const type = -1 - i;
|
|
4159
|
+
return new ExtData(type, data);
|
|
4194
4160
|
}
|
|
4195
4161
|
}
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4162
|
+
}
|
|
4163
|
+
for (let i = 0; i < this.encoders.length; i++) {
|
|
4164
|
+
const encodeExt = this.encoders[i];
|
|
4165
|
+
if (encodeExt != null) {
|
|
4166
|
+
const data = encodeExt(object, context);
|
|
4167
|
+
if (data != null) {
|
|
4168
|
+
const type = i;
|
|
4169
|
+
return new ExtData(type, data);
|
|
4204
4170
|
}
|
|
4205
4171
|
}
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
}
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
)
|
|
4223
|
-
function isArrayBuffer(buffer) {
|
|
4172
|
+
}
|
|
4173
|
+
if (object instanceof ExtData) {
|
|
4174
|
+
return object;
|
|
4175
|
+
}
|
|
4176
|
+
return null;
|
|
4177
|
+
}
|
|
4178
|
+
decode(data, type, context) {
|
|
4179
|
+
const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
|
4180
|
+
if (decodeExt) {
|
|
4181
|
+
return decodeExt(data, type, context);
|
|
4182
|
+
} else {
|
|
4183
|
+
return new ExtData(type, data);
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
ExtensionCodec.defaultCodec = new ExtensionCodec();
|
|
4188
|
+
function isArrayBufferLike(buffer) {
|
|
4224
4189
|
return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
|
|
4225
4190
|
}
|
|
4226
4191
|
function ensureUint8Array(buffer) {
|
|
@@ -4228,359 +4193,477 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
4228
4193
|
return buffer;
|
|
4229
4194
|
} else if (ArrayBuffer.isView(buffer)) {
|
|
4230
4195
|
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4231
|
-
} else if (
|
|
4196
|
+
} else if (isArrayBufferLike(buffer)) {
|
|
4232
4197
|
return new Uint8Array(buffer);
|
|
4233
4198
|
} else {
|
|
4234
4199
|
return Uint8Array.from(buffer);
|
|
4235
4200
|
}
|
|
4236
4201
|
}
|
|
4237
|
-
var
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4202
|
+
var __addDisposableResource = function(env, value, async) {
|
|
4203
|
+
if (value !== null && value !== void 0) {
|
|
4204
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4205
|
+
var dispose, inner;
|
|
4206
|
+
if (async) {
|
|
4207
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
4208
|
+
dispose = value[Symbol.asyncDispose];
|
|
4209
|
+
}
|
|
4210
|
+
if (dispose === void 0) {
|
|
4211
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
4212
|
+
dispose = value[Symbol.dispose];
|
|
4213
|
+
if (async) inner = dispose;
|
|
4214
|
+
}
|
|
4215
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
4216
|
+
if (inner) dispose = function() {
|
|
4217
|
+
try {
|
|
4218
|
+
inner.call(this);
|
|
4219
|
+
} catch (e) {
|
|
4220
|
+
return Promise.reject(e);
|
|
4221
|
+
}
|
|
4222
|
+
};
|
|
4223
|
+
env.stack.push({ value, dispose, async });
|
|
4224
|
+
} else if (async) {
|
|
4225
|
+
env.stack.push({ async: true });
|
|
4226
|
+
}
|
|
4227
|
+
return value;
|
|
4228
|
+
};
|
|
4229
|
+
var __disposeResources = /* @__PURE__ */ function(SuppressedError2) {
|
|
4230
|
+
return function(env) {
|
|
4231
|
+
function fail(e) {
|
|
4232
|
+
env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
|
|
4233
|
+
env.hasError = true;
|
|
4234
|
+
}
|
|
4235
|
+
var r, s = 0;
|
|
4236
|
+
function next() {
|
|
4237
|
+
while (r = env.stack.pop()) {
|
|
4238
|
+
try {
|
|
4239
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
4240
|
+
if (r.dispose) {
|
|
4241
|
+
var result = r.dispose.call(r.value);
|
|
4242
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
4243
|
+
fail(e);
|
|
4244
|
+
return next();
|
|
4245
|
+
});
|
|
4246
|
+
} else s |= 1;
|
|
4247
|
+
} catch (e) {
|
|
4248
|
+
fail(e);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
4252
|
+
if (env.hasError) throw env.error;
|
|
4253
|
+
}
|
|
4254
|
+
return next();
|
|
4255
|
+
};
|
|
4256
|
+
}(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
4257
|
+
var e = new Error(message);
|
|
4258
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4259
|
+
});
|
|
4260
|
+
const DEFAULT_MAX_DEPTH = 100;
|
|
4261
|
+
const DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
|
4262
|
+
class Encoder {
|
|
4263
|
+
constructor(options) {
|
|
4264
|
+
this.entered = false;
|
|
4265
|
+
this.extensionCodec = (options == null ? void 0 : options.extensionCodec) ?? ExtensionCodec.defaultCodec;
|
|
4266
|
+
this.context = options == null ? void 0 : options.context;
|
|
4267
|
+
this.useBigInt64 = (options == null ? void 0 : options.useBigInt64) ?? false;
|
|
4268
|
+
this.maxDepth = (options == null ? void 0 : options.maxDepth) ?? DEFAULT_MAX_DEPTH;
|
|
4269
|
+
this.initialBufferSize = (options == null ? void 0 : options.initialBufferSize) ?? DEFAULT_INITIAL_BUFFER_SIZE;
|
|
4270
|
+
this.sortKeys = (options == null ? void 0 : options.sortKeys) ?? false;
|
|
4271
|
+
this.forceFloat32 = (options == null ? void 0 : options.forceFloat32) ?? false;
|
|
4272
|
+
this.ignoreUndefined = (options == null ? void 0 : options.ignoreUndefined) ?? false;
|
|
4273
|
+
this.forceIntegerToFloat = (options == null ? void 0 : options.forceIntegerToFloat) ?? false;
|
|
4274
|
+
this.pos = 0;
|
|
4275
|
+
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
|
4276
|
+
this.bytes = new Uint8Array(this.view.buffer);
|
|
4277
|
+
}
|
|
4278
|
+
clone() {
|
|
4279
|
+
return new Encoder({
|
|
4280
|
+
extensionCodec: this.extensionCodec,
|
|
4281
|
+
context: this.context,
|
|
4282
|
+
useBigInt64: this.useBigInt64,
|
|
4283
|
+
maxDepth: this.maxDepth,
|
|
4284
|
+
initialBufferSize: this.initialBufferSize,
|
|
4285
|
+
sortKeys: this.sortKeys,
|
|
4286
|
+
forceFloat32: this.forceFloat32,
|
|
4287
|
+
ignoreUndefined: this.ignoreUndefined,
|
|
4288
|
+
forceIntegerToFloat: this.forceIntegerToFloat
|
|
4289
|
+
});
|
|
4290
|
+
}
|
|
4291
|
+
reinitializeState() {
|
|
4292
|
+
this.pos = 0;
|
|
4293
|
+
}
|
|
4294
|
+
enteringGuard() {
|
|
4295
|
+
this.entered = true;
|
|
4296
|
+
return {
|
|
4297
|
+
[Symbol.dispose]: () => {
|
|
4298
|
+
this.entered = false;
|
|
4299
|
+
}
|
|
4259
4300
|
};
|
|
4260
|
-
|
|
4301
|
+
}
|
|
4302
|
+
/**
|
|
4303
|
+
* 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}.
|
|
4304
|
+
*
|
|
4305
|
+
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
|
4306
|
+
*/
|
|
4307
|
+
encodeSharedRef(object) {
|
|
4308
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
4309
|
+
try {
|
|
4310
|
+
if (this.entered) {
|
|
4311
|
+
const instance = this.clone();
|
|
4312
|
+
return instance.encodeSharedRef(object);
|
|
4313
|
+
}
|
|
4314
|
+
const _guard = __addDisposableResource(env_1, this.enteringGuard(), false);
|
|
4261
4315
|
this.reinitializeState();
|
|
4262
4316
|
this.doEncode(object, 1);
|
|
4263
4317
|
return this.bytes.subarray(0, this.pos);
|
|
4264
|
-
}
|
|
4265
|
-
|
|
4318
|
+
} catch (e_1) {
|
|
4319
|
+
env_1.error = e_1;
|
|
4320
|
+
env_1.hasError = true;
|
|
4321
|
+
} finally {
|
|
4322
|
+
__disposeResources(env_1);
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4325
|
+
/**
|
|
4326
|
+
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
|
4327
|
+
*/
|
|
4328
|
+
encode(object) {
|
|
4329
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
4330
|
+
try {
|
|
4331
|
+
if (this.entered) {
|
|
4332
|
+
const instance = this.clone();
|
|
4333
|
+
return instance.encode(object);
|
|
4334
|
+
}
|
|
4335
|
+
const _guard = __addDisposableResource(env_2, this.enteringGuard(), false);
|
|
4266
4336
|
this.reinitializeState();
|
|
4267
4337
|
this.doEncode(object, 1);
|
|
4268
4338
|
return this.bytes.slice(0, this.pos);
|
|
4269
|
-
}
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4339
|
+
} catch (e_2) {
|
|
4340
|
+
env_2.error = e_2;
|
|
4341
|
+
env_2.hasError = true;
|
|
4342
|
+
} finally {
|
|
4343
|
+
__disposeResources(env_2);
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
doEncode(object, depth) {
|
|
4347
|
+
if (depth > this.maxDepth) {
|
|
4348
|
+
throw new Error(`Too deep objects in depth ${depth}`);
|
|
4349
|
+
}
|
|
4350
|
+
if (object == null) {
|
|
4351
|
+
this.encodeNil();
|
|
4352
|
+
} else if (typeof object === "boolean") {
|
|
4353
|
+
this.encodeBoolean(object);
|
|
4354
|
+
} else if (typeof object === "number") {
|
|
4355
|
+
if (!this.forceIntegerToFloat) {
|
|
4356
|
+
this.encodeNumber(object);
|
|
4357
|
+
} else {
|
|
4358
|
+
this.encodeNumberAsFloat(object);
|
|
4359
|
+
}
|
|
4360
|
+
} else if (typeof object === "string") {
|
|
4361
|
+
this.encodeString(object);
|
|
4362
|
+
} else if (this.useBigInt64 && typeof object === "bigint") {
|
|
4363
|
+
this.encodeBigInt64(object);
|
|
4364
|
+
} else {
|
|
4365
|
+
this.encodeObject(object, depth);
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
ensureBufferSizeToWrite(sizeToWrite) {
|
|
4369
|
+
const requiredSize = this.pos + sizeToWrite;
|
|
4370
|
+
if (this.view.byteLength < requiredSize) {
|
|
4371
|
+
this.resizeBuffer(requiredSize * 2);
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
resizeBuffer(newSize) {
|
|
4375
|
+
const newBuffer = new ArrayBuffer(newSize);
|
|
4376
|
+
const newBytes = new Uint8Array(newBuffer);
|
|
4377
|
+
const newView = new DataView(newBuffer);
|
|
4378
|
+
newBytes.set(this.bytes);
|
|
4379
|
+
this.view = newView;
|
|
4380
|
+
this.bytes = newBytes;
|
|
4381
|
+
}
|
|
4382
|
+
encodeNil() {
|
|
4383
|
+
this.writeU8(192);
|
|
4384
|
+
}
|
|
4385
|
+
encodeBoolean(object) {
|
|
4386
|
+
if (object === false) {
|
|
4387
|
+
this.writeU8(194);
|
|
4388
|
+
} else {
|
|
4389
|
+
this.writeU8(195);
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
encodeNumber(object) {
|
|
4393
|
+
if (!this.forceIntegerToFloat && Number.isSafeInteger(object)) {
|
|
4394
|
+
if (object >= 0) {
|
|
4395
|
+
if (object < 128) {
|
|
4396
|
+
this.writeU8(object);
|
|
4397
|
+
} else if (object < 256) {
|
|
4398
|
+
this.writeU8(204);
|
|
4399
|
+
this.writeU8(object);
|
|
4400
|
+
} else if (object < 65536) {
|
|
4401
|
+
this.writeU8(205);
|
|
4402
|
+
this.writeU16(object);
|
|
4403
|
+
} else if (object < 4294967296) {
|
|
4404
|
+
this.writeU8(206);
|
|
4405
|
+
this.writeU32(object);
|
|
4406
|
+
} else if (!this.useBigInt64) {
|
|
4407
|
+
this.writeU8(207);
|
|
4408
|
+
this.writeU64(object);
|
|
4281
4409
|
} else {
|
|
4282
4410
|
this.encodeNumberAsFloat(object);
|
|
4283
4411
|
}
|
|
4284
|
-
} else if (typeof object === "string") {
|
|
4285
|
-
this.encodeString(object);
|
|
4286
|
-
} else if (this.useBigInt64 && typeof object === "bigint") {
|
|
4287
|
-
this.encodeBigInt64(object);
|
|
4288
4412
|
} else {
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
this.view = newView;
|
|
4304
|
-
this.bytes = newBytes;
|
|
4305
|
-
};
|
|
4306
|
-
Encoder2.prototype.encodeNil = function() {
|
|
4307
|
-
this.writeU8(192);
|
|
4308
|
-
};
|
|
4309
|
-
Encoder2.prototype.encodeBoolean = function(object) {
|
|
4310
|
-
if (object === false) {
|
|
4311
|
-
this.writeU8(194);
|
|
4312
|
-
} else {
|
|
4313
|
-
this.writeU8(195);
|
|
4314
|
-
}
|
|
4315
|
-
};
|
|
4316
|
-
Encoder2.prototype.encodeNumber = function(object) {
|
|
4317
|
-
if (!this.forceIntegerToFloat && Number.isSafeInteger(object)) {
|
|
4318
|
-
if (object >= 0) {
|
|
4319
|
-
if (object < 128) {
|
|
4320
|
-
this.writeU8(object);
|
|
4321
|
-
} else if (object < 256) {
|
|
4322
|
-
this.writeU8(204);
|
|
4323
|
-
this.writeU8(object);
|
|
4324
|
-
} else if (object < 65536) {
|
|
4325
|
-
this.writeU8(205);
|
|
4326
|
-
this.writeU16(object);
|
|
4327
|
-
} else if (object < 4294967296) {
|
|
4328
|
-
this.writeU8(206);
|
|
4329
|
-
this.writeU32(object);
|
|
4330
|
-
} else if (!this.useBigInt64) {
|
|
4331
|
-
this.writeU8(207);
|
|
4332
|
-
this.writeU64(object);
|
|
4333
|
-
} else {
|
|
4334
|
-
this.encodeNumberAsFloat(object);
|
|
4335
|
-
}
|
|
4413
|
+
if (object >= -32) {
|
|
4414
|
+
this.writeU8(224 | object + 32);
|
|
4415
|
+
} else if (object >= -128) {
|
|
4416
|
+
this.writeU8(208);
|
|
4417
|
+
this.writeI8(object);
|
|
4418
|
+
} else if (object >= -32768) {
|
|
4419
|
+
this.writeU8(209);
|
|
4420
|
+
this.writeI16(object);
|
|
4421
|
+
} else if (object >= -2147483648) {
|
|
4422
|
+
this.writeU8(210);
|
|
4423
|
+
this.writeI32(object);
|
|
4424
|
+
} else if (!this.useBigInt64) {
|
|
4425
|
+
this.writeU8(211);
|
|
4426
|
+
this.writeI64(object);
|
|
4336
4427
|
} else {
|
|
4337
|
-
|
|
4338
|
-
this.writeU8(224 | object + 32);
|
|
4339
|
-
} else if (object >= -128) {
|
|
4340
|
-
this.writeU8(208);
|
|
4341
|
-
this.writeI8(object);
|
|
4342
|
-
} else if (object >= -32768) {
|
|
4343
|
-
this.writeU8(209);
|
|
4344
|
-
this.writeI16(object);
|
|
4345
|
-
} else if (object >= -2147483648) {
|
|
4346
|
-
this.writeU8(210);
|
|
4347
|
-
this.writeI32(object);
|
|
4348
|
-
} else if (!this.useBigInt64) {
|
|
4349
|
-
this.writeU8(211);
|
|
4350
|
-
this.writeI64(object);
|
|
4351
|
-
} else {
|
|
4352
|
-
this.encodeNumberAsFloat(object);
|
|
4353
|
-
}
|
|
4428
|
+
this.encodeNumberAsFloat(object);
|
|
4354
4429
|
}
|
|
4355
|
-
} else {
|
|
4356
|
-
this.encodeNumberAsFloat(object);
|
|
4357
4430
|
}
|
|
4358
|
-
}
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
}
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
}
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
}
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4431
|
+
} else {
|
|
4432
|
+
this.encodeNumberAsFloat(object);
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
encodeNumberAsFloat(object) {
|
|
4436
|
+
if (this.forceFloat32) {
|
|
4437
|
+
this.writeU8(202);
|
|
4438
|
+
this.writeF32(object);
|
|
4439
|
+
} else {
|
|
4440
|
+
this.writeU8(203);
|
|
4441
|
+
this.writeF64(object);
|
|
4442
|
+
}
|
|
4443
|
+
}
|
|
4444
|
+
encodeBigInt64(object) {
|
|
4445
|
+
if (object >= BigInt(0)) {
|
|
4446
|
+
this.writeU8(207);
|
|
4447
|
+
this.writeBigUint64(object);
|
|
4448
|
+
} else {
|
|
4449
|
+
this.writeU8(211);
|
|
4450
|
+
this.writeBigInt64(object);
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
writeStringHeader(byteLength) {
|
|
4454
|
+
if (byteLength < 32) {
|
|
4455
|
+
this.writeU8(160 + byteLength);
|
|
4456
|
+
} else if (byteLength < 256) {
|
|
4457
|
+
this.writeU8(217);
|
|
4458
|
+
this.writeU8(byteLength);
|
|
4459
|
+
} else if (byteLength < 65536) {
|
|
4460
|
+
this.writeU8(218);
|
|
4461
|
+
this.writeU16(byteLength);
|
|
4462
|
+
} else if (byteLength < 4294967296) {
|
|
4463
|
+
this.writeU8(219);
|
|
4464
|
+
this.writeU32(byteLength);
|
|
4465
|
+
} else {
|
|
4466
|
+
throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
encodeString(object) {
|
|
4470
|
+
const maxHeaderSize = 1 + 4;
|
|
4471
|
+
const byteLength = utf8Count(object);
|
|
4472
|
+
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
|
4473
|
+
this.writeStringHeader(byteLength);
|
|
4474
|
+
utf8Encode(object, this.bytes, this.pos);
|
|
4475
|
+
this.pos += byteLength;
|
|
4476
|
+
}
|
|
4477
|
+
encodeObject(object, depth) {
|
|
4478
|
+
const ext = this.extensionCodec.tryToEncode(object, this.context);
|
|
4479
|
+
if (ext != null) {
|
|
4480
|
+
this.encodeExtension(ext);
|
|
4481
|
+
} else if (Array.isArray(object)) {
|
|
4482
|
+
this.encodeArray(object, depth);
|
|
4483
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
4484
|
+
this.encodeBinary(object);
|
|
4485
|
+
} else if (typeof object === "object") {
|
|
4486
|
+
this.encodeMap(object, depth);
|
|
4487
|
+
} else {
|
|
4488
|
+
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object)}`);
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
encodeBinary(object) {
|
|
4492
|
+
const size = object.byteLength;
|
|
4493
|
+
if (size < 256) {
|
|
4494
|
+
this.writeU8(196);
|
|
4495
|
+
this.writeU8(size);
|
|
4496
|
+
} else if (size < 65536) {
|
|
4497
|
+
this.writeU8(197);
|
|
4498
|
+
this.writeU16(size);
|
|
4499
|
+
} else if (size < 4294967296) {
|
|
4500
|
+
this.writeU8(198);
|
|
4501
|
+
this.writeU32(size);
|
|
4502
|
+
} else {
|
|
4503
|
+
throw new Error(`Too large binary: ${size}`);
|
|
4504
|
+
}
|
|
4505
|
+
const bytes = ensureUint8Array(object);
|
|
4506
|
+
this.writeU8a(bytes);
|
|
4507
|
+
}
|
|
4508
|
+
encodeArray(object, depth) {
|
|
4509
|
+
const size = object.length;
|
|
4510
|
+
if (size < 16) {
|
|
4511
|
+
this.writeU8(144 + size);
|
|
4512
|
+
} else if (size < 65536) {
|
|
4513
|
+
this.writeU8(220);
|
|
4514
|
+
this.writeU16(size);
|
|
4515
|
+
} else if (size < 4294967296) {
|
|
4516
|
+
this.writeU8(221);
|
|
4517
|
+
this.writeU32(size);
|
|
4518
|
+
} else {
|
|
4519
|
+
throw new Error(`Too large array: ${size}`);
|
|
4520
|
+
}
|
|
4521
|
+
for (const item of object) {
|
|
4522
|
+
this.doEncode(item, depth + 1);
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
countWithoutUndefined(object, keys) {
|
|
4526
|
+
let count = 0;
|
|
4527
|
+
for (const key of keys) {
|
|
4528
|
+
if (object[key] !== void 0) {
|
|
4529
|
+
count++;
|
|
4457
4530
|
}
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
}
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
}
|
|
4531
|
+
}
|
|
4532
|
+
return count;
|
|
4533
|
+
}
|
|
4534
|
+
encodeMap(object, depth) {
|
|
4535
|
+
const keys = Object.keys(object);
|
|
4536
|
+
if (this.sortKeys) {
|
|
4537
|
+
keys.sort();
|
|
4538
|
+
}
|
|
4539
|
+
const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
|
|
4540
|
+
if (size < 16) {
|
|
4541
|
+
this.writeU8(128 + size);
|
|
4542
|
+
} else if (size < 65536) {
|
|
4543
|
+
this.writeU8(222);
|
|
4544
|
+
this.writeU16(size);
|
|
4545
|
+
} else if (size < 4294967296) {
|
|
4546
|
+
this.writeU8(223);
|
|
4547
|
+
this.writeU32(size);
|
|
4548
|
+
} else {
|
|
4549
|
+
throw new Error(`Too large map object: ${size}`);
|
|
4550
|
+
}
|
|
4551
|
+
for (const key of keys) {
|
|
4552
|
+
const value = object[key];
|
|
4553
|
+
if (!(this.ignoreUndefined && value === void 0)) {
|
|
4554
|
+
this.encodeString(key);
|
|
4555
|
+
this.doEncode(value, depth + 1);
|
|
4484
4556
|
}
|
|
4485
|
-
}
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
this.writeU8(214);
|
|
4494
|
-
} else if (size === 8) {
|
|
4495
|
-
this.writeU8(215);
|
|
4496
|
-
} else if (size === 16) {
|
|
4497
|
-
this.writeU8(216);
|
|
4498
|
-
} else if (size < 256) {
|
|
4499
|
-
this.writeU8(199);
|
|
4500
|
-
this.writeU8(size);
|
|
4501
|
-
} else if (size < 65536) {
|
|
4502
|
-
this.writeU8(200);
|
|
4503
|
-
this.writeU16(size);
|
|
4504
|
-
} else if (size < 4294967296) {
|
|
4505
|
-
this.writeU8(201);
|
|
4506
|
-
this.writeU32(size);
|
|
4507
|
-
} else {
|
|
4508
|
-
throw new Error("Too large extension object: ".concat(size));
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
encodeExtension(ext) {
|
|
4560
|
+
if (typeof ext.data === "function") {
|
|
4561
|
+
const data = ext.data(this.pos + 6);
|
|
4562
|
+
const size2 = data.length;
|
|
4563
|
+
if (size2 >= 4294967296) {
|
|
4564
|
+
throw new Error(`Too large extension object: ${size2}`);
|
|
4509
4565
|
}
|
|
4566
|
+
this.writeU8(201);
|
|
4567
|
+
this.writeU32(size2);
|
|
4510
4568
|
this.writeI8(ext.type);
|
|
4511
|
-
this.writeU8a(
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
this.
|
|
4517
|
-
}
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
this.
|
|
4521
|
-
|
|
4522
|
-
this.
|
|
4523
|
-
}
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
this.
|
|
4527
|
-
this.
|
|
4528
|
-
}
|
|
4529
|
-
|
|
4530
|
-
this.
|
|
4531
|
-
|
|
4532
|
-
this.
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
}
|
|
4581
|
-
|
|
4569
|
+
this.writeU8a(data);
|
|
4570
|
+
return;
|
|
4571
|
+
}
|
|
4572
|
+
const size = ext.data.length;
|
|
4573
|
+
if (size === 1) {
|
|
4574
|
+
this.writeU8(212);
|
|
4575
|
+
} else if (size === 2) {
|
|
4576
|
+
this.writeU8(213);
|
|
4577
|
+
} else if (size === 4) {
|
|
4578
|
+
this.writeU8(214);
|
|
4579
|
+
} else if (size === 8) {
|
|
4580
|
+
this.writeU8(215);
|
|
4581
|
+
} else if (size === 16) {
|
|
4582
|
+
this.writeU8(216);
|
|
4583
|
+
} else if (size < 256) {
|
|
4584
|
+
this.writeU8(199);
|
|
4585
|
+
this.writeU8(size);
|
|
4586
|
+
} else if (size < 65536) {
|
|
4587
|
+
this.writeU8(200);
|
|
4588
|
+
this.writeU16(size);
|
|
4589
|
+
} else if (size < 4294967296) {
|
|
4590
|
+
this.writeU8(201);
|
|
4591
|
+
this.writeU32(size);
|
|
4592
|
+
} else {
|
|
4593
|
+
throw new Error(`Too large extension object: ${size}`);
|
|
4594
|
+
}
|
|
4595
|
+
this.writeI8(ext.type);
|
|
4596
|
+
this.writeU8a(ext.data);
|
|
4597
|
+
}
|
|
4598
|
+
writeU8(value) {
|
|
4599
|
+
this.ensureBufferSizeToWrite(1);
|
|
4600
|
+
this.view.setUint8(this.pos, value);
|
|
4601
|
+
this.pos++;
|
|
4602
|
+
}
|
|
4603
|
+
writeU8a(values) {
|
|
4604
|
+
const size = values.length;
|
|
4605
|
+
this.ensureBufferSizeToWrite(size);
|
|
4606
|
+
this.bytes.set(values, this.pos);
|
|
4607
|
+
this.pos += size;
|
|
4608
|
+
}
|
|
4609
|
+
writeI8(value) {
|
|
4610
|
+
this.ensureBufferSizeToWrite(1);
|
|
4611
|
+
this.view.setInt8(this.pos, value);
|
|
4612
|
+
this.pos++;
|
|
4613
|
+
}
|
|
4614
|
+
writeU16(value) {
|
|
4615
|
+
this.ensureBufferSizeToWrite(2);
|
|
4616
|
+
this.view.setUint16(this.pos, value);
|
|
4617
|
+
this.pos += 2;
|
|
4618
|
+
}
|
|
4619
|
+
writeI16(value) {
|
|
4620
|
+
this.ensureBufferSizeToWrite(2);
|
|
4621
|
+
this.view.setInt16(this.pos, value);
|
|
4622
|
+
this.pos += 2;
|
|
4623
|
+
}
|
|
4624
|
+
writeU32(value) {
|
|
4625
|
+
this.ensureBufferSizeToWrite(4);
|
|
4626
|
+
this.view.setUint32(this.pos, value);
|
|
4627
|
+
this.pos += 4;
|
|
4628
|
+
}
|
|
4629
|
+
writeI32(value) {
|
|
4630
|
+
this.ensureBufferSizeToWrite(4);
|
|
4631
|
+
this.view.setInt32(this.pos, value);
|
|
4632
|
+
this.pos += 4;
|
|
4633
|
+
}
|
|
4634
|
+
writeF32(value) {
|
|
4635
|
+
this.ensureBufferSizeToWrite(4);
|
|
4636
|
+
this.view.setFloat32(this.pos, value);
|
|
4637
|
+
this.pos += 4;
|
|
4638
|
+
}
|
|
4639
|
+
writeF64(value) {
|
|
4640
|
+
this.ensureBufferSizeToWrite(8);
|
|
4641
|
+
this.view.setFloat64(this.pos, value);
|
|
4642
|
+
this.pos += 8;
|
|
4643
|
+
}
|
|
4644
|
+
writeU64(value) {
|
|
4645
|
+
this.ensureBufferSizeToWrite(8);
|
|
4646
|
+
setUint64(this.view, this.pos, value);
|
|
4647
|
+
this.pos += 8;
|
|
4648
|
+
}
|
|
4649
|
+
writeI64(value) {
|
|
4650
|
+
this.ensureBufferSizeToWrite(8);
|
|
4651
|
+
setInt64(this.view, this.pos, value);
|
|
4652
|
+
this.pos += 8;
|
|
4653
|
+
}
|
|
4654
|
+
writeBigUint64(value) {
|
|
4655
|
+
this.ensureBufferSizeToWrite(8);
|
|
4656
|
+
this.view.setBigUint64(this.pos, value);
|
|
4657
|
+
this.pos += 8;
|
|
4658
|
+
}
|
|
4659
|
+
writeBigInt64(value) {
|
|
4660
|
+
this.ensureBufferSizeToWrite(8);
|
|
4661
|
+
this.view.setBigInt64(this.pos, value);
|
|
4662
|
+
this.pos += 8;
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4582
4665
|
function encode(value, options) {
|
|
4583
|
-
|
|
4666
|
+
const encoder = new Encoder(options);
|
|
4584
4667
|
return encoder.encodeSharedRef(value);
|
|
4585
4668
|
}
|
|
4586
4669
|
class PublishTransportRESTServer extends stsutils.STSOptionsBase {
|
|
@@ -5725,7 +5808,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5725
5808
|
const native = { randomUUID };
|
|
5726
5809
|
function v4(options, buf, offset) {
|
|
5727
5810
|
var _a2;
|
|
5728
|
-
if (native.randomUUID &&
|
|
5811
|
+
if (native.randomUUID && true && !options) {
|
|
5729
5812
|
return native.randomUUID();
|
|
5730
5813
|
}
|
|
5731
5814
|
options = options || {};
|