@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.
@@ -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
- var strLength = str.length;
3947
- var byteLength = 0;
3948
- var pos = 0;
3946
+ const strLength = str.length;
3947
+ let byteLength = 0;
3948
+ let pos = 0;
3949
3949
  while (pos < strLength) {
3950
- var value = str.charCodeAt(pos++);
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
- var extra = str.charCodeAt(pos);
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
- var strLength = str.length;
3977
- var offset = outputOffset;
3978
- var pos = 0;
3976
+ const strLength = str.length;
3977
+ let offset = outputOffset;
3978
+ let pos = 0;
3979
3979
  while (pos < strLength) {
3980
- var value = str.charCodeAt(pos++);
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
- var extra = str.charCodeAt(pos);
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
- var sharedTextEncoder = new TextEncoder();
4009
- var TEXT_ENCODER_THRESHOLD = 50;
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
- var ExtData = (
4022
- /** @class */
4023
- /* @__PURE__ */ function() {
4024
- function ExtData2(type, data) {
4025
- this.type = type;
4026
- this.data = data;
4027
- }
4028
- return ExtData2;
4029
- }()
4030
- );
4031
- var __extends = /* @__PURE__ */ function() {
4032
- var extendStatics = function(d, b) {
4033
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
4034
- d2.__proto__ = b2;
4035
- } || function(d2, b2) {
4036
- for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
4037
- };
4038
- return extendStatics(d, b);
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
- var high = value / 4294967296;
4070
- var low = value;
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
- var high = Math.floor(value / 4294967296);
4076
- var low = value;
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
- var high = view.getInt32(offset);
4082
- var low = view.getUint32(offset + 4);
4052
+ const high = view.getInt32(offset);
4053
+ const low = view.getUint32(offset + 4);
4083
4054
  return high * 4294967296 + low;
4084
4055
  }
4085
- var EXT_TIMESTAMP = -1;
4086
- var TIMESTAMP32_MAX_SEC = 4294967296 - 1;
4087
- var TIMESTAMP64_MAX_SEC = 17179869184 - 1;
4088
- function encodeTimeSpecToTimestamp(_a2) {
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
- var rv = new Uint8Array(4);
4093
- var view = new DataView(rv.buffer);
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
- var secHigh = sec / 4294967296;
4098
- var secLow = sec & 4294967295;
4099
- var rv = new Uint8Array(8);
4100
- var view = new DataView(rv.buffer);
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
- var rv = new Uint8Array(12);
4107
- var view = new DataView(rv.buffer);
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
- var msec = date.getTime();
4115
- var sec = Math.floor(msec / 1e3);
4116
- var nsec = (msec - sec * 1e3) * 1e6;
4117
- var nsecInSec = Math.floor(nsec / 1e9);
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
- var timeSpec = encodeDateToTimeSpec(object);
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
- var view = new DataView(data.buffer, data.byteOffset, data.byteLength);
4102
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
4133
4103
  switch (data.byteLength) {
4134
4104
  case 4: {
4135
- var sec = view.getUint32(0);
4136
- var nsec = 0;
4105
+ const sec = view.getUint32(0);
4106
+ const nsec = 0;
4137
4107
  return { sec, nsec };
4138
4108
  }
4139
4109
  case 8: {
4140
- var nsec30AndSecHigh2 = view.getUint32(0);
4141
- var secLow32 = view.getUint32(4);
4142
- var sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
4143
- var nsec = nsec30AndSecHigh2 >>> 2;
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
- var sec = getInt64(view, 4);
4148
- var nsec = view.getUint32(0);
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("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(data.length));
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
- var timeSpec = decodeTimestampToTimeSpec(data);
4126
+ const timeSpec = decodeTimestampToTimeSpec(data);
4157
4127
  return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
4158
4128
  }
4159
- var timestampExtension = {
4129
+ const timestampExtension = {
4160
4130
  type: EXT_TIMESTAMP,
4161
4131
  encode: encodeTimestampExtension,
4162
4132
  decode: decodeTimestampExtension
4163
4133
  };
4164
- var ExtensionCodec = (
4165
- /** @class */
4166
- function() {
4167
- function ExtensionCodec2() {
4168
- this.builtInEncoders = [];
4169
- this.builtInDecoders = [];
4170
- this.encoders = [];
4171
- this.decoders = [];
4172
- this.register(timestampExtension);
4173
- }
4174
- ExtensionCodec2.prototype.register = function(_a2) {
4175
- var type = _a2.type, encode2 = _a2.encode, decode = _a2.decode;
4176
- if (type >= 0) {
4177
- this.encoders[type] = encode2;
4178
- this.decoders[type] = decode;
4179
- } else {
4180
- var index = 1 + type;
4181
- this.builtInEncoders[index] = encode2;
4182
- this.builtInDecoders[index] = decode;
4183
- }
4184
- };
4185
- ExtensionCodec2.prototype.tryToEncode = function(object, context) {
4186
- for (var i = 0; i < this.builtInEncoders.length; i++) {
4187
- var encodeExt = this.builtInEncoders[i];
4188
- if (encodeExt != null) {
4189
- var data = encodeExt(object, context);
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
- for (var i = 0; i < this.encoders.length; i++) {
4197
- var encodeExt = this.encoders[i];
4198
- if (encodeExt != null) {
4199
- var data = encodeExt(object, context);
4200
- if (data != null) {
4201
- var type = i;
4202
- return new ExtData(type, data);
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
- if (object instanceof ExtData) {
4207
- return object;
4208
- }
4209
- return null;
4210
- };
4211
- ExtensionCodec2.prototype.decode = function(data, type, context) {
4212
- var decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
4213
- if (decodeExt) {
4214
- return decodeExt(data, type, context);
4215
- } else {
4216
- return new ExtData(type, data);
4217
- }
4218
- };
4219
- ExtensionCodec2.defaultCodec = new ExtensionCodec2();
4220
- return ExtensionCodec2;
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 (isArrayBuffer(buffer)) {
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 DEFAULT_MAX_DEPTH = 100;
4238
- var DEFAULT_INITIAL_BUFFER_SIZE = 2048;
4239
- var Encoder = (
4240
- /** @class */
4241
- function() {
4242
- function Encoder2(options) {
4243
- var _a2, _b, _c, _d, _e, _f, _g, _h;
4244
- this.extensionCodec = (_a2 = options === null || options === void 0 ? void 0 : options.extensionCodec) !== null && _a2 !== void 0 ? _a2 : ExtensionCodec.defaultCodec;
4245
- this.context = options === null || options === void 0 ? void 0 : options.context;
4246
- this.useBigInt64 = (_b = options === null || options === void 0 ? void 0 : options.useBigInt64) !== null && _b !== void 0 ? _b : false;
4247
- this.maxDepth = (_c = options === null || options === void 0 ? void 0 : options.maxDepth) !== null && _c !== void 0 ? _c : DEFAULT_MAX_DEPTH;
4248
- this.initialBufferSize = (_d = options === null || options === void 0 ? void 0 : options.initialBufferSize) !== null && _d !== void 0 ? _d : DEFAULT_INITIAL_BUFFER_SIZE;
4249
- this.sortKeys = (_e = options === null || options === void 0 ? void 0 : options.sortKeys) !== null && _e !== void 0 ? _e : false;
4250
- this.forceFloat32 = (_f = options === null || options === void 0 ? void 0 : options.forceFloat32) !== null && _f !== void 0 ? _f : false;
4251
- this.ignoreUndefined = (_g = options === null || options === void 0 ? void 0 : options.ignoreUndefined) !== null && _g !== void 0 ? _g : false;
4252
- this.forceIntegerToFloat = (_h = options === null || options === void 0 ? void 0 : options.forceIntegerToFloat) !== null && _h !== void 0 ? _h : false;
4253
- this.pos = 0;
4254
- this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
4255
- this.bytes = new Uint8Array(this.view.buffer);
4256
- }
4257
- Encoder2.prototype.reinitializeState = function() {
4258
- this.pos = 0;
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
- Encoder2.prototype.encodeSharedRef = function(object) {
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
- Encoder2.prototype.encode = function(object) {
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
- Encoder2.prototype.doEncode = function(object, depth) {
4271
- if (depth > this.maxDepth) {
4272
- throw new Error("Too deep objects in depth ".concat(depth));
4273
- }
4274
- if (object == null) {
4275
- this.encodeNil();
4276
- } else if (typeof object === "boolean") {
4277
- this.encodeBoolean(object);
4278
- } else if (typeof object === "number") {
4279
- if (!this.forceIntegerToFloat) {
4280
- this.encodeNumber(object);
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
- this.encodeObject(object, depth);
4290
- }
4291
- };
4292
- Encoder2.prototype.ensureBufferSizeToWrite = function(sizeToWrite) {
4293
- var requiredSize = this.pos + sizeToWrite;
4294
- if (this.view.byteLength < requiredSize) {
4295
- this.resizeBuffer(requiredSize * 2);
4296
- }
4297
- };
4298
- Encoder2.prototype.resizeBuffer = function(newSize) {
4299
- var newBuffer = new ArrayBuffer(newSize);
4300
- var newBytes = new Uint8Array(newBuffer);
4301
- var newView = new DataView(newBuffer);
4302
- newBytes.set(this.bytes);
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
- if (object >= -32) {
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
- Encoder2.prototype.encodeNumberAsFloat = function(object) {
4360
- if (this.forceFloat32) {
4361
- this.writeU8(202);
4362
- this.writeF32(object);
4363
- } else {
4364
- this.writeU8(203);
4365
- this.writeF64(object);
4366
- }
4367
- };
4368
- Encoder2.prototype.encodeBigInt64 = function(object) {
4369
- if (object >= BigInt(0)) {
4370
- this.writeU8(207);
4371
- this.writeBigUint64(object);
4372
- } else {
4373
- this.writeU8(211);
4374
- this.writeBigInt64(object);
4375
- }
4376
- };
4377
- Encoder2.prototype.writeStringHeader = function(byteLength) {
4378
- if (byteLength < 32) {
4379
- this.writeU8(160 + byteLength);
4380
- } else if (byteLength < 256) {
4381
- this.writeU8(217);
4382
- this.writeU8(byteLength);
4383
- } else if (byteLength < 65536) {
4384
- this.writeU8(218);
4385
- this.writeU16(byteLength);
4386
- } else if (byteLength < 4294967296) {
4387
- this.writeU8(219);
4388
- this.writeU32(byteLength);
4389
- } else {
4390
- throw new Error("Too long string: ".concat(byteLength, " bytes in UTF-8"));
4391
- }
4392
- };
4393
- Encoder2.prototype.encodeString = function(object) {
4394
- var maxHeaderSize = 1 + 4;
4395
- var byteLength = utf8Count(object);
4396
- this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
4397
- this.writeStringHeader(byteLength);
4398
- utf8Encode(object, this.bytes, this.pos);
4399
- this.pos += byteLength;
4400
- };
4401
- Encoder2.prototype.encodeObject = function(object, depth) {
4402
- var ext = this.extensionCodec.tryToEncode(object, this.context);
4403
- if (ext != null) {
4404
- this.encodeExtension(ext);
4405
- } else if (Array.isArray(object)) {
4406
- this.encodeArray(object, depth);
4407
- } else if (ArrayBuffer.isView(object)) {
4408
- this.encodeBinary(object);
4409
- } else if (typeof object === "object") {
4410
- this.encodeMap(object, depth);
4411
- } else {
4412
- throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(object)));
4413
- }
4414
- };
4415
- Encoder2.prototype.encodeBinary = function(object) {
4416
- var size = object.byteLength;
4417
- if (size < 256) {
4418
- this.writeU8(196);
4419
- this.writeU8(size);
4420
- } else if (size < 65536) {
4421
- this.writeU8(197);
4422
- this.writeU16(size);
4423
- } else if (size < 4294967296) {
4424
- this.writeU8(198);
4425
- this.writeU32(size);
4426
- } else {
4427
- throw new Error("Too large binary: ".concat(size));
4428
- }
4429
- var bytes = ensureUint8Array(object);
4430
- this.writeU8a(bytes);
4431
- };
4432
- Encoder2.prototype.encodeArray = function(object, depth) {
4433
- var size = object.length;
4434
- if (size < 16) {
4435
- this.writeU8(144 + size);
4436
- } else if (size < 65536) {
4437
- this.writeU8(220);
4438
- this.writeU16(size);
4439
- } else if (size < 4294967296) {
4440
- this.writeU8(221);
4441
- this.writeU32(size);
4442
- } else {
4443
- throw new Error("Too large array: ".concat(size));
4444
- }
4445
- for (var _i = 0, object_1 = object; _i < object_1.length; _i++) {
4446
- var item = object_1[_i];
4447
- this.doEncode(item, depth + 1);
4448
- }
4449
- };
4450
- Encoder2.prototype.countWithoutUndefined = function(object, keys) {
4451
- var count = 0;
4452
- for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
4453
- var key = keys_1[_i];
4454
- if (object[key] !== void 0) {
4455
- count++;
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
- return count;
4459
- };
4460
- Encoder2.prototype.encodeMap = function(object, depth) {
4461
- var keys = Object.keys(object);
4462
- if (this.sortKeys) {
4463
- keys.sort();
4464
- }
4465
- var size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
4466
- if (size < 16) {
4467
- this.writeU8(128 + size);
4468
- } else if (size < 65536) {
4469
- this.writeU8(222);
4470
- this.writeU16(size);
4471
- } else if (size < 4294967296) {
4472
- this.writeU8(223);
4473
- this.writeU32(size);
4474
- } else {
4475
- throw new Error("Too large map object: ".concat(size));
4476
- }
4477
- for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
4478
- var key = keys_2[_i];
4479
- var value = object[key];
4480
- if (!(this.ignoreUndefined && value === void 0)) {
4481
- this.encodeString(key);
4482
- this.doEncode(value, depth + 1);
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
- Encoder2.prototype.encodeExtension = function(ext) {
4487
- var size = ext.data.length;
4488
- if (size === 1) {
4489
- this.writeU8(212);
4490
- } else if (size === 2) {
4491
- this.writeU8(213);
4492
- } else if (size === 4) {
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(ext.data);
4512
- };
4513
- Encoder2.prototype.writeU8 = function(value) {
4514
- this.ensureBufferSizeToWrite(1);
4515
- this.view.setUint8(this.pos, value);
4516
- this.pos++;
4517
- };
4518
- Encoder2.prototype.writeU8a = function(values) {
4519
- var size = values.length;
4520
- this.ensureBufferSizeToWrite(size);
4521
- this.bytes.set(values, this.pos);
4522
- this.pos += size;
4523
- };
4524
- Encoder2.prototype.writeI8 = function(value) {
4525
- this.ensureBufferSizeToWrite(1);
4526
- this.view.setInt8(this.pos, value);
4527
- this.pos++;
4528
- };
4529
- Encoder2.prototype.writeU16 = function(value) {
4530
- this.ensureBufferSizeToWrite(2);
4531
- this.view.setUint16(this.pos, value);
4532
- this.pos += 2;
4533
- };
4534
- Encoder2.prototype.writeI16 = function(value) {
4535
- this.ensureBufferSizeToWrite(2);
4536
- this.view.setInt16(this.pos, value);
4537
- this.pos += 2;
4538
- };
4539
- Encoder2.prototype.writeU32 = function(value) {
4540
- this.ensureBufferSizeToWrite(4);
4541
- this.view.setUint32(this.pos, value);
4542
- this.pos += 4;
4543
- };
4544
- Encoder2.prototype.writeI32 = function(value) {
4545
- this.ensureBufferSizeToWrite(4);
4546
- this.view.setInt32(this.pos, value);
4547
- this.pos += 4;
4548
- };
4549
- Encoder2.prototype.writeF32 = function(value) {
4550
- this.ensureBufferSizeToWrite(4);
4551
- this.view.setFloat32(this.pos, value);
4552
- this.pos += 4;
4553
- };
4554
- Encoder2.prototype.writeF64 = function(value) {
4555
- this.ensureBufferSizeToWrite(8);
4556
- this.view.setFloat64(this.pos, value);
4557
- this.pos += 8;
4558
- };
4559
- Encoder2.prototype.writeU64 = function(value) {
4560
- this.ensureBufferSizeToWrite(8);
4561
- setUint64(this.view, this.pos, value);
4562
- this.pos += 8;
4563
- };
4564
- Encoder2.prototype.writeI64 = function(value) {
4565
- this.ensureBufferSizeToWrite(8);
4566
- setInt64(this.view, this.pos, value);
4567
- this.pos += 8;
4568
- };
4569
- Encoder2.prototype.writeBigUint64 = function(value) {
4570
- this.ensureBufferSizeToWrite(8);
4571
- this.view.setBigUint64(this.pos, value);
4572
- this.pos += 8;
4573
- };
4574
- Encoder2.prototype.writeBigInt64 = function(value) {
4575
- this.ensureBufferSizeToWrite(8);
4576
- this.view.setBigInt64(this.pos, value);
4577
- this.pos += 8;
4578
- };
4579
- return Encoder2;
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
- var encoder = new Encoder(options);
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 && !buf && !options) {
5811
+ if (native.randomUUID && true && !options) {
5729
5812
  return native.randomUUID();
5730
5813
  }
5731
5814
  options = options || {};