protobufjs 8.2.0 → 8.3.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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v8.2.0 (c) 2016, daniel wirtz
3
- * compiled sat, 09 may 2026 19:37:43 utc
2
+ * protobuf.js v8.3.0 (c) 2016, daniel wirtz
3
+ * compiled wed, 13 may 2026 21:15:34 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -2027,12 +2027,19 @@ function merge(dst, src, ifNotSet) { // used by converters
2027
2027
 
2028
2028
  util.merge = merge;
2029
2029
 
2030
+ /**
2031
+ * Schema declaration nesting limit.
2032
+ * @memberof util
2033
+ * @type {number}
2034
+ */
2035
+ util.nestingLimit = 32; // protoc: MaxMessageDeclarationNestingDepth
2036
+
2030
2037
  /**
2031
2038
  * Recursion limit.
2032
2039
  * @memberof util
2033
2040
  * @type {number}
2034
2041
  */
2035
- util.recursionLimit = 100;
2042
+ util.recursionLimit = 100; // protoc: CodedInputStream::default_recursion_limit_
2036
2043
 
2037
2044
  /**
2038
2045
  * Makes a property safe for assignment as an own property.
@@ -2330,19 +2337,7 @@ utf8.length = function utf8_length(string) {
2330
2337
  return len;
2331
2338
  };
2332
2339
 
2333
- /**
2334
- * Reads UTF8 bytes as a string.
2335
- * @param {Uint8Array} buffer Source buffer
2336
- * @param {number} start Source start
2337
- * @param {number} end Source end
2338
- * @returns {string} String read
2339
- */
2340
- utf8.read = function utf8_read(buffer, start, end) {
2341
- if (end - start < 1) {
2342
- return "";
2343
- }
2344
-
2345
- var str = "";
2340
+ function utf8_read_js(buffer, start, end, str) {
2346
2341
  for (var i = start; i < end;) {
2347
2342
  var t = buffer[i++];
2348
2343
  if (t <= 0x7F) {
@@ -2364,6 +2359,44 @@ utf8.read = function utf8_read(buffer, start, end) {
2364
2359
  }
2365
2360
  }
2366
2361
  }
2362
+ return str;
2363
+ }
2364
+
2365
+ /**
2366
+ * Reads UTF8 bytes as a string.
2367
+ * @param {Uint8Array} buffer Source buffer
2368
+ * @param {number} start Source start
2369
+ * @param {number} end Source end
2370
+ * @returns {string} String read
2371
+ */
2372
+ utf8.read = function utf8_read_ascii(buffer, start, end) {
2373
+ if (end - start < 1)
2374
+ return "";
2375
+
2376
+ var str = "",
2377
+ i = start,
2378
+ c1, c2, c3, c4, c5, c6, c7, c8;
2379
+
2380
+ for (; i + 7 < end; i += 8) {
2381
+ c1 = buffer[i];
2382
+ c2 = buffer[i + 1];
2383
+ c3 = buffer[i + 2];
2384
+ c4 = buffer[i + 3];
2385
+ c5 = buffer[i + 4];
2386
+ c6 = buffer[i + 5];
2387
+ c7 = buffer[i + 6];
2388
+ c8 = buffer[i + 7];
2389
+ if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
2390
+ return utf8_read_js(buffer, i, end, str);
2391
+ str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
2392
+ }
2393
+
2394
+ for (; i < end; ++i) {
2395
+ c1 = buffer[i];
2396
+ if (c1 & 0x80)
2397
+ return utf8_read_js(buffer, i, end, str);
2398
+ str += String.fromCharCode(c1);
2399
+ }
2367
2400
 
2368
2401
  return str;
2369
2402
  };
@@ -2578,6 +2611,11 @@ function writeByte(val, buf, pos) {
2578
2611
  buf[pos] = val & 255;
2579
2612
  }
2580
2613
 
2614
+ function writeStringAscii(val, buf, pos) {
2615
+ for (var i = 0; i < val.length;)
2616
+ buf[pos++] = val.charCodeAt(i++);
2617
+ }
2618
+
2581
2619
  function writeVarint32(val, buf, pos) {
2582
2620
  while (val > 127) {
2583
2621
  buf[pos++] = val & 127 | 128;
@@ -2806,7 +2844,7 @@ Writer.prototype.raw = function write_raw(value) {
2806
2844
  Writer.prototype.string = function write_string(value) {
2807
2845
  var len = utf8.length(value);
2808
2846
  return len
2809
- ? this.uint32(len)._push(utf8.write, len, value)
2847
+ ? this.uint32(len)._push(len === value.length ? writeStringAscii : utf8.write, len, value)
2810
2848
  : this._push(writeByte, 1, 0);
2811
2849
  };
2812
2850
 
@@ -2961,6 +2999,11 @@ BufferWriter.prototype.raw = function write_raw_buffer(value) {
2961
2999
  return len ? this._push(BufferWriter.writeBytesBuffer, len, value) : this;
2962
3000
  };
2963
3001
 
3002
+ function writeStringBufferAscii(val, buf, pos) {
3003
+ for (var i = 0; i < val.length;)
3004
+ buf[pos++] = val.charCodeAt(i++);
3005
+ }
3006
+
2964
3007
  function writeStringBuffer(val, buf, pos) {
2965
3008
  if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)
2966
3009
  util.utf8.write(val, buf, pos);
@@ -2977,7 +3020,7 @@ BufferWriter.prototype.string = function write_string_buffer(value) {
2977
3020
  var len = util.Buffer.byteLength(value);
2978
3021
  this.uint32(len);
2979
3022
  if (len)
2980
- this._push(writeStringBuffer, len, value);
3023
+ this._push(len === value.length && len < 40 ? writeStringBufferAscii : writeStringBuffer, len, value);
2981
3024
  return this;
2982
3025
  };
2983
3026