@bufbuild/protobuf 2.2.5 → 2.4.0

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.
Files changed (88) hide show
  1. package/dist/cjs/clone.js +4 -6
  2. package/dist/cjs/codegenv1/boot.js +1 -1
  3. package/dist/cjs/codegenv1/embed.js +0 -1
  4. package/dist/cjs/codegenv1/file.js +1 -1
  5. package/dist/cjs/codegenv1/symbols.js +4 -1
  6. package/dist/cjs/create.js +0 -1
  7. package/dist/cjs/equals.js +2 -1
  8. package/dist/cjs/extensions.js +1 -1
  9. package/dist/cjs/from-binary.js +5 -3
  10. package/dist/cjs/from-json.js +8 -10
  11. package/dist/cjs/proto-int64.js +4 -1
  12. package/dist/cjs/reflect/guard.js +2 -1
  13. package/dist/cjs/reflect/index.d.ts +1 -0
  14. package/dist/cjs/reflect/index.js +1 -0
  15. package/dist/cjs/reflect/names.d.ts +8 -0
  16. package/dist/cjs/reflect/names.js +28 -0
  17. package/dist/cjs/reflect/nested-types.d.ts +23 -0
  18. package/dist/cjs/reflect/nested-types.js +40 -0
  19. package/dist/cjs/reflect/path.d.ts +107 -0
  20. package/dist/cjs/reflect/path.js +376 -0
  21. package/dist/cjs/reflect/reflect-check.js +3 -3
  22. package/dist/cjs/reflect/reflect-types.d.ts +1 -1
  23. package/dist/cjs/reflect/reflect.js +9 -7
  24. package/dist/cjs/reflect/scalar.js +4 -5
  25. package/dist/cjs/reflect/unsafe.d.ts +3 -6
  26. package/dist/cjs/reflect/unsafe.js +11 -10
  27. package/dist/cjs/registry.js +24 -30
  28. package/dist/cjs/to-binary.js +1 -1
  29. package/dist/cjs/to-json.d.ts +6 -0
  30. package/dist/cjs/to-json.js +16 -18
  31. package/dist/cjs/wire/base64-encoding.js +4 -3
  32. package/dist/cjs/wire/binary-encoding.js +7 -6
  33. package/dist/cjs/wire/text-encoding.js +1 -1
  34. package/dist/cjs/wire/text-format.js +3 -4
  35. package/dist/cjs/wire/varint.js +0 -1
  36. package/dist/cjs/wkt/gen/google/protobuf/cpp_features_pb.d.ts +89 -0
  37. package/dist/cjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
  38. package/dist/cjs/wkt/gen/google/protobuf/go_features_pb.d.ts +122 -0
  39. package/dist/cjs/wkt/gen/google/protobuf/go_features_pb.js +90 -0
  40. package/dist/cjs/wkt/gen/google/protobuf/java_features_pb.d.ts +113 -0
  41. package/dist/cjs/wkt/gen/google/protobuf/java_features_pb.js +67 -0
  42. package/dist/cjs/wkt/index.d.ts +4 -1
  43. package/dist/cjs/wkt/index.js +4 -1
  44. package/dist/esm/clone.js +4 -6
  45. package/dist/esm/codegenv1/boot.js +1 -1
  46. package/dist/esm/codegenv1/embed.js +0 -1
  47. package/dist/esm/codegenv1/file.js +1 -1
  48. package/dist/esm/codegenv1/symbols.js +4 -1
  49. package/dist/esm/create.js +0 -2
  50. package/dist/esm/equals.js +2 -1
  51. package/dist/esm/extensions.js +1 -1
  52. package/dist/esm/from-binary.js +5 -3
  53. package/dist/esm/from-json.js +8 -10
  54. package/dist/esm/proto-int64.js +4 -1
  55. package/dist/esm/reflect/guard.js +2 -1
  56. package/dist/esm/reflect/index.d.ts +1 -0
  57. package/dist/esm/reflect/index.js +1 -0
  58. package/dist/esm/reflect/names.d.ts +8 -0
  59. package/dist/esm/reflect/names.js +27 -0
  60. package/dist/esm/reflect/nested-types.d.ts +23 -0
  61. package/dist/esm/reflect/nested-types.js +39 -0
  62. package/dist/esm/reflect/path.d.ts +107 -0
  63. package/dist/esm/reflect/path.js +369 -0
  64. package/dist/esm/reflect/reflect-check.js +3 -3
  65. package/dist/esm/reflect/reflect-types.d.ts +1 -1
  66. package/dist/esm/reflect/reflect-types.js +0 -1
  67. package/dist/esm/reflect/reflect.js +9 -7
  68. package/dist/esm/reflect/scalar.js +4 -5
  69. package/dist/esm/reflect/unsafe.d.ts +3 -6
  70. package/dist/esm/reflect/unsafe.js +11 -10
  71. package/dist/esm/registry.js +24 -30
  72. package/dist/esm/to-binary.js +1 -1
  73. package/dist/esm/to-json.d.ts +6 -0
  74. package/dist/esm/to-json.js +16 -18
  75. package/dist/esm/wire/base64-encoding.js +4 -3
  76. package/dist/esm/wire/binary-encoding.js +7 -6
  77. package/dist/esm/wire/text-encoding.js +1 -1
  78. package/dist/esm/wire/text-format.js +3 -4
  79. package/dist/esm/wire/varint.js +0 -1
  80. package/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.d.ts +89 -0
  81. package/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
  82. package/dist/esm/wkt/gen/google/protobuf/go_features_pb.d.ts +122 -0
  83. package/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +87 -0
  84. package/dist/esm/wkt/gen/google/protobuf/java_features_pb.d.ts +113 -0
  85. package/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +64 -0
  86. package/dist/esm/wkt/index.d.ts +4 -1
  87. package/dist/esm/wkt/index.js +4 -1
  88. package/package.json +9 -24
@@ -0,0 +1,369 @@
1
+ // Copyright 2021-2025 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ScalarType, } from "../descriptors.js";
15
+ /**
16
+ * Create a PathBuilder.
17
+ */
18
+ export function buildPath(schema) {
19
+ return new PathBuilderImpl(schema, schema, []);
20
+ }
21
+ /**
22
+ * Parse a Path from a string.
23
+ *
24
+ * Throws an InvalidPathError if the path is invalid.
25
+ *
26
+ * Note that a Registry must be provided via the options argument to parse
27
+ * paths that refer to an extension.
28
+ */
29
+ export function parsePath(schema, path, options) {
30
+ var _a, _b;
31
+ const builder = new PathBuilderImpl(schema, schema, []);
32
+ const err = (message, i) => new InvalidPathError(schema, message + " at column " + (i + 1), path);
33
+ for (let i = 0; i < path.length;) {
34
+ const token = nextToken(i, path);
35
+ const left = builder.getLeft();
36
+ let right = undefined;
37
+ if ("field" in token) {
38
+ right =
39
+ (left === null || left === void 0 ? void 0 : left.kind) != "message"
40
+ ? undefined
41
+ : ((_a = left.fields.find((field) => field.name === token.field)) !== null && _a !== void 0 ? _a : left.oneofs.find((oneof) => oneof.name === token.field));
42
+ if (!right) {
43
+ throw err(`Unknown field "${token.field}"`, i);
44
+ }
45
+ }
46
+ else if ("ext" in token) {
47
+ right = (_b = options === null || options === void 0 ? void 0 : options.registry) === null || _b === void 0 ? void 0 : _b.getExtension(token.ext);
48
+ if (!right) {
49
+ throw err(`Unknown extension "${token.ext}"`, i);
50
+ }
51
+ }
52
+ else if ("val" in token) {
53
+ // list or map
54
+ right =
55
+ (left === null || left === void 0 ? void 0 : left.kind) == "field" &&
56
+ left.fieldKind == "list" &&
57
+ typeof token.val == "bigint"
58
+ ? { kind: "list_sub", index: Number(token.val) }
59
+ : { kind: "map_sub", key: token.val };
60
+ }
61
+ else if ("err" in token) {
62
+ throw err(token.err, token.i);
63
+ }
64
+ if (right) {
65
+ try {
66
+ builder.add([right]);
67
+ }
68
+ catch (e) {
69
+ throw err(e instanceof InvalidPathError ? e.message : String(e), i);
70
+ }
71
+ }
72
+ i = token.i;
73
+ }
74
+ return builder.toPath();
75
+ }
76
+ /**
77
+ * Stringify a path.
78
+ */
79
+ export function pathToString(path) {
80
+ const str = [];
81
+ for (const ele of path) {
82
+ switch (ele.kind) {
83
+ case "field":
84
+ case "oneof":
85
+ if (str.length > 0) {
86
+ str.push(".");
87
+ }
88
+ str.push(ele.name);
89
+ break;
90
+ case "extension":
91
+ str.push("[", ele.typeName, "]");
92
+ break;
93
+ case "list_sub":
94
+ str.push("[", ele.index, "]");
95
+ break;
96
+ case "map_sub":
97
+ if (typeof ele.key == "string") {
98
+ str.push('["', ele.key
99
+ .split("\\")
100
+ .join("\\\\")
101
+ .split('"')
102
+ .join('\\"')
103
+ .split("\r")
104
+ .join("\\r")
105
+ .split("\n")
106
+ .join("\\n"), '"]');
107
+ }
108
+ else {
109
+ str.push("[", ele.key, "]");
110
+ }
111
+ break;
112
+ }
113
+ }
114
+ return str.join("");
115
+ }
116
+ /**
117
+ * InvalidPathError is thrown for invalid Paths, for example during parsing from
118
+ * a string, or when a new Path is built.
119
+ */
120
+ export class InvalidPathError extends Error {
121
+ constructor(schema, message, path) {
122
+ super(message);
123
+ this.name = "InvalidPathError";
124
+ this.schema = schema;
125
+ this.path = path;
126
+ // see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#example
127
+ Object.setPrototypeOf(this, new.target.prototype);
128
+ }
129
+ }
130
+ class PathBuilderImpl {
131
+ constructor(schema, left, path) {
132
+ this.schema = schema;
133
+ this.left = left;
134
+ this.path = path;
135
+ }
136
+ getLeft() {
137
+ return this.left;
138
+ }
139
+ field(field) {
140
+ return this.push(field);
141
+ }
142
+ oneof(oneof) {
143
+ return this.push(oneof);
144
+ }
145
+ extension(extension) {
146
+ return this.push(extension);
147
+ }
148
+ list(index) {
149
+ return this.push({ kind: "list_sub", index });
150
+ }
151
+ map(key) {
152
+ return this.push({ kind: "map_sub", key });
153
+ }
154
+ add(pathOrBuilder) {
155
+ const path = Array.isArray(pathOrBuilder)
156
+ ? pathOrBuilder
157
+ : pathOrBuilder.toPath();
158
+ const l = this.path.length;
159
+ try {
160
+ for (const ele of path) {
161
+ this.push(ele);
162
+ }
163
+ }
164
+ catch (e) {
165
+ // undo pushes
166
+ this.path.splice(l);
167
+ throw e;
168
+ }
169
+ return this;
170
+ }
171
+ toPath() {
172
+ return this.path.concat();
173
+ }
174
+ clone() {
175
+ return new PathBuilderImpl(this.schema, this.left, this.path.concat());
176
+ }
177
+ push(ele) {
178
+ switch (ele.kind) {
179
+ case "field":
180
+ if (!this.left ||
181
+ this.left.kind != "message" ||
182
+ this.left.typeName != ele.parent.typeName) {
183
+ throw this.err("field access");
184
+ }
185
+ this.path.push(ele);
186
+ this.left =
187
+ ele.fieldKind == "message"
188
+ ? ele.message
189
+ : ele.fieldKind == "list" || ele.fieldKind == "map"
190
+ ? ele
191
+ : undefined;
192
+ return this;
193
+ case "oneof":
194
+ if (!this.left ||
195
+ this.left.kind != "message" ||
196
+ this.left.typeName != ele.parent.typeName) {
197
+ throw this.err("oneof access");
198
+ }
199
+ this.path.push(ele);
200
+ this.left = undefined;
201
+ return this;
202
+ case "extension":
203
+ if (!this.left ||
204
+ this.left.kind != "message" ||
205
+ this.left.typeName != ele.extendee.typeName) {
206
+ throw this.err("extension access");
207
+ }
208
+ this.path.push(ele);
209
+ this.left = ele.fieldKind == "message" ? ele.message : undefined;
210
+ return this;
211
+ case "list_sub":
212
+ if (!this.left ||
213
+ this.left.kind != "field" ||
214
+ this.left.fieldKind != "list") {
215
+ throw this.err("list access");
216
+ }
217
+ if (ele.index < 0 || !Number.isInteger(ele.index)) {
218
+ throw this.err("list index");
219
+ }
220
+ this.path.push(ele);
221
+ this.left =
222
+ this.left.listKind == "message" ? this.left.message : undefined;
223
+ return this;
224
+ case "map_sub":
225
+ if (!this.left ||
226
+ this.left.kind != "field" ||
227
+ this.left.fieldKind != "map") {
228
+ throw this.err("map access");
229
+ }
230
+ if (!checkKeyType(ele.key, this.left.mapKey)) {
231
+ throw this.err("map key");
232
+ }
233
+ this.path.push(ele);
234
+ this.left =
235
+ this.left.mapKind == "message" ? this.left.message : undefined;
236
+ return this;
237
+ }
238
+ }
239
+ err(what) {
240
+ return new InvalidPathError(this.schema, "Invalid " + what, this.path);
241
+ }
242
+ }
243
+ function checkKeyType(key, type) {
244
+ switch (type) {
245
+ case ScalarType.STRING:
246
+ return typeof key == "string";
247
+ case ScalarType.INT32:
248
+ case ScalarType.UINT32:
249
+ case ScalarType.SINT32:
250
+ case ScalarType.SFIXED32:
251
+ case ScalarType.FIXED32:
252
+ return typeof key == "number";
253
+ case ScalarType.UINT64:
254
+ case ScalarType.INT64:
255
+ case ScalarType.FIXED64:
256
+ case ScalarType.SFIXED64:
257
+ case ScalarType.SINT64:
258
+ return typeof key == "bigint";
259
+ case ScalarType.BOOL:
260
+ return typeof key == "boolean";
261
+ }
262
+ }
263
+ function nextToken(i, path) {
264
+ const re_extension = /^[A-Za-z_][A-Za-z_0-9]*(?:\.[A-Za-z_][A-Za-z_0-9]*)*$/;
265
+ const re_field = /^[A-Za-z_][A-Za-z_0-9]*$/;
266
+ if (path[i] == "[") {
267
+ i++;
268
+ while (path[i] == " ") {
269
+ // skip leading whitespace
270
+ i++;
271
+ }
272
+ if (i >= path.length) {
273
+ return { err: "Premature end", i: path.length - 1 };
274
+ }
275
+ let token;
276
+ if (path[i] == `"`) {
277
+ // string literal
278
+ i++;
279
+ let val = "";
280
+ for (;;) {
281
+ if (path[i] == `"`) {
282
+ // end of string literal
283
+ i++;
284
+ break;
285
+ }
286
+ if (path[i] == "\\") {
287
+ switch (path[i + 1]) {
288
+ case `"`:
289
+ case "\\":
290
+ val += path[i + 1];
291
+ break;
292
+ case "r":
293
+ val += "\r";
294
+ break;
295
+ case "n":
296
+ val += "\n";
297
+ break;
298
+ default:
299
+ return { err: "Invalid escape sequence", i };
300
+ }
301
+ i++;
302
+ }
303
+ else {
304
+ val += path[i];
305
+ }
306
+ if (i >= path.length) {
307
+ return { err: "Premature end of string", i: path.length - 1 };
308
+ }
309
+ i++;
310
+ }
311
+ token = { val };
312
+ }
313
+ else if (path[i].match(/\d/)) {
314
+ // integer literal
315
+ const start = i;
316
+ while (i < path.length && /\d/.test(path[i])) {
317
+ i++;
318
+ }
319
+ token = { val: BigInt(path.substring(start, i)) };
320
+ }
321
+ else if (path[i] == "]") {
322
+ return { err: "Premature ]", i };
323
+ }
324
+ else {
325
+ // extension identifier or bool literal
326
+ const start = i;
327
+ while (i < path.length && path[i] != " " && path[i] != "]") {
328
+ i++;
329
+ }
330
+ const name = path.substring(start, i);
331
+ if (name === "true") {
332
+ token = { val: true };
333
+ }
334
+ else if (name === "false") {
335
+ token = { val: false };
336
+ }
337
+ else if (re_extension.test(name)) {
338
+ token = { ext: name };
339
+ }
340
+ else {
341
+ return { err: "Invalid ident", i: start };
342
+ }
343
+ }
344
+ while (path[i] == " ") {
345
+ // skip trailing whitespace
346
+ i++;
347
+ }
348
+ if (path[i] != "]") {
349
+ return { err: "Missing ]", i };
350
+ }
351
+ i++;
352
+ return Object.assign(Object.assign({}, token), { i });
353
+ }
354
+ // field identifier
355
+ if (i > 0) {
356
+ if (path[i] != ".") {
357
+ return { err: `Expected "."`, i };
358
+ }
359
+ i++;
360
+ }
361
+ const start = i;
362
+ while (i < path.length && path[i] != "." && path[i] != "[") {
363
+ i++;
364
+ }
365
+ const field = path.substring(start, i);
366
+ return re_field.test(field)
367
+ ? { field, i }
368
+ : { err: "Invalid ident", i: start };
369
+ }
@@ -136,7 +136,7 @@ function checkScalarValue(value, scalar) {
136
136
  protoInt64.parse(value);
137
137
  return true;
138
138
  }
139
- catch (e) {
139
+ catch (_) {
140
140
  return `${value} out of range`;
141
141
  }
142
142
  }
@@ -151,7 +151,7 @@ function checkScalarValue(value, scalar) {
151
151
  protoInt64.uParse(value);
152
152
  return true;
153
153
  }
154
- catch (e) {
154
+ catch (_) {
155
155
  return `${value} out of range`;
156
156
  }
157
157
  }
@@ -164,7 +164,7 @@ function reasonSingular(field, val, details) {
164
164
  if (field.scalar !== undefined) {
165
165
  return `expected ${scalarTypeDescription(field.scalar)}` + details;
166
166
  }
167
- else if (field.enum !== undefined) {
167
+ if (field.enum !== undefined) {
168
168
  return `expected ${field.enum.toString()}` + details;
169
169
  }
170
170
  return `expected ${formatReflectMessage(field.message)}` + details;
@@ -1,4 +1,4 @@
1
- import { type DescField, type DescMessage, type DescOneof } from "../descriptors.js";
1
+ import type { DescField, DescMessage, DescOneof } from "../descriptors.js";
2
2
  import { unsafeLocal } from "./unsafe.js";
3
3
  import type { Message, UnknownField } from "../types.js";
4
4
  import type { ScalarValue } from "./scalar.js";
@@ -11,5 +11,4 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import {} from "../descriptors.js";
15
14
  import { unsafeLocal } from "./unsafe.js";
@@ -37,7 +37,9 @@ check = true) {
37
37
  class ReflectMessageImpl {
38
38
  get sortedFields() {
39
39
  var _a;
40
- return ((_a = this._sortedFields) !== null && _a !== void 0 ? _a : (this._sortedFields = this.desc.fields
40
+ return ((_a = this._sortedFields) !== null && _a !== void 0 ? _a :
41
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
42
+ (this._sortedFields = this.desc.fields
41
43
  .concat()
42
44
  .sort((a, b) => a.number - b.number)));
43
45
  }
@@ -77,14 +79,17 @@ class ReflectMessageImpl {
77
79
  // eslint-disable-next-line no-case-declarations
78
80
  let list = this.lists.get(field);
79
81
  if (!list || list[unsafeLocal] !== value) {
80
- this.lists.set(field, (list = new ReflectListImpl(field, value, this.check)));
82
+ this.lists.set(field,
83
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
84
+ (list = new ReflectListImpl(field, value, this.check)));
81
85
  }
82
86
  return list;
83
87
  case "map":
84
- // eslint-disable-next-line no-case-declarations
85
88
  let map = this.maps.get(field);
86
89
  if (!map || map[unsafeLocal] !== value) {
87
- this.maps.set(field, (map = new ReflectMapImpl(field, value, this.check)));
90
+ this.maps.set(field,
91
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
92
+ (map = new ReflectMapImpl(field, value, this.check)));
88
93
  }
89
94
  return map;
90
95
  case "message":
@@ -407,7 +412,6 @@ function mapKeyToReflect(key, type) {
407
412
  return key;
408
413
  }
409
414
  function longToReflect(field, value) {
410
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
411
415
  switch (field.scalar) {
412
416
  case ScalarType.INT64:
413
417
  case ScalarType.SFIXED64:
@@ -430,7 +434,6 @@ function longToReflect(field, value) {
430
434
  return value;
431
435
  }
432
436
  function longToLocal(field, value) {
433
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
434
437
  switch (field.scalar) {
435
438
  case ScalarType.INT64:
436
439
  case ScalarType.SFIXED64:
@@ -491,7 +494,6 @@ function wktValueToReflect(json) {
491
494
  $typeName: "google.protobuf.Value",
492
495
  kind: { case: undefined },
493
496
  };
494
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- invalid input is unselected kind
495
497
  switch (typeof json) {
496
498
  case "number":
497
499
  value.kind = { case: "numberValue", value: json };
@@ -37,7 +37,6 @@ export function scalarEquals(type, a, b) {
37
37
  return true;
38
38
  }
39
39
  // Special case 64-bit integers - we support number, string and bigint representation.
40
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
41
40
  switch (type) {
42
41
  case ScalarType.UINT64:
43
42
  case ScalarType.FIXED64:
@@ -60,10 +59,6 @@ export function scalarZeroValue(type, longAsString) {
60
59
  return "";
61
60
  case ScalarType.BOOL:
62
61
  return false;
63
- default:
64
- // Handles INT32, UINT32, SINT32, FIXED32, SFIXED32.
65
- // We do not use individual cases to save a few bytes code size.
66
- return 0;
67
62
  case ScalarType.DOUBLE:
68
63
  case ScalarType.FLOAT:
69
64
  return 0.0;
@@ -75,6 +70,10 @@ export function scalarZeroValue(type, longAsString) {
75
70
  return (longAsString ? "0" : protoInt64.zero);
76
71
  case ScalarType.BYTES:
77
72
  return new Uint8Array(0);
73
+ default:
74
+ // Handles INT32, UINT32, SINT32, FIXED32, SFIXED32.
75
+ // We do not use individual cases to save a few bytes code size.
76
+ return 0;
78
77
  }
79
78
  }
80
79
  /**
@@ -5,15 +5,13 @@ export declare const unsafeLocal: unique symbol;
5
5
  *
6
6
  * @private
7
7
  */
8
- export declare function unsafeOneofCase(target: Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
9
- oneof: DescOneof): DescField | undefined;
8
+ export declare function unsafeOneofCase(target: Record<string, any>, oneof: DescOneof): DescField | undefined;
10
9
  /**
11
10
  * Returns true if the field is set.
12
11
  *
13
12
  * @private
14
13
  */
15
- export declare function unsafeIsSet(target: Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
16
- field: DescField): boolean;
14
+ export declare function unsafeIsSet(target: Record<string, any>, field: DescField): boolean;
17
15
  /**
18
16
  * Returns true if the field is set, but only for singular fields with explicit
19
17
  * presence (proto2).
@@ -38,5 +36,4 @@ export declare function unsafeSet(target: Record<string, unknown>, field: DescFi
38
36
  *
39
37
  * @private
40
38
  */
41
- export declare function unsafeClear(target: Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
42
- field: DescField): void;
39
+ export declare function unsafeClear(target: Record<string, any>, field: DescField): void;
@@ -20,8 +20,9 @@ export const unsafeLocal = Symbol.for("reflect unsafe local");
20
20
  *
21
21
  * @private
22
22
  */
23
- export function unsafeOneofCase(target, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
24
- oneof) {
23
+ export function unsafeOneofCase(
24
+ // biome-ignore lint/suspicious/noExplicitAny: `any` is the best choice for dynamic access
25
+ target, oneof) {
25
26
  const c = target[oneof.localName].case;
26
27
  if (c === undefined) {
27
28
  return c;
@@ -33,11 +34,12 @@ oneof) {
33
34
  *
34
35
  * @private
35
36
  */
36
- export function unsafeIsSet(target, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
37
- field) {
37
+ export function unsafeIsSet(
38
+ // biome-ignore lint/suspicious/noExplicitAny: `any` is the best choice for dynamic access
39
+ target, field) {
38
40
  const name = field.localName;
39
41
  if (field.oneof) {
40
- return target[field.oneof.localName].case === name; // eslint-disable-line @typescript-eslint/no-unsafe-member-access
42
+ return target[field.oneof.localName].case === name;
41
43
  }
42
44
  if (field.presence != IMPLICIT) {
43
45
  // Fields with explicit presence have properties on the prototype chain
@@ -45,12 +47,11 @@ field) {
45
47
  return (target[name] !== undefined &&
46
48
  Object.prototype.hasOwnProperty.call(target, name));
47
49
  }
48
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
49
50
  switch (field.fieldKind) {
50
51
  case "list":
51
52
  return target[name].length > 0;
52
53
  case "map":
53
- return Object.keys(target[name]).length > 0; // eslint-disable-line @typescript-eslint/no-unsafe-argument
54
+ return Object.keys(target[name]).length > 0;
54
55
  case "scalar":
55
56
  return !isScalarZeroValue(field.scalar, target[name]);
56
57
  case "enum":
@@ -104,8 +105,9 @@ export function unsafeSet(target, field, value) {
104
105
  *
105
106
  * @private
106
107
  */
107
- export function unsafeClear(target, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
108
- field) {
108
+ export function unsafeClear(
109
+ // biome-ignore lint/suspicious/noExplicitAny: `any` is the best choice for dynamic access
110
+ target, field) {
109
111
  const name = field.localName;
110
112
  if (field.oneof) {
111
113
  const oneofLocalName = field.oneof.localName;
@@ -120,7 +122,6 @@ field) {
120
122
  delete target[name];
121
123
  }
122
124
  else {
123
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
124
125
  switch (field.fieldKind) {
125
126
  case "map":
126
127
  target[name] = {};