@omnibuf/node 0.1.1 → 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,7 +1,7 @@
1
1
  // Code generated by protoc-gen-omnibuf-es. DO NOT EDIT.
2
2
  // source: omnibuf/conformance/conformance.proto
3
3
  /* eslint-disable @typescript-eslint/no-unused-vars */
4
- import { Encoder, MaxNestingDepth, appendStringArrBody, appendUint32ArrBody, countSubMsgArrElems, decodeSchemaMeta as $decodeSchemaMeta, decodeUTF8, decodeVarintAuto, decodeVarintBigInt, decodeZigZag32, decodeZigZagAuto, defineMessage, encodeField0SchemaMeta, float32FromBits, parseArrayHeader, readBool, readBytes, readEnum, readField0SchemaMeta, readFixed32, readFixed64Auto, readFloat32, readFloat64, readFloat64At, readInt32, readIntAuto, readLenSlice, readString, readStringArr, readSubMsgArrDecoded, readSubMsgMerged, readTypedMap, readUint32, readUint32Arr, readUintAuto, roundFloat32Shortest, spliceFields, validateMapTypes, validateMessage, validateValue, writeField0SchemaMeta, } from '@omnibuf/core';
4
+ import * as $ob from '@omnibuf/core';
5
5
  export var WireFormat;
6
6
  (function (WireFormat) {
7
7
  WireFormat[WireFormat["WIRE_FORMAT_UNSPECIFIED"] = 0] = "WIRE_FORMAT_UNSPECIFIED";
@@ -16,7 +16,7 @@ export var TestTier;
16
16
  TestTier[TestTier["TEST_TIER_ANNOTATED_STRUCT"] = 3] = "TEST_TIER_ANNOTATED_STRUCT";
17
17
  TestTier[TestTier["TEST_TIER_BLIND"] = 4] = "TEST_TIER_BLIND";
18
18
  })(TestTier || (TestTier = {}));
19
- export const ConformanceRequestSchema = defineMessage('omnibuf.conformance.ConformanceRequest', {
19
+ export const ConformanceRequestSchema = $ob.defineMessage('omnibuf.conformance.ConformanceRequest', {
20
20
  testName: { fieldNum: 1, name: 'test_name', type: 'string' },
21
21
  messageType: { fieldNum: 2, name: 'message_type', type: 'string' },
22
22
  tier: { fieldNum: 3, type: 'enum' },
@@ -50,7 +50,7 @@ class ConformanceRequestMsg {
50
50
  set requested_output_format(v) {
51
51
  this.requestedOutputFormat = v;
52
52
  }
53
- omnibufPayload = new Uint8Array(0);
53
+ omnibufPayload = new globalThis.Uint8Array(0);
54
54
  get omnibuf_payload() {
55
55
  return this.omnibufPayload;
56
56
  }
@@ -86,7 +86,7 @@ class ConformanceRequestMsg {
86
86
  this.testOpaqueSpliceShrink = v;
87
87
  }
88
88
  }
89
- Object.defineProperty(ConformanceRequestMsg.prototype, '$typeName', {
89
+ globalThis.Object.defineProperty(ConformanceRequestMsg.prototype, '$typeName', {
90
90
  value: 'omnibuf.conformance.ConformanceRequest',
91
91
  enumerable: false,
92
92
  writable: true,
@@ -100,14 +100,14 @@ export function createConformanceRequest(init) {
100
100
  export function encodeConformanceRequest(enc, msg, options) {
101
101
  enc.writeString(1, msg.testName ?? msg.test_name ?? '');
102
102
  enc.writeString(2, msg.messageType ?? msg.message_type ?? '');
103
- enc.writeInt(3, Number(msg.tier ?? 0) | 0);
104
- enc.writeInt(4, Number(msg.requestedOutputFormat ?? msg.requested_output_format ?? 0) | 0);
105
- enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new Uint8Array(0));
103
+ enc.writeInt(3, globalThis.Number(msg.tier ?? 0) | 0);
104
+ enc.writeInt(4, globalThis.Number(msg.requestedOutputFormat ?? msg.requested_output_format ?? 0) | 0);
105
+ enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new globalThis.Uint8Array(0));
106
106
  enc.writeString(6, msg.jsonPayload ?? msg.json_payload ?? '');
107
- enc.writeBool(7, Boolean(msg.selfDescribing ?? msg.self_describing));
108
- enc.writeBool(8, Boolean(msg.testOpaqueSplice ?? msg.test_opaque_splice));
109
- enc.writeBool(9, Boolean(msg.testOpaqueSpliceShrink ?? msg.test_opaque_splice_shrink));
110
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
107
+ enc.writeBool(7, globalThis.Boolean(msg.selfDescribing ?? msg.self_describing));
108
+ enc.writeBool(8, globalThis.Boolean(msg.testOpaqueSplice ?? msg.test_opaque_splice));
109
+ enc.writeBool(9, globalThis.Boolean(msg.testOpaqueSpliceShrink ?? msg.test_opaque_splice_shrink));
110
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
111
111
  for (const uf of msg.$unknown) {
112
112
  enc.writeTag(uf.no, uf.wireType);
113
113
  enc.writeRaw(uf.data);
@@ -115,50 +115,50 @@ export function encodeConformanceRequest(enc, msg, options) {
115
115
  }
116
116
  }
117
117
  export function marshalConformanceRequestOmniBuf(msg, options) {
118
- const enc = new Encoder(256);
118
+ const enc = new $ob.Encoder(256);
119
119
  if (options?.selfDescribing) {
120
- writeField0SchemaMeta(enc, ConformanceRequestSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
120
+ $ob.writeField0SchemaMeta(enc, ConformanceRequestSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
121
121
  }
122
122
  encodeConformanceRequest(enc, msg, options);
123
123
  return enc.finish();
124
124
  }
125
125
  export function decodeConformanceRequest(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
126
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
126
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
127
127
  const readUnknown = options?.readUnknownFields ?? true;
128
128
  if (depth > maxDepth) {
129
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
129
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
130
130
  }
131
131
  const out = target ?? new ConformanceRequestMsg();
132
132
  if (target !== undefined) {
133
133
  if (!(out instanceof ConformanceRequestMsg)) {
134
- Object.setPrototypeOf(out, ConformanceRequestMsg.prototype);
134
+ globalThis.Object.setPrototypeOf(out, ConformanceRequestMsg.prototype);
135
135
  }
136
136
  if (!options?.merge) {
137
- if (Object.hasOwn(out, 'test_name'))
137
+ if (globalThis.Object.hasOwn(out, 'test_name'))
138
138
  delete out.test_name;
139
- if (Object.hasOwn(out, 'message_type'))
139
+ if (globalThis.Object.hasOwn(out, 'message_type'))
140
140
  delete out.message_type;
141
- if (Object.hasOwn(out, 'requested_output_format'))
141
+ if (globalThis.Object.hasOwn(out, 'requested_output_format'))
142
142
  delete out.requested_output_format;
143
- if (Object.hasOwn(out, 'omnibuf_payload'))
143
+ if (globalThis.Object.hasOwn(out, 'omnibuf_payload'))
144
144
  delete out.omnibuf_payload;
145
- if (Object.hasOwn(out, 'json_payload'))
145
+ if (globalThis.Object.hasOwn(out, 'json_payload'))
146
146
  delete out.json_payload;
147
- if (Object.hasOwn(out, 'self_describing'))
147
+ if (globalThis.Object.hasOwn(out, 'self_describing'))
148
148
  delete out.self_describing;
149
- if (Object.hasOwn(out, 'test_opaque_splice'))
149
+ if (globalThis.Object.hasOwn(out, 'test_opaque_splice'))
150
150
  delete out.test_opaque_splice;
151
- if (Object.hasOwn(out, 'test_opaque_splice_shrink'))
151
+ if (globalThis.Object.hasOwn(out, 'test_opaque_splice_shrink'))
152
152
  delete out.test_opaque_splice_shrink;
153
- Object.assign(out, new ConformanceRequestMsg());
154
- if (Object.hasOwn(out, '$unknown'))
153
+ globalThis.Object.assign(out, new ConformanceRequestMsg());
154
+ if (globalThis.Object.hasOwn(out, '$unknown'))
155
155
  delete out.$unknown;
156
156
  }
157
157
  }
158
158
  const n = endPos;
159
159
  let pos = startPos;
160
160
  let seenMask = 0;
161
- let unknownFields = Array.isArray(out.$unknown)
161
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
162
162
  ? out.$unknown
163
163
  : null;
164
164
  while (pos < n) {
@@ -170,34 +170,33 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
170
170
  }
171
171
  else if ((b0 & 2) !== 0) {
172
172
  if (pos + 2 > n)
173
- throw new Error('omnibuf: truncated tag');
173
+ throw new globalThis.Error('omnibuf: truncated tag');
174
174
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
175
175
  pos += 2;
176
176
  }
177
177
  else {
178
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
178
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
179
179
  if (tn === 0 || t64 >> 4n > 536870911n)
180
- throw new Error('omnibuf: invalid tag');
181
- tag = Number(t64);
180
+ throw new globalThis.Error('omnibuf: invalid tag');
181
+ tag = globalThis.Number(t64);
182
182
  pos += tn;
183
183
  }
184
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
184
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
185
185
  const wt = tag & 0x0f;
186
186
  if (fieldNum === 0) {
187
- if (wt !== 12)
188
- throw new Error('omnibuf: invalid Field #0 wire type');
189
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
190
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
187
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
188
+ if (nextPos < 0)
189
+ throw new globalThis.Error('omnibuf: invalid Field #0');
191
190
  pos = nextPos;
192
191
  continue;
193
192
  }
194
193
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
195
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
194
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
196
195
  switch (fieldNum) {
197
196
  case 1: {
198
197
  if (!(wt === 10)) {
199
198
  const valStart = pos;
200
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
199
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
201
200
  if (readUnknown) {
202
201
  if (!unknownFields)
203
202
  unknownFields = [];
@@ -211,19 +210,19 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
211
210
  }
212
211
  seenMask |= bit;
213
212
  if (pos >= n)
214
- throw new Error('omnibuf: truncated string');
213
+ throw new globalThis.Error('omnibuf: truncated string');
215
214
  const sb = buf[pos];
216
215
  if ((sb & 1) !== 0) {
217
216
  const sLen = sb >>> 1;
218
217
  pos += 1;
219
218
  if (pos + sLen > n)
220
- throw new Error('omnibuf: truncated string');
221
- out.testName = decodeUTF8(buf, pos, pos + sLen);
219
+ throw new globalThis.Error('omnibuf: truncated string');
220
+ out.testName = $ob.decodeUTF8(buf, pos, pos + sLen);
222
221
  pos += sLen;
223
222
  }
224
223
  else {
225
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
226
- out.testName = decodeUTF8(s);
224
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
225
+ out.testName = $ob.decodeUTF8(s);
227
226
  pos = nextPos;
228
227
  }
229
228
  break;
@@ -231,7 +230,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
231
230
  case 2: {
232
231
  if (!(wt === 10)) {
233
232
  const valStart = pos;
234
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
233
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
235
234
  if (readUnknown) {
236
235
  if (!unknownFields)
237
236
  unknownFields = [];
@@ -245,19 +244,19 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
245
244
  }
246
245
  seenMask |= bit;
247
246
  if (pos >= n)
248
- throw new Error('omnibuf: truncated string');
247
+ throw new globalThis.Error('omnibuf: truncated string');
249
248
  const sb = buf[pos];
250
249
  if ((sb & 1) !== 0) {
251
250
  const sLen = sb >>> 1;
252
251
  pos += 1;
253
252
  if (pos + sLen > n)
254
- throw new Error('omnibuf: truncated string');
255
- out.messageType = decodeUTF8(buf, pos, pos + sLen);
253
+ throw new globalThis.Error('omnibuf: truncated string');
254
+ out.messageType = $ob.decodeUTF8(buf, pos, pos + sLen);
256
255
  pos += sLen;
257
256
  }
258
257
  else {
259
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
260
- out.messageType = decodeUTF8(s);
258
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
259
+ out.messageType = $ob.decodeUTF8(s);
261
260
  pos = nextPos;
262
261
  }
263
262
  break;
@@ -265,7 +264,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
265
264
  case 3: {
266
265
  if (!(wt === 1)) {
267
266
  const valStart = pos;
268
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
267
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
269
268
  if (readUnknown) {
270
269
  if (!unknownFields)
271
270
  unknownFields = [];
@@ -279,7 +278,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
279
278
  }
280
279
  seenMask |= bit;
281
280
  if (pos >= n)
282
- throw new Error('omnibuf: truncated int32/enum');
281
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
283
282
  const vb = buf[pos];
284
283
  let i32Val = 0;
285
284
  if ((vb & 1) !== 0) {
@@ -289,24 +288,24 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
289
288
  }
290
289
  else if ((vb & 2) !== 0) {
291
290
  if (pos + 2 > n)
292
- throw new Error('omnibuf: truncated int32/enum');
291
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
293
292
  const u = (vb | (buf[pos + 1] << 8)) >>> 2;
294
293
  i32Val = (u >>> 1) ^ -(u & 1);
295
294
  pos += 2;
296
295
  }
297
296
  else if ((vb & 4) !== 0) {
298
297
  if (pos + 4 > n)
299
- throw new Error('omnibuf: truncated int32/enum');
298
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
300
299
  const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
301
300
  0;
302
301
  i32Val = (u >>> 1) ^ -(u & 1);
303
302
  pos += 4;
304
303
  }
305
304
  else {
306
- const [v, vn] = decodeVarintBigInt(buf, pos, n);
305
+ const [v, vn] = $ob.decodeVarintBigInt(buf, pos, n);
307
306
  if (vn === 0)
308
- throw new Error('omnibuf: truncated int32/enum');
309
- i32Val = decodeZigZag32(v);
307
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
308
+ i32Val = $ob.decodeZigZag32(v);
310
309
  pos += vn;
311
310
  }
312
311
  out.tier = i32Val;
@@ -315,7 +314,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
315
314
  case 4: {
316
315
  if (!(wt === 1)) {
317
316
  const valStart = pos;
318
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
317
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
319
318
  if (readUnknown) {
320
319
  if (!unknownFields)
321
320
  unknownFields = [];
@@ -329,7 +328,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
329
328
  }
330
329
  seenMask |= bit;
331
330
  if (pos >= n)
332
- throw new Error('omnibuf: truncated int32/enum');
331
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
333
332
  const vb = buf[pos];
334
333
  let i32Val = 0;
335
334
  if ((vb & 1) !== 0) {
@@ -339,24 +338,24 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
339
338
  }
340
339
  else if ((vb & 2) !== 0) {
341
340
  if (pos + 2 > n)
342
- throw new Error('omnibuf: truncated int32/enum');
341
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
343
342
  const u = (vb | (buf[pos + 1] << 8)) >>> 2;
344
343
  i32Val = (u >>> 1) ^ -(u & 1);
345
344
  pos += 2;
346
345
  }
347
346
  else if ((vb & 4) !== 0) {
348
347
  if (pos + 4 > n)
349
- throw new Error('omnibuf: truncated int32/enum');
348
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
350
349
  const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
351
350
  0;
352
351
  i32Val = (u >>> 1) ^ -(u & 1);
353
352
  pos += 4;
354
353
  }
355
354
  else {
356
- const [v, vn] = decodeVarintBigInt(buf, pos, n);
355
+ const [v, vn] = $ob.decodeVarintBigInt(buf, pos, n);
357
356
  if (vn === 0)
358
- throw new Error('omnibuf: truncated int32/enum');
359
- i32Val = decodeZigZag32(v);
357
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
358
+ i32Val = $ob.decodeZigZag32(v);
360
359
  pos += vn;
361
360
  }
362
361
  out.requestedOutputFormat = i32Val;
@@ -365,7 +364,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
365
364
  case 5: {
366
365
  if (!(wt === 11)) {
367
366
  const valStart = pos;
368
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
367
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
369
368
  if (readUnknown) {
370
369
  if (!unknownFields)
371
370
  unknownFields = [];
@@ -378,15 +377,15 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
378
377
  break;
379
378
  }
380
379
  seenMask |= bit;
381
- const [b, nextPos] = readLenSlice(buf, pos, 0, n);
382
- out.omnibufPayload = b.slice();
380
+ const [b, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
381
+ out.omnibufPayload = options?.zeroCopy ? b : b.slice();
383
382
  pos = nextPos;
384
383
  break;
385
384
  }
386
385
  case 6: {
387
386
  if (!(wt === 10)) {
388
387
  const valStart = pos;
389
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
388
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
390
389
  if (readUnknown) {
391
390
  if (!unknownFields)
392
391
  unknownFields = [];
@@ -400,19 +399,19 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
400
399
  }
401
400
  seenMask |= bit;
402
401
  if (pos >= n)
403
- throw new Error('omnibuf: truncated string');
402
+ throw new globalThis.Error('omnibuf: truncated string');
404
403
  const sb = buf[pos];
405
404
  if ((sb & 1) !== 0) {
406
405
  const sLen = sb >>> 1;
407
406
  pos += 1;
408
407
  if (pos + sLen > n)
409
- throw new Error('omnibuf: truncated string');
410
- out.jsonPayload = decodeUTF8(buf, pos, pos + sLen);
408
+ throw new globalThis.Error('omnibuf: truncated string');
409
+ out.jsonPayload = $ob.decodeUTF8(buf, pos, pos + sLen);
411
410
  pos += sLen;
412
411
  }
413
412
  else {
414
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
415
- out.jsonPayload = decodeUTF8(s);
413
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
414
+ out.jsonPayload = $ob.decodeUTF8(s);
416
415
  pos = nextPos;
417
416
  }
418
417
  break;
@@ -420,7 +419,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
420
419
  case 7: {
421
420
  if (!(wt === 2 || wt === 3)) {
422
421
  const valStart = pos;
423
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
422
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
424
423
  if (readUnknown) {
425
424
  if (!unknownFields)
426
425
  unknownFields = [];
@@ -439,7 +438,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
439
438
  case 8: {
440
439
  if (!(wt === 2 || wt === 3)) {
441
440
  const valStart = pos;
442
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
441
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
443
442
  if (readUnknown) {
444
443
  if (!unknownFields)
445
444
  unknownFields = [];
@@ -458,7 +457,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
458
457
  case 9: {
459
458
  if (!(wt === 2 || wt === 3)) {
460
459
  const valStart = pos;
461
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
460
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
462
461
  if (readUnknown) {
463
462
  if (!unknownFields)
464
463
  unknownFields = [];
@@ -476,7 +475,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
476
475
  }
477
476
  default: {
478
477
  const valStart = pos;
479
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
478
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
480
479
  if (readUnknown) {
481
480
  if (!unknownFields)
482
481
  unknownFields = [];
@@ -491,7 +490,7 @@ export function decodeConformanceRequest(buf, target, depth = 0, options, startP
491
490
  }
492
491
  }
493
492
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
494
- Object.defineProperty(out, '$unknown', {
493
+ globalThis.Object.defineProperty(out, '$unknown', {
495
494
  value: unknownFields,
496
495
  enumerable: false,
497
496
  writable: true,
@@ -508,8 +507,12 @@ ConformanceRequestSchema.setGeneratedCodec({
508
507
  encode: encodeConformanceRequest,
509
508
  decode: decodeConformanceRequest,
510
509
  });
510
+ $ob.registerClassSchema(ConformanceRequestMsg, ConformanceRequestSchema);
511
511
  export class OpaqueConformanceRequest {
512
512
  _raw;
513
+ _depth;
514
+ _readCount = 0;
515
+ _fieldIndex = null;
513
516
  _dirtyMask = 0;
514
517
  _testName;
515
518
  _messageType;
@@ -520,8 +523,19 @@ export class OpaqueConformanceRequest {
520
523
  _selfDescribing;
521
524
  _testOpaqueSplice;
522
525
  _testOpaqueSpliceShrink;
523
- constructor(raw) {
526
+ constructor(raw, depth = 0) {
524
527
  this._raw = raw;
528
+ this._depth = depth;
529
+ }
530
+ _sliceField(fieldNum) {
531
+ if (this._fieldIndex === null) {
532
+ if (this._readCount < 2) {
533
+ this._readCount++;
534
+ return this._raw;
535
+ }
536
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
537
+ }
538
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
525
539
  }
526
540
  raw() {
527
541
  return this._raw;
@@ -530,7 +544,8 @@ export class OpaqueConformanceRequest {
530
544
  if ((this._dirtyMask & (1 << 1)) !== 0) {
531
545
  return this._testName;
532
546
  }
533
- return readString(this._raw, 1)[0];
547
+ const __src = this._sliceField(1);
548
+ return __src ? $ob.readString(__src, 1)[0] : '';
534
549
  }
535
550
  testName() {
536
551
  return this.getTestName();
@@ -546,7 +561,8 @@ export class OpaqueConformanceRequest {
546
561
  if ((this._dirtyMask & (1 << 2)) !== 0) {
547
562
  return this._messageType;
548
563
  }
549
- return readString(this._raw, 2)[0];
564
+ const __src = this._sliceField(2);
565
+ return __src ? $ob.readString(__src, 2)[0] : '';
550
566
  }
551
567
  messageType() {
552
568
  return this.getMessageType();
@@ -562,7 +578,8 @@ export class OpaqueConformanceRequest {
562
578
  if ((this._dirtyMask & (1 << 3)) !== 0) {
563
579
  return this._tier;
564
580
  }
565
- return readEnum(this._raw, 3)[0];
581
+ const __src = this._sliceField(3);
582
+ return (__src ? $ob.readEnum(__src, 3)[0] : 0);
566
583
  }
567
584
  tier() {
568
585
  return this.getTier();
@@ -575,7 +592,8 @@ export class OpaqueConformanceRequest {
575
592
  if ((this._dirtyMask & (1 << 4)) !== 0) {
576
593
  return this._requestedOutputFormat;
577
594
  }
578
- return readEnum(this._raw, 4)[0];
595
+ const __src = this._sliceField(4);
596
+ return (__src ? $ob.readEnum(__src, 4)[0] : 0);
579
597
  }
580
598
  requestedOutputFormat() {
581
599
  return this.getRequestedOutputFormat();
@@ -591,7 +609,15 @@ export class OpaqueConformanceRequest {
591
609
  if ((this._dirtyMask & (1 << 5)) !== 0) {
592
610
  return this._omnibufPayload;
593
611
  }
594
- return readBytes(this._raw, 5)[0];
612
+ const __src = this._sliceField(5);
613
+ return __src ? $ob.readBytes(__src, 5)[0] : new globalThis.Uint8Array(0);
614
+ }
615
+ getOmnibufPayloadView() {
616
+ if ((this._dirtyMask & (1 << 5)) !== 0) {
617
+ return this._omnibufPayload;
618
+ }
619
+ const __src = this._sliceField(5);
620
+ return __src ? $ob.readBytesView(__src, 5)[0] : new globalThis.Uint8Array(0);
595
621
  }
596
622
  omnibufPayload() {
597
623
  return this.getOmnibufPayload();
@@ -607,7 +633,8 @@ export class OpaqueConformanceRequest {
607
633
  if ((this._dirtyMask & (1 << 6)) !== 0) {
608
634
  return this._jsonPayload;
609
635
  }
610
- return readString(this._raw, 6)[0];
636
+ const __src = this._sliceField(6);
637
+ return __src ? $ob.readString(__src, 6)[0] : '';
611
638
  }
612
639
  jsonPayload() {
613
640
  return this.getJsonPayload();
@@ -623,7 +650,8 @@ export class OpaqueConformanceRequest {
623
650
  if ((this._dirtyMask & (1 << 7)) !== 0) {
624
651
  return this._selfDescribing;
625
652
  }
626
- return readBool(this._raw, 7)[0];
653
+ const __src = this._sliceField(7);
654
+ return __src ? $ob.readBool(__src, 7)[0] : false;
627
655
  }
628
656
  selfDescribing() {
629
657
  return this.getSelfDescribing();
@@ -639,7 +667,8 @@ export class OpaqueConformanceRequest {
639
667
  if ((this._dirtyMask & (1 << 8)) !== 0) {
640
668
  return this._testOpaqueSplice;
641
669
  }
642
- return readBool(this._raw, 8)[0];
670
+ const __src = this._sliceField(8);
671
+ return __src ? $ob.readBool(__src, 8)[0] : false;
643
672
  }
644
673
  testOpaqueSplice() {
645
674
  return this.getTestOpaqueSplice();
@@ -655,7 +684,8 @@ export class OpaqueConformanceRequest {
655
684
  if ((this._dirtyMask & (1 << 9)) !== 0) {
656
685
  return this._testOpaqueSpliceShrink;
657
686
  }
658
- return readBool(this._raw, 9)[0];
687
+ const __src = this._sliceField(9);
688
+ return __src ? $ob.readBool(__src, 9)[0] : false;
659
689
  }
660
690
  testOpaqueSpliceShrink() {
661
691
  return this.getTestOpaqueSpliceShrink();
@@ -668,8 +698,9 @@ export class OpaqueConformanceRequest {
668
698
  this._dirtyMask |= 1 << 9;
669
699
  }
670
700
  marshal(options) {
701
+ let outBuf;
671
702
  if (this._dirtyMask !== 0) {
672
- this._raw = spliceFields(this._raw, this._dirtyMask, 9, (enc, fnum) => {
703
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 9, (enc, fnum) => {
673
704
  switch (fnum) {
674
705
  case 1: {
675
706
  const msg = { testName: this._testName };
@@ -683,19 +714,19 @@ export class OpaqueConformanceRequest {
683
714
  }
684
715
  case 3: {
685
716
  const msg = { tier: this._tier };
686
- enc.writeInt(3, Number(msg.tier ?? 0) | 0);
717
+ enc.writeInt(3, globalThis.Number(msg.tier ?? 0) | 0);
687
718
  break;
688
719
  }
689
720
  case 4: {
690
721
  const msg = {
691
722
  requestedOutputFormat: this._requestedOutputFormat,
692
723
  };
693
- enc.writeInt(4, Number(msg.requestedOutputFormat ?? msg.requested_output_format ?? 0) | 0);
724
+ enc.writeInt(4, globalThis.Number(msg.requestedOutputFormat ?? msg.requested_output_format ?? 0) | 0);
694
725
  break;
695
726
  }
696
727
  case 5: {
697
728
  const msg = { omnibufPayload: this._omnibufPayload };
698
- enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new Uint8Array(0));
729
+ enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new globalThis.Uint8Array(0));
699
730
  break;
700
731
  }
701
732
  case 6: {
@@ -705,41 +736,57 @@ export class OpaqueConformanceRequest {
705
736
  }
706
737
  case 7: {
707
738
  const msg = { selfDescribing: this._selfDescribing };
708
- enc.writeBool(7, Boolean(msg.selfDescribing ?? msg.self_describing));
739
+ enc.writeBool(7, globalThis.Boolean(msg.selfDescribing ?? msg.self_describing));
709
740
  break;
710
741
  }
711
742
  case 8: {
712
743
  const msg = {
713
744
  testOpaqueSplice: this._testOpaqueSplice,
714
745
  };
715
- enc.writeBool(8, Boolean(msg.testOpaqueSplice ?? msg.test_opaque_splice));
746
+ enc.writeBool(8, globalThis.Boolean(msg.testOpaqueSplice ?? msg.test_opaque_splice));
716
747
  break;
717
748
  }
718
749
  case 9: {
719
750
  const msg = {
720
751
  testOpaqueSpliceShrink: this._testOpaqueSpliceShrink,
721
752
  };
722
- enc.writeBool(9, Boolean(msg.testOpaqueSpliceShrink ?? msg.test_opaque_splice_shrink));
753
+ enc.writeBool(9, globalThis.Boolean(msg.testOpaqueSpliceShrink ?? msg.test_opaque_splice_shrink));
723
754
  break;
724
755
  }
725
756
  }
726
757
  });
727
- this._dirtyMask = 0;
728
758
  }
729
759
  else {
730
- validateMessage(this._raw);
760
+ $ob.validateMessage(this._raw, this._depth);
761
+ outBuf = this._raw.slice();
731
762
  }
732
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
733
- const f0 = encodeField0SchemaMeta(ConformanceRequestSchema.getSchemaMeta(0), Boolean(options.deterministic));
734
- const out = new Uint8Array(f0.length + this._raw.length);
735
- out.set(f0, 0);
736
- out.set(this._raw, f0.length);
737
- return out;
763
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
764
+ const f0 = $ob.encodeField0SchemaMeta(ConformanceRequestSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
765
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
766
+ withF0.set(f0, 0);
767
+ withF0.set(outBuf, f0.length);
768
+ return withF0;
769
+ }
770
+ return outBuf;
771
+ }
772
+ marshalValidated(options) {
773
+ const out = this.marshal(options);
774
+ $ob.validateMessage(out, this._depth);
775
+ return out;
776
+ }
777
+ tryMarshal(options) {
778
+ try {
779
+ return { ok: true, value: this.marshalValidated(options) };
780
+ }
781
+ catch (err) {
782
+ return {
783
+ ok: false,
784
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
785
+ };
738
786
  }
739
- return this._raw;
740
787
  }
741
788
  }
742
- export const ConformanceResponseSchema = defineMessage('omnibuf.conformance.ConformanceResponse', {
789
+ export const ConformanceResponseSchema = $ob.defineMessage('omnibuf.conformance.ConformanceResponse', {
743
790
  parseError: { fieldNum: 1, name: 'parse_error', type: 'string' },
744
791
  serializeError: { fieldNum: 2, name: 'serialize_error', type: 'string' },
745
792
  runtimeError: { fieldNum: 3, name: 'runtime_error', type: 'string' },
@@ -770,7 +817,7 @@ class ConformanceResponseMsg {
770
817
  this.runtimeError = v;
771
818
  }
772
819
  skipped = '';
773
- omnibufPayload = new Uint8Array(0);
820
+ omnibufPayload = new globalThis.Uint8Array(0);
774
821
  get omnibuf_payload() {
775
822
  return this.omnibufPayload;
776
823
  }
@@ -785,7 +832,7 @@ class ConformanceResponseMsg {
785
832
  this.jsonPayload = v;
786
833
  }
787
834
  }
788
- Object.defineProperty(ConformanceResponseMsg.prototype, '$typeName', {
835
+ globalThis.Object.defineProperty(ConformanceResponseMsg.prototype, '$typeName', {
789
836
  value: 'omnibuf.conformance.ConformanceResponse',
790
837
  enumerable: false,
791
838
  writable: true,
@@ -801,9 +848,9 @@ export function encodeConformanceResponse(enc, msg, options) {
801
848
  enc.writeString(2, msg.serializeError ?? msg.serialize_error ?? '');
802
849
  enc.writeString(3, msg.runtimeError ?? msg.runtime_error ?? '');
803
850
  enc.writeString(4, msg.skipped ?? '');
804
- enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new Uint8Array(0));
851
+ enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new globalThis.Uint8Array(0));
805
852
  enc.writeString(6, msg.jsonPayload ?? msg.json_payload ?? '');
806
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
853
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
807
854
  for (const uf of msg.$unknown) {
808
855
  enc.writeTag(uf.no, uf.wireType);
809
856
  enc.writeRaw(uf.data);
@@ -811,44 +858,44 @@ export function encodeConformanceResponse(enc, msg, options) {
811
858
  }
812
859
  }
813
860
  export function marshalConformanceResponseOmniBuf(msg, options) {
814
- const enc = new Encoder(256);
861
+ const enc = new $ob.Encoder(256);
815
862
  if (options?.selfDescribing) {
816
- writeField0SchemaMeta(enc, ConformanceResponseSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
863
+ $ob.writeField0SchemaMeta(enc, ConformanceResponseSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
817
864
  }
818
865
  encodeConformanceResponse(enc, msg, options);
819
866
  return enc.finish();
820
867
  }
821
868
  export function decodeConformanceResponse(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
822
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
869
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
823
870
  const readUnknown = options?.readUnknownFields ?? true;
824
871
  if (depth > maxDepth) {
825
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
872
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
826
873
  }
827
874
  const out = target ?? new ConformanceResponseMsg();
828
875
  if (target !== undefined) {
829
876
  if (!(out instanceof ConformanceResponseMsg)) {
830
- Object.setPrototypeOf(out, ConformanceResponseMsg.prototype);
877
+ globalThis.Object.setPrototypeOf(out, ConformanceResponseMsg.prototype);
831
878
  }
832
879
  if (!options?.merge) {
833
- if (Object.hasOwn(out, 'parse_error'))
880
+ if (globalThis.Object.hasOwn(out, 'parse_error'))
834
881
  delete out.parse_error;
835
- if (Object.hasOwn(out, 'serialize_error'))
882
+ if (globalThis.Object.hasOwn(out, 'serialize_error'))
836
883
  delete out.serialize_error;
837
- if (Object.hasOwn(out, 'runtime_error'))
884
+ if (globalThis.Object.hasOwn(out, 'runtime_error'))
838
885
  delete out.runtime_error;
839
- if (Object.hasOwn(out, 'omnibuf_payload'))
886
+ if (globalThis.Object.hasOwn(out, 'omnibuf_payload'))
840
887
  delete out.omnibuf_payload;
841
- if (Object.hasOwn(out, 'json_payload'))
888
+ if (globalThis.Object.hasOwn(out, 'json_payload'))
842
889
  delete out.json_payload;
843
- Object.assign(out, new ConformanceResponseMsg());
844
- if (Object.hasOwn(out, '$unknown'))
890
+ globalThis.Object.assign(out, new ConformanceResponseMsg());
891
+ if (globalThis.Object.hasOwn(out, '$unknown'))
845
892
  delete out.$unknown;
846
893
  }
847
894
  }
848
895
  const n = endPos;
849
896
  let pos = startPos;
850
897
  let seenMask = 0;
851
- let unknownFields = Array.isArray(out.$unknown)
898
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
852
899
  ? out.$unknown
853
900
  : null;
854
901
  while (pos < n) {
@@ -860,34 +907,33 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
860
907
  }
861
908
  else if ((b0 & 2) !== 0) {
862
909
  if (pos + 2 > n)
863
- throw new Error('omnibuf: truncated tag');
910
+ throw new globalThis.Error('omnibuf: truncated tag');
864
911
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
865
912
  pos += 2;
866
913
  }
867
914
  else {
868
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
915
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
869
916
  if (tn === 0 || t64 >> 4n > 536870911n)
870
- throw new Error('omnibuf: invalid tag');
871
- tag = Number(t64);
917
+ throw new globalThis.Error('omnibuf: invalid tag');
918
+ tag = globalThis.Number(t64);
872
919
  pos += tn;
873
920
  }
874
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
921
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
875
922
  const wt = tag & 0x0f;
876
923
  if (fieldNum === 0) {
877
- if (wt !== 12)
878
- throw new Error('omnibuf: invalid Field #0 wire type');
879
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
880
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
924
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
925
+ if (nextPos < 0)
926
+ throw new globalThis.Error('omnibuf: invalid Field #0');
881
927
  pos = nextPos;
882
928
  continue;
883
929
  }
884
930
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
885
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
931
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
886
932
  switch (fieldNum) {
887
933
  case 1: {
888
934
  if (!(wt === 10)) {
889
935
  const valStart = pos;
890
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
936
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
891
937
  if (readUnknown) {
892
938
  if (!unknownFields)
893
939
  unknownFields = [];
@@ -901,19 +947,19 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
901
947
  }
902
948
  seenMask |= bit;
903
949
  if (pos >= n)
904
- throw new Error('omnibuf: truncated string');
950
+ throw new globalThis.Error('omnibuf: truncated string');
905
951
  const sb = buf[pos];
906
952
  if ((sb & 1) !== 0) {
907
953
  const sLen = sb >>> 1;
908
954
  pos += 1;
909
955
  if (pos + sLen > n)
910
- throw new Error('omnibuf: truncated string');
911
- out.parseError = decodeUTF8(buf, pos, pos + sLen);
956
+ throw new globalThis.Error('omnibuf: truncated string');
957
+ out.parseError = $ob.decodeUTF8(buf, pos, pos + sLen);
912
958
  pos += sLen;
913
959
  }
914
960
  else {
915
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
916
- out.parseError = decodeUTF8(s);
961
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
962
+ out.parseError = $ob.decodeUTF8(s);
917
963
  pos = nextPos;
918
964
  }
919
965
  break;
@@ -921,7 +967,7 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
921
967
  case 2: {
922
968
  if (!(wt === 10)) {
923
969
  const valStart = pos;
924
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
970
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
925
971
  if (readUnknown) {
926
972
  if (!unknownFields)
927
973
  unknownFields = [];
@@ -935,19 +981,19 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
935
981
  }
936
982
  seenMask |= bit;
937
983
  if (pos >= n)
938
- throw new Error('omnibuf: truncated string');
984
+ throw new globalThis.Error('omnibuf: truncated string');
939
985
  const sb = buf[pos];
940
986
  if ((sb & 1) !== 0) {
941
987
  const sLen = sb >>> 1;
942
988
  pos += 1;
943
989
  if (pos + sLen > n)
944
- throw new Error('omnibuf: truncated string');
945
- out.serializeError = decodeUTF8(buf, pos, pos + sLen);
990
+ throw new globalThis.Error('omnibuf: truncated string');
991
+ out.serializeError = $ob.decodeUTF8(buf, pos, pos + sLen);
946
992
  pos += sLen;
947
993
  }
948
994
  else {
949
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
950
- out.serializeError = decodeUTF8(s);
995
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
996
+ out.serializeError = $ob.decodeUTF8(s);
951
997
  pos = nextPos;
952
998
  }
953
999
  break;
@@ -955,7 +1001,7 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
955
1001
  case 3: {
956
1002
  if (!(wt === 10)) {
957
1003
  const valStart = pos;
958
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1004
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
959
1005
  if (readUnknown) {
960
1006
  if (!unknownFields)
961
1007
  unknownFields = [];
@@ -969,19 +1015,19 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
969
1015
  }
970
1016
  seenMask |= bit;
971
1017
  if (pos >= n)
972
- throw new Error('omnibuf: truncated string');
1018
+ throw new globalThis.Error('omnibuf: truncated string');
973
1019
  const sb = buf[pos];
974
1020
  if ((sb & 1) !== 0) {
975
1021
  const sLen = sb >>> 1;
976
1022
  pos += 1;
977
1023
  if (pos + sLen > n)
978
- throw new Error('omnibuf: truncated string');
979
- out.runtimeError = decodeUTF8(buf, pos, pos + sLen);
1024
+ throw new globalThis.Error('omnibuf: truncated string');
1025
+ out.runtimeError = $ob.decodeUTF8(buf, pos, pos + sLen);
980
1026
  pos += sLen;
981
1027
  }
982
1028
  else {
983
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
984
- out.runtimeError = decodeUTF8(s);
1029
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1030
+ out.runtimeError = $ob.decodeUTF8(s);
985
1031
  pos = nextPos;
986
1032
  }
987
1033
  break;
@@ -989,7 +1035,7 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
989
1035
  case 4: {
990
1036
  if (!(wt === 10)) {
991
1037
  const valStart = pos;
992
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1038
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
993
1039
  if (readUnknown) {
994
1040
  if (!unknownFields)
995
1041
  unknownFields = [];
@@ -1003,19 +1049,19 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
1003
1049
  }
1004
1050
  seenMask |= bit;
1005
1051
  if (pos >= n)
1006
- throw new Error('omnibuf: truncated string');
1052
+ throw new globalThis.Error('omnibuf: truncated string');
1007
1053
  const sb = buf[pos];
1008
1054
  if ((sb & 1) !== 0) {
1009
1055
  const sLen = sb >>> 1;
1010
1056
  pos += 1;
1011
1057
  if (pos + sLen > n)
1012
- throw new Error('omnibuf: truncated string');
1013
- out.skipped = decodeUTF8(buf, pos, pos + sLen);
1058
+ throw new globalThis.Error('omnibuf: truncated string');
1059
+ out.skipped = $ob.decodeUTF8(buf, pos, pos + sLen);
1014
1060
  pos += sLen;
1015
1061
  }
1016
1062
  else {
1017
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
1018
- out.skipped = decodeUTF8(s);
1063
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1064
+ out.skipped = $ob.decodeUTF8(s);
1019
1065
  pos = nextPos;
1020
1066
  }
1021
1067
  break;
@@ -1023,7 +1069,7 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
1023
1069
  case 5: {
1024
1070
  if (!(wt === 11)) {
1025
1071
  const valStart = pos;
1026
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1072
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1027
1073
  if (readUnknown) {
1028
1074
  if (!unknownFields)
1029
1075
  unknownFields = [];
@@ -1036,15 +1082,15 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
1036
1082
  break;
1037
1083
  }
1038
1084
  seenMask |= bit;
1039
- const [b, nextPos] = readLenSlice(buf, pos, 0, n);
1040
- out.omnibufPayload = b.slice();
1085
+ const [b, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1086
+ out.omnibufPayload = options?.zeroCopy ? b : b.slice();
1041
1087
  pos = nextPos;
1042
1088
  break;
1043
1089
  }
1044
1090
  case 6: {
1045
1091
  if (!(wt === 10)) {
1046
1092
  const valStart = pos;
1047
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1093
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1048
1094
  if (readUnknown) {
1049
1095
  if (!unknownFields)
1050
1096
  unknownFields = [];
@@ -1058,26 +1104,26 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
1058
1104
  }
1059
1105
  seenMask |= bit;
1060
1106
  if (pos >= n)
1061
- throw new Error('omnibuf: truncated string');
1107
+ throw new globalThis.Error('omnibuf: truncated string');
1062
1108
  const sb = buf[pos];
1063
1109
  if ((sb & 1) !== 0) {
1064
1110
  const sLen = sb >>> 1;
1065
1111
  pos += 1;
1066
1112
  if (pos + sLen > n)
1067
- throw new Error('omnibuf: truncated string');
1068
- out.jsonPayload = decodeUTF8(buf, pos, pos + sLen);
1113
+ throw new globalThis.Error('omnibuf: truncated string');
1114
+ out.jsonPayload = $ob.decodeUTF8(buf, pos, pos + sLen);
1069
1115
  pos += sLen;
1070
1116
  }
1071
1117
  else {
1072
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
1073
- out.jsonPayload = decodeUTF8(s);
1118
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1119
+ out.jsonPayload = $ob.decodeUTF8(s);
1074
1120
  pos = nextPos;
1075
1121
  }
1076
1122
  break;
1077
1123
  }
1078
1124
  default: {
1079
1125
  const valStart = pos;
1080
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1126
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1081
1127
  if (readUnknown) {
1082
1128
  if (!unknownFields)
1083
1129
  unknownFields = [];
@@ -1092,7 +1138,7 @@ export function decodeConformanceResponse(buf, target, depth = 0, options, start
1092
1138
  }
1093
1139
  }
1094
1140
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
1095
- Object.defineProperty(out, '$unknown', {
1141
+ globalThis.Object.defineProperty(out, '$unknown', {
1096
1142
  value: unknownFields,
1097
1143
  enumerable: false,
1098
1144
  writable: true,
@@ -1109,8 +1155,12 @@ ConformanceResponseSchema.setGeneratedCodec({
1109
1155
  encode: encodeConformanceResponse,
1110
1156
  decode: decodeConformanceResponse,
1111
1157
  });
1158
+ $ob.registerClassSchema(ConformanceResponseMsg, ConformanceResponseSchema);
1112
1159
  export class OpaqueConformanceResponse {
1113
1160
  _raw;
1161
+ _depth;
1162
+ _readCount = 0;
1163
+ _fieldIndex = null;
1114
1164
  _dirtyMask = 0;
1115
1165
  _parseError;
1116
1166
  _serializeError;
@@ -1118,8 +1168,19 @@ export class OpaqueConformanceResponse {
1118
1168
  _skipped;
1119
1169
  _omnibufPayload;
1120
1170
  _jsonPayload;
1121
- constructor(raw) {
1171
+ constructor(raw, depth = 0) {
1122
1172
  this._raw = raw;
1173
+ this._depth = depth;
1174
+ }
1175
+ _sliceField(fieldNum) {
1176
+ if (this._fieldIndex === null) {
1177
+ if (this._readCount < 2) {
1178
+ this._readCount++;
1179
+ return this._raw;
1180
+ }
1181
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
1182
+ }
1183
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
1123
1184
  }
1124
1185
  raw() {
1125
1186
  return this._raw;
@@ -1128,7 +1189,8 @@ export class OpaqueConformanceResponse {
1128
1189
  if ((this._dirtyMask & (1 << 1)) !== 0) {
1129
1190
  return this._parseError;
1130
1191
  }
1131
- return readString(this._raw, 1)[0];
1192
+ const __src = this._sliceField(1);
1193
+ return __src ? $ob.readString(__src, 1)[0] : '';
1132
1194
  }
1133
1195
  parseError() {
1134
1196
  return this.getParseError();
@@ -1144,7 +1206,8 @@ export class OpaqueConformanceResponse {
1144
1206
  if ((this._dirtyMask & (1 << 2)) !== 0) {
1145
1207
  return this._serializeError;
1146
1208
  }
1147
- return readString(this._raw, 2)[0];
1209
+ const __src = this._sliceField(2);
1210
+ return __src ? $ob.readString(__src, 2)[0] : '';
1148
1211
  }
1149
1212
  serializeError() {
1150
1213
  return this.getSerializeError();
@@ -1160,7 +1223,8 @@ export class OpaqueConformanceResponse {
1160
1223
  if ((this._dirtyMask & (1 << 3)) !== 0) {
1161
1224
  return this._runtimeError;
1162
1225
  }
1163
- return readString(this._raw, 3)[0];
1226
+ const __src = this._sliceField(3);
1227
+ return __src ? $ob.readString(__src, 3)[0] : '';
1164
1228
  }
1165
1229
  runtimeError() {
1166
1230
  return this.getRuntimeError();
@@ -1176,7 +1240,8 @@ export class OpaqueConformanceResponse {
1176
1240
  if ((this._dirtyMask & (1 << 4)) !== 0) {
1177
1241
  return this._skipped;
1178
1242
  }
1179
- return readString(this._raw, 4)[0];
1243
+ const __src = this._sliceField(4);
1244
+ return __src ? $ob.readString(__src, 4)[0] : '';
1180
1245
  }
1181
1246
  skipped() {
1182
1247
  return this.getSkipped();
@@ -1189,7 +1254,15 @@ export class OpaqueConformanceResponse {
1189
1254
  if ((this._dirtyMask & (1 << 5)) !== 0) {
1190
1255
  return this._omnibufPayload;
1191
1256
  }
1192
- return readBytes(this._raw, 5)[0];
1257
+ const __src = this._sliceField(5);
1258
+ return __src ? $ob.readBytes(__src, 5)[0] : new globalThis.Uint8Array(0);
1259
+ }
1260
+ getOmnibufPayloadView() {
1261
+ if ((this._dirtyMask & (1 << 5)) !== 0) {
1262
+ return this._omnibufPayload;
1263
+ }
1264
+ const __src = this._sliceField(5);
1265
+ return __src ? $ob.readBytesView(__src, 5)[0] : new globalThis.Uint8Array(0);
1193
1266
  }
1194
1267
  omnibufPayload() {
1195
1268
  return this.getOmnibufPayload();
@@ -1205,7 +1278,8 @@ export class OpaqueConformanceResponse {
1205
1278
  if ((this._dirtyMask & (1 << 6)) !== 0) {
1206
1279
  return this._jsonPayload;
1207
1280
  }
1208
- return readString(this._raw, 6)[0];
1281
+ const __src = this._sliceField(6);
1282
+ return __src ? $ob.readString(__src, 6)[0] : '';
1209
1283
  }
1210
1284
  jsonPayload() {
1211
1285
  return this.getJsonPayload();
@@ -1218,8 +1292,9 @@ export class OpaqueConformanceResponse {
1218
1292
  this._dirtyMask |= 1 << 6;
1219
1293
  }
1220
1294
  marshal(options) {
1295
+ let outBuf;
1221
1296
  if (this._dirtyMask !== 0) {
1222
- this._raw = spliceFields(this._raw, this._dirtyMask, 6, (enc, fnum) => {
1297
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 6, (enc, fnum) => {
1223
1298
  switch (fnum) {
1224
1299
  case 1: {
1225
1300
  const msg = { parseError: this._parseError };
@@ -1243,7 +1318,7 @@ export class OpaqueConformanceResponse {
1243
1318
  }
1244
1319
  case 5: {
1245
1320
  const msg = { omnibufPayload: this._omnibufPayload };
1246
- enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new Uint8Array(0));
1321
+ enc.writeBytes(5, msg.omnibufPayload ?? msg.omnibuf_payload ?? new globalThis.Uint8Array(0));
1247
1322
  break;
1248
1323
  }
1249
1324
  case 6: {
@@ -1253,22 +1328,38 @@ export class OpaqueConformanceResponse {
1253
1328
  }
1254
1329
  }
1255
1330
  });
1256
- this._dirtyMask = 0;
1257
1331
  }
1258
1332
  else {
1259
- validateMessage(this._raw);
1333
+ $ob.validateMessage(this._raw, this._depth);
1334
+ outBuf = this._raw.slice();
1260
1335
  }
1261
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
1262
- const f0 = encodeField0SchemaMeta(ConformanceResponseSchema.getSchemaMeta(0), Boolean(options.deterministic));
1263
- const out = new Uint8Array(f0.length + this._raw.length);
1264
- out.set(f0, 0);
1265
- out.set(this._raw, f0.length);
1266
- return out;
1336
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
1337
+ const f0 = $ob.encodeField0SchemaMeta(ConformanceResponseSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
1338
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
1339
+ withF0.set(f0, 0);
1340
+ withF0.set(outBuf, f0.length);
1341
+ return withF0;
1342
+ }
1343
+ return outBuf;
1344
+ }
1345
+ marshalValidated(options) {
1346
+ const out = this.marshal(options);
1347
+ $ob.validateMessage(out, this._depth);
1348
+ return out;
1349
+ }
1350
+ tryMarshal(options) {
1351
+ try {
1352
+ return { ok: true, value: this.marshalValidated(options) };
1353
+ }
1354
+ catch (err) {
1355
+ return {
1356
+ ok: false,
1357
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
1358
+ };
1267
1359
  }
1268
- return this._raw;
1269
1360
  }
1270
1361
  }
1271
- export const AllTypesSubMsgSchema = defineMessage('omnibuf.conformance.AllTypesSubMsg', {
1362
+ export const AllTypesSubMsgSchema = $ob.defineMessage('omnibuf.conformance.AllTypesSubMsg', {
1272
1363
  id: { fieldNum: 1, type: 'uint32' },
1273
1364
  label: { fieldNum: 2, type: 'string' },
1274
1365
  flag: { fieldNum: 3, type: 'bool' },
@@ -1280,7 +1371,7 @@ class AllTypesSubMsgMsg {
1280
1371
  flag = false;
1281
1372
  score = 0;
1282
1373
  }
1283
- Object.defineProperty(AllTypesSubMsgMsg.prototype, '$typeName', {
1374
+ globalThis.Object.defineProperty(AllTypesSubMsgMsg.prototype, '$typeName', {
1284
1375
  value: 'omnibuf.conformance.AllTypesSubMsg',
1285
1376
  enumerable: false,
1286
1377
  writable: true,
@@ -1292,11 +1383,11 @@ export function createAllTypesSubMsg(init) {
1292
1383
  return AllTypesSubMsgSchema.create(init);
1293
1384
  }
1294
1385
  export function encodeAllTypesSubMsg(enc, msg, options) {
1295
- enc.writeUint(1, Number(msg.id ?? 0) >>> 0);
1386
+ enc.writeUint(1, globalThis.Number(msg.id ?? 0) >>> 0);
1296
1387
  enc.writeString(2, msg.label ?? '');
1297
- enc.writeBool(3, Boolean(msg.flag));
1388
+ enc.writeBool(3, globalThis.Boolean(msg.flag));
1298
1389
  enc.writeInt(4, msg.score ?? 0);
1299
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
1390
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
1300
1391
  for (const uf of msg.$unknown) {
1301
1392
  enc.writeTag(uf.no, uf.wireType);
1302
1393
  enc.writeRaw(uf.data);
@@ -1304,34 +1395,34 @@ export function encodeAllTypesSubMsg(enc, msg, options) {
1304
1395
  }
1305
1396
  }
1306
1397
  export function marshalAllTypesSubMsgOmniBuf(msg, options) {
1307
- const enc = new Encoder(256);
1398
+ const enc = new $ob.Encoder(256);
1308
1399
  if (options?.selfDescribing) {
1309
- writeField0SchemaMeta(enc, AllTypesSubMsgSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
1400
+ $ob.writeField0SchemaMeta(enc, AllTypesSubMsgSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
1310
1401
  }
1311
1402
  encodeAllTypesSubMsg(enc, msg, options);
1312
1403
  return enc.finish();
1313
1404
  }
1314
1405
  export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
1315
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
1406
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
1316
1407
  const readUnknown = options?.readUnknownFields ?? true;
1317
1408
  if (depth > maxDepth) {
1318
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
1409
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
1319
1410
  }
1320
1411
  const out = target ?? new AllTypesSubMsgMsg();
1321
1412
  if (target !== undefined) {
1322
1413
  if (!(out instanceof AllTypesSubMsgMsg)) {
1323
- Object.setPrototypeOf(out, AllTypesSubMsgMsg.prototype);
1414
+ globalThis.Object.setPrototypeOf(out, AllTypesSubMsgMsg.prototype);
1324
1415
  }
1325
1416
  if (!options?.merge) {
1326
- Object.assign(out, new AllTypesSubMsgMsg());
1327
- if (Object.hasOwn(out, '$unknown'))
1417
+ globalThis.Object.assign(out, new AllTypesSubMsgMsg());
1418
+ if (globalThis.Object.hasOwn(out, '$unknown'))
1328
1419
  delete out.$unknown;
1329
1420
  }
1330
1421
  }
1331
1422
  const n = endPos;
1332
1423
  let pos = startPos;
1333
1424
  let seenMask = 0;
1334
- let unknownFields = Array.isArray(out.$unknown)
1425
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
1335
1426
  ? out.$unknown
1336
1427
  : null;
1337
1428
  while (pos < n) {
@@ -1343,34 +1434,33 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1343
1434
  }
1344
1435
  else if ((b0 & 2) !== 0) {
1345
1436
  if (pos + 2 > n)
1346
- throw new Error('omnibuf: truncated tag');
1437
+ throw new globalThis.Error('omnibuf: truncated tag');
1347
1438
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
1348
1439
  pos += 2;
1349
1440
  }
1350
1441
  else {
1351
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
1442
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
1352
1443
  if (tn === 0 || t64 >> 4n > 536870911n)
1353
- throw new Error('omnibuf: invalid tag');
1354
- tag = Number(t64);
1444
+ throw new globalThis.Error('omnibuf: invalid tag');
1445
+ tag = globalThis.Number(t64);
1355
1446
  pos += tn;
1356
1447
  }
1357
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
1448
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
1358
1449
  const wt = tag & 0x0f;
1359
1450
  if (fieldNum === 0) {
1360
- if (wt !== 12)
1361
- throw new Error('omnibuf: invalid Field #0 wire type');
1362
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
1363
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
1451
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
1452
+ if (nextPos < 0)
1453
+ throw new globalThis.Error('omnibuf: invalid Field #0');
1364
1454
  pos = nextPos;
1365
1455
  continue;
1366
1456
  }
1367
1457
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
1368
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
1458
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
1369
1459
  switch (fieldNum) {
1370
1460
  case 1: {
1371
1461
  if (!(wt === 0)) {
1372
1462
  const valStart = pos;
1373
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1463
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1374
1464
  if (readUnknown) {
1375
1465
  if (!unknownFields)
1376
1466
  unknownFields = [];
@@ -1384,7 +1474,7 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1384
1474
  }
1385
1475
  seenMask |= bit;
1386
1476
  if (pos >= n)
1387
- throw new Error('omnibuf: truncated uint32');
1477
+ throw new globalThis.Error('omnibuf: truncated uint32');
1388
1478
  const vb = buf[pos];
1389
1479
  let u32Val = 0;
1390
1480
  if ((vb & 1) !== 0) {
@@ -1393,13 +1483,13 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1393
1483
  }
1394
1484
  else if ((vb & 2) !== 0) {
1395
1485
  if (pos + 2 > n)
1396
- throw new Error('omnibuf: truncated uint32');
1486
+ throw new globalThis.Error('omnibuf: truncated uint32');
1397
1487
  u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
1398
1488
  pos += 2;
1399
1489
  }
1400
1490
  else if ((vb & 4) !== 0) {
1401
1491
  if (pos + 4 > n)
1402
- throw new Error('omnibuf: truncated uint32');
1492
+ throw new globalThis.Error('omnibuf: truncated uint32');
1403
1493
  u32Val =
1404
1494
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
1405
1495
  0;
@@ -1407,7 +1497,7 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1407
1497
  }
1408
1498
  else {
1409
1499
  if (vb !== 0 || pos + 9 > n)
1410
- throw new Error('omnibuf: truncated uint32');
1500
+ throw new globalThis.Error('omnibuf: truncated uint32');
1411
1501
  u32Val =
1412
1502
  (buf[pos + 1] |
1413
1503
  (buf[pos + 2] << 8) |
@@ -1422,7 +1512,7 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1422
1512
  case 2: {
1423
1513
  if (!(wt === 10)) {
1424
1514
  const valStart = pos;
1425
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1515
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1426
1516
  if (readUnknown) {
1427
1517
  if (!unknownFields)
1428
1518
  unknownFields = [];
@@ -1436,19 +1526,19 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1436
1526
  }
1437
1527
  seenMask |= bit;
1438
1528
  if (pos >= n)
1439
- throw new Error('omnibuf: truncated string');
1529
+ throw new globalThis.Error('omnibuf: truncated string');
1440
1530
  const sb = buf[pos];
1441
1531
  if ((sb & 1) !== 0) {
1442
1532
  const sLen = sb >>> 1;
1443
1533
  pos += 1;
1444
1534
  if (pos + sLen > n)
1445
- throw new Error('omnibuf: truncated string');
1446
- out.label = decodeUTF8(buf, pos, pos + sLen);
1535
+ throw new globalThis.Error('omnibuf: truncated string');
1536
+ out.label = $ob.decodeUTF8(buf, pos, pos + sLen);
1447
1537
  pos += sLen;
1448
1538
  }
1449
1539
  else {
1450
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
1451
- out.label = decodeUTF8(s);
1540
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
1541
+ out.label = $ob.decodeUTF8(s);
1452
1542
  pos = nextPos;
1453
1543
  }
1454
1544
  break;
@@ -1456,7 +1546,7 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1456
1546
  case 3: {
1457
1547
  if (!(wt === 2 || wt === 3)) {
1458
1548
  const valStart = pos;
1459
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1549
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1460
1550
  if (readUnknown) {
1461
1551
  if (!unknownFields)
1462
1552
  unknownFields = [];
@@ -1475,7 +1565,7 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1475
1565
  case 4: {
1476
1566
  if (!(wt === 1)) {
1477
1567
  const valStart = pos;
1478
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1568
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1479
1569
  if (readUnknown) {
1480
1570
  if (!unknownFields)
1481
1571
  unknownFields = [];
@@ -1488,16 +1578,16 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1488
1578
  break;
1489
1579
  }
1490
1580
  seenMask |= bit;
1491
- const [v, vn] = decodeVarintBigInt(buf, pos, n);
1581
+ const [v, vn] = $ob.decodeVarintBigInt(buf, pos, n);
1492
1582
  if (vn === 0)
1493
- throw new Error('omnibuf: truncated int64');
1494
- out.score = decodeZigZagAuto(v);
1583
+ throw new globalThis.Error('omnibuf: truncated int64');
1584
+ out.score = $ob.decodeZigZagAuto(v);
1495
1585
  pos += vn;
1496
1586
  break;
1497
1587
  }
1498
1588
  default: {
1499
1589
  const valStart = pos;
1500
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1590
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1501
1591
  if (readUnknown) {
1502
1592
  if (!unknownFields)
1503
1593
  unknownFields = [];
@@ -1512,7 +1602,7 @@ export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos =
1512
1602
  }
1513
1603
  }
1514
1604
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
1515
- Object.defineProperty(out, '$unknown', {
1605
+ globalThis.Object.defineProperty(out, '$unknown', {
1516
1606
  value: unknownFields,
1517
1607
  enumerable: false,
1518
1608
  writable: true,
@@ -1529,15 +1619,30 @@ AllTypesSubMsgSchema.setGeneratedCodec({
1529
1619
  encode: encodeAllTypesSubMsg,
1530
1620
  decode: decodeAllTypesSubMsg,
1531
1621
  });
1622
+ $ob.registerClassSchema(AllTypesSubMsgMsg, AllTypesSubMsgSchema);
1532
1623
  export class OpaqueAllTypesSubMsg {
1533
1624
  _raw;
1625
+ _depth;
1626
+ _readCount = 0;
1627
+ _fieldIndex = null;
1534
1628
  _dirtyMask = 0;
1535
1629
  _id;
1536
1630
  _label;
1537
1631
  _flag;
1538
1632
  _score;
1539
- constructor(raw) {
1633
+ constructor(raw, depth = 0) {
1540
1634
  this._raw = raw;
1635
+ this._depth = depth;
1636
+ }
1637
+ _sliceField(fieldNum) {
1638
+ if (this._fieldIndex === null) {
1639
+ if (this._readCount < 2) {
1640
+ this._readCount++;
1641
+ return this._raw;
1642
+ }
1643
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
1644
+ }
1645
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
1541
1646
  }
1542
1647
  raw() {
1543
1648
  return this._raw;
@@ -1546,7 +1651,8 @@ export class OpaqueAllTypesSubMsg {
1546
1651
  if ((this._dirtyMask & (1 << 1)) !== 0) {
1547
1652
  return this._id;
1548
1653
  }
1549
- return readUint32(this._raw, 1)[0];
1654
+ const __src = this._sliceField(1);
1655
+ return (__src ? $ob.readUint32(__src, 1)[0] : 0);
1550
1656
  }
1551
1657
  id() {
1552
1658
  return this.getId();
@@ -1559,7 +1665,8 @@ export class OpaqueAllTypesSubMsg {
1559
1665
  if ((this._dirtyMask & (1 << 2)) !== 0) {
1560
1666
  return this._label;
1561
1667
  }
1562
- return readString(this._raw, 2)[0];
1668
+ const __src = this._sliceField(2);
1669
+ return __src ? $ob.readString(__src, 2)[0] : '';
1563
1670
  }
1564
1671
  label() {
1565
1672
  return this.getLabel();
@@ -1572,7 +1679,8 @@ export class OpaqueAllTypesSubMsg {
1572
1679
  if ((this._dirtyMask & (1 << 3)) !== 0) {
1573
1680
  return this._flag;
1574
1681
  }
1575
- return readBool(this._raw, 3)[0];
1682
+ const __src = this._sliceField(3);
1683
+ return __src ? $ob.readBool(__src, 3)[0] : false;
1576
1684
  }
1577
1685
  flag() {
1578
1686
  return this.getFlag();
@@ -1585,7 +1693,8 @@ export class OpaqueAllTypesSubMsg {
1585
1693
  if ((this._dirtyMask & (1 << 4)) !== 0) {
1586
1694
  return this._score;
1587
1695
  }
1588
- return readIntAuto(this._raw, 4)[0];
1696
+ const __src = this._sliceField(4);
1697
+ return __src ? $ob.readIntAuto(__src, 4)[0] : 0;
1589
1698
  }
1590
1699
  score() {
1591
1700
  return this.getScore();
@@ -1595,12 +1704,13 @@ export class OpaqueAllTypesSubMsg {
1595
1704
  this._dirtyMask |= 1 << 4;
1596
1705
  }
1597
1706
  marshal(options) {
1707
+ let outBuf;
1598
1708
  if (this._dirtyMask !== 0) {
1599
- this._raw = spliceFields(this._raw, this._dirtyMask, 4, (enc, fnum) => {
1709
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 4, (enc, fnum) => {
1600
1710
  switch (fnum) {
1601
1711
  case 1: {
1602
1712
  const msg = { id: this._id };
1603
- enc.writeUint(1, Number(msg.id ?? 0) >>> 0);
1713
+ enc.writeUint(1, globalThis.Number(msg.id ?? 0) >>> 0);
1604
1714
  break;
1605
1715
  }
1606
1716
  case 2: {
@@ -1610,7 +1720,7 @@ export class OpaqueAllTypesSubMsg {
1610
1720
  }
1611
1721
  case 3: {
1612
1722
  const msg = { flag: this._flag };
1613
- enc.writeBool(3, Boolean(msg.flag));
1723
+ enc.writeBool(3, globalThis.Boolean(msg.flag));
1614
1724
  break;
1615
1725
  }
1616
1726
  case 4: {
@@ -1620,22 +1730,38 @@ export class OpaqueAllTypesSubMsg {
1620
1730
  }
1621
1731
  }
1622
1732
  });
1623
- this._dirtyMask = 0;
1624
1733
  }
1625
1734
  else {
1626
- validateMessage(this._raw);
1735
+ $ob.validateMessage(this._raw, this._depth);
1736
+ outBuf = this._raw.slice();
1627
1737
  }
1628
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
1629
- const f0 = encodeField0SchemaMeta(AllTypesSubMsgSchema.getSchemaMeta(0), Boolean(options.deterministic));
1630
- const out = new Uint8Array(f0.length + this._raw.length);
1631
- out.set(f0, 0);
1632
- out.set(this._raw, f0.length);
1633
- return out;
1738
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
1739
+ const f0 = $ob.encodeField0SchemaMeta(AllTypesSubMsgSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
1740
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
1741
+ withF0.set(f0, 0);
1742
+ withF0.set(outBuf, f0.length);
1743
+ return withF0;
1744
+ }
1745
+ return outBuf;
1746
+ }
1747
+ marshalValidated(options) {
1748
+ const out = this.marshal(options);
1749
+ $ob.validateMessage(out, this._depth);
1750
+ return out;
1751
+ }
1752
+ tryMarshal(options) {
1753
+ try {
1754
+ return { ok: true, value: this.marshalValidated(options) };
1755
+ }
1756
+ catch (err) {
1757
+ return {
1758
+ ok: false,
1759
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
1760
+ };
1634
1761
  }
1635
- return this._raw;
1636
1762
  }
1637
1763
  }
1638
- export const TestAllTypesSchema = defineMessage('omnibuf.conformance.TestAllTypes', {
1764
+ export const TestAllTypesSchema = $ob.defineMessage('omnibuf.conformance.TestAllTypes', {
1639
1765
  f1Uint32: { fieldNum: 1, name: 'f1_uint32', type: 'uint32' },
1640
1766
  f2Uint64: { fieldNum: 2, name: 'f2_uint64', type: 'uint64' },
1641
1767
  f3Sint32: { fieldNum: 3, name: 'f3_sint32', type: 'sint32' },
@@ -1713,7 +1839,7 @@ class TestAllTypesMsg {
1713
1839
  set f6_string(v) {
1714
1840
  this.f6String = v;
1715
1841
  }
1716
- f7Bytes = new Uint8Array(0);
1842
+ f7Bytes = new globalThis.Uint8Array(0);
1717
1843
  get f7_bytes() {
1718
1844
  return this.f7Bytes;
1719
1845
  }
@@ -1791,7 +1917,7 @@ class TestAllTypesMsg {
1791
1917
  this.f20OverflowStr = v;
1792
1918
  }
1793
1919
  }
1794
- Object.defineProperty(TestAllTypesMsg.prototype, '$typeName', {
1920
+ globalThis.Object.defineProperty(TestAllTypesMsg.prototype, '$typeName', {
1795
1921
  value: 'omnibuf.conformance.TestAllTypes',
1796
1922
  enumerable: false,
1797
1923
  writable: true,
@@ -1803,13 +1929,13 @@ export function createTestAllTypes(init) {
1803
1929
  return TestAllTypesSchema.create(init);
1804
1930
  }
1805
1931
  export function encodeTestAllTypes(enc, msg, options) {
1806
- enc.writeUint(1, Number(msg.f1Uint32 ?? msg.f1_uint32 ?? 0) >>> 0);
1932
+ enc.writeUint(1, globalThis.Number(msg.f1Uint32 ?? msg.f1_uint32 ?? 0) >>> 0);
1807
1933
  enc.writeUint(2, msg.f2Uint64 ?? msg.f2_uint64 ?? 0);
1808
- enc.writeInt(3, Number(msg.f3Sint32 ?? msg.f3_sint32 ?? 0) | 0);
1934
+ enc.writeInt(3, globalThis.Number(msg.f3Sint32 ?? msg.f3_sint32 ?? 0) | 0);
1809
1935
  enc.writeInt(4, msg.f4Sint64 ?? msg.f4_sint64 ?? 0);
1810
- enc.writeBool(5, Boolean(msg.f5Bool ?? msg.f5_bool));
1936
+ enc.writeBool(5, globalThis.Boolean(msg.f5Bool ?? msg.f5_bool));
1811
1937
  enc.writeString(6, msg.f6String ?? msg.f6_string ?? '');
1812
- enc.writeBytes(7, msg.f7Bytes ?? msg.f7_bytes ?? new Uint8Array(0));
1938
+ enc.writeBytes(7, msg.f7Bytes ?? msg.f7_bytes ?? new globalThis.Uint8Array(0));
1813
1939
  {
1814
1940
  const subVal = msg.f8SubMsg ?? msg.f8_sub_msg;
1815
1941
  if (subVal !== null && subVal !== undefined) {
@@ -1832,26 +1958,26 @@ export function encodeTestAllTypes(enc, msg, options) {
1832
1958
  enc.endSubMsgArr();
1833
1959
  }
1834
1960
  {
1835
- const entries = Object.entries(msg.f12MapStrUint ?? msg.f12_map_str_uint ?? {});
1961
+ const entries = globalThis.Object.entries(msg.f12MapStrUint ?? msg.f12_map_str_uint ?? {});
1836
1962
  if (options?.deterministic)
1837
- entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
1963
+ entries.sort(([a], [b]) => $ob.compareUTF8Strings(a, b));
1838
1964
  enc.writeTag(12, 14);
1839
- enc.beginContainer();
1965
+ enc.beginContainer(3 + entries.length * 2);
1840
1966
  enc.writeByte(10);
1841
1967
  enc.writeByte(0);
1842
1968
  enc.writeRawVarint(entries.length);
1843
1969
  for (const [k, v] of entries) {
1844
1970
  enc.writeRawStringPayload(k);
1845
- enc.writeRawVarint(BigInt(v));
1971
+ enc.writeRawVarint($ob.toBigInt64Input(v));
1846
1972
  }
1847
1973
  enc.endContainer();
1848
1974
  }
1849
1975
  enc.writeFloat32(13, msg.f13Float32 ?? msg.f13_float32 ?? 0);
1850
1976
  enc.writeFloat64(14, msg.f14Float64 ?? msg.f14_float64 ?? 0);
1851
- enc.writeFixed32(15, Number(msg.f15Fixed32 ?? msg.f15_fixed32 ?? 0) >>> 0);
1977
+ enc.writeFixed32(15, globalThis.Number(msg.f15Fixed32 ?? msg.f15_fixed32 ?? 0) >>> 0);
1852
1978
  enc.writeFixed64(16, msg.f16Fixed64 ?? msg.f16_fixed64 ?? 0);
1853
1979
  enc.writeString(20, msg.f20OverflowStr ?? msg.f20_overflow_str ?? '');
1854
- if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
1980
+ if (options?.writeUnknownFields && globalThis.Array.isArray(msg.$unknown)) {
1855
1981
  for (const uf of msg.$unknown) {
1856
1982
  enc.writeTag(uf.no, uf.wireType);
1857
1983
  enc.writeRaw(uf.data);
@@ -1859,68 +1985,68 @@ export function encodeTestAllTypes(enc, msg, options) {
1859
1985
  }
1860
1986
  }
1861
1987
  export function marshalTestAllTypesOmniBuf(msg, options) {
1862
- const enc = new Encoder(256);
1988
+ const enc = new $ob.Encoder(256);
1863
1989
  if (options?.selfDescribing) {
1864
- writeField0SchemaMeta(enc, TestAllTypesSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
1990
+ $ob.writeField0SchemaMeta(enc, TestAllTypesSchema.getSchemaMeta(0, msg), globalThis.Boolean(options.deterministic));
1865
1991
  }
1866
1992
  encodeTestAllTypes(enc, msg, options);
1867
1993
  return enc.finish();
1868
1994
  }
1869
1995
  export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
1870
- const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
1996
+ const maxDepth = options?.recursionLimit ?? $ob.MaxNestingDepth;
1871
1997
  const readUnknown = options?.readUnknownFields ?? true;
1872
1998
  if (depth > maxDepth) {
1873
- throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
1999
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
1874
2000
  }
1875
2001
  const out = target ?? new TestAllTypesMsg();
1876
2002
  if (target !== undefined) {
1877
2003
  if (!(out instanceof TestAllTypesMsg)) {
1878
- Object.setPrototypeOf(out, TestAllTypesMsg.prototype);
2004
+ globalThis.Object.setPrototypeOf(out, TestAllTypesMsg.prototype);
1879
2005
  }
1880
2006
  if (!options?.merge) {
1881
- if (Object.hasOwn(out, 'f1_uint32'))
2007
+ if (globalThis.Object.hasOwn(out, 'f1_uint32'))
1882
2008
  delete out.f1_uint32;
1883
- if (Object.hasOwn(out, 'f2_uint64'))
2009
+ if (globalThis.Object.hasOwn(out, 'f2_uint64'))
1884
2010
  delete out.f2_uint64;
1885
- if (Object.hasOwn(out, 'f3_sint32'))
2011
+ if (globalThis.Object.hasOwn(out, 'f3_sint32'))
1886
2012
  delete out.f3_sint32;
1887
- if (Object.hasOwn(out, 'f4_sint64'))
2013
+ if (globalThis.Object.hasOwn(out, 'f4_sint64'))
1888
2014
  delete out.f4_sint64;
1889
- if (Object.hasOwn(out, 'f5_bool'))
2015
+ if (globalThis.Object.hasOwn(out, 'f5_bool'))
1890
2016
  delete out.f5_bool;
1891
- if (Object.hasOwn(out, 'f6_string'))
2017
+ if (globalThis.Object.hasOwn(out, 'f6_string'))
1892
2018
  delete out.f6_string;
1893
- if (Object.hasOwn(out, 'f7_bytes'))
2019
+ if (globalThis.Object.hasOwn(out, 'f7_bytes'))
1894
2020
  delete out.f7_bytes;
1895
- if (Object.hasOwn(out, 'f8_sub_msg'))
2021
+ if (globalThis.Object.hasOwn(out, 'f8_sub_msg'))
1896
2022
  delete out.f8_sub_msg;
1897
- if (Object.hasOwn(out, 'f9_string_arr'))
2023
+ if (globalThis.Object.hasOwn(out, 'f9_string_arr'))
1898
2024
  delete out.f9_string_arr;
1899
- if (Object.hasOwn(out, 'f10_uint32_arr'))
2025
+ if (globalThis.Object.hasOwn(out, 'f10_uint32_arr'))
1900
2026
  delete out.f10_uint32_arr;
1901
- if (Object.hasOwn(out, 'f11_sub_msg_arr'))
2027
+ if (globalThis.Object.hasOwn(out, 'f11_sub_msg_arr'))
1902
2028
  delete out.f11_sub_msg_arr;
1903
- if (Object.hasOwn(out, 'f12_map_str_uint'))
2029
+ if (globalThis.Object.hasOwn(out, 'f12_map_str_uint'))
1904
2030
  delete out.f12_map_str_uint;
1905
- if (Object.hasOwn(out, 'f13_float32'))
2031
+ if (globalThis.Object.hasOwn(out, 'f13_float32'))
1906
2032
  delete out.f13_float32;
1907
- if (Object.hasOwn(out, 'f14_float64'))
2033
+ if (globalThis.Object.hasOwn(out, 'f14_float64'))
1908
2034
  delete out.f14_float64;
1909
- if (Object.hasOwn(out, 'f15_fixed32'))
2035
+ if (globalThis.Object.hasOwn(out, 'f15_fixed32'))
1910
2036
  delete out.f15_fixed32;
1911
- if (Object.hasOwn(out, 'f16_fixed64'))
2037
+ if (globalThis.Object.hasOwn(out, 'f16_fixed64'))
1912
2038
  delete out.f16_fixed64;
1913
- if (Object.hasOwn(out, 'f20_overflow_str'))
2039
+ if (globalThis.Object.hasOwn(out, 'f20_overflow_str'))
1914
2040
  delete out.f20_overflow_str;
1915
- Object.assign(out, new TestAllTypesMsg());
1916
- if (Object.hasOwn(out, '$unknown'))
2041
+ globalThis.Object.assign(out, new TestAllTypesMsg());
2042
+ if (globalThis.Object.hasOwn(out, '$unknown'))
1917
2043
  delete out.$unknown;
1918
2044
  }
1919
2045
  }
1920
2046
  const n = endPos;
1921
2047
  let pos = startPos;
1922
2048
  let seenMask = 0;
1923
- let unknownFields = Array.isArray(out.$unknown)
2049
+ let unknownFields = globalThis.Array.isArray(out.$unknown)
1924
2050
  ? out.$unknown
1925
2051
  : null;
1926
2052
  while (pos < n) {
@@ -1932,34 +2058,33 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
1932
2058
  }
1933
2059
  else if ((b0 & 2) !== 0) {
1934
2060
  if (pos + 2 > n)
1935
- throw new Error('omnibuf: truncated tag');
2061
+ throw new globalThis.Error('omnibuf: truncated tag');
1936
2062
  tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
1937
2063
  pos += 2;
1938
2064
  }
1939
2065
  else {
1940
- const [t64, tn] = decodeVarintBigInt(buf, pos, n);
2066
+ const [t64, tn] = $ob.decodeVarintBigInt(buf, pos, n);
1941
2067
  if (tn === 0 || t64 >> 4n > 536870911n)
1942
- throw new Error('omnibuf: invalid tag');
1943
- tag = Number(t64);
2068
+ throw new globalThis.Error('omnibuf: invalid tag');
2069
+ tag = globalThis.Number(t64);
1944
2070
  pos += tn;
1945
2071
  }
1946
- const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
2072
+ const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : globalThis.Math.floor(tag / 16);
1947
2073
  const wt = tag & 0x0f;
1948
2074
  if (fieldNum === 0) {
1949
- if (wt !== 12)
1950
- throw new Error('omnibuf: invalid Field #0 wire type');
1951
- const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
1952
- $decodeSchemaMeta(meta, depth + 1, maxDepth);
2075
+ const nextPos = $ob.validateField0At(buf, pos, wt, depth, maxDepth, n);
2076
+ if (nextPos < 0)
2077
+ throw new globalThis.Error('omnibuf: invalid Field #0');
1953
2078
  pos = nextPos;
1954
2079
  continue;
1955
2080
  }
1956
2081
  const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
1957
- const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
2082
+ const alreadySeen = (seenMask & bit) !== 0 || globalThis.Boolean(options?.merge);
1958
2083
  switch (fieldNum) {
1959
2084
  case 1: {
1960
2085
  if (!(wt === 0)) {
1961
2086
  const valStart = pos;
1962
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2087
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
1963
2088
  if (readUnknown) {
1964
2089
  if (!unknownFields)
1965
2090
  unknownFields = [];
@@ -1973,7 +2098,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
1973
2098
  }
1974
2099
  seenMask |= bit;
1975
2100
  if (pos >= n)
1976
- throw new Error('omnibuf: truncated uint32');
2101
+ throw new globalThis.Error('omnibuf: truncated uint32');
1977
2102
  const vb = buf[pos];
1978
2103
  let u32Val = 0;
1979
2104
  if ((vb & 1) !== 0) {
@@ -1982,13 +2107,13 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
1982
2107
  }
1983
2108
  else if ((vb & 2) !== 0) {
1984
2109
  if (pos + 2 > n)
1985
- throw new Error('omnibuf: truncated uint32');
2110
+ throw new globalThis.Error('omnibuf: truncated uint32');
1986
2111
  u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
1987
2112
  pos += 2;
1988
2113
  }
1989
2114
  else if ((vb & 4) !== 0) {
1990
2115
  if (pos + 4 > n)
1991
- throw new Error('omnibuf: truncated uint32');
2116
+ throw new globalThis.Error('omnibuf: truncated uint32');
1992
2117
  u32Val =
1993
2118
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
1994
2119
  0;
@@ -1996,7 +2121,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
1996
2121
  }
1997
2122
  else {
1998
2123
  if (vb !== 0 || pos + 9 > n)
1999
- throw new Error('omnibuf: truncated uint32');
2124
+ throw new globalThis.Error('omnibuf: truncated uint32');
2000
2125
  u32Val =
2001
2126
  (buf[pos + 1] |
2002
2127
  (buf[pos + 2] << 8) |
@@ -2011,7 +2136,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2011
2136
  case 2: {
2012
2137
  if (!(wt === 0)) {
2013
2138
  const valStart = pos;
2014
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2139
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2015
2140
  if (readUnknown) {
2016
2141
  if (!unknownFields)
2017
2142
  unknownFields = [];
@@ -2025,7 +2150,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2025
2150
  }
2026
2151
  seenMask |= bit;
2027
2152
  if (pos >= n)
2028
- throw new Error('omnibuf: truncated uint64');
2153
+ throw new globalThis.Error('omnibuf: truncated uint64');
2029
2154
  const vb = buf[pos];
2030
2155
  let u64Val;
2031
2156
  if ((vb & 1) !== 0) {
@@ -2034,13 +2159,13 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2034
2159
  }
2035
2160
  else if ((vb & 2) !== 0) {
2036
2161
  if (pos + 2 > n)
2037
- throw new Error('omnibuf: truncated uint64');
2162
+ throw new globalThis.Error('omnibuf: truncated uint64');
2038
2163
  u64Val = (vb | (buf[pos + 1] << 8)) >>> 2;
2039
2164
  pos += 2;
2040
2165
  }
2041
2166
  else if ((vb & 4) !== 0) {
2042
2167
  if (pos + 4 > n)
2043
- throw new Error('omnibuf: truncated uint64');
2168
+ throw new globalThis.Error('omnibuf: truncated uint64');
2044
2169
  u64Val =
2045
2170
  ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
2046
2171
  0;
@@ -2048,7 +2173,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2048
2173
  }
2049
2174
  else {
2050
2175
  if (vb !== 0 || pos + 9 > n)
2051
- throw new Error('omnibuf: truncated uint64');
2176
+ throw new globalThis.Error('omnibuf: truncated uint64');
2052
2177
  const lo = (buf[pos + 1] |
2053
2178
  (buf[pos + 2] << 8) |
2054
2179
  (buf[pos + 3] << 16) |
@@ -2059,7 +2184,10 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2059
2184
  (buf[pos + 7] << 16) |
2060
2185
  (buf[pos + 8] << 24)) >>>
2061
2186
  0;
2062
- u64Val = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
2187
+ u64Val =
2188
+ hi <= 0x1fffff
2189
+ ? hi * 0x100000000 + lo
2190
+ : (globalThis.BigInt(hi) << 32n) | globalThis.BigInt(lo);
2063
2191
  pos += 9;
2064
2192
  }
2065
2193
  out.f2Uint64 = u64Val;
@@ -2068,7 +2196,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2068
2196
  case 3: {
2069
2197
  if (!(wt === 1)) {
2070
2198
  const valStart = pos;
2071
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2199
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2072
2200
  if (readUnknown) {
2073
2201
  if (!unknownFields)
2074
2202
  unknownFields = [];
@@ -2082,7 +2210,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2082
2210
  }
2083
2211
  seenMask |= bit;
2084
2212
  if (pos >= n)
2085
- throw new Error('omnibuf: truncated int32/enum');
2213
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
2086
2214
  const vb = buf[pos];
2087
2215
  let i32Val = 0;
2088
2216
  if ((vb & 1) !== 0) {
@@ -2092,24 +2220,24 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2092
2220
  }
2093
2221
  else if ((vb & 2) !== 0) {
2094
2222
  if (pos + 2 > n)
2095
- throw new Error('omnibuf: truncated int32/enum');
2223
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
2096
2224
  const u = (vb | (buf[pos + 1] << 8)) >>> 2;
2097
2225
  i32Val = (u >>> 1) ^ -(u & 1);
2098
2226
  pos += 2;
2099
2227
  }
2100
2228
  else if ((vb & 4) !== 0) {
2101
2229
  if (pos + 4 > n)
2102
- throw new Error('omnibuf: truncated int32/enum');
2230
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
2103
2231
  const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
2104
2232
  0;
2105
2233
  i32Val = (u >>> 1) ^ -(u & 1);
2106
2234
  pos += 4;
2107
2235
  }
2108
2236
  else {
2109
- const [v, vn] = decodeVarintBigInt(buf, pos, n);
2237
+ const [v, vn] = $ob.decodeVarintBigInt(buf, pos, n);
2110
2238
  if (vn === 0)
2111
- throw new Error('omnibuf: truncated int32/enum');
2112
- i32Val = decodeZigZag32(v);
2239
+ throw new globalThis.Error('omnibuf: truncated int32/enum');
2240
+ i32Val = $ob.decodeZigZag32(v);
2113
2241
  pos += vn;
2114
2242
  }
2115
2243
  out.f3Sint32 = i32Val;
@@ -2118,7 +2246,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2118
2246
  case 4: {
2119
2247
  if (!(wt === 1)) {
2120
2248
  const valStart = pos;
2121
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2249
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2122
2250
  if (readUnknown) {
2123
2251
  if (!unknownFields)
2124
2252
  unknownFields = [];
@@ -2131,17 +2259,17 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2131
2259
  break;
2132
2260
  }
2133
2261
  seenMask |= bit;
2134
- const [v, vn] = decodeVarintBigInt(buf, pos, n);
2262
+ const [v, vn] = $ob.decodeVarintBigInt(buf, pos, n);
2135
2263
  if (vn === 0)
2136
- throw new Error('omnibuf: truncated int64');
2137
- out.f4Sint64 = decodeZigZagAuto(v);
2264
+ throw new globalThis.Error('omnibuf: truncated int64');
2265
+ out.f4Sint64 = $ob.decodeZigZagAuto(v);
2138
2266
  pos += vn;
2139
2267
  break;
2140
2268
  }
2141
2269
  case 5: {
2142
2270
  if (!(wt === 2 || wt === 3)) {
2143
2271
  const valStart = pos;
2144
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2272
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2145
2273
  if (readUnknown) {
2146
2274
  if (!unknownFields)
2147
2275
  unknownFields = [];
@@ -2160,7 +2288,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2160
2288
  case 6: {
2161
2289
  if (!(wt === 10)) {
2162
2290
  const valStart = pos;
2163
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2291
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2164
2292
  if (readUnknown) {
2165
2293
  if (!unknownFields)
2166
2294
  unknownFields = [];
@@ -2174,19 +2302,19 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2174
2302
  }
2175
2303
  seenMask |= bit;
2176
2304
  if (pos >= n)
2177
- throw new Error('omnibuf: truncated string');
2305
+ throw new globalThis.Error('omnibuf: truncated string');
2178
2306
  const sb = buf[pos];
2179
2307
  if ((sb & 1) !== 0) {
2180
2308
  const sLen = sb >>> 1;
2181
2309
  pos += 1;
2182
2310
  if (pos + sLen > n)
2183
- throw new Error('omnibuf: truncated string');
2184
- out.f6String = decodeUTF8(buf, pos, pos + sLen);
2311
+ throw new globalThis.Error('omnibuf: truncated string');
2312
+ out.f6String = $ob.decodeUTF8(buf, pos, pos + sLen);
2185
2313
  pos += sLen;
2186
2314
  }
2187
2315
  else {
2188
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
2189
- out.f6String = decodeUTF8(s);
2316
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
2317
+ out.f6String = $ob.decodeUTF8(s);
2190
2318
  pos = nextPos;
2191
2319
  }
2192
2320
  break;
@@ -2194,7 +2322,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2194
2322
  case 7: {
2195
2323
  if (!(wt === 11)) {
2196
2324
  const valStart = pos;
2197
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2325
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2198
2326
  if (readUnknown) {
2199
2327
  if (!unknownFields)
2200
2328
  unknownFields = [];
@@ -2207,15 +2335,15 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2207
2335
  break;
2208
2336
  }
2209
2337
  seenMask |= bit;
2210
- const [b, nextPos] = readLenSlice(buf, pos, 0, n);
2211
- out.f7Bytes = b.slice();
2338
+ const [b, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
2339
+ out.f7Bytes = options?.zeroCopy ? b : b.slice();
2212
2340
  pos = nextPos;
2213
2341
  break;
2214
2342
  }
2215
2343
  case 8: {
2216
2344
  if (!(wt === 12)) {
2217
2345
  const valStart = pos;
2218
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2346
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2219
2347
  if (readUnknown) {
2220
2348
  if (!unknownFields)
2221
2349
  unknownFields = [];
@@ -2229,7 +2357,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2229
2357
  }
2230
2358
  seenMask |= bit;
2231
2359
  if (pos >= n)
2232
- throw new Error('omnibuf: truncated submsg');
2360
+ throw new globalThis.Error('omnibuf: truncated submsg');
2233
2361
  let subLen = 0;
2234
2362
  const lb = buf[pos];
2235
2363
  if ((lb & 1) !== 0) {
@@ -2238,12 +2366,12 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2238
2366
  }
2239
2367
  else if ((lb & 2) !== 0) {
2240
2368
  if (pos + 2 > n)
2241
- throw new Error('omnibuf: truncated submsg');
2369
+ throw new globalThis.Error('omnibuf: truncated submsg');
2242
2370
  subLen = (lb | (buf[pos + 1] << 8)) >>> 2;
2243
2371
  pos += 2;
2244
2372
  }
2245
2373
  else {
2246
- const [subBytes, nextPos] = readLenSlice(buf, pos, 0, n);
2374
+ const [subBytes, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
2247
2375
  const existing = out.f8SubMsg;
2248
2376
  const doMerge = alreadySeen;
2249
2377
  const decodedSub = decodeAllTypesSubMsg(subBytes, doMerge ? (existing ?? undefined) : undefined, depth + 1, doMerge ? { ...options, merge: true } : options);
@@ -2252,7 +2380,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2252
2380
  break;
2253
2381
  }
2254
2382
  if (pos + subLen > n)
2255
- throw new Error('omnibuf: truncated submsg');
2383
+ throw new globalThis.Error('omnibuf: truncated submsg');
2256
2384
  const existing = out.f8SubMsg;
2257
2385
  const doMerge = alreadySeen;
2258
2386
  const decodedSub = decodeAllTypesSubMsg(buf, doMerge ? (existing ?? undefined) : undefined, depth + 1, doMerge ? { ...options, merge: true } : options, pos, pos + subLen);
@@ -2263,7 +2391,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2263
2391
  case 9: {
2264
2392
  if (!(wt === 13)) {
2265
2393
  const valStart = pos;
2266
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2394
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2267
2395
  if (readUnknown) {
2268
2396
  if (!unknownFields)
2269
2397
  unknownFields = [];
@@ -2277,9 +2405,9 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2277
2405
  }
2278
2406
  seenMask |= bit;
2279
2407
  if (depth + 1 > maxDepth)
2280
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2408
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2281
2409
  if (pos >= n)
2282
- throw new Error('omnibuf: invalid string array');
2410
+ throw new globalThis.Error('omnibuf: invalid string array');
2283
2411
  const lb = buf[pos];
2284
2412
  let bodyLen = 0;
2285
2413
  if ((lb & 1) !== 0) {
@@ -2288,30 +2416,30 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2288
2416
  }
2289
2417
  else if ((lb & 2) !== 0) {
2290
2418
  if (pos + 2 > n)
2291
- throw new Error('omnibuf: invalid string array');
2419
+ throw new globalThis.Error('omnibuf: invalid string array');
2292
2420
  bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
2293
2421
  pos += 2;
2294
2422
  }
2295
2423
  else {
2296
- const [body, nextPos] = readLenSlice(buf, pos, 2, n);
2297
- const prev = alreadySeen && Array.isArray(out.f9StringArr) ? out.f9StringArr : [];
2298
- const [arr, ok] = appendStringArrBody(prev, body);
2424
+ const [body, nextPos] = $ob.readLenSlice(buf, pos, 2, n);
2425
+ const prev = alreadySeen && globalThis.Array.isArray(out.f9StringArr) ? out.f9StringArr : [];
2426
+ const [arr, ok] = $ob.appendStringArrBody(prev, body);
2299
2427
  if (!ok)
2300
- throw new Error('omnibuf: invalid string array');
2428
+ throw new globalThis.Error('omnibuf: invalid string array');
2301
2429
  out.f9StringArr = arr;
2302
2430
  pos = nextPos;
2303
2431
  break;
2304
2432
  }
2305
2433
  const bodyEnd = pos + bodyLen;
2306
2434
  if (bodyLen < 2 || bodyEnd > n)
2307
- throw new Error('omnibuf: invalid string array');
2435
+ throw new globalThis.Error('omnibuf: invalid string array');
2308
2436
  if (buf[pos] === 10 && (buf[pos + 1] & 1) !== 0) {
2309
2437
  const count = buf[pos + 1] >>> 1;
2310
2438
  let p = pos + 2;
2311
2439
  if (count > bodyEnd - p)
2312
- throw new Error('omnibuf: invalid string array');
2440
+ throw new globalThis.Error('omnibuf: invalid string array');
2313
2441
  let dst = out.f9StringArr;
2314
- if (!Array.isArray(dst)) {
2442
+ if (!globalThis.Array.isArray(dst)) {
2315
2443
  dst = [];
2316
2444
  out.f9StringArr = dst;
2317
2445
  }
@@ -2320,35 +2448,35 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2320
2448
  }
2321
2449
  for (let i = 0; i < count; i++) {
2322
2450
  if (p >= bodyEnd)
2323
- throw new Error('omnibuf: invalid string array');
2451
+ throw new globalThis.Error('omnibuf: invalid string array');
2324
2452
  const sb = buf[p];
2325
2453
  if ((sb & 1) !== 0) {
2326
2454
  const sLen = sb >>> 1;
2327
2455
  p += 1;
2328
2456
  if (p + sLen > bodyEnd)
2329
- throw new Error('omnibuf: invalid string array');
2330
- dst.push(decodeUTF8(buf, p, p + sLen));
2457
+ throw new globalThis.Error('omnibuf: invalid string array');
2458
+ dst.push($ob.decodeUTF8(buf, p, p + sLen));
2331
2459
  p += sLen;
2332
2460
  }
2333
2461
  else {
2334
- const [sLen, sn] = decodeVarintBigInt(buf, p, bodyEnd);
2335
- if (sn === 0 || sLen > BigInt(bodyEnd - (p + sn)))
2336
- throw new Error('omnibuf: invalid string array');
2462
+ const [sLen, sn] = $ob.decodeVarintBigInt(buf, p, bodyEnd);
2463
+ if (sn === 0 || sLen > globalThis.BigInt(bodyEnd - (p + sn)))
2464
+ throw new globalThis.Error('omnibuf: invalid string array');
2337
2465
  p += sn;
2338
- const sLenNum = Number(sLen);
2339
- dst.push(decodeUTF8(buf, p, p + sLenNum));
2466
+ const sLenNum = globalThis.Number(sLen);
2467
+ dst.push($ob.decodeUTF8(buf, p, p + sLenNum));
2340
2468
  p += sLenNum;
2341
2469
  }
2342
2470
  }
2343
2471
  if (p !== bodyEnd)
2344
- throw new Error('omnibuf: invalid string array');
2472
+ throw new globalThis.Error('omnibuf: invalid string array');
2345
2473
  pos = bodyEnd;
2346
2474
  break;
2347
2475
  }
2348
- const prev = alreadySeen && Array.isArray(out.f9StringArr) ? out.f9StringArr : [];
2349
- const [arr, ok] = appendStringArrBody(prev, buf.subarray(pos, bodyEnd));
2476
+ const prev = alreadySeen && globalThis.Array.isArray(out.f9StringArr) ? out.f9StringArr : [];
2477
+ const [arr, ok] = $ob.appendStringArrBody(prev, buf.subarray(pos, bodyEnd));
2350
2478
  if (!ok)
2351
- throw new Error('omnibuf: invalid string array');
2479
+ throw new globalThis.Error('omnibuf: invalid string array');
2352
2480
  out.f9StringArr = arr;
2353
2481
  pos = bodyEnd;
2354
2482
  break;
@@ -2356,7 +2484,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2356
2484
  case 10: {
2357
2485
  if (!(wt === 13)) {
2358
2486
  const valStart = pos;
2359
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2487
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2360
2488
  if (readUnknown) {
2361
2489
  if (!unknownFields)
2362
2490
  unknownFields = [];
@@ -2370,9 +2498,9 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2370
2498
  }
2371
2499
  seenMask |= bit;
2372
2500
  if (depth + 1 > maxDepth)
2373
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2501
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2374
2502
  if (pos >= n)
2375
- throw new Error('omnibuf: invalid uint32 array');
2503
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2376
2504
  const lb = buf[pos];
2377
2505
  let bodyLen = 0;
2378
2506
  if ((lb & 1) !== 0) {
@@ -2381,30 +2509,30 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2381
2509
  }
2382
2510
  else if ((lb & 2) !== 0) {
2383
2511
  if (pos + 2 > n)
2384
- throw new Error('omnibuf: invalid uint32 array');
2512
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2385
2513
  bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
2386
2514
  pos += 2;
2387
2515
  }
2388
2516
  else {
2389
- const [body, nextPos] = readLenSlice(buf, pos, 2, n);
2390
- const prev = alreadySeen && Array.isArray(out.f10Uint32Arr) ? out.f10Uint32Arr : [];
2391
- const [arr, ok] = appendUint32ArrBody(prev, body);
2517
+ const [body, nextPos] = $ob.readLenSlice(buf, pos, 2, n);
2518
+ const prev = alreadySeen && globalThis.Array.isArray(out.f10Uint32Arr) ? out.f10Uint32Arr : [];
2519
+ const [arr, ok] = $ob.appendUint32ArrBody(prev, body);
2392
2520
  if (!ok)
2393
- throw new Error('omnibuf: invalid uint32 array');
2521
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2394
2522
  out.f10Uint32Arr = arr;
2395
2523
  pos = nextPos;
2396
2524
  break;
2397
2525
  }
2398
2526
  const bodyEnd = pos + bodyLen;
2399
2527
  if (bodyLen < 2 || bodyEnd > n)
2400
- throw new Error('omnibuf: invalid uint32 array');
2528
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2401
2529
  if (buf[pos] === 0 && (buf[pos + 1] & 1) !== 0) {
2402
2530
  const count = buf[pos + 1] >>> 1;
2403
2531
  let p = pos + 2;
2404
2532
  if (count > bodyEnd - p)
2405
- throw new Error('omnibuf: invalid uint32 array');
2533
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2406
2534
  let dst = out.f10Uint32Arr;
2407
- if (!Array.isArray(dst)) {
2535
+ if (!globalThis.Array.isArray(dst)) {
2408
2536
  dst = [];
2409
2537
  out.f10Uint32Arr = dst;
2410
2538
  }
@@ -2413,7 +2541,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2413
2541
  }
2414
2542
  for (let i = 0; i < count; i++) {
2415
2543
  if (p >= bodyEnd)
2416
- throw new Error('omnibuf: invalid uint32 array');
2544
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2417
2545
  const vb = buf[p];
2418
2546
  if ((vb & 1) !== 0) {
2419
2547
  dst.push(vb >>> 1);
@@ -2421,33 +2549,33 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2421
2549
  }
2422
2550
  else if ((vb & 2) !== 0) {
2423
2551
  if (p + 2 > bodyEnd)
2424
- throw new Error('omnibuf: invalid uint32 array');
2552
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2425
2553
  dst.push((vb | (buf[p + 1] << 8)) >>> 2);
2426
2554
  p += 2;
2427
2555
  }
2428
2556
  else if ((vb & 4) !== 0) {
2429
2557
  if (p + 4 > bodyEnd)
2430
- throw new Error('omnibuf: invalid uint32 array');
2558
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2431
2559
  dst.push(((vb | (buf[p + 1] << 8) | (buf[p + 2] << 16) | (buf[p + 3] << 24)) >>> 3) >>> 0);
2432
2560
  p += 4;
2433
2561
  }
2434
2562
  else {
2435
2563
  if (vb !== 0 || p + 9 > bodyEnd)
2436
- throw new Error('omnibuf: invalid uint32 array');
2564
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2437
2565
  dst.push((buf[p + 1] | (buf[p + 2] << 8) | (buf[p + 3] << 16) | (buf[p + 4] << 24)) >>>
2438
2566
  0);
2439
2567
  p += 9;
2440
2568
  }
2441
2569
  }
2442
2570
  if (p !== bodyEnd)
2443
- throw new Error('omnibuf: invalid uint32 array');
2571
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2444
2572
  pos = bodyEnd;
2445
2573
  break;
2446
2574
  }
2447
- const prev = alreadySeen && Array.isArray(out.f10Uint32Arr) ? out.f10Uint32Arr : [];
2448
- const [arr, ok] = appendUint32ArrBody(prev, buf.subarray(pos, bodyEnd));
2575
+ const prev = alreadySeen && globalThis.Array.isArray(out.f10Uint32Arr) ? out.f10Uint32Arr : [];
2576
+ const [arr, ok] = $ob.appendUint32ArrBody(prev, buf.subarray(pos, bodyEnd));
2449
2577
  if (!ok)
2450
- throw new Error('omnibuf: invalid uint32 array');
2578
+ throw new globalThis.Error('omnibuf: invalid uint32 array');
2451
2579
  out.f10Uint32Arr = arr;
2452
2580
  pos = bodyEnd;
2453
2581
  break;
@@ -2455,7 +2583,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2455
2583
  case 11: {
2456
2584
  if (!(wt === 13)) {
2457
2585
  const valStart = pos;
2458
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2586
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2459
2587
  if (readUnknown) {
2460
2588
  if (!unknownFields)
2461
2589
  unknownFields = [];
@@ -2469,9 +2597,9 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2469
2597
  }
2470
2598
  seenMask |= bit;
2471
2599
  if (depth + 1 > maxDepth)
2472
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2600
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2473
2601
  if (pos >= n)
2474
- throw new Error('omnibuf: corrupt submsg array');
2602
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2475
2603
  let arrLen = 0;
2476
2604
  const lb = buf[pos];
2477
2605
  if ((lb & 1) !== 0) {
@@ -2480,21 +2608,21 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2480
2608
  }
2481
2609
  else if ((lb & 2) !== 0) {
2482
2610
  if (pos + 2 > n)
2483
- throw new Error('omnibuf: corrupt submsg array');
2611
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2484
2612
  arrLen = (lb | (buf[pos + 1] << 8)) >>> 2;
2485
2613
  pos += 2;
2486
2614
  }
2487
2615
  else {
2488
- const [arrPayload, nextPos] = readLenSlice(buf, pos, 2, n);
2489
- const [elemCount, ok] = countSubMsgArrElems(arrPayload);
2616
+ const [arrPayload, nextPos] = $ob.readLenSlice(buf, pos, 2, n);
2617
+ const [elemCount, ok] = $ob.countSubMsgArrElems(arrPayload);
2490
2618
  if (!ok)
2491
- throw new Error('omnibuf: corrupt submsg array');
2492
- const elems = alreadySeen && Array.isArray(out.f11SubMsgArr) ? out.f11SubMsgArr : [];
2493
- let [, , p] = parseArrayHeader(arrPayload);
2619
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2620
+ const elems = alreadySeen && globalThis.Array.isArray(out.f11SubMsgArr) ? out.f11SubMsgArr : [];
2621
+ let [, , p] = $ob.parseArrayHeader(arrPayload);
2494
2622
  for (let i = 0; i < elemCount; i++) {
2495
- const [el, en] = decodeVarintBigInt(arrPayload, p);
2623
+ const [el, en] = $ob.decodeVarintBigInt(arrPayload, p);
2496
2624
  p += en;
2497
- const elNum = Number(el);
2625
+ const elNum = globalThis.Number(el);
2498
2626
  elems.push(decodeAllTypesSubMsg(arrPayload, undefined, depth + 2, options, p, p + elNum));
2499
2627
  p += elNum;
2500
2628
  }
@@ -2504,14 +2632,14 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2504
2632
  }
2505
2633
  const arrEnd = pos + arrLen;
2506
2634
  if (arrLen < 2 || arrEnd > n)
2507
- throw new Error('omnibuf: corrupt submsg array');
2635
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2508
2636
  if (buf[pos] === 12 && (buf[pos + 1] & 1) !== 0) {
2509
2637
  const elemCount = buf[pos + 1] >>> 1;
2510
2638
  let p = pos + 2;
2511
2639
  if (elemCount > arrEnd - p)
2512
- throw new Error('omnibuf: corrupt submsg array');
2640
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2513
2641
  let elems = out.f11SubMsgArr;
2514
- if (!Array.isArray(elems)) {
2642
+ if (!globalThis.Array.isArray(elems)) {
2515
2643
  elems = [];
2516
2644
  out.f11SubMsgArr = elems;
2517
2645
  }
@@ -2520,7 +2648,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2520
2648
  }
2521
2649
  for (let i = 0; i < elemCount; i++) {
2522
2650
  if (p >= arrEnd)
2523
- throw new Error('omnibuf: corrupt submsg array');
2651
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2524
2652
  let elNum = 0;
2525
2653
  const eb0 = buf[p];
2526
2654
  if ((eb0 & 1) !== 0) {
@@ -2529,37 +2657,37 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2529
2657
  }
2530
2658
  else if ((eb0 & 2) !== 0) {
2531
2659
  if (p + 2 > arrEnd)
2532
- throw new Error('omnibuf: corrupt submsg array');
2660
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2533
2661
  elNum = (eb0 | (buf[p + 1] << 8)) >>> 2;
2534
2662
  p += 2;
2535
2663
  }
2536
2664
  else {
2537
- const [el, en] = decodeVarintBigInt(buf, p, arrEnd);
2538
- if (en === 0 || el > BigInt(arrEnd - (p + en)))
2539
- throw new Error('omnibuf: corrupt submsg array');
2665
+ const [el, en] = $ob.decodeVarintBigInt(buf, p, arrEnd);
2666
+ if (en === 0 || el > globalThis.BigInt(arrEnd - (p + en)))
2667
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2540
2668
  p += en;
2541
- elNum = Number(el);
2669
+ elNum = globalThis.Number(el);
2542
2670
  }
2543
2671
  if (p + elNum > arrEnd)
2544
- throw new Error('omnibuf: corrupt submsg array');
2672
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2545
2673
  elems.push(decodeAllTypesSubMsg(buf, undefined, depth + 2, options, p, p + elNum));
2546
2674
  p += elNum;
2547
2675
  }
2548
2676
  if (p !== arrEnd)
2549
- throw new Error('omnibuf: corrupt submsg array');
2677
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2550
2678
  pos = arrEnd;
2551
2679
  break;
2552
2680
  }
2553
2681
  const arrPayload = buf.subarray(pos, arrEnd);
2554
- const [elemCount, ok] = countSubMsgArrElems(arrPayload);
2682
+ const [elemCount, ok] = $ob.countSubMsgArrElems(arrPayload);
2555
2683
  if (!ok)
2556
- throw new Error('omnibuf: corrupt submsg array');
2557
- const elems = alreadySeen && Array.isArray(out.f11SubMsgArr) ? out.f11SubMsgArr : [];
2558
- let [, , p] = parseArrayHeader(arrPayload);
2684
+ throw new globalThis.Error('omnibuf: corrupt submsg array');
2685
+ const elems = alreadySeen && globalThis.Array.isArray(out.f11SubMsgArr) ? out.f11SubMsgArr : [];
2686
+ let [, , p] = $ob.parseArrayHeader(arrPayload);
2559
2687
  for (let i = 0; i < elemCount; i++) {
2560
- const [el, en] = decodeVarintBigInt(arrPayload, p);
2688
+ const [el, en] = $ob.decodeVarintBigInt(arrPayload, p);
2561
2689
  p += en;
2562
- const elNum = Number(el);
2690
+ const elNum = globalThis.Number(el);
2563
2691
  elems.push(decodeAllTypesSubMsg(arrPayload, undefined, depth + 2, options, p, p + elNum));
2564
2692
  p += elNum;
2565
2693
  }
@@ -2570,7 +2698,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2570
2698
  case 12: {
2571
2699
  if (!(wt === 14)) {
2572
2700
  const valStart = pos;
2573
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2701
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2574
2702
  if (readUnknown) {
2575
2703
  if (!unknownFields)
2576
2704
  unknownFields = [];
@@ -2584,49 +2712,67 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2584
2712
  }
2585
2713
  seenMask |= bit;
2586
2714
  if (depth + 1 > maxDepth)
2587
- throw new Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2588
- const [body, nextPos] = readLenSlice(buf, pos, 3, n);
2715
+ throw new globalThis.Error(`omnibuf: nesting depth ${depth + 1} exceeds MaxNestingDepth (${maxDepth})`);
2716
+ const [body, nextPos] = $ob.readLenSlice(buf, pos, 3, n);
2589
2717
  const keyWT = body[0];
2590
2718
  const valWT = body[1];
2591
- validateMapTypes(keyWT, valWT);
2719
+ $ob.validateMapTypes(keyWT, valWT);
2592
2720
  if (keyWT !== 10 || valWT !== 0)
2593
- throw new Error('omnibuf: WireMap header mismatch');
2594
- const [count, cn] = decodeVarintBigInt(body, 2);
2595
- if (cn === 0 || count > BigInt(Math.floor((body.length - (2 + cn)) / 2)))
2596
- throw new Error('omnibuf: invalid map count');
2721
+ throw new globalThis.Error('omnibuf: WireMap header mismatch');
2722
+ const [count, cn] = $ob.decodeVarintBigInt(body, 2);
2723
+ if (cn === 0 ||
2724
+ count > globalThis.BigInt(globalThis.Math.floor((body.length - (2 + cn)) / 2)))
2725
+ throw new globalThis.Error('omnibuf: invalid map count');
2597
2726
  const dst = alreadySeen && out.f12MapStrUint && typeof out.f12MapStrUint === 'object'
2598
2727
  ? out.f12MapStrUint
2599
2728
  : {};
2600
2729
  let p = 2 + cn;
2601
- const c = Number(count);
2730
+ const c = globalThis.Number(count);
2602
2731
  for (let i = 0; i < c; i++) {
2603
2732
  let kVal;
2604
2733
  let vVal;
2605
2734
  {
2606
- if (keyWT !== 10)
2607
- throw new Error('omnibuf: invalid map string wire type');
2608
- const [__s, __np] = readLenSlice(body, p, 0);
2609
- kVal = decodeUTF8(__s);
2610
- p = __np;
2735
+ if (keyWT !== 10 || p >= body.length)
2736
+ throw new globalThis.Error('omnibuf: invalid map string wire type');
2737
+ const __sb = body[p];
2738
+ if ((__sb & 1) !== 0) {
2739
+ const __sl = __sb >>> 1;
2740
+ p += 1;
2741
+ if (p + __sl > body.length)
2742
+ throw new globalThis.Error('omnibuf: truncated map string');
2743
+ kVal = $ob.decodeUTF8(body, p, p + __sl);
2744
+ p += __sl;
2745
+ }
2746
+ else {
2747
+ const [__s, __np] = $ob.readLenSlice(body, p, 0);
2748
+ kVal = $ob.decodeUTF8(__s);
2749
+ p = __np;
2750
+ }
2611
2751
  }
2612
2752
  {
2613
2753
  if (valWT !== 0)
2614
- throw new Error('omnibuf: invalid map uint64 wire type');
2615
- const [__u, __un] = decodeVarintAuto(body, p);
2754
+ throw new globalThis.Error('omnibuf: invalid map uint64 wire type');
2755
+ const [__u, __un] = $ob.decodeVarintAuto(body, p);
2616
2756
  if (__un === 0)
2617
- throw new Error('omnibuf: truncated map uint64');
2757
+ throw new globalThis.Error('omnibuf: truncated map uint64');
2618
2758
  vVal = __u;
2619
2759
  p += __un;
2620
2760
  }
2621
- Object.defineProperty(dst, String(kVal), {
2622
- value: vVal,
2623
- writable: true,
2624
- enumerable: true,
2625
- configurable: true,
2626
- });
2761
+ const __kStr = globalThis.String(kVal);
2762
+ if (__kStr === '__proto__') {
2763
+ globalThis.Object.defineProperty(dst, __kStr, {
2764
+ value: vVal,
2765
+ writable: true,
2766
+ enumerable: true,
2767
+ configurable: true,
2768
+ });
2769
+ }
2770
+ else {
2771
+ dst[__kStr] = vVal;
2772
+ }
2627
2773
  }
2628
2774
  if (p !== body.length)
2629
- throw new Error('omnibuf: map trailing bytes');
2775
+ throw new globalThis.Error('omnibuf: map trailing bytes');
2630
2776
  out.f12MapStrUint = dst;
2631
2777
  pos = nextPos;
2632
2778
  break;
@@ -2634,7 +2780,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2634
2780
  case 13: {
2635
2781
  if (!(wt === 8)) {
2636
2782
  const valStart = pos;
2637
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2783
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2638
2784
  if (readUnknown) {
2639
2785
  if (!unknownFields)
2640
2786
  unknownFields = [];
@@ -2648,16 +2794,16 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2648
2794
  }
2649
2795
  seenMask |= bit;
2650
2796
  if (n - pos < 4)
2651
- throw new Error('omnibuf: truncated float32');
2797
+ throw new globalThis.Error('omnibuf: truncated float32');
2652
2798
  const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
2653
- out.f13Float32 = roundFloat32Shortest(float32FromBits(bits));
2799
+ out.f13Float32 = $ob.float32FromBits(bits);
2654
2800
  pos += 4;
2655
2801
  break;
2656
2802
  }
2657
2803
  case 14: {
2658
2804
  if (!(wt === 9)) {
2659
2805
  const valStart = pos;
2660
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2806
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2661
2807
  if (readUnknown) {
2662
2808
  if (!unknownFields)
2663
2809
  unknownFields = [];
@@ -2671,15 +2817,15 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2671
2817
  }
2672
2818
  seenMask |= bit;
2673
2819
  if (n - pos < 8)
2674
- throw new Error('omnibuf: truncated float64');
2675
- out.f14Float64 = readFloat64At(buf, pos);
2820
+ throw new globalThis.Error('omnibuf: truncated float64');
2821
+ out.f14Float64 = $ob.readFloat64At(buf, pos);
2676
2822
  pos += 8;
2677
2823
  break;
2678
2824
  }
2679
2825
  case 15: {
2680
2826
  if (!(wt === 4)) {
2681
2827
  const valStart = pos;
2682
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2828
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2683
2829
  if (readUnknown) {
2684
2830
  if (!unknownFields)
2685
2831
  unknownFields = [];
@@ -2693,7 +2839,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2693
2839
  }
2694
2840
  seenMask |= bit;
2695
2841
  if (n - pos < 4)
2696
- throw new Error('omnibuf: truncated fixed32');
2842
+ throw new globalThis.Error('omnibuf: truncated fixed32');
2697
2843
  const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
2698
2844
  out.f15Fixed32 = bits;
2699
2845
  pos += 4;
@@ -2702,7 +2848,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2702
2848
  case 16: {
2703
2849
  if (!(wt === 5)) {
2704
2850
  const valStart = pos;
2705
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2851
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2706
2852
  if (readUnknown) {
2707
2853
  if (!unknownFields)
2708
2854
  unknownFields = [];
@@ -2716,18 +2862,18 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2716
2862
  }
2717
2863
  seenMask |= bit;
2718
2864
  if (n - pos < 8)
2719
- throw new Error('omnibuf: truncated fixed64');
2865
+ throw new globalThis.Error('omnibuf: truncated fixed64');
2720
2866
  let u64 = 0n;
2721
2867
  for (let b = 7; b >= 0; b--)
2722
- u64 = (u64 << 8n) | BigInt(buf[pos + b]);
2723
- out.f16Fixed64 = u64 <= 9007199254740991n ? Number(u64) : u64;
2868
+ u64 = (u64 << 8n) | globalThis.BigInt(buf[pos + b]);
2869
+ out.f16Fixed64 = u64 <= 9007199254740991n ? globalThis.Number(u64) : u64;
2724
2870
  pos += 8;
2725
2871
  break;
2726
2872
  }
2727
2873
  case 20: {
2728
2874
  if (!(wt === 10)) {
2729
2875
  const valStart = pos;
2730
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2876
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2731
2877
  if (readUnknown) {
2732
2878
  if (!unknownFields)
2733
2879
  unknownFields = [];
@@ -2741,26 +2887,26 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2741
2887
  }
2742
2888
  seenMask |= bit;
2743
2889
  if (pos >= n)
2744
- throw new Error('omnibuf: truncated string');
2890
+ throw new globalThis.Error('omnibuf: truncated string');
2745
2891
  const sb = buf[pos];
2746
2892
  if ((sb & 1) !== 0) {
2747
2893
  const sLen = sb >>> 1;
2748
2894
  pos += 1;
2749
2895
  if (pos + sLen > n)
2750
- throw new Error('omnibuf: truncated string');
2751
- out.f20OverflowStr = decodeUTF8(buf, pos, pos + sLen);
2896
+ throw new globalThis.Error('omnibuf: truncated string');
2897
+ out.f20OverflowStr = $ob.decodeUTF8(buf, pos, pos + sLen);
2752
2898
  pos += sLen;
2753
2899
  }
2754
2900
  else {
2755
- const [s, nextPos] = readLenSlice(buf, pos, 0, n);
2756
- out.f20OverflowStr = decodeUTF8(s);
2901
+ const [s, nextPos] = $ob.readLenSlice(buf, pos, 0, n);
2902
+ out.f20OverflowStr = $ob.decodeUTF8(s);
2757
2903
  pos = nextPos;
2758
2904
  }
2759
2905
  break;
2760
2906
  }
2761
2907
  default: {
2762
2908
  const valStart = pos;
2763
- pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2909
+ pos = $ob.validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
2764
2910
  if (readUnknown) {
2765
2911
  if (!unknownFields)
2766
2912
  unknownFields = [];
@@ -2775,7 +2921,7 @@ export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0
2775
2921
  }
2776
2922
  }
2777
2923
  if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
2778
- Object.defineProperty(out, '$unknown', {
2924
+ globalThis.Object.defineProperty(out, '$unknown', {
2779
2925
  value: unknownFields,
2780
2926
  enumerable: false,
2781
2927
  writable: true,
@@ -2792,8 +2938,12 @@ TestAllTypesSchema.setGeneratedCodec({
2792
2938
  encode: encodeTestAllTypes,
2793
2939
  decode: decodeTestAllTypes,
2794
2940
  });
2941
+ $ob.registerClassSchema(TestAllTypesMsg, TestAllTypesSchema);
2795
2942
  export class OpaqueTestAllTypes {
2796
2943
  _raw;
2944
+ _depth;
2945
+ _readCount = 0;
2946
+ _fieldIndex = null;
2797
2947
  _dirtyMask = 0;
2798
2948
  _f1Uint32;
2799
2949
  _f2Uint64;
@@ -2812,8 +2962,20 @@ export class OpaqueTestAllTypes {
2812
2962
  _f15Fixed32;
2813
2963
  _f16Fixed64;
2814
2964
  _f20OverflowStr;
2815
- constructor(raw) {
2965
+ _opaque_f8SubMsg;
2966
+ constructor(raw, depth = 0) {
2816
2967
  this._raw = raw;
2968
+ this._depth = depth;
2969
+ }
2970
+ _sliceField(fieldNum) {
2971
+ if (this._fieldIndex === null) {
2972
+ if (this._readCount < 2) {
2973
+ this._readCount++;
2974
+ return this._raw;
2975
+ }
2976
+ this._fieldIndex = $ob.indexTopLevelFields(this._raw);
2977
+ }
2978
+ return $ob.sliceIndexedField(this._raw, this._fieldIndex, fieldNum);
2817
2979
  }
2818
2980
  raw() {
2819
2981
  return this._raw;
@@ -2822,7 +2984,8 @@ export class OpaqueTestAllTypes {
2822
2984
  if ((this._dirtyMask & (1 << 1)) !== 0) {
2823
2985
  return this._f1Uint32;
2824
2986
  }
2825
- return readUint32(this._raw, 1)[0];
2987
+ const __src = this._sliceField(1);
2988
+ return (__src ? $ob.readUint32(__src, 1)[0] : 0);
2826
2989
  }
2827
2990
  f1Uint32() {
2828
2991
  return this.getF1Uint32();
@@ -2838,7 +3001,8 @@ export class OpaqueTestAllTypes {
2838
3001
  if ((this._dirtyMask & (1 << 2)) !== 0) {
2839
3002
  return this._f2Uint64;
2840
3003
  }
2841
- return readUintAuto(this._raw, 2)[0];
3004
+ const __src = this._sliceField(2);
3005
+ return __src ? $ob.readUintAuto(__src, 2)[0] : 0;
2842
3006
  }
2843
3007
  f2Uint64() {
2844
3008
  return this.getF2Uint64();
@@ -2854,7 +3018,8 @@ export class OpaqueTestAllTypes {
2854
3018
  if ((this._dirtyMask & (1 << 3)) !== 0) {
2855
3019
  return this._f3Sint32;
2856
3020
  }
2857
- return readInt32(this._raw, 3)[0];
3021
+ const __src = this._sliceField(3);
3022
+ return __src ? $ob.readInt32(__src, 3)[0] : 0;
2858
3023
  }
2859
3024
  f3Sint32() {
2860
3025
  return this.getF3Sint32();
@@ -2870,7 +3035,8 @@ export class OpaqueTestAllTypes {
2870
3035
  if ((this._dirtyMask & (1 << 4)) !== 0) {
2871
3036
  return this._f4Sint64;
2872
3037
  }
2873
- return readIntAuto(this._raw, 4)[0];
3038
+ const __src = this._sliceField(4);
3039
+ return __src ? $ob.readIntAuto(__src, 4)[0] : 0;
2874
3040
  }
2875
3041
  f4Sint64() {
2876
3042
  return this.getF4Sint64();
@@ -2886,7 +3052,8 @@ export class OpaqueTestAllTypes {
2886
3052
  if ((this._dirtyMask & (1 << 5)) !== 0) {
2887
3053
  return this._f5Bool;
2888
3054
  }
2889
- return readBool(this._raw, 5)[0];
3055
+ const __src = this._sliceField(5);
3056
+ return __src ? $ob.readBool(__src, 5)[0] : false;
2890
3057
  }
2891
3058
  f5Bool() {
2892
3059
  return this.getF5Bool();
@@ -2902,7 +3069,8 @@ export class OpaqueTestAllTypes {
2902
3069
  if ((this._dirtyMask & (1 << 6)) !== 0) {
2903
3070
  return this._f6String;
2904
3071
  }
2905
- return readString(this._raw, 6)[0];
3072
+ const __src = this._sliceField(6);
3073
+ return __src ? $ob.readString(__src, 6)[0] : '';
2906
3074
  }
2907
3075
  f6String() {
2908
3076
  return this.getF6String();
@@ -2918,7 +3086,15 @@ export class OpaqueTestAllTypes {
2918
3086
  if ((this._dirtyMask & (1 << 7)) !== 0) {
2919
3087
  return this._f7Bytes;
2920
3088
  }
2921
- return readBytes(this._raw, 7)[0];
3089
+ const __src = this._sliceField(7);
3090
+ return __src ? $ob.readBytes(__src, 7)[0] : new globalThis.Uint8Array(0);
3091
+ }
3092
+ getF7BytesView() {
3093
+ if ((this._dirtyMask & (1 << 7)) !== 0) {
3094
+ return this._f7Bytes;
3095
+ }
3096
+ const __src = this._sliceField(7);
3097
+ return __src ? $ob.readBytesView(__src, 7)[0] : new globalThis.Uint8Array(0);
2922
3098
  }
2923
3099
  f7Bytes() {
2924
3100
  return this.getF7Bytes();
@@ -2935,10 +3111,34 @@ export class OpaqueTestAllTypes {
2935
3111
  return this._f8SubMsg;
2936
3112
  }
2937
3113
  if (this._f8SubMsg === undefined) {
2938
- this._f8SubMsg = readSubMsgMerged(this._raw, 8, (sub, target, merge, s, e) => decodeAllTypesSubMsg(sub, target, 0, merge ? { merge: true } : undefined, s, e))[0];
3114
+ const __src = this._sliceField(8);
3115
+ this._f8SubMsg = __src
3116
+ ? $ob.readSubMsgMerged(__src, 8, (sub, target, merge, s, e) => decodeAllTypesSubMsg(sub, target, this._depth + 1, merge ? { merge: true } : undefined, s, e))[0]
3117
+ : null;
2939
3118
  }
2940
3119
  return this._f8SubMsg;
2941
3120
  }
3121
+ getF8SubMsgOpaque() {
3122
+ if (this._depth + 1 > $ob.MaxNestingDepth) {
3123
+ throw new globalThis.Error(`omnibuf: nesting depth ${this._depth + 1} exceeds MaxNestingDepth (${$ob.MaxNestingDepth})`);
3124
+ }
3125
+ if (this._opaque_f8SubMsg !== undefined) {
3126
+ return this._opaque_f8SubMsg ?? undefined;
3127
+ }
3128
+ const __src = this._sliceField(8);
3129
+ if (!__src) {
3130
+ this._opaque_f8SubMsg = null;
3131
+ return undefined;
3132
+ }
3133
+ const [sub, ok] = $ob.readSubMsg(__src, 8);
3134
+ if (!ok) {
3135
+ this._opaque_f8SubMsg = null;
3136
+ return undefined;
3137
+ }
3138
+ const nested = new OpaqueAllTypesSubMsg(sub, this._depth + 1);
3139
+ this._opaque_f8SubMsg = nested;
3140
+ return nested;
3141
+ }
2942
3142
  f8SubMsg() {
2943
3143
  return this.getF8SubMsg();
2944
3144
  }
@@ -2947,6 +3147,7 @@ export class OpaqueTestAllTypes {
2947
3147
  }
2948
3148
  setF8SubMsg(val) {
2949
3149
  this._f8SubMsg = val;
3150
+ this._opaque_f8SubMsg = undefined;
2950
3151
  this._dirtyMask |= 1 << 8;
2951
3152
  }
2952
3153
  getF9StringArr() {
@@ -2954,7 +3155,8 @@ export class OpaqueTestAllTypes {
2954
3155
  return this._f9StringArr;
2955
3156
  }
2956
3157
  if (this._f9StringArr === undefined) {
2957
- this._f9StringArr = readStringArr(this._raw, 9)[0];
3158
+ const __src = this._sliceField(9);
3159
+ this._f9StringArr = __src ? $ob.readStringArr(__src, 9)[0] : [];
2958
3160
  }
2959
3161
  return this._f9StringArr;
2960
3162
  }
@@ -2973,7 +3175,8 @@ export class OpaqueTestAllTypes {
2973
3175
  return this._f10Uint32Arr;
2974
3176
  }
2975
3177
  if (this._f10Uint32Arr === undefined) {
2976
- this._f10Uint32Arr = readUint32Arr(this._raw, 10)[0];
3178
+ const __src = this._sliceField(10);
3179
+ this._f10Uint32Arr = __src ? $ob.readUint32Arr(__src, 10)[0] : [];
2977
3180
  }
2978
3181
  return this._f10Uint32Arr;
2979
3182
  }
@@ -2992,7 +3195,10 @@ export class OpaqueTestAllTypes {
2992
3195
  return this._f11SubMsgArr;
2993
3196
  }
2994
3197
  if (this._f11SubMsgArr === undefined) {
2995
- this._f11SubMsgArr = readSubMsgArrDecoded(this._raw, 11, (sub) => decodeAllTypesSubMsg(sub))[0];
3198
+ const __src = this._sliceField(11);
3199
+ this._f11SubMsgArr = __src
3200
+ ? $ob.readSubMsgArrDecoded(__src, 11, (sub) => decodeAllTypesSubMsg(sub, undefined, this._depth + 1))[0]
3201
+ : [];
2996
3202
  }
2997
3203
  return this._f11SubMsgArr;
2998
3204
  }
@@ -3011,7 +3217,7 @@ export class OpaqueTestAllTypes {
3011
3217
  return this._f12MapStrUint;
3012
3218
  }
3013
3219
  if (this._f12MapStrUint === undefined) {
3014
- this._f12MapStrUint = readTypedMap(this._raw, 12, 'string', 'uint64')[0];
3220
+ this._f12MapStrUint = $ob.readTypedMap(this._raw, 12, 'string', 'uint64')[0];
3015
3221
  }
3016
3222
  return this._f12MapStrUint;
3017
3223
  }
@@ -3029,7 +3235,8 @@ export class OpaqueTestAllTypes {
3029
3235
  if ((this._dirtyMask & (1 << 13)) !== 0) {
3030
3236
  return this._f13Float32;
3031
3237
  }
3032
- return roundFloat32Shortest(readFloat32(this._raw, 13)[0]);
3238
+ const __src = this._sliceField(13);
3239
+ return __src ? $ob.readFloat32(__src, 13)[0] : 0;
3033
3240
  }
3034
3241
  f13Float32() {
3035
3242
  return this.getF13Float32();
@@ -3045,7 +3252,8 @@ export class OpaqueTestAllTypes {
3045
3252
  if ((this._dirtyMask & (1 << 14)) !== 0) {
3046
3253
  return this._f14Float64;
3047
3254
  }
3048
- return readFloat64(this._raw, 14)[0];
3255
+ const __src = this._sliceField(14);
3256
+ return __src ? $ob.readFloat64(__src, 14)[0] : 0;
3049
3257
  }
3050
3258
  f14Float64() {
3051
3259
  return this.getF14Float64();
@@ -3061,7 +3269,8 @@ export class OpaqueTestAllTypes {
3061
3269
  if ((this._dirtyMask & (1 << 15)) !== 0) {
3062
3270
  return this._f15Fixed32;
3063
3271
  }
3064
- return readFixed32(this._raw, 15)[0];
3272
+ const __src = this._sliceField(15);
3273
+ return __src ? $ob.readFixed32(__src, 15)[0] : 0;
3065
3274
  }
3066
3275
  f15Fixed32() {
3067
3276
  return this.getF15Fixed32();
@@ -3077,7 +3286,8 @@ export class OpaqueTestAllTypes {
3077
3286
  if ((this._dirtyMask & (1 << 16)) !== 0) {
3078
3287
  return this._f16Fixed64;
3079
3288
  }
3080
- return readFixed64Auto(this._raw, 16)[0];
3289
+ const __src = this._sliceField(16);
3290
+ return __src ? $ob.readFixed64Auto(__src, 16)[0] : 0;
3081
3291
  }
3082
3292
  f16Fixed64() {
3083
3293
  return this.getF16Fixed64();
@@ -3093,7 +3303,8 @@ export class OpaqueTestAllTypes {
3093
3303
  if ((this._dirtyMask & (1 << 20)) !== 0) {
3094
3304
  return this._f20OverflowStr;
3095
3305
  }
3096
- return readString(this._raw, 20)[0];
3306
+ const __src = this._sliceField(20);
3307
+ return __src ? $ob.readString(__src, 20)[0] : '';
3097
3308
  }
3098
3309
  f20OverflowStr() {
3099
3310
  return this.getF20OverflowStr();
@@ -3106,12 +3317,13 @@ export class OpaqueTestAllTypes {
3106
3317
  this._dirtyMask |= 1 << 20;
3107
3318
  }
3108
3319
  marshal(options) {
3320
+ let outBuf;
3109
3321
  if (this._dirtyMask !== 0) {
3110
- this._raw = spliceFields(this._raw, this._dirtyMask, 20, (enc, fnum) => {
3322
+ outBuf = $ob.spliceFields(this._raw, this._dirtyMask, 20, (enc, fnum) => {
3111
3323
  switch (fnum) {
3112
3324
  case 1: {
3113
3325
  const msg = { f1Uint32: this._f1Uint32 };
3114
- enc.writeUint(1, Number(msg.f1Uint32 ?? msg.f1_uint32 ?? 0) >>> 0);
3326
+ enc.writeUint(1, globalThis.Number(msg.f1Uint32 ?? msg.f1_uint32 ?? 0) >>> 0);
3115
3327
  break;
3116
3328
  }
3117
3329
  case 2: {
@@ -3121,7 +3333,7 @@ export class OpaqueTestAllTypes {
3121
3333
  }
3122
3334
  case 3: {
3123
3335
  const msg = { f3Sint32: this._f3Sint32 };
3124
- enc.writeInt(3, Number(msg.f3Sint32 ?? msg.f3_sint32 ?? 0) | 0);
3336
+ enc.writeInt(3, globalThis.Number(msg.f3Sint32 ?? msg.f3_sint32 ?? 0) | 0);
3125
3337
  break;
3126
3338
  }
3127
3339
  case 4: {
@@ -3131,7 +3343,7 @@ export class OpaqueTestAllTypes {
3131
3343
  }
3132
3344
  case 5: {
3133
3345
  const msg = { f5Bool: this._f5Bool };
3134
- enc.writeBool(5, Boolean(msg.f5Bool ?? msg.f5_bool));
3346
+ enc.writeBool(5, globalThis.Boolean(msg.f5Bool ?? msg.f5_bool));
3135
3347
  break;
3136
3348
  }
3137
3349
  case 6: {
@@ -3141,7 +3353,7 @@ export class OpaqueTestAllTypes {
3141
3353
  }
3142
3354
  case 7: {
3143
3355
  const msg = { f7Bytes: this._f7Bytes };
3144
- enc.writeBytes(7, msg.f7Bytes ?? msg.f7_bytes ?? new Uint8Array(0));
3356
+ enc.writeBytes(7, msg.f7Bytes ?? msg.f7_bytes ?? new globalThis.Uint8Array(0));
3145
3357
  break;
3146
3358
  }
3147
3359
  case 8: {
@@ -3184,17 +3396,17 @@ export class OpaqueTestAllTypes {
3184
3396
  case 12: {
3185
3397
  const msg = { f12MapStrUint: this._f12MapStrUint };
3186
3398
  {
3187
- const entries = Object.entries(msg.f12MapStrUint ?? msg.f12_map_str_uint ?? {});
3399
+ const entries = globalThis.Object.entries(msg.f12MapStrUint ?? msg.f12_map_str_uint ?? {});
3188
3400
  if (options?.deterministic)
3189
- entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
3401
+ entries.sort(([a], [b]) => $ob.compareUTF8Strings(a, b));
3190
3402
  enc.writeTag(12, 14);
3191
- enc.beginContainer();
3403
+ enc.beginContainer(3 + entries.length * 2);
3192
3404
  enc.writeByte(10);
3193
3405
  enc.writeByte(0);
3194
3406
  enc.writeRawVarint(entries.length);
3195
3407
  for (const [k, v] of entries) {
3196
3408
  enc.writeRawStringPayload(k);
3197
- enc.writeRawVarint(BigInt(v));
3409
+ enc.writeRawVarint($ob.toBigInt64Input(v));
3198
3410
  }
3199
3411
  enc.endContainer();
3200
3412
  }
@@ -3212,7 +3424,7 @@ export class OpaqueTestAllTypes {
3212
3424
  }
3213
3425
  case 15: {
3214
3426
  const msg = { f15Fixed32: this._f15Fixed32 };
3215
- enc.writeFixed32(15, Number(msg.f15Fixed32 ?? msg.f15_fixed32 ?? 0) >>> 0);
3427
+ enc.writeFixed32(15, globalThis.Number(msg.f15Fixed32 ?? msg.f15_fixed32 ?? 0) >>> 0);
3216
3428
  break;
3217
3429
  }
3218
3430
  case 16: {
@@ -3227,19 +3439,35 @@ export class OpaqueTestAllTypes {
3227
3439
  }
3228
3440
  }
3229
3441
  });
3230
- this._dirtyMask = 0;
3231
3442
  }
3232
3443
  else {
3233
- validateMessage(this._raw);
3444
+ $ob.validateMessage(this._raw, this._depth);
3445
+ outBuf = this._raw.slice();
3234
3446
  }
3235
- if (options?.selfDescribing && !readField0SchemaMeta(this._raw)[1]) {
3236
- const f0 = encodeField0SchemaMeta(TestAllTypesSchema.getSchemaMeta(0), Boolean(options.deterministic));
3237
- const out = new Uint8Array(f0.length + this._raw.length);
3238
- out.set(f0, 0);
3239
- out.set(this._raw, f0.length);
3240
- return out;
3447
+ if (options?.selfDescribing && !$ob.readField0SchemaMeta(outBuf)[1]) {
3448
+ const f0 = $ob.encodeField0SchemaMeta(TestAllTypesSchema.getSchemaMeta(0), globalThis.Boolean(options.deterministic));
3449
+ const withF0 = new globalThis.Uint8Array(f0.length + outBuf.length);
3450
+ withF0.set(f0, 0);
3451
+ withF0.set(outBuf, f0.length);
3452
+ return withF0;
3453
+ }
3454
+ return outBuf;
3455
+ }
3456
+ marshalValidated(options) {
3457
+ const out = this.marshal(options);
3458
+ $ob.validateMessage(out, this._depth);
3459
+ return out;
3460
+ }
3461
+ tryMarshal(options) {
3462
+ try {
3463
+ return { ok: true, value: this.marshalValidated(options) };
3464
+ }
3465
+ catch (err) {
3466
+ return {
3467
+ ok: false,
3468
+ error: err instanceof globalThis.Error ? err : new globalThis.Error(globalThis.String(err)),
3469
+ };
3241
3470
  }
3242
- return this._raw;
3243
3471
  }
3244
3472
  }
3245
3473
  //# sourceMappingURL=conformance_omnibuf.pb.js.map