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