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