protobufjs 7.5.8 → 7.6.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.
- package/README.md +1 -1
- package/dist/light/protobuf.js +193 -157
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +14 -5
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +213 -177
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/index.d.ts +2 -1
- package/package.json +7 -4
- package/src/converter.js +5 -3
- package/src/type.js +1 -1
- package/src/util/fs.js +11 -0
- package/src/util/minimal.js +10 -2
- package/src/util.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1779,7 +1779,7 @@ export interface IConversionOptions {
|
|
|
1779
1779
|
|
|
1780
1780
|
/**
|
|
1781
1781
|
* Long conversion type.
|
|
1782
|
-
* Valid values are `String` and `Number` (the global types).
|
|
1782
|
+
* Valid values are `BigInt`, `String` and `Number` (the global types).
|
|
1783
1783
|
* Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
|
|
1784
1784
|
*/
|
|
1785
1785
|
longs?: Function;
|
|
@@ -2484,6 +2484,7 @@ export namespace util {
|
|
|
2484
2484
|
* Requires a module only if available.
|
|
2485
2485
|
* @param moduleName Module to require
|
|
2486
2486
|
* @returns Required module if available and not empty, otherwise `null`
|
|
2487
|
+
* @deprecated Legacy optional require helper. Will be removed in a future release.
|
|
2487
2488
|
*/
|
|
2488
2489
|
function inquire(moduleName: string): object;
|
|
2489
2490
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "protobufjs",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"versionScheme": "~",
|
|
5
5
|
"description": "Protocol Buffers for JavaScript (& TypeScript).",
|
|
6
6
|
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"main": "index.js",
|
|
29
29
|
"types": "index.d.ts",
|
|
30
|
+
"browser": {
|
|
31
|
+
"fs": false
|
|
32
|
+
},
|
|
30
33
|
"publishConfig": {
|
|
31
34
|
"tag": "latest-7"
|
|
32
35
|
},
|
|
@@ -58,14 +61,14 @@
|
|
|
58
61
|
"@protobufjs/base64": "^1.1.2",
|
|
59
62
|
"@protobufjs/codegen": "^2.0.5",
|
|
60
63
|
"@protobufjs/eventemitter": "^1.1.0",
|
|
61
|
-
"@protobufjs/fetch": "^1.1.
|
|
64
|
+
"@protobufjs/fetch": "^1.1.1",
|
|
62
65
|
"@protobufjs/float": "^1.0.2",
|
|
63
|
-
"@protobufjs/inquire": "^1.1.
|
|
66
|
+
"@protobufjs/inquire": "^1.1.2",
|
|
64
67
|
"@protobufjs/path": "^1.1.2",
|
|
65
68
|
"@protobufjs/pool": "^1.1.0",
|
|
66
69
|
"@protobufjs/utf8": "^1.1.1",
|
|
67
70
|
"@types/node": ">=13.7.0",
|
|
68
|
-
"long": "^5.
|
|
71
|
+
"long": "^5.3.2"
|
|
69
72
|
},
|
|
70
73
|
"devDependencies": {
|
|
71
74
|
"benchmark": "^2.1.4",
|
package/src/converter.js
CHANGED
|
@@ -187,7 +187,9 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
|
|
|
187
187
|
case "sint64":
|
|
188
188
|
case "fixed64":
|
|
189
189
|
case "sfixed64": gen
|
|
190
|
-
("if(typeof
|
|
190
|
+
("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
|
|
191
|
+
("d%s=typeof m%s===\"number\"?BigInt(m%s):util.Long.fromBits(m%s.low>>>0,m%s.high>>>0,%j).toBigInt()", prop, prop, prop, prop, prop, isUnsigned)
|
|
192
|
+
("else if(typeof m%s===\"number\")", prop)
|
|
191
193
|
("d%s=o.longs===String?String(m%s):m%s", prop, prop, prop)
|
|
192
194
|
("else") // Long-like
|
|
193
195
|
("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true": "", prop);
|
|
@@ -255,9 +257,9 @@ converter.toObject = function toObject(mtype) {
|
|
|
255
257
|
else if (field.long) gen
|
|
256
258
|
("if(util.Long){")
|
|
257
259
|
("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
|
|
258
|
-
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
|
|
260
|
+
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!==\"undefined\"&&o.longs===BigInt?n.toBigInt():n", prop)
|
|
259
261
|
("}else")
|
|
260
|
-
("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
262
|
+
("d%s=o.longs===String?%j:typeof BigInt!==\"undefined\"&&o.longs===BigInt?BigInt(%j):%i", prop, field.typeDefault.toString(), field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
261
263
|
else if (field.bytes) {
|
|
262
264
|
var arrayDefault = Array.prototype.slice.call(field.typeDefault);
|
|
263
265
|
gen
|
package/src/type.js
CHANGED
|
@@ -580,7 +580,7 @@ Type.prototype.fromObject = function fromObject(object, depth) {
|
|
|
580
580
|
* Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
|
|
581
581
|
* @interface IConversionOptions
|
|
582
582
|
* @property {Function} [longs] Long conversion type.
|
|
583
|
-
* Valid values are `String` and `Number` (the global types).
|
|
583
|
+
* Valid values are `BigInt`, `String` and `Number` (the global types).
|
|
584
584
|
* Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
|
|
585
585
|
* @property {Function} [enums] Enum value conversion type.
|
|
586
586
|
* Only valid value is `String` (the global type).
|
package/src/util/fs.js
ADDED
package/src/util/minimal.js
CHANGED
|
@@ -125,7 +125,7 @@ util.isSet = function isSet(obj, prop) {
|
|
|
125
125
|
*/
|
|
126
126
|
util.Buffer = (function() {
|
|
127
127
|
try {
|
|
128
|
-
var Buffer = util.
|
|
128
|
+
var Buffer = util.global.Buffer;
|
|
129
129
|
// refuse to use non-node buffers if not explicitly assigned (perf reasons):
|
|
130
130
|
return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
|
|
131
131
|
} catch (e) {
|
|
@@ -179,7 +179,15 @@ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore n
|
|
|
179
179
|
*/
|
|
180
180
|
util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
|
|
181
181
|
|| /* istanbul ignore next */ util.global.Long
|
|
182
|
-
||
|
|
182
|
+
|| (function() {
|
|
183
|
+
try {
|
|
184
|
+
var Long = require("long");
|
|
185
|
+
return Long && Long.isLong ? Long : null;
|
|
186
|
+
} catch (e) {
|
|
187
|
+
/* istanbul ignore next */
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
})();
|
|
183
191
|
|
|
184
192
|
/**
|
|
185
193
|
* Regular expression used to verify 2 bit (`bool`) map keys.
|