@omnibuf/node 0.1.2 → 0.1.3

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.
@@ -1,8 +1,8 @@
1
1
  // Code generated by protoc-gen-omnibuf-es. DO NOT EDIT.
2
2
  // source: omnibuf/bench/peer.proto
3
3
  /* eslint-disable @typescript-eslint/no-unused-vars */
4
- import { Encoder, MaxNestingDepth, appendStringArrBody, appendUint32ArrBody, countSubMsgArrElems, decodeSchemaMeta as $decodeSchemaMeta, decodeUTF8, decodeVarintBigInt, decodeZigZag32, defineMessage, encodeField0SchemaMeta, float32FromBits, parseArrayHeader, readBool, readField0SchemaMeta, readFloat32, readFloat64, readFloat64At, readInt32, readLenSlice, readString, readStringArr, readSubMsgArrDecoded, readSubMsgMerged, readUint32, readUint32Arr, readUintAuto, roundFloat32Shortest, spliceFields, validateMessage, validateValue, writeField0SchemaMeta, } from '@omnibuf/core';
5
- export const LocationSchema = defineMessage('omnibuf.bench.Location', {
4
+ import * as $ob from '@omnibuf/core';
5
+ export const LocationSchema = $ob.defineMessage('omnibuf.bench.Location', {
6
6
  region: { fieldNum: 1, type: 'string' },
7
7
  datacenter: { fieldNum: 2, type: 'string' },
8
8
  city: { fieldNum: 3, type: 'string' },
@@ -18,7 +18,7 @@ class LocationMsg {
18
18
  latitude = 0;
19
19
  longitude = 0;
20
20
  }
21
- Object.defineProperty(LocationMsg.prototype, '$typeName', {
21
+ globalThis.Object.defineProperty(LocationMsg.prototype, '$typeName', {
22
22
  value: 'omnibuf.bench.Location',
23
23
  enumerable: false,
24
24
  writable: true,
@@ -33,10 +33,10 @@ export function encodeLocation(enc, msg, options) {
33
33
  enc.writeString(1, msg.region ?? '');
34
34
  enc.writeString(2, msg.datacenter ?? '');
35
35
  enc.writeString(3, msg.city ?? '');
36
- enc.writeUint(4, Number(msg.rack ?? 0) >>> 0);
36
+ enc.writeUint(4, globalThis.Number(msg.rack ?? 0) >>> 0);
37
37
  enc.writeFloat32(5, msg.latitude ?? 0);
38
38
  enc.writeFloat32(6, msg.longitude ?? 0);
39
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
39
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
40
40
  for (const uf of msg.$unknown) {
41
41
  enc.writeTag(uf.no, uf.wireType);
42
42
  enc.writeRaw(uf.data);
@@ -44,34 +44,34 @@ export function encodeLocation(enc, msg, options) {
44
44
  }
45
45
  }
46
46
  export function marshalLocationOmniBuf(msg, options) {
47
- const enc = new Encoder(256);
47
+ const enc = new $ob.Encoder(256);
48
48
  if (options?.selfDescribing) {
49
- writeField0SchemaMeta(enc, LocationSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
49
+ $ob.writeField0SchemaMeta(enc, LocationSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
50
50
  }
51
51
  encodeLocation(enc, msg, options);
52
52
  return enc.finish();
53
53
  }
54
54
  export function decodeLocation(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
55
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
55
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
56
56
  const readUnknown = options?.readUnknownFields ?? true;
57
57
  if (depth > maxDepth) {
58
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
58
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
59
59
  }
60
60
  const out = target ?? new LocationMsg();
61
61
  if (target !== undefined) {
62
62
  if (!(out instanceof LocationMsg)) {
63
- Object.setPrototypeOf(out, LocationMsg.prototype);
63
+ globalThis.Object.setPrototypeOf(out, LocationMsg.prototype);
64
64
  }
65
65
  if (!options?.merge) {
66
- Object.assign(out, new LocationMsg());
67
- if (Object.hasOwn(out, '$unknown'))
66
+ globalThis.Object.assign(out, new LocationMsg());
67
+ if (globalThis.Object.hasOwn(out, '$unknown'))
68
68
  delete out.$unknown;
69
69
  }
70
70
  }
71
71
  const n = endPos;
72
72
  let pos = startPos;
73
73
  let seenMask = 0;
74
- let unknownFields = Array.isArray(out.$unknown)
74
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
75
75
  ? out.$unknown
76
76
  : null;
77
77
  while (pos < n) {
@@ -83,34 +83,33 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
83
83
  }
84
84
  else if ((b0 & 2) !== 0) {
85
85
  if (pos + 2 > n)
86
- throw new Error('omnibuf: truncated tag');
86
+ throw new globalThis.Error('omnibuf: truncated tag');
87
87
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
88
88
  pos += 2;
89
89
  }
90
90
  else {
91
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
91
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
92
92
  if (tn === 0 || t64 >> 4n > 536870911n)
93
- throw new Error('omnibuf: invalid tag');
94
- tag = Number(t64);
93
+ throw new globalThis.Error('omnibuf: invalid tag');
94
+ tag = globalThis.Number(t64);
95
95
  pos += tn;
96
96
  }
97
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
97
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
98
98
  const wt = tag & 0x0f;
99
99
  if (fieldNum === 0) {
100
- if (wt !== 12)
101
- throw new Error('omnibuf: invalid Field #0 wire type');
102
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
103
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
100
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
101
+ if (nextPos < 0)
102
+ throw new globalThis.Error('omnibuf: invalid Field #0');
104
103
  pos = nextPos;
105
104
  continue;
106
105
  }
107
106
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
108
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
107
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
109
108
  switch (fieldNum) {
110
109
  case 1: {
111
110
  if (!(wt === 10)) {
112
111
  const valStart = pos;
113
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
112
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
114
113
  if (readUnknown) {
115
114
  if (!unknownFields)
116
115
  unknownFields = [];
@@ -124,19 +123,19 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
124
123
  }
125
124
  seenMask |= bit;
126
125
  if (pos >= n)
127
- throw new Error('omnibuf: truncated string');
126
+ throw new globalThis.Error('omnibuf: truncated string');
128
127
  const sb = buf[pos];
129
128
  if ((sb & 1) !== 0) {
130
129
  const sLen = sb >>> 1;
131
130
  pos += 1;
132
131
  if (pos + sLen > n)
133
- throw new Error('omnibuf: truncated string');
134
- out.region = decodeUTF8(buf, pos, pos + sLen);
132
+ throw new globalThis.Error('omnibuf: truncated string');
133
+ out.region = $ob.decodeUTF8(buf, pos, pos + sLen);
135
134
  pos += sLen;
136
135
  }
137
136
  else {
138
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
139
- out.region = decodeUTF8(s);
137
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
138
+ out.region = $ob.decodeUTF8(s);
140
139
  pos = nextPos;
141
140
  }
142
141
  break;
@@ -144,7 +143,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
144
143
  case 2: {
145
144
  if (!(wt === 10)) {
146
145
  const valStart = pos;
147
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
146
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
148
147
  if (readUnknown) {
149
148
  if (!unknownFields)
150
149
  unknownFields = [];
@@ -158,19 +157,19 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
158
157
  }
159
158
  seenMask |= bit;
160
159
  if (pos >= n)
161
- throw new Error('omnibuf: truncated string');
160
+ throw new globalThis.Error('omnibuf: truncated string');
162
161
  const sb = buf[pos];
163
162
  if ((sb & 1) !== 0) {
164
163
  const sLen = sb >>> 1;
165
164
  pos += 1;
166
165
  if (pos + sLen > n)
167
- throw new Error('omnibuf: truncated string');
168
- out.datacenter = decodeUTF8(buf, pos, pos + sLen);
166
+ throw new globalThis.Error('omnibuf: truncated string');
167
+ out.datacenter = $ob.decodeUTF8(buf, pos, pos + sLen);
169
168
  pos += sLen;
170
169
  }
171
170
  else {
172
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
173
- out.datacenter = decodeUTF8(s);
171
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
172
+ out.datacenter = $ob.decodeUTF8(s);
174
173
  pos = nextPos;
175
174
  }
176
175
  break;
@@ -178,7 +177,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
178
177
  case 3: {
179
178
  if (!(wt === 10)) {
180
179
  const valStart = pos;
181
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
180
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
182
181
  if (readUnknown) {
183
182
  if (!unknownFields)
184
183
  unknownFields = [];
@@ -192,19 +191,19 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
192
191
  }
193
192
  seenMask |= bit;
194
193
  if (pos >= n)
195
- throw new Error('omnibuf: truncated string');
194
+ throw new globalThis.Error('omnibuf: truncated string');
196
195
  const sb = buf[pos];
197
196
  if ((sb & 1) !== 0) {
198
197
  const sLen = sb >>> 1;
199
198
  pos += 1;
200
199
  if (pos + sLen > n)
201
- throw new Error('omnibuf: truncated string');
202
- out.city = decodeUTF8(buf, pos, pos + sLen);
200
+ throw new globalThis.Error('omnibuf: truncated string');
201
+ out.city = $ob.decodeUTF8(buf, pos, pos + sLen);
203
202
  pos += sLen;
204
203
  }
205
204
  else {
206
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
207
- out.city = decodeUTF8(s);
205
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
206
+ out.city = $ob.decodeUTF8(s);
208
207
  pos = nextPos;
209
208
  }
210
209
  break;
@@ -212,7 +211,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
212
211
  case 4: {
213
212
  if (!(wt === 0)) {
214
213
  const valStart = pos;
215
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
214
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
216
215
  if (readUnknown) {
217
216
  if (!unknownFields)
218
217
  unknownFields = [];
@@ -226,7 +225,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
226
225
  }
227
226
  seenMask |= bit;
228
227
  if (pos >= n)
229
- throw new Error('omnibuf: truncated uint32');
228
+ throw new globalThis.Error('omnibuf: truncated uint32');
230
229
  const vb = buf[pos];
231
230
  let u32Val = 0;
232
231
  if ((vb & 1) !== 0) {
@@ -235,13 +234,13 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
235
234
  }
236
235
  else if ((vb & 2) !== 0) {
237
236
  if (pos + 2 > n)
238
- throw new Error('omnibuf: truncated uint32');
237
+ throw new globalThis.Error('omnibuf: truncated uint32');
239
238
  u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
240
239
  pos += 2;
241
240
  }
242
241
  else if ((vb & 4) !== 0) {
243
242
  if (pos + 4 > n)
244
- throw new Error('omnibuf: truncated uint32');
243
+ throw new globalThis.Error('omnibuf: truncated uint32');
245
244
  u32Val =
246
245
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
247
246
  0;
@@ -249,7 +248,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
249
248
  }
250
249
  else {
251
250
  if (vb !== 0 || pos + 9 > n)
252
- throw new Error('omnibuf: truncated uint32');
251
+ throw new globalThis.Error('omnibuf: truncated uint32');
253
252
  u32Val =
254
253
  (buf[pos + 1] |
255
254
  (buf[pos + 2] << 8) |
@@ -264,7 +263,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
264
263
  case 5: {
265
264
  if (!(wt === 8)) {
266
265
  const valStart = pos;
267
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
266
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
268
267
  if (readUnknown) {
269
268
  if (!unknownFields)
270
269
  unknownFields = [];
@@ -278,16 +277,16 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
278
277
  }
279
278
  seenMask |= bit;
280
279
  if (n - pos < 4)
281
- throw new Error('omnibuf: truncated float32');
280
+ throw new globalThis.Error('omnibuf: truncated float32');
282
281
  const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
283
- out.latitude = roundFloat32Shortest(float32FromBits(bits));
282
+ out.latitude = $ob.float32FromBits(bits);
284
283
  pos += 4;
285
284
  break;
286
285
  }
287
286
  case 6: {
288
287
  if (!(wt === 8)) {
289
288
  const valStart = pos;
290
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
289
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
291
290
  if (readUnknown) {
292
291
  if (!unknownFields)
293
292
  unknownFields = [];
@@ -301,15 +300,15 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
301
300
  }
302
301
  seenMask |= bit;
303
302
  if (n - pos < 4)
304
- throw new Error('omnibuf: truncated float32');
303
+ throw new globalThis.Error('omnibuf: truncated float32');
305
304
  const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
306
- out.longitude = roundFloat32Shortest(float32FromBits(bits));
305
+ out.longitude = $ob.float32FromBits(bits);
307
306
  pos += 4;
308
307
  break;
309
308
  }
310
309
  default: {
311
310
  const valStart = pos;
312
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
311
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
313
312
  if (readUnknown) {
314
313
  if (!unknownFields)
315
314
  unknownFields = [];
@@ -324,7 +323,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
324
323
  }
325
324
  }
326
325
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
327
- Object.defineProperty(out, '$unknown', {
326
+ globalThis.Object.defineProperty(out, '$unknown', {
328
327
  value: unknownFields,
329
328
  enumerable: false,
330
329
  writable: true,
@@ -341,8 +340,12 @@ LocationSchema.setGeneratedCodec({
341
340
  encode: encodeLocation,
342
341
  decode: decodeLocation,
343
342
  });
343
+ $ob.registerClassSchema(LocationMsg, LocationSchema);
344
344
  export class OpaqueLocation {
345
345
  _raw;
346
+ _depth;
347
+ _readCount = 0;
348
+ _fieldIndex = null;
346
349
  _dirtyMask = 0;
347
350
  _region;
348
351
  _datacenter;
@@ -350,8 +353,19 @@ export class OpaqueLocation {
350
353
  _rack;
351
354
  _latitude;
352
355
  _longitude;
353
- constructor(raw) {
356
+ constructor(raw, depth = 0) {
354
357
  this._raw = raw;
358
+ this._depth = depth;
359
+ }
360
+ _sliceField(fieldNum) {
361
+ if (this._fieldIndex === null) {
362
+ if (this._readCount < 2) {
363
+ this._readCount++;
364
+ return this._raw;
365
+ }
366
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
367
+ }
368
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
355
369
  }
356
370
  raw() {
357
371
  return this._raw;
@@ -360,7 +374,8 @@ export class OpaqueLocation {
360
374
  if ((this._dirtyMask & (1 << 1)) !== 0) {
361
375
  return this._region;
362
376
  }
363
- return readString(this._raw, 1)[0];
377
+ const __src = this._sliceField(1);
378
+ return __src ? $ob.readString(__src, 1)[0] : '';
364
379
  }
365
380
  region() {
366
381
  return this.getRegion();
@@ -373,7 +388,8 @@ export class OpaqueLocation {
373
388
  if ((this._dirtyMask & (1 << 2)) !== 0) {
374
389
  return this._datacenter;
375
390
  }
376
- return readString(this._raw, 2)[0];
391
+ const __src = this._sliceField(2);
392
+ return __src ? $ob.readString(__src, 2)[0] : '';
377
393
  }
378
394
  datacenter() {
379
395
  return this.getDatacenter();
@@ -386,7 +402,8 @@ export class OpaqueLocation {
386
402
  if ((this._dirtyMask & (1 << 3)) !== 0) {
387
403
  return this._city;
388
404
  }
389
- return readString(this._raw, 3)[0];
405
+ const __src = this._sliceField(3);
406
+ return __src ? $ob.readString(__src, 3)[0] : '';
390
407
  }
391
408
  city() {
392
409
  return this.getCity();
@@ -399,7 +416,8 @@ export class OpaqueLocation {
399
416
  if ((this._dirtyMask & (1 << 4)) !== 0) {
400
417
  return this._rack;
401
418
  }
402
- return readUint32(this._raw, 4)[0];
419
+ const __src = this._sliceField(4);
420
+ return (__src ? $ob.readUint32(__src, 4)[0] : 0);
403
421
  }
404
422
  rack() {
405
423
  return this.getRack();
@@ -412,7 +430,8 @@ export class OpaqueLocation {
412
430
  if ((this._dirtyMask & (1 << 5)) !== 0) {
413
431
  return this._latitude;
414
432
  }
415
- return roundFloat32Shortest(readFloat32(this._raw, 5)[0]);
433
+ const __src = this._sliceField(5);
434
+ return __src ? $ob.readFloat32(__src, 5)[0] : 0;
416
435
  }
417
436
  latitude() {
418
437
  return this.getLatitude();
@@ -425,7 +444,8 @@ export class OpaqueLocation {
425
444
  if ((this._dirtyMask & (1 << 6)) !== 0) {
426
445
  return this._longitude;
427
446
  }
428
- return roundFloat32Shortest(readFloat32(this._raw, 6)[0]);
447
+ const __src = this._sliceField(6);
448
+ return __src ? $ob.readFloat32(__src, 6)[0] : 0;
429
449
  }
430
450
  longitude() {
431
451
  return this.getLongitude();
@@ -435,8 +455,9 @@ export class OpaqueLocation {
435
455
  this._dirtyMask |= 1 << 6;
436
456
  }
437
457
  marshal(options) {
458
+ let outBuf;
438
459
  if (this._dirtyMask !== 0) {
439
- this._raw = spliceFields(this._raw, this._dirtyMask, 6, (enc, fnum) => {
460
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 6, (enc, fnum) => {
440
461
  switch (fnum) {
441
462
  case 1: {
442
463
  const msg = { region: this._region };
@@ -455,7 +476,7 @@ export class OpaqueLocation {
455
476
  }
456
477
  case 4: {
457
478
  const msg = { rack: this._rack };
458
- enc.writeUint(4, Number(msg.rack ?? 0) >>> 0);
479
+ enc.writeUint(4, globalThis.Number(msg.rack ?? 0) >>> 0);
459
480
  break;
460
481
  }
461
482
  case 5: {
@@ -470,22 +491,38 @@ export class OpaqueLocation {
470
491
  }
471
492
  }
472
493
  });
473
- this._dirtyMask = 0;
474
494
  }
475
495
  else {
476
- validateMessage(this._raw);
496
+ $ob.validateMessage(this._raw, this._depth);
497
+ outBuf = this._raw.slice();
477
498
  }
478
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
479
- const f0 = encodeField0SchemaMeta(LocationSchema.getSchemaMeta(0), Boolean(options.deterministic));
480
- const out = new Uint8Array(f0.length + this._raw.length);
481
- out.set(f0, 0);
482
- out.set(this._raw, f0.length);
483
- return out;
499
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
500
+ const f0 = $ob.encodeField0SchemaMeta(LocationSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
501
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
502
+ withF0.set(f0, 0);
503
+ withF0.set(outBuf, f0.length);
504
+ return withF0;
505
+ }
506
+ return outBuf;
507
+ }
508
+ marshalValidated(options) {
509
+ const out = this.marshal(options);
510
+ $ob.validateMessage(out, this._depth);
511
+ return out;
512
+ }
513
+ tryMarshal(options) {
514
+ try {
515
+ return { ok: true, value: this.marshalValidated(options) };
516
+ }
517
+ catch (err) {
518
+ return {
519
+ ok: false,
520
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
521
+ };
484
522
  }
485
- return this._raw;
486
523
  }
487
524
  }
488
- export const NeighborSchema = defineMessage('omnibuf.bench.Neighbor', {
525
+ export const NeighborSchema = $ob.defineMessage('omnibuf.bench.Neighbor', {
489
526
  peerAsn: { fieldNum: 1, name: 'peer_asn', type: 'uint32' },
490
527
  router: { fieldNum: 2, type: 'string' },
491
528
  latencyUs: { fieldNum: 3, name: 'latency_us', type: 'uint32' },
@@ -509,7 +546,7 @@ class NeighborMsg {
509
546
  }
510
547
  established = false;
511
548
  }
512
- Object.defineProperty(NeighborMsg.prototype, '$typeName', {
549
+ globalThis.Object.defineProperty(NeighborMsg.prototype, '$typeName', {
513
550
  value: 'omnibuf.bench.Neighbor',
514
551
  enumerable: false,
515
552
  writable: true,
@@ -521,11 +558,11 @@ export function createNeighbor(init) {
521
558
  return NeighborSchema.create(init);
522
559
  }
523
560
  export function encodeNeighbor(enc, msg, options) {
524
- enc.writeUint(1, Number(msg.peerAsn ?? msg.peer_asn ?? 0) >>> 0);
561
+ enc.writeUint(1, globalThis.Number(msg.peerAsn ?? msg.peer_asn ?? 0) >>> 0);
525
562
  enc.writeString(2, msg.router ?? '');
526
- enc.writeUint(3, Number(msg.latencyUs ?? msg.latency_us ?? 0) >>> 0);
527
- enc.writeBool(4, Boolean(msg.established));
528
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
563
+ enc.writeUint(3, globalThis.Number(msg.latencyUs ?? msg.latency_us ?? 0) >>> 0);
564
+ enc.writeBool(4, globalThis.Boolean(msg.established));
565
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
529
566
  for (const uf of msg.$unknown) {
530
567
  enc.writeTag(uf.no, uf.wireType);
531
568
  enc.writeRaw(uf.data);
@@ -533,38 +570,38 @@ export function encodeNeighbor(enc, msg, options) {
533
570
  }
534
571
  }
535
572
  export function marshalNeighborOmniBuf(msg, options) {
536
- const enc = new Encoder(256);
573
+ const enc = new $ob.Encoder(256);
537
574
  if (options?.selfDescribing) {
538
- writeField0SchemaMeta(enc, NeighborSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
575
+ $ob.writeField0SchemaMeta(enc, NeighborSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
539
576
  }
540
577
  encodeNeighbor(enc, msg, options);
541
578
  return enc.finish();
542
579
  }
543
580
  export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
544
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
581
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
545
582
  const readUnknown = options?.readUnknownFields ?? true;
546
583
  if (depth > maxDepth) {
547
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
584
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
548
585
  }
549
586
  const out = target ?? new NeighborMsg();
550
587
  if (target !== undefined) {
551
588
  if (!(out instanceof NeighborMsg)) {
552
- Object.setPrototypeOf(out, NeighborMsg.prototype);
589
+ globalThis.Object.setPrototypeOf(out, NeighborMsg.prototype);
553
590
  }
554
591
  if (!options?.merge) {
555
- if (Object.hasOwn(out, 'peer_asn'))
592
+ if (globalThis.Object.hasOwn(out, 'peer_asn'))
556
593
  delete out.peer_asn;
557
- if (Object.hasOwn(out, 'latency_us'))
594
+ if (globalThis.Object.hasOwn(out, 'latency_us'))
558
595
  delete out.latency_us;
559
- Object.assign(out, new NeighborMsg());
560
- if (Object.hasOwn(out, '$unknown'))
596
+ globalThis.Object.assign(out, new NeighborMsg());
597
+ if (globalThis.Object.hasOwn(out, '$unknown'))
561
598
  delete out.$unknown;
562
599
  }
563
600
  }
564
601
  const n = endPos;
565
602
  let pos = startPos;
566
603
  let seenMask = 0;
567
- let unknownFields = Array.isArray(out.$unknown)
604
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
568
605
  ? out.$unknown
569
606
  : null;
570
607
  while (pos < n) {
@@ -576,34 +613,33 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
576
613
  }
577
614
  else if ((b0 & 2) !== 0) {
578
615
  if (pos + 2 > n)
579
- throw new Error('omnibuf: truncated tag');
616
+ throw new globalThis.Error('omnibuf: truncated tag');
580
617
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
581
618
  pos += 2;
582
619
  }
583
620
  else {
584
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
621
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
585
622
  if (tn === 0 || t64 >> 4n > 536870911n)
586
- throw new Error('omnibuf: invalid tag');
587
- tag = Number(t64);
623
+ throw new globalThis.Error('omnibuf: invalid tag');
624
+ tag = globalThis.Number(t64);
588
625
  pos += tn;
589
626
  }
590
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
627
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
591
628
  const wt = tag & 0x0f;
592
629
  if (fieldNum === 0) {
593
- if (wt !== 12)
594
- throw new Error('omnibuf: invalid Field #0 wire type');
595
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
596
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
630
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
631
+ if (nextPos < 0)
632
+ throw new globalThis.Error('omnibuf: invalid Field #0');
597
633
  pos = nextPos;
598
634
  continue;
599
635
  }
600
636
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
601
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
637
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
602
638
  switch (fieldNum) {
603
639
  case 1: {
604
640
  if (!(wt === 0)) {
605
641
  const valStart = pos;
606
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
642
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
607
643
  if (readUnknown) {
608
644
  if (!unknownFields)
609
645
  unknownFields = [];
@@ -617,7 +653,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
617
653
  }
618
654
  seenMask |= bit;
619
655
  if (pos >= n)
620
- throw new Error('omnibuf: truncated uint32');
656
+ throw new globalThis.Error('omnibuf: truncated uint32');
621
657
  const vb = buf[pos];
622
658
  let u32Val = 0;
623
659
  if ((vb & 1) !== 0) {
@@ -626,13 +662,13 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
626
662
  }
627
663
  else if ((vb & 2) !== 0) {
628
664
  if (pos + 2 > n)
629
- throw new Error('omnibuf: truncated uint32');
665
+ throw new globalThis.Error('omnibuf: truncated uint32');
630
666
  u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
631
667
  pos += 2;
632
668
  }
633
669
  else if ((vb & 4) !== 0) {
634
670
  if (pos + 4 > n)
635
- throw new Error('omnibuf: truncated uint32');
671
+ throw new globalThis.Error('omnibuf: truncated uint32');
636
672
  u32Val =
637
673
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
638
674
  0;
@@ -640,7 +676,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
640
676
  }
641
677
  else {
642
678
  if (vb !== 0 || pos + 9 > n)
643
- throw new Error('omnibuf: truncated uint32');
679
+ throw new globalThis.Error('omnibuf: truncated uint32');
644
680
  u32Val =
645
681
  (buf[pos + 1] |
646
682
  (buf[pos + 2] << 8) |
@@ -655,7 +691,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
655
691
  case 2: {
656
692
  if (!(wt === 10)) {
657
693
  const valStart = pos;
658
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
694
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
659
695
  if (readUnknown) {
660
696
  if (!unknownFields)
661
697
  unknownFields = [];
@@ -669,19 +705,19 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
669
705
  }
670
706
  seenMask |= bit;
671
707
  if (pos >= n)
672
- throw new Error('omnibuf: truncated string');
708
+ throw new globalThis.Error('omnibuf: truncated string');
673
709
  const sb = buf[pos];
674
710
  if ((sb & 1) !== 0) {
675
711
  const sLen = sb >>> 1;
676
712
  pos += 1;
677
713
  if (pos + sLen > n)
678
- throw new Error('omnibuf: truncated string');
679
- out.router = decodeUTF8(buf, pos, pos + sLen);
714
+ throw new globalThis.Error('omnibuf: truncated string');
715
+ out.router = $ob.decodeUTF8(buf, pos, pos + sLen);
680
716
  pos += sLen;
681
717
  }
682
718
  else {
683
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
684
- out.router = decodeUTF8(s);
719
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
720
+ out.router = $ob.decodeUTF8(s);
685
721
  pos = nextPos;
686
722
  }
687
723
  break;
@@ -689,7 +725,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
689
725
  case 3: {
690
726
  if (!(wt === 0)) {
691
727
  const valStart = pos;
692
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
728
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
693
729
  if (readUnknown) {
694
730
  if (!unknownFields)
695
731
  unknownFields = [];
@@ -703,7 +739,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
703
739
  }
704
740
  seenMask |= bit;
705
741
  if (pos >= n)
706
- throw new Error('omnibuf: truncated uint32');
742
+ throw new globalThis.Error('omnibuf: truncated uint32');
707
743
  const vb = buf[pos];
708
744
  let u32Val = 0;
709
745
  if ((vb & 1) !== 0) {
@@ -712,13 +748,13 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
712
748
  }
713
749
  else if ((vb & 2) !== 0) {
714
750
  if (pos + 2 > n)
715
- throw new Error('omnibuf: truncated uint32');
751
+ throw new globalThis.Error('omnibuf: truncated uint32');
716
752
  u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
717
753
  pos += 2;
718
754
  }
719
755
  else if ((vb & 4) !== 0) {
720
756
  if (pos + 4 > n)
721
- throw new Error('omnibuf: truncated uint32');
757
+ throw new globalThis.Error('omnibuf: truncated uint32');
722
758
  u32Val =
723
759
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
724
760
  0;
@@ -726,7 +762,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
726
762
  }
727
763
  else {
728
764
  if (vb !== 0 || pos + 9 > n)
729
- throw new Error('omnibuf: truncated uint32');
765
+ throw new globalThis.Error('omnibuf: truncated uint32');
730
766
  u32Val =
731
767
  (buf[pos + 1] |
732
768
  (buf[pos + 2] << 8) |
@@ -741,7 +777,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
741
777
  case 4: {
742
778
  if (!(wt === 2 || wt === 3)) {
743
779
  const valStart = pos;
744
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
780
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
745
781
  if (readUnknown) {
746
782
  if (!unknownFields)
747
783
  unknownFields = [];
@@ -759,7 +795,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
759
795
  }
760
796
  default: {
761
797
  const valStart = pos;
762
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
798
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
763
799
  if (readUnknown) {
764
800
  if (!unknownFields)
765
801
  unknownFields = [];
@@ -774,7 +810,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
774
810
  }
775
811
  }
776
812
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
777
- Object.defineProperty(out, '$unknown', {
813
+ globalThis.Object.defineProperty(out, '$unknown', {
778
814
  value: unknownFields,
779
815
  enumerable: false,
780
816
  writable: true,
@@ -791,15 +827,30 @@ NeighborSchema.setGeneratedCodec({
791
827
  encode: encodeNeighbor,
792
828
  decode: decodeNeighbor,
793
829
  });
830
+ $ob.registerClassSchema(NeighborMsg, NeighborSchema);
794
831
  export class OpaqueNeighbor {
795
832
  _raw;
833
+ _depth;
834
+ _readCount = 0;
835
+ _fieldIndex = null;
796
836
  _dirtyMask = 0;
797
837
  _peerAsn;
798
838
  _router;
799
839
  _latencyUs;
800
840
  _established;
801
- constructor(raw) {
841
+ constructor(raw, depth = 0) {
802
842
  this._raw = raw;
843
+ this._depth = depth;
844
+ }
845
+ _sliceField(fieldNum) {
846
+ if (this._fieldIndex === null) {
847
+ if (this._readCount < 2) {
848
+ this._readCount++;
849
+ return this._raw;
850
+ }
851
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
852
+ }
853
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
803
854
  }
804
855
  raw() {
805
856
  return this._raw;
@@ -808,7 +859,8 @@ export class OpaqueNeighbor {
808
859
  if ((this._dirtyMask & (1 << 1)) !== 0) {
809
860
  return this._peerAsn;
810
861
  }
811
- return readUint32(this._raw, 1)[0];
862
+ const __src = this._sliceField(1);
863
+ return (__src ? $ob.readUint32(__src, 1)[0] : 0);
812
864
  }
813
865
  peerAsn() {
814
866
  return this.getPeerAsn();
@@ -824,7 +876,8 @@ export class OpaqueNeighbor {
824
876
  if ((this._dirtyMask & (1 << 2)) !== 0) {
825
877
  return this._router;
826
878
  }
827
- return readString(this._raw, 2)[0];
879
+ const __src = this._sliceField(2);
880
+ return __src ? $ob.readString(__src, 2)[0] : '';
828
881
  }
829
882
  router() {
830
883
  return this.getRouter();
@@ -837,7 +890,8 @@ export class OpaqueNeighbor {
837
890
  if ((this._dirtyMask & (1 << 3)) !== 0) {
838
891
  return this._latencyUs;
839
892
  }
840
- return readUint32(this._raw, 3)[0];
893
+ const __src = this._sliceField(3);
894
+ return (__src ? $ob.readUint32(__src, 3)[0] : 0);
841
895
  }
842
896
  latencyUs() {
843
897
  return this.getLatencyUs();
@@ -853,7 +907,8 @@ export class OpaqueNeighbor {
853
907
  if ((this._dirtyMask & (1 << 4)) !== 0) {
854
908
  return this._established;
855
909
  }
856
- return readBool(this._raw, 4)[0];
910
+ const __src = this._sliceField(4);
911
+ return __src ? $ob.readBool(__src, 4)[0] : false;
857
912
  }
858
913
  established() {
859
914
  return this.getEstablished();
@@ -863,12 +918,13 @@ export class OpaqueNeighbor {
863
918
  this._dirtyMask |= 1 << 4;
864
919
  }
865
920
  marshal(options) {
921
+ let outBuf;
866
922
  if (this._dirtyMask !== 0) {
867
- this._raw = spliceFields(this._raw, this._dirtyMask, 4, (enc, fnum) => {
923
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 4, (enc, fnum) => {
868
924
  switch (fnum) {
869
925
  case 1: {
870
926
  const msg = { peerAsn: this._peerAsn };
871
- enc.writeUint(1, Number(msg.peerAsn ?? msg.peer_asn ?? 0) >>> 0);
927
+ enc.writeUint(1, globalThis.Number(msg.peerAsn ?? msg.peer_asn ?? 0) >>> 0);
872
928
  break;
873
929
  }
874
930
  case 2: {
@@ -878,32 +934,48 @@ export class OpaqueNeighbor {
878
934
  }
879
935
  case 3: {
880
936
  const msg = { latencyUs: this._latencyUs };
881
- enc.writeUint(3, Number(msg.latencyUs ?? msg.latency_us ?? 0) >>> 0);
937
+ enc.writeUint(3, globalThis.Number(msg.latencyUs ?? msg.latency_us ?? 0) >>> 0);
882
938
  break;
883
939
  }
884
940
  case 4: {
885
941
  const msg = { established: this._established };
886
- enc.writeBool(4, Boolean(msg.established));
942
+ enc.writeBool(4, globalThis.Boolean(msg.established));
887
943
  break;
888
944
  }
889
945
  }
890
946
  });
891
- this._dirtyMask = 0;
892
947
  }
893
948
  else {
894
- validateMessage(this._raw);
949
+ $ob.validateMessage(this._raw, this._depth);
950
+ outBuf = this._raw.slice();
895
951
  }
896
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
897
- const f0 = encodeField0SchemaMeta(NeighborSchema.getSchemaMeta(0), Boolean(options.deterministic));
898
- const out = new Uint8Array(f0.length + this._raw.length);
899
- out.set(f0, 0);
900
- out.set(this._raw, f0.length);
901
- return out;
952
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
953
+ const f0 = $ob.encodeField0SchemaMeta(NeighborSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
954
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
955
+ withF0.set(f0, 0);
956
+ withF0.set(outBuf, f0.length);
957
+ return withF0;
958
+ }
959
+ return outBuf;
960
+ }
961
+ marshalValidated(options) {
962
+ const out = this.marshal(options);
963
+ $ob.validateMessage(out, this._depth);
964
+ return out;
965
+ }
966
+ tryMarshal(options) {
967
+ try {
968
+ return { ok: true, value: this.marshalValidated(options) };
969
+ }
970
+ catch (err) {
971
+ return {
972
+ ok: false,
973
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
974
+ };
902
975
  }
903
- return this._raw;
904
976
  }
905
977
  }
906
- export const PeerUpdateSchema = defineMessage('omnibuf.bench.PeerUpdate', {
978
+ export const PeerUpdateSchema = $ob.defineMessage('omnibuf.bench.PeerUpdate', {
907
979
  asn: { fieldNum: 1, type: 'uint32' },
908
980
  routerId: { fieldNum: 2, name: 'router_id', type: 'string' },
909
981
  active: { fieldNum: 3, type: 'bool' },
@@ -953,7 +1025,7 @@ class PeerUpdateMsg {
953
1025
  neighbors = [];
954
1026
  sequence = 0;
955
1027
  }
956
- Object.defineProperty(PeerUpdateMsg.prototype, '$typeName', {
1028
+ globalThis.Object.defineProperty(PeerUpdateMsg.prototype, '$typeName', {
957
1029
  value: 'omnibuf.bench.PeerUpdate',
958
1030
  enumerable: false,
959
1031
  writable: true,
@@ -965,11 +1037,11 @@ export function createPeerUpdate(init) {
965
1037
  return PeerUpdateSchema.create(init);
966
1038
  }
967
1039
  export function encodePeerUpdate(enc, msg, options) {
968
- enc.writeUint(1, Number(msg.asn ?? 0) >>> 0);
1040
+ enc.writeUint(1, globalThis.Number(msg.asn ?? 0) >>> 0);
969
1041
  enc.writeString(2, msg.routerId ?? msg.router_id ?? '');
970
- enc.writeBool(3, Boolean(msg.active));
1042
+ enc.writeBool(3, globalThis.Boolean(msg.active));
971
1043
  enc.writeUint(4, msg.uptimeSec ?? msg.uptime_sec ?? 0);
972
- enc.writeInt(5, Number(msg.rssiDbm ?? msg.rssi_dbm ?? 0) | 0);
1044
+ enc.writeInt(5, globalThis.Number(msg.rssiDbm ?? msg.rssi_dbm ?? 0) | 0);
973
1045
  enc.writeFloat64(6, msg.cpuLoad ?? msg.cpu_load ?? 0);
974
1046
  enc.writeStringArr(7, msg.tags ?? []);
975
1047
  enc.writeUint32Arr(8, msg.prefixes ?? []);
@@ -993,7 +1065,7 @@ export function encodePeerUpdate(enc, msg, options) {
993
1065
  enc.endSubMsgArr();
994
1066
  }
995
1067
  enc.writeUint(11, msg.sequence ?? 0);
996
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
1068
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
997
1069
  for (const uf of msg.$unknown) {
998
1070
  enc.writeTag(uf.no, uf.wireType);
999
1071
  enc.writeRaw(uf.data);
@@ -1001,42 +1073,42 @@ export function encodePeerUpdate(enc, msg, options) {
1001
1073
  }
1002
1074
  }
1003
1075
  export function marshalPeerUpdateOmniBuf(msg, options) {
1004
- const enc = new Encoder(256);
1076
+ const enc = new $ob.Encoder(256);
1005
1077
  if (options?.selfDescribing) {
1006
- writeField0SchemaMeta(enc, PeerUpdateSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
1078
+ $ob.writeField0SchemaMeta(enc, PeerUpdateSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
1007
1079
  }
1008
1080
  encodePeerUpdate(enc, msg, options);
1009
1081
  return enc.finish();
1010
1082
  }
1011
1083
  export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
1012
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
1084
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
1013
1085
  const readUnknown = options?.readUnknownFields ?? true;
1014
1086
  if (depth > maxDepth) {
1015
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
1087
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
1016
1088
  }
1017
1089
  const out = target ?? new PeerUpdateMsg();
1018
1090
  if (target !== undefined) {
1019
1091
  if (!(out instanceof PeerUpdateMsg)) {
1020
- Object.setPrototypeOf(out, PeerUpdateMsg.prototype);
1092
+ globalThis.Object.setPrototypeOf(out, PeerUpdateMsg.prototype);
1021
1093
  }
1022
1094
  if (!options?.merge) {
1023
- if (Object.hasOwn(out, 'router_id'))
1095
+ if (globalThis.Object.hasOwn(out, 'router_id'))
1024
1096
  delete out.router_id;
1025
- if (Object.hasOwn(out, 'uptime_sec'))
1097
+ if (globalThis.Object.hasOwn(out, 'uptime_sec'))
1026
1098
  delete out.uptime_sec;
1027
- if (Object.hasOwn(out, 'rssi_dbm'))
1099
+ if (globalThis.Object.hasOwn(out, 'rssi_dbm'))
1028
1100
  delete out.rssi_dbm;
1029
- if (Object.hasOwn(out, 'cpu_load'))
1101
+ if (globalThis.Object.hasOwn(out, 'cpu_load'))
1030
1102
  delete out.cpu_load;
1031
- Object.assign(out, new PeerUpdateMsg());
1032
- if (Object.hasOwn(out, '$unknown'))
1103
+ globalThis.Object.assign(out, new PeerUpdateMsg());
1104
+ if (globalThis.Object.hasOwn(out, '$unknown'))
1033
1105
  delete out.$unknown;
1034
1106
  }
1035
1107
  }
1036
1108
  const n = endPos;
1037
1109
  let pos = startPos;
1038
1110
  let seenMask = 0;
1039
- let unknownFields = Array.isArray(out.$unknown)
1111
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
1040
1112
  ? out.$unknown
1041
1113
  : null;
1042
1114
  while (pos < n) {
@@ -1048,34 +1120,33 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1048
1120
  }
1049
1121
  else if ((b0 & 2) !== 0) {
1050
1122
  if (pos + 2 > n)
1051
- throw new Error('omnibuf: truncated tag');
1123
+ throw new globalThis.Error('omnibuf: truncated tag');
1052
1124
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
1053
1125
  pos += 2;
1054
1126
  }
1055
1127
  else {
1056
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
1128
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
1057
1129
  if (tn === 0 || t64 >> 4n > 536870911n)
1058
- throw new Error('omnibuf: invalid tag');
1059
- tag = Number(t64);
1130
+ throw new globalThis.Error('omnibuf: invalid tag');
1131
+ tag = globalThis.Number(t64);
1060
1132
  pos += tn;
1061
1133
  }
1062
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
1134
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
1063
1135
  const wt = tag & 0x0f;
1064
1136
  if (fieldNum === 0) {
1065
- if (wt !== 12)
1066
- throw new Error('omnibuf: invalid Field #0 wire type');
1067
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
1068
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
1137
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
1138
+ if (nextPos < 0)
1139
+ throw new globalThis.Error('omnibuf: invalid Field #0');
1069
1140
  pos = nextPos;
1070
1141
  continue;
1071
1142
  }
1072
1143
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
1073
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
1144
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
1074
1145
  switch (fieldNum) {
1075
1146
  case 1: {
1076
1147
  if (!(wt === 0)) {
1077
1148
  const valStart = pos;
1078
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1149
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1079
1150
  if (readUnknown) {
1080
1151
  if (!unknownFields)
1081
1152
  unknownFields = [];
@@ -1089,7 +1160,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1089
1160
  }
1090
1161
  seenMask |= bit;
1091
1162
  if (pos >= n)
1092
- throw new Error('omnibuf: truncated uint32');
1163
+ throw new globalThis.Error('omnibuf: truncated uint32');
1093
1164
  const vb = buf[pos];
1094
1165
  let u32Val = 0;
1095
1166
  if ((vb & 1) !== 0) {
@@ -1098,13 +1169,13 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1098
1169
  }
1099
1170
  else if ((vb & 2) !== 0) {
1100
1171
  if (pos + 2 > n)
1101
- throw new Error('omnibuf: truncated uint32');
1172
+ throw new globalThis.Error('omnibuf: truncated uint32');
1102
1173
  u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
1103
1174
  pos += 2;
1104
1175
  }
1105
1176
  else if ((vb & 4) !== 0) {
1106
1177
  if (pos + 4 > n)
1107
- throw new Error('omnibuf: truncated uint32');
1178
+ throw new globalThis.Error('omnibuf: truncated uint32');
1108
1179
  u32Val =
1109
1180
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
1110
1181
  0;
@@ -1112,7 +1183,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1112
1183
  }
1113
1184
  else {
1114
1185
  if (vb !== 0 || pos + 9 > n)
1115
- throw new Error('omnibuf: truncated uint32');
1186
+ throw new globalThis.Error('omnibuf: truncated uint32');
1116
1187
  u32Val =
1117
1188
  (buf[pos + 1] |
1118
1189
  (buf[pos + 2] << 8) |
@@ -1127,7 +1198,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1127
1198
  case 2: {
1128
1199
  if (!(wt === 10)) {
1129
1200
  const valStart = pos;
1130
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1201
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1131
1202
  if (readUnknown) {
1132
1203
  if (!unknownFields)
1133
1204
  unknownFields = [];
@@ -1141,19 +1212,19 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1141
1212
  }
1142
1213
  seenMask |= bit;
1143
1214
  if (pos >= n)
1144
- throw new Error('omnibuf: truncated string');
1215
+ throw new globalThis.Error('omnibuf: truncated string');
1145
1216
  const sb = buf[pos];
1146
1217
  if ((sb & 1) !== 0) {
1147
1218
  const sLen = sb >>> 1;
1148
1219
  pos += 1;
1149
1220
  if (pos + sLen > n)
1150
- throw new Error('omnibuf: truncated string');
1151
- out.routerId = decodeUTF8(buf, pos, pos + sLen);
1221
+ throw new globalThis.Error('omnibuf: truncated string');
1222
+ out.routerId = $ob.decodeUTF8(buf, pos, pos + sLen);
1152
1223
  pos += sLen;
1153
1224
  }
1154
1225
  else {
1155
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
1156
- out.routerId = decodeUTF8(s);
1226
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1227
+ out.routerId = $ob.decodeUTF8(s);
1157
1228
  pos = nextPos;
1158
1229
  }
1159
1230
  break;
@@ -1161,7 +1232,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1161
1232
  case 3: {
1162
1233
  if (!(wt === 2 || wt === 3)) {
1163
1234
  const valStart = pos;
1164
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1235
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1165
1236
  if (readUnknown) {
1166
1237
  if (!unknownFields)
1167
1238
  unknownFields = [];
@@ -1180,7 +1251,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1180
1251
  case 4: {
1181
1252
  if (!(wt === 0)) {
1182
1253
  const valStart = pos;
1183
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1254
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1184
1255
  if (readUnknown) {
1185
1256
  if (!unknownFields)
1186
1257
  unknownFields = [];
@@ -1194,7 +1265,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1194
1265
  }
1195
1266
  seenMask |= bit;
1196
1267
  if (pos >= n)
1197
- throw new Error('omnibuf: truncated uint64');
1268
+ throw new globalThis.Error('omnibuf: truncated uint64');
1198
1269
  const vb = buf[pos];
1199
1270
  let u64Val;
1200
1271
  if ((vb & 1) !== 0) {
@@ -1203,13 +1274,13 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1203
1274
  }
1204
1275
  else if ((vb & 2) !== 0) {
1205
1276
  if (pos + 2 > n)
1206
- throw new Error('omnibuf: truncated uint64');
1277
+ throw new globalThis.Error('omnibuf: truncated uint64');
1207
1278
  u64Val = (vb | (buf[pos + 1] << 8)) >>> 2;
1208
1279
  pos += 2;
1209
1280
  }
1210
1281
  else if ((vb & 4) !== 0) {
1211
1282
  if (pos + 4 > n)
1212
- throw new Error('omnibuf: truncated uint64');
1283
+ throw new globalThis.Error('omnibuf: truncated uint64');
1213
1284
  u64Val =
1214
1285
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
1215
1286
  0;
@@ -1217,7 +1288,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1217
1288
  }
1218
1289
  else {
1219
1290
  if (vb !== 0 || pos + 9 > n)
1220
- throw new Error('omnibuf: truncated uint64');
1291
+ throw new globalThis.Error('omnibuf: truncated uint64');
1221
1292
  const lo = (buf[pos + 1] |
1222
1293
  (buf[pos + 2] << 8) |
1223
1294
  (buf[pos + 3] << 16) |
@@ -1228,7 +1299,10 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1228
1299
  (buf[pos + 7] << 16) |
1229
1300
  (buf[pos + 8] << 24)) >>>
1230
1301
  0;
1231
- u64Val = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
1302
+ u64Val =
1303
+ hi <= 0x1fffff
1304
+ ? hi * 0x100000000 + lo
1305
+ : (globalThis.BigInt(hi) << 32n) | globalThis.BigInt(lo);
1232
1306
  pos += 9;
1233
1307
  }
1234
1308
  out.uptimeSec = u64Val;
@@ -1237,7 +1311,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1237
1311
  case 5: {
1238
1312
  if (!(wt === 1)) {
1239
1313
  const valStart = pos;
1240
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1314
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1241
1315
  if (readUnknown) {
1242
1316
  if (!unknownFields)
1243
1317
  unknownFields = [];
@@ -1251,7 +1325,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1251
1325
  }
1252
1326
  seenMask |= bit;
1253
1327
  if (pos >= n)
1254
- throw new Error('omnibuf: truncated int32/enum');
1328
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
1255
1329
  const vb = buf[pos];
1256
1330
  let i32Val = 0;
1257
1331
  if ((vb & 1) !== 0) {
@@ -1261,24 +1335,24 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1261
1335
  }
1262
1336
  else if ((vb & 2) !== 0) {
1263
1337
  if (pos + 2 > n)
1264
- throw new Error('omnibuf: truncated int32/enum');
1338
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
1265
1339
  const u = (vb | (buf[pos + 1] << 8)) >>> 2;
1266
1340
  i32Val = (u >>> 1) ^ -(u & 1);
1267
1341
  pos += 2;
1268
1342
  }
1269
1343
  else if ((vb & 4) !== 0) {
1270
1344
  if (pos + 4 > n)
1271
- throw new Error('omnibuf: truncated int32/enum');
1345
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
1272
1346
  const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
1273
1347
  0;
1274
1348
  i32Val = (u >>> 1) ^ -(u & 1);
1275
1349
  pos += 4;
1276
1350
  }
1277
1351
  else {
1278
- const [v, vn] = decodeVarintBigInt(buf, pos, n);
1352
+ const [v, vn] = $ob.decodeVarintBigInt(buf, pos, n);
1279
1353
  if (vn === 0)
1280
- throw new Error('omnibuf: truncated int32/enum');
1281
- i32Val = decodeZigZag32(v);
1354
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
1355
+ i32Val = $ob.decodeZigZag32(v);
1282
1356
  pos += vn;
1283
1357
  }
1284
1358
  out.rssiDbm = i32Val;
@@ -1287,7 +1361,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1287
1361
  case 6: {
1288
1362
  if (!(wt === 9)) {
1289
1363
  const valStart = pos;
1290
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1364
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1291
1365
  if (readUnknown) {
1292
1366
  if (!unknownFields)
1293
1367
  unknownFields = [];
@@ -1301,15 +1375,15 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1301
1375
  }
1302
1376
  seenMask |= bit;
1303
1377
  if (n - pos < 8)
1304
- throw new Error('omnibuf: truncated float64');
1305
- out.cpuLoad = readFloat64At(buf, pos);
1378
+ throw new globalThis.Error('omnibuf: truncated float64');
1379
+ out.cpuLoad = $ob.readFloat64At(buf, pos);
1306
1380
  pos += 8;
1307
1381
  break;
1308
1382
  }
1309
1383
  case 7: {
1310
1384
  if (!(wt === 13)) {
1311
1385
  const valStart = pos;
1312
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1386
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1313
1387
  if (readUnknown) {
1314
1388
  if (!unknownFields)
1315
1389
  unknownFields = [];
@@ -1323,9 +1397,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1323
1397
  }
1324
1398
  seenMask |= bit;
1325
1399
  if (depth + 1 > maxDepth)
1326
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
1400
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
1327
1401
  if (pos >= n)
1328
- throw new Error('omnibuf: invalid string array');
1402
+ throw new globalThis.Error('omnibuf: invalid string array');
1329
1403
  const lb = buf[pos];
1330
1404
  let bodyLen = 0;
1331
1405
  if ((lb & 1) !== 0) {
@@ -1334,30 +1408,30 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1334
1408
  }
1335
1409
  else if ((lb & 2) !== 0) {
1336
1410
  if (pos + 2 > n)
1337
- throw new Error('omnibuf: invalid string array');
1411
+ throw new globalThis.Error('omnibuf: invalid string array');
1338
1412
  bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
1339
1413
  pos += 2;
1340
1414
  }
1341
1415
  else {
1342
- const [body, nextPos] = readLenSlice(buf, pos, 2, n);
1343
- const prev = alreadySeen && Array.isArray(out.tags) ? out.tags : [];
1344
- const [arr, ok] = appendStringArrBody(prev, body);
1416
+ const [body, nextPos] = $ob.readLenSlice(buf, pos, 2, n);
1417
+ const prev = alreadySeen && globalThis.Array.isArray(out.tags) ? out.tags : [];
1418
+ const [arr, ok] = $ob.appendStringArrBody(prev, body);
1345
1419
  if (!ok)
1346
- throw new Error('omnibuf: invalid string array');
1420
+ throw new globalThis.Error('omnibuf: invalid string array');
1347
1421
  out.tags = arr;
1348
1422
  pos = nextPos;
1349
1423
  break;
1350
1424
  }
1351
1425
  const bodyEnd = pos + bodyLen;
1352
1426
  if (bodyLen < 2 || bodyEnd > n)
1353
- throw new Error('omnibuf: invalid string array');
1427
+ throw new globalThis.Error('omnibuf: invalid string array');
1354
1428
  if (buf[pos] === 10 && (buf[pos + 1] & 1) !== 0) {
1355
1429
  const count = buf[pos + 1] >>> 1;
1356
1430
  let p = pos + 2;
1357
1431
  if (count > bodyEnd - p)
1358
- throw new Error('omnibuf: invalid string array');
1432
+ throw new globalThis.Error('omnibuf: invalid string array');
1359
1433
  let dst = out.tags;
1360
- if (!Array.isArray(dst)) {
1434
+ if (!globalThis.Array.isArray(dst)) {
1361
1435
  dst = [];
1362
1436
  out.tags = dst;
1363
1437
  }
@@ -1366,35 +1440,35 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1366
1440
  }
1367
1441
  for (let i = 0; i < count; i++) {
1368
1442
  if (p >= bodyEnd)
1369
- throw new Error('omnibuf: invalid string array');
1443
+ throw new globalThis.Error('omnibuf: invalid string array');
1370
1444
  const sb = buf[p];
1371
1445
  if ((sb & 1) !== 0) {
1372
1446
  const sLen = sb >>> 1;
1373
1447
  p += 1;
1374
1448
  if (p + sLen > bodyEnd)
1375
- throw new Error('omnibuf: invalid string array');
1376
- dst.push(decodeUTF8(buf, p, p + sLen));
1449
+ throw new globalThis.Error('omnibuf: invalid string array');
1450
+ dst.push($ob.decodeUTF8(buf, p, p + sLen));
1377
1451
  p += sLen;
1378
1452
  }
1379
1453
  else {
1380
- const [sLen, sn] = decodeVarintBigInt(buf, p, bodyEnd);
1381
- if (sn === 0 || sLen > BigInt(bodyEnd - (p + sn)))
1382
- throw new Error('omnibuf: invalid string array');
1454
+ const [sLen, sn] = $ob.decodeVarintBigInt(buf, p, bodyEnd);
1455
+ if (sn === 0 || sLen > globalThis.BigInt(bodyEnd - (p + sn)))
1456
+ throw new globalThis.Error('omnibuf: invalid string array');
1383
1457
  p += sn;
1384
- const sLenNum = Number(sLen);
1385
- dst.push(decodeUTF8(buf, p, p + sLenNum));
1458
+ const sLenNum = globalThis.Number(sLen);
1459
+ dst.push($ob.decodeUTF8(buf, p, p + sLenNum));
1386
1460
  p += sLenNum;
1387
1461
  }
1388
1462
  }
1389
1463
  if (p !== bodyEnd)
1390
- throw new Error('omnibuf: invalid string array');
1464
+ throw new globalThis.Error('omnibuf: invalid string array');
1391
1465
  pos = bodyEnd;
1392
1466
  break;
1393
1467
  }
1394
- const prev = alreadySeen && Array.isArray(out.tags) ? out.tags : [];
1395
- const [arr, ok] = appendStringArrBody(prev, buf.subarray(pos, bodyEnd));
1468
+ const prev = alreadySeen && globalThis.Array.isArray(out.tags) ? out.tags : [];
1469
+ const [arr, ok] = $ob.appendStringArrBody(prev, buf.subarray(pos, bodyEnd));
1396
1470
  if (!ok)
1397
- throw new Error('omnibuf: invalid string array');
1471
+ throw new globalThis.Error('omnibuf: invalid string array');
1398
1472
  out.tags = arr;
1399
1473
  pos = bodyEnd;
1400
1474
  break;
@@ -1402,7 +1476,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1402
1476
  case 8: {
1403
1477
  if (!(wt === 13)) {
1404
1478
  const valStart = pos;
1405
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1479
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1406
1480
  if (readUnknown) {
1407
1481
  if (!unknownFields)
1408
1482
  unknownFields = [];
@@ -1416,9 +1490,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1416
1490
  }
1417
1491
  seenMask |= bit;
1418
1492
  if (depth + 1 > maxDepth)
1419
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
1493
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
1420
1494
  if (pos >= n)
1421
- throw new Error('omnibuf: invalid uint32 array');
1495
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1422
1496
  const lb = buf[pos];
1423
1497
  let bodyLen = 0;
1424
1498
  if ((lb & 1) !== 0) {
@@ -1427,30 +1501,30 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1427
1501
  }
1428
1502
  else if ((lb & 2) !== 0) {
1429
1503
  if (pos + 2 > n)
1430
- throw new Error('omnibuf: invalid uint32 array');
1504
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1431
1505
  bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
1432
1506
  pos += 2;
1433
1507
  }
1434
1508
  else {
1435
- const [body, nextPos] = readLenSlice(buf, pos, 2, n);
1436
- const prev = alreadySeen && Array.isArray(out.prefixes) ? out.prefixes : [];
1437
- const [arr, ok] = appendUint32ArrBody(prev, body);
1509
+ const [body, nextPos] = $ob.readLenSlice(buf, pos, 2, n);
1510
+ const prev = alreadySeen && globalThis.Array.isArray(out.prefixes) ? out.prefixes : [];
1511
+ const [arr, ok] = $ob.appendUint32ArrBody(prev, body);
1438
1512
  if (!ok)
1439
- throw new Error('omnibuf: invalid uint32 array');
1513
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1440
1514
  out.prefixes = arr;
1441
1515
  pos = nextPos;
1442
1516
  break;
1443
1517
  }
1444
1518
  const bodyEnd = pos + bodyLen;
1445
1519
  if (bodyLen < 2 || bodyEnd > n)
1446
- throw new Error('omnibuf: invalid uint32 array');
1520
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1447
1521
  if (buf[pos] === 0 && (buf[pos + 1] & 1) !== 0) {
1448
1522
  const count = buf[pos + 1] >>> 1;
1449
1523
  let p = pos + 2;
1450
1524
  if (count > bodyEnd - p)
1451
- throw new Error('omnibuf: invalid uint32 array');
1525
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1452
1526
  let dst = out.prefixes;
1453
- if (!Array.isArray(dst)) {
1527
+ if (!globalThis.Array.isArray(dst)) {
1454
1528
  dst = [];
1455
1529
  out.prefixes = dst;
1456
1530
  }
@@ -1459,7 +1533,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1459
1533
  }
1460
1534
  for (let i = 0; i < count; i++) {
1461
1535
  if (p >= bodyEnd)
1462
- throw new Error('omnibuf: invalid uint32 array');
1536
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1463
1537
  const vb = buf[p];
1464
1538
  if ((vb & 1) !== 0) {
1465
1539
  dst.push(vb >>> 1);
@@ -1467,33 +1541,33 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1467
1541
  }
1468
1542
  else if ((vb & 2) !== 0) {
1469
1543
  if (p + 2 > bodyEnd)
1470
- throw new Error('omnibuf: invalid uint32 array');
1544
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1471
1545
  dst.push((vb | (buf[p + 1] << 8)) >>> 2);
1472
1546
  p += 2;
1473
1547
  }
1474
1548
  else if ((vb & 4) !== 0) {
1475
1549
  if (p + 4 > bodyEnd)
1476
- throw new Error('omnibuf: invalid uint32 array');
1550
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1477
1551
  dst.push(((vb | (buf[p + 1] << 8) | (buf[p + 2] << 16) | (buf[p + 3] << 24)) >>> 3) >>> 0);
1478
1552
  p += 4;
1479
1553
  }
1480
1554
  else {
1481
1555
  if (vb !== 0 || p + 9 > bodyEnd)
1482
- throw new Error('omnibuf: invalid uint32 array');
1556
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1483
1557
  dst.push((buf[p + 1] | (buf[p + 2] << 8) | (buf[p + 3] << 16) | (buf[p + 4] << 24)) >>>
1484
1558
  0);
1485
1559
  p += 9;
1486
1560
  }
1487
1561
  }
1488
1562
  if (p !== bodyEnd)
1489
- throw new Error('omnibuf: invalid uint32 array');
1563
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1490
1564
  pos = bodyEnd;
1491
1565
  break;
1492
1566
  }
1493
- const prev = alreadySeen && Array.isArray(out.prefixes) ? out.prefixes : [];
1494
- const [arr, ok] = appendUint32ArrBody(prev, buf.subarray(pos, bodyEnd));
1567
+ const prev = alreadySeen && globalThis.Array.isArray(out.prefixes) ? out.prefixes : [];
1568
+ const [arr, ok] = $ob.appendUint32ArrBody(prev, buf.subarray(pos, bodyEnd));
1495
1569
  if (!ok)
1496
- throw new Error('omnibuf: invalid uint32 array');
1570
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
1497
1571
  out.prefixes = arr;
1498
1572
  pos = bodyEnd;
1499
1573
  break;
@@ -1501,7 +1575,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1501
1575
  case 9: {
1502
1576
  if (!(wt === 12)) {
1503
1577
  const valStart = pos;
1504
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1578
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1505
1579
  if (readUnknown) {
1506
1580
  if (!unknownFields)
1507
1581
  unknownFields = [];
@@ -1515,7 +1589,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1515
1589
  }
1516
1590
  seenMask |= bit;
1517
1591
  if (pos >= n)
1518
- throw new Error('omnibuf: truncated submsg');
1592
+ throw new globalThis.Error('omnibuf: truncated submsg');
1519
1593
  let subLen = 0;
1520
1594
  const lb = buf[pos];
1521
1595
  if ((lb & 1) !== 0) {
@@ -1524,12 +1598,12 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1524
1598
  }
1525
1599
  else if ((lb & 2) !== 0) {
1526
1600
  if (pos + 2 > n)
1527
- throw new Error('omnibuf: truncated submsg');
1601
+ throw new globalThis.Error('omnibuf: truncated submsg');
1528
1602
  subLen = (lb | (buf[pos + 1] << 8)) >>> 2;
1529
1603
  pos += 2;
1530
1604
  }
1531
1605
  else {
1532
- const [subBytes, nextPos] = readLenSlice(buf, pos, 0, n);
1606
+ const [subBytes, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1533
1607
  const existing = out.location;
1534
1608
  const doMerge = alreadySeen;
1535
1609
  const decodedSub = decodeLocation(subBytes, doMerge ? (existing ?? undefined) : undefined, depth + 1, doMerge ? { ...options, merge: true } : options);
@@ -1538,7 +1612,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1538
1612
  break;
1539
1613
  }
1540
1614
  if (pos + subLen > n)
1541
- throw new Error('omnibuf: truncated submsg');
1615
+ throw new globalThis.Error('omnibuf: truncated submsg');
1542
1616
  const existing = out.location;
1543
1617
  const doMerge = alreadySeen;
1544
1618
  const decodedSub = decodeLocation(buf, doMerge ? (existing ?? undefined) : undefined, depth + 1, doMerge ? { ...options, merge: true } : options, pos, pos + subLen);
@@ -1549,7 +1623,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1549
1623
  case 10: {
1550
1624
  if (!(wt === 13)) {
1551
1625
  const valStart = pos;
1552
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1626
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1553
1627
  if (readUnknown) {
1554
1628
  if (!unknownFields)
1555
1629
  unknownFields = [];
@@ -1563,9 +1637,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1563
1637
  }
1564
1638
  seenMask |= bit;
1565
1639
  if (depth + 1 > maxDepth)
1566
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
1640
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
1567
1641
  if (pos >= n)
1568
- throw new Error('omnibuf: corrupt submsg array');
1642
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1569
1643
  let arrLen = 0;
1570
1644
  const lb = buf[pos];
1571
1645
  if ((lb & 1) !== 0) {
@@ -1574,21 +1648,21 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1574
1648
  }
1575
1649
  else if ((lb & 2) !== 0) {
1576
1650
  if (pos + 2 > n)
1577
- throw new Error('omnibuf: corrupt submsg array');
1651
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1578
1652
  arrLen = (lb | (buf[pos + 1] << 8)) >>> 2;
1579
1653
  pos += 2;
1580
1654
  }
1581
1655
  else {
1582
- const [arrPayload, nextPos] = readLenSlice(buf, pos, 2, n);
1583
- const [elemCount, ok] = countSubMsgArrElems(arrPayload);
1656
+ const [arrPayload, nextPos] = $ob.readLenSlice(buf, pos, 2, n);
1657
+ const [elemCount, ok] = $ob.countSubMsgArrElems(arrPayload);
1584
1658
  if (!ok)
1585
- throw new Error('omnibuf: corrupt submsg array');
1586
- const elems = alreadySeen && Array.isArray(out.neighbors) ? out.neighbors : [];
1587
- let [, , p] = parseArrayHeader(arrPayload);
1659
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1660
+ const elems = alreadySeen && globalThis.Array.isArray(out.neighbors) ? out.neighbors : [];
1661
+ let [, , p] = $ob.parseArrayHeader(arrPayload);
1588
1662
  for (let i = 0; i < elemCount; i++) {
1589
- const [el, en] = decodeVarintBigInt(arrPayload, p);
1663
+ const [el, en] = $ob.decodeVarintBigInt(arrPayload, p);
1590
1664
  p += en;
1591
- const elNum = Number(el);
1665
+ const elNum = globalThis.Number(el);
1592
1666
  elems.push(decodeNeighbor(arrPayload, undefined, depth + 2, options, p, p + elNum));
1593
1667
  p += elNum;
1594
1668
  }
@@ -1598,14 +1672,14 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1598
1672
  }
1599
1673
  const arrEnd = pos + arrLen;
1600
1674
  if (arrLen < 2 || arrEnd > n)
1601
- throw new Error('omnibuf: corrupt submsg array');
1675
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1602
1676
  if (buf[pos] === 12 && (buf[pos + 1] & 1) !== 0) {
1603
1677
  const elemCount = buf[pos + 1] >>> 1;
1604
1678
  let p = pos + 2;
1605
1679
  if (elemCount > arrEnd - p)
1606
- throw new Error('omnibuf: corrupt submsg array');
1680
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1607
1681
  let elems = out.neighbors;
1608
- if (!Array.isArray(elems)) {
1682
+ if (!globalThis.Array.isArray(elems)) {
1609
1683
  elems = [];
1610
1684
  out.neighbors = elems;
1611
1685
  }
@@ -1614,7 +1688,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1614
1688
  }
1615
1689
  for (let i = 0; i < elemCount; i++) {
1616
1690
  if (p >= arrEnd)
1617
- throw new Error('omnibuf: corrupt submsg array');
1691
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1618
1692
  let elNum = 0;
1619
1693
  const eb0 = buf[p];
1620
1694
  if ((eb0 & 1) !== 0) {
@@ -1623,37 +1697,37 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1623
1697
  }
1624
1698
  else if ((eb0 & 2) !== 0) {
1625
1699
  if (p + 2 > arrEnd)
1626
- throw new Error('omnibuf: corrupt submsg array');
1700
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1627
1701
  elNum = (eb0 | (buf[p + 1] << 8)) >>> 2;
1628
1702
  p += 2;
1629
1703
  }
1630
1704
  else {
1631
- const [el, en] = decodeVarintBigInt(buf, p, arrEnd);
1632
- if (en === 0 || el > BigInt(arrEnd - (p + en)))
1633
- throw new Error('omnibuf: corrupt submsg array');
1705
+ const [el, en] = $ob.decodeVarintBigInt(buf, p, arrEnd);
1706
+ if (en === 0 || el > globalThis.BigInt(arrEnd - (p + en)))
1707
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1634
1708
  p += en;
1635
- elNum = Number(el);
1709
+ elNum = globalThis.Number(el);
1636
1710
  }
1637
1711
  if (p + elNum > arrEnd)
1638
- throw new Error('omnibuf: corrupt submsg array');
1712
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1639
1713
  elems.push(decodeNeighbor(buf, undefined, depth + 2, options, p, p + elNum));
1640
1714
  p += elNum;
1641
1715
  }
1642
1716
  if (p !== arrEnd)
1643
- throw new Error('omnibuf: corrupt submsg array');
1717
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1644
1718
  pos = arrEnd;
1645
1719
  break;
1646
1720
  }
1647
1721
  const arrPayload = buf.subarray(pos, arrEnd);
1648
- const [elemCount, ok] = countSubMsgArrElems(arrPayload);
1722
+ const [elemCount, ok] = $ob.countSubMsgArrElems(arrPayload);
1649
1723
  if (!ok)
1650
- throw new Error('omnibuf: corrupt submsg array');
1651
- const elems = alreadySeen && Array.isArray(out.neighbors) ? out.neighbors : [];
1652
- let [, , p] = parseArrayHeader(arrPayload);
1724
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
1725
+ const elems = alreadySeen && globalThis.Array.isArray(out.neighbors) ? out.neighbors : [];
1726
+ let [, , p] = $ob.parseArrayHeader(arrPayload);
1653
1727
  for (let i = 0; i < elemCount; i++) {
1654
- const [el, en] = decodeVarintBigInt(arrPayload, p);
1728
+ const [el, en] = $ob.decodeVarintBigInt(arrPayload, p);
1655
1729
  p += en;
1656
- const elNum = Number(el);
1730
+ const elNum = globalThis.Number(el);
1657
1731
  elems.push(decodeNeighbor(arrPayload, undefined, depth + 2, options, p, p + elNum));
1658
1732
  p += elNum;
1659
1733
  }
@@ -1664,7 +1738,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1664
1738
  case 11: {
1665
1739
  if (!(wt === 0)) {
1666
1740
  const valStart = pos;
1667
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1741
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1668
1742
  if (readUnknown) {
1669
1743
  if (!unknownFields)
1670
1744
  unknownFields = [];
@@ -1678,7 +1752,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1678
1752
  }
1679
1753
  seenMask |= bit;
1680
1754
  if (pos >= n)
1681
- throw new Error('omnibuf: truncated uint64');
1755
+ throw new globalThis.Error('omnibuf: truncated uint64');
1682
1756
  const vb = buf[pos];
1683
1757
  let u64Val;
1684
1758
  if ((vb & 1) !== 0) {
@@ -1687,13 +1761,13 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1687
1761
  }
1688
1762
  else if ((vb & 2) !== 0) {
1689
1763
  if (pos + 2 > n)
1690
- throw new Error('omnibuf: truncated uint64');
1764
+ throw new globalThis.Error('omnibuf: truncated uint64');
1691
1765
  u64Val = (vb | (buf[pos + 1] << 8)) >>> 2;
1692
1766
  pos += 2;
1693
1767
  }
1694
1768
  else if ((vb & 4) !== 0) {
1695
1769
  if (pos + 4 > n)
1696
- throw new Error('omnibuf: truncated uint64');
1770
+ throw new globalThis.Error('omnibuf: truncated uint64');
1697
1771
  u64Val =
1698
1772
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
1699
1773
  0;
@@ -1701,7 +1775,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1701
1775
  }
1702
1776
  else {
1703
1777
  if (vb !== 0 || pos + 9 > n)
1704
- throw new Error('omnibuf: truncated uint64');
1778
+ throw new globalThis.Error('omnibuf: truncated uint64');
1705
1779
  const lo = (buf[pos + 1] |
1706
1780
  (buf[pos + 2] << 8) |
1707
1781
  (buf[pos + 3] << 16) |
@@ -1712,7 +1786,10 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1712
1786
  (buf[pos + 7] << 16) |
1713
1787
  (buf[pos + 8] << 24)) >>>
1714
1788
  0;
1715
- u64Val = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
1789
+ u64Val =
1790
+ hi <= 0x1fffff
1791
+ ? hi * 0x100000000 + lo
1792
+ : (globalThis.BigInt(hi) << 32n) | globalThis.BigInt(lo);
1716
1793
  pos += 9;
1717
1794
  }
1718
1795
  out.sequence = u64Val;
@@ -1720,7 +1797,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1720
1797
  }
1721
1798
  default: {
1722
1799
  const valStart = pos;
1723
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1800
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1724
1801
  if (readUnknown) {
1725
1802
  if (!unknownFields)
1726
1803
  unknownFields = [];
@@ -1735,7 +1812,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0,
1735
1812
  }
1736
1813
  }
1737
1814
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
1738
- Object.defineProperty(out, '$unknown', {
1815
+ globalThis.Object.defineProperty(out, '$unknown', {
1739
1816
  value: unknownFields,
1740
1817
  enumerable: false,
1741
1818
  writable: true,
@@ -1752,8 +1829,12 @@ PeerUpdateSchema.setGeneratedCodec({
1752
1829
  encode: encodePeerUpdate,
1753
1830
  decode: decodePeerUpdate,
1754
1831
  });
1832
+ $ob.registerClassSchema(PeerUpdateMsg, PeerUpdateSchema);
1755
1833
  export class OpaquePeerUpdate {
1756
1834
  _raw;
1835
+ _depth;
1836
+ _readCount = 0;
1837
+ _fieldIndex = null;
1757
1838
  _dirtyMask = 0;
1758
1839
  _asn;
1759
1840
  _routerId;
@@ -1766,8 +1847,20 @@ export class OpaquePeerUpdate {
1766
1847
  _location;
1767
1848
  _neighbors;
1768
1849
  _sequence;
1769
- constructor(raw) {
1850
+ _opaque_location;
1851
+ constructor(raw, depth = 0) {
1770
1852
  this._raw = raw;
1853
+ this._depth = depth;
1854
+ }
1855
+ _sliceField(fieldNum) {
1856
+ if (this._fieldIndex === null) {
1857
+ if (this._readCount < 2) {
1858
+ this._readCount++;
1859
+ return this._raw;
1860
+ }
1861
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
1862
+ }
1863
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
1771
1864
  }
1772
1865
  raw() {
1773
1866
  return this._raw;
@@ -1776,7 +1869,8 @@ export class OpaquePeerUpdate {
1776
1869
  if ((this._dirtyMask & (1 << 1)) !== 0) {
1777
1870
  return this._asn;
1778
1871
  }
1779
- return readUint32(this._raw, 1)[0];
1872
+ const __src = this._sliceField(1);
1873
+ return (__src ? $ob.readUint32(__src, 1)[0] : 0);
1780
1874
  }
1781
1875
  asn() {
1782
1876
  return this.getAsn();
@@ -1789,7 +1883,8 @@ export class OpaquePeerUpdate {
1789
1883
  if ((this._dirtyMask & (1 << 2)) !== 0) {
1790
1884
  return this._routerId;
1791
1885
  }
1792
- return readString(this._raw, 2)[0];
1886
+ const __src = this._sliceField(2);
1887
+ return __src ? $ob.readString(__src, 2)[0] : '';
1793
1888
  }
1794
1889
  routerId() {
1795
1890
  return this.getRouterId();
@@ -1805,7 +1900,8 @@ export class OpaquePeerUpdate {
1805
1900
  if ((this._dirtyMask & (1 << 3)) !== 0) {
1806
1901
  return this._active;
1807
1902
  }
1808
- return readBool(this._raw, 3)[0];
1903
+ const __src = this._sliceField(3);
1904
+ return __src ? $ob.readBool(__src, 3)[0] : false;
1809
1905
  }
1810
1906
  active() {
1811
1907
  return this.getActive();
@@ -1818,7 +1914,8 @@ export class OpaquePeerUpdate {
1818
1914
  if ((this._dirtyMask & (1 << 4)) !== 0) {
1819
1915
  return this._uptimeSec;
1820
1916
  }
1821
- return readUintAuto(this._raw, 4)[0];
1917
+ const __src = this._sliceField(4);
1918
+ return __src ? $ob.readUintAuto(__src, 4)[0] : 0;
1822
1919
  }
1823
1920
  uptimeSec() {
1824
1921
  return this.getUptimeSec();
@@ -1834,7 +1931,8 @@ export class OpaquePeerUpdate {
1834
1931
  if ((this._dirtyMask & (1 << 5)) !== 0) {
1835
1932
  return this._rssiDbm;
1836
1933
  }
1837
- return readInt32(this._raw, 5)[0];
1934
+ const __src = this._sliceField(5);
1935
+ return __src ? $ob.readInt32(__src, 5)[0] : 0;
1838
1936
  }
1839
1937
  rssiDbm() {
1840
1938
  return this.getRssiDbm();
@@ -1850,7 +1948,8 @@ export class OpaquePeerUpdate {
1850
1948
  if ((this._dirtyMask & (1 << 6)) !== 0) {
1851
1949
  return this._cpuLoad;
1852
1950
  }
1853
- return readFloat64(this._raw, 6)[0];
1951
+ const __src = this._sliceField(6);
1952
+ return __src ? $ob.readFloat64(__src, 6)[0] : 0;
1854
1953
  }
1855
1954
  cpuLoad() {
1856
1955
  return this.getCpuLoad();
@@ -1867,7 +1966,8 @@ export class OpaquePeerUpdate {
1867
1966
  return this._tags;
1868
1967
  }
1869
1968
  if (this._tags === undefined) {
1870
- this._tags = readStringArr(this._raw, 7)[0];
1969
+ const __src = this._sliceField(7);
1970
+ this._tags = __src ? $ob.readStringArr(__src, 7)[0] : [];
1871
1971
  }
1872
1972
  return this._tags;
1873
1973
  }
@@ -1883,7 +1983,8 @@ export class OpaquePeerUpdate {
1883
1983
  return this._prefixes;
1884
1984
  }
1885
1985
  if (this._prefixes === undefined) {
1886
- this._prefixes = readUint32Arr(this._raw, 8)[0];
1986
+ const __src = this._sliceField(8);
1987
+ this._prefixes = __src ? $ob.readUint32Arr(__src, 8)[0] : [];
1887
1988
  }
1888
1989
  return this._prefixes;
1889
1990
  }
@@ -1899,15 +2000,40 @@ export class OpaquePeerUpdate {
1899
2000
  return this._location;
1900
2001
  }
1901
2002
  if (this._location === undefined) {
1902
- this._location = readSubMsgMerged(this._raw, 9, (sub, target, merge, s, e) => decodeLocation(sub, target, 0, merge ? { merge: true } : undefined, s, e))[0];
2003
+ const __src = this._sliceField(9);
2004
+ this._location = __src
2005
+ ? $ob.readSubMsgMerged(__src, 9, (sub, target, merge, s, e) => decodeLocation(sub, target, this._depth + 1, merge ? { merge: true } : undefined, s, e))[0]
2006
+ : null;
1903
2007
  }
1904
2008
  return this._location;
1905
2009
  }
2010
+ getLocationOpaque() {
2011
+ if (this._depth + 1 > $ob.MaxNestingDepth) {
2012
+ throw new globalThis.Error(`omnibuf: nesting depth ${this._depth + 1} exceeds MaxNestingDepth (${$ob.MaxNestingDepth})`);
2013
+ }
2014
+ if (this._opaque_location !== undefined) {
2015
+ return this._opaque_location ?? undefined;
2016
+ }
2017
+ const __src = this._sliceField(9);
2018
+ if (!__src) {
2019
+ this._opaque_location = null;
2020
+ return undefined;
2021
+ }
2022
+ const [sub, ok] = $ob.readSubMsg(__src, 9);
2023
+ if (!ok) {
2024
+ this._opaque_location = null;
2025
+ return undefined;
2026
+ }
2027
+ const nested = new OpaqueLocation(sub, this._depth + 1);
2028
+ this._opaque_location = nested;
2029
+ return nested;
2030
+ }
1906
2031
  location() {
1907
2032
  return this.getLocation();
1908
2033
  }
1909
2034
  setLocation(val) {
1910
2035
  this._location = val;
2036
+ this._opaque_location = undefined;
1911
2037
  this._dirtyMask |= 1 << 9;
1912
2038
  }
1913
2039
  getNeighbors() {
@@ -1915,7 +2041,10 @@ export class OpaquePeerUpdate {
1915
2041
  return this._neighbors;
1916
2042
  }
1917
2043
  if (this._neighbors === undefined) {
1918
- this._neighbors = readSubMsgArrDecoded(this._raw, 10, (sub) => decodeNeighbor(sub))[0];
2044
+ const __src = this._sliceField(10);
2045
+ this._neighbors = __src
2046
+ ? $ob.readSubMsgArrDecoded(__src, 10, (sub) => decodeNeighbor(sub, undefined, this._depth + 1))[0]
2047
+ : [];
1919
2048
  }
1920
2049
  return this._neighbors;
1921
2050
  }
@@ -1930,7 +2059,8 @@ export class OpaquePeerUpdate {
1930
2059
  if ((this._dirtyMask & (1 << 11)) !== 0) {
1931
2060
  return this._sequence;
1932
2061
  }
1933
- return readUintAuto(this._raw, 11)[0];
2062
+ const __src = this._sliceField(11);
2063
+ return __src ? $ob.readUintAuto(__src, 11)[0] : 0;
1934
2064
  }
1935
2065
  sequence() {
1936
2066
  return this.getSequence();
@@ -1940,12 +2070,13 @@ export class OpaquePeerUpdate {
1940
2070
  this._dirtyMask |= 1 << 11;
1941
2071
  }
1942
2072
  marshal(options) {
2073
+ let outBuf;
1943
2074
  if (this._dirtyMask !== 0) {
1944
- this._raw = spliceFields(this._raw, this._dirtyMask, 11, (enc, fnum) => {
2075
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 11, (enc, fnum) => {
1945
2076
  switch (fnum) {
1946
2077
  case 1: {
1947
2078
  const msg = { asn: this._asn };
1948
- enc.writeUint(1, Number(msg.asn ?? 0) >>> 0);
2079
+ enc.writeUint(1, globalThis.Number(msg.asn ?? 0) >>> 0);
1949
2080
  break;
1950
2081
  }
1951
2082
  case 2: {
@@ -1955,7 +2086,7 @@ export class OpaquePeerUpdate {
1955
2086
  }
1956
2087
  case 3: {
1957
2088
  const msg = { active: this._active };
1958
- enc.writeBool(3, Boolean(msg.active));
2089
+ enc.writeBool(3, globalThis.Boolean(msg.active));
1959
2090
  break;
1960
2091
  }
1961
2092
  case 4: {
@@ -1965,7 +2096,7 @@ export class OpaquePeerUpdate {
1965
2096
  }
1966
2097
  case 5: {
1967
2098
  const msg = { rssiDbm: this._rssiDbm };
1968
- enc.writeInt(5, Number(msg.rssiDbm ?? msg.rssi_dbm ?? 0) | 0);
2099
+ enc.writeInt(5, globalThis.Number(msg.rssiDbm ?? msg.rssi_dbm ?? 0) | 0);
1969
2100
  break;
1970
2101
  }
1971
2102
  case 6: {
@@ -2017,19 +2148,35 @@ export class OpaquePeerUpdate {
2017
2148
  }
2018
2149
  }
2019
2150
  });
2020
- this._dirtyMask = 0;
2021
2151
  }
2022
2152
  else {
2023
- validateMessage(this._raw);
2153
+ $ob.validateMessage(this._raw, this._depth);
2154
+ outBuf = this._raw.slice();
2024
2155
  }
2025
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
2026
- const f0 = encodeField0SchemaMeta(PeerUpdateSchema.getSchemaMeta(0), Boolean(options.deterministic));
2027
- const out = new Uint8Array(f0.length + this._raw.length);
2028
- out.set(f0, 0);
2029
- out.set(this._raw, f0.length);
2030
- return out;
2156
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
2157
+ const f0 = $ob.encodeField0SchemaMeta(PeerUpdateSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
2158
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
2159
+ withF0.set(f0, 0);
2160
+ withF0.set(outBuf, f0.length);
2161
+ return withF0;
2162
+ }
2163
+ return outBuf;
2164
+ }
2165
+ marshalValidated(options) {
2166
+ const out = this.marshal(options);
2167
+ $ob.validateMessage(out, this._depth);
2168
+ return out;
2169
+ }
2170
+ tryMarshal(options) {
2171
+ try {
2172
+ return { ok: true, value: this.marshalValidated(options) };
2173
+ }
2174
+ catch (err) {
2175
+ return {
2176
+ ok: false,
2177
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
2178
+ };
2031
2179
  }
2032
- return this._raw;
2033
2180
  }
2034
2181
  }
2035
2182
  //# sourceMappingURL=peer_omnibuf.pb.js.map