protobufjs 6.8.4 → 6.8.8
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/CHANGELOG.md +46 -0
- package/README.md +2 -2
- package/cli/node_modules/os-tmpdir/index.js +25 -0
- package/cli/node_modules/os-tmpdir/license +21 -0
- package/cli/node_modules/os-tmpdir/readme.md +32 -0
- package/cli/node_modules/tmp/LICENSE +21 -0
- package/cli/node_modules/tmp/README.md +314 -0
- package/cli/node_modules/tmp/lib/tmp.js +611 -0
- package/cli/pbjs.d.ts +1 -1
- package/cli/pbjs.js +11 -1
- package/cli/pbts.d.ts +1 -1
- package/cli/pbts.js +36 -7
- package/cli/targets/proto.js +1 -1
- package/cli/targets/static.js +3 -6
- package/dist/light/protobuf.js +143 -64
- 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 +23 -14
- 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 +268 -90
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor/index.d.ts +0 -1
- package/ext/descriptor/index.js +3 -0
- package/index.d.ts +57 -16
- package/package-lock.json +4579 -3191
- package/package.json +122 -125
- package/src/common.js +22 -1
- package/src/converter.js +9 -3
- package/src/enum.js +17 -5
- package/src/field.js +17 -4
- package/src/index-light.js +2 -2
- package/src/index-minimal.js +1 -1
- package/src/mapfield.js +9 -5
- package/src/message.js +1 -1
- package/src/method.js +14 -4
- package/src/namespace.js +14 -10
- package/src/object.js +1 -0
- package/src/oneof.js +14 -4
- package/src/parse.js +11 -3
- package/src/reader.js +2 -4
- package/src/root.js +3 -2
- package/src/service.js +8 -4
- package/src/tokenize.js +92 -22
- package/src/type.js +10 -5
- package/src/util/minimal.js +11 -2
- package/google/protobuf/field_mask.json +0 -21
- package/google/protobuf/field_mask.proto +0 -7
package/ext/descriptor/index.js
CHANGED
|
@@ -96,6 +96,9 @@ Root.fromDescriptor = function fromDescriptor(descriptor) {
|
|
|
96
96
|
if (fileDescriptor.extension)
|
|
97
97
|
for (i = 0; i < fileDescriptor.extension.length; ++i)
|
|
98
98
|
filePackage.add(Field.fromDescriptor(fileDescriptor.extension[i]));
|
|
99
|
+
if (fileDescriptor.service)
|
|
100
|
+
for (i = 0; i < fileDescriptor.service.length; ++i)
|
|
101
|
+
filePackage.add(Service.fromDescriptor(fileDescriptor.service[i]));
|
|
99
102
|
var opts = fromDescriptorOptions(fileDescriptor.options, exports.FileOptions);
|
|
100
103
|
if (opts) {
|
|
101
104
|
var ks = Object.keys(opts);
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'.
|
|
2
|
+
|
|
1
3
|
export as namespace protobuf;
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -105,6 +107,7 @@ export namespace common {
|
|
|
105
107
|
* - google/protobuf/any.proto
|
|
106
108
|
* - google/protobuf/duration.proto
|
|
107
109
|
* - google/protobuf/empty.proto
|
|
110
|
+
* - google/protobuf/field_mask.proto
|
|
108
111
|
* - google/protobuf/struct.proto
|
|
109
112
|
* - google/protobuf/timestamp.proto
|
|
110
113
|
* - google/protobuf/wrappers.proto
|
|
@@ -155,8 +158,10 @@ export class Enum extends ReflectionObject {
|
|
|
155
158
|
* @param name Unique name within its namespace
|
|
156
159
|
* @param [values] Enum values as an object, by name
|
|
157
160
|
* @param [options] Declared options
|
|
161
|
+
* @param [comment] The comment for this enum
|
|
162
|
+
* @param [comments] The value comments for this enum
|
|
158
163
|
*/
|
|
159
|
-
constructor(name: string, values?: { [k: string]: number }, options?: { [k: string]: any });
|
|
164
|
+
constructor(name: string, values?: { [k: string]: number }, options?: { [k: string]: any }, comment?: string, comments?: { [k: string]: string });
|
|
160
165
|
|
|
161
166
|
/** Enum values by id. */
|
|
162
167
|
public valuesById: { [k: number]: string };
|
|
@@ -164,6 +169,9 @@ export class Enum extends ReflectionObject {
|
|
|
164
169
|
/** Enum values by name. */
|
|
165
170
|
public values: { [k: string]: number };
|
|
166
171
|
|
|
172
|
+
/** Enum comment text. */
|
|
173
|
+
public comment: (string|null);
|
|
174
|
+
|
|
167
175
|
/** Value comment texts, if any. */
|
|
168
176
|
public comments: { [k: string]: string };
|
|
169
177
|
|
|
@@ -181,9 +189,10 @@ export class Enum extends ReflectionObject {
|
|
|
181
189
|
|
|
182
190
|
/**
|
|
183
191
|
* Converts this enum to an enum descriptor.
|
|
192
|
+
* @param [toJSONOptions] JSON conversion options
|
|
184
193
|
* @returns Enum descriptor
|
|
185
194
|
*/
|
|
186
|
-
public toJSON(): IEnum;
|
|
195
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IEnum;
|
|
187
196
|
|
|
188
197
|
/**
|
|
189
198
|
* Adds a value to this enum.
|
|
@@ -287,8 +296,9 @@ export class FieldBase extends ReflectionObject {
|
|
|
287
296
|
* @param [rule="optional"] Field rule
|
|
288
297
|
* @param [extend] Extended type if different from parent
|
|
289
298
|
* @param [options] Declared options
|
|
299
|
+
* @param [comment] Comment associated with this field
|
|
290
300
|
*/
|
|
291
|
-
constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any });
|
|
301
|
+
constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
|
|
292
302
|
|
|
293
303
|
/** Field rule, if any. */
|
|
294
304
|
public rule?: string;
|
|
@@ -341,11 +351,15 @@ export class FieldBase extends ReflectionObject {
|
|
|
341
351
|
/** Sister-field within the declaring namespace if an extended field. */
|
|
342
352
|
public declaringField: (Field|null);
|
|
343
353
|
|
|
354
|
+
/** Comment for this field. */
|
|
355
|
+
public comment: (string|null);
|
|
356
|
+
|
|
344
357
|
/**
|
|
345
358
|
* Converts this field to a field descriptor.
|
|
359
|
+
* @param [toJSONOptions] JSON conversion options
|
|
346
360
|
* @returns Field descriptor
|
|
347
361
|
*/
|
|
348
|
-
public toJSON(): IField;
|
|
362
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IField;
|
|
349
363
|
|
|
350
364
|
/**
|
|
351
365
|
* Resolves this field's type references.
|
|
@@ -444,8 +458,9 @@ export class MapField extends FieldBase {
|
|
|
444
458
|
* @param keyType Key type
|
|
445
459
|
* @param type Value type
|
|
446
460
|
* @param [options] Declared options
|
|
461
|
+
* @param [comment] Comment associated with this field
|
|
447
462
|
*/
|
|
448
|
-
constructor(name: string, id: number, keyType: string, type: string, options?: { [k: string]: any });
|
|
463
|
+
constructor(name: string, id: number, keyType: string, type: string, options?: { [k: string]: any }, comment?: string);
|
|
449
464
|
|
|
450
465
|
/** Key type. */
|
|
451
466
|
public keyType: string;
|
|
@@ -464,9 +479,10 @@ export class MapField extends FieldBase {
|
|
|
464
479
|
|
|
465
480
|
/**
|
|
466
481
|
* Converts this map field to a map field descriptor.
|
|
482
|
+
* @param [toJSONOptions] JSON conversion options
|
|
467
483
|
* @returns Map field descriptor
|
|
468
484
|
*/
|
|
469
|
-
public toJSON(): IMapField;
|
|
485
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IMapField;
|
|
470
486
|
|
|
471
487
|
/**
|
|
472
488
|
* Map field decorator (TypeScript).
|
|
@@ -493,7 +509,7 @@ export interface IExtensionMapField extends IMapField {
|
|
|
493
509
|
}
|
|
494
510
|
|
|
495
511
|
/** Abstract runtime message. */
|
|
496
|
-
export class Message<T extends object> {
|
|
512
|
+
export class Message<T extends object = object> {
|
|
497
513
|
|
|
498
514
|
/**
|
|
499
515
|
* Constructs a new message instance.
|
|
@@ -585,8 +601,9 @@ export class Method extends ReflectionObject {
|
|
|
585
601
|
* @param [requestStream] Whether the request is streamed
|
|
586
602
|
* @param [responseStream] Whether the response is streamed
|
|
587
603
|
* @param [options] Declared options
|
|
604
|
+
* @param [comment] The comment for this method
|
|
588
605
|
*/
|
|
589
|
-
constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any });
|
|
606
|
+
constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
|
|
590
607
|
|
|
591
608
|
/** Method type. */
|
|
592
609
|
public type: string;
|
|
@@ -609,6 +626,9 @@ export class Method extends ReflectionObject {
|
|
|
609
626
|
/** Resolved response type. */
|
|
610
627
|
public resolvedResponseType: (Type|null);
|
|
611
628
|
|
|
629
|
+
/** Comment for this method */
|
|
630
|
+
public comment: (string|null);
|
|
631
|
+
|
|
612
632
|
/**
|
|
613
633
|
* Constructs a method from a method descriptor.
|
|
614
634
|
* @param name Method name
|
|
@@ -620,9 +640,10 @@ export class Method extends ReflectionObject {
|
|
|
620
640
|
|
|
621
641
|
/**
|
|
622
642
|
* Converts this method to a method descriptor.
|
|
643
|
+
* @param [toJSONOptions] JSON conversion options
|
|
623
644
|
* @returns Method descriptor
|
|
624
645
|
*/
|
|
625
|
-
public toJSON(): IMethod;
|
|
646
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IMethod;
|
|
626
647
|
}
|
|
627
648
|
|
|
628
649
|
/** Method descriptor. */
|
|
@@ -669,9 +690,10 @@ export class Namespace extends NamespaceBase {
|
|
|
669
690
|
/**
|
|
670
691
|
* Converts an array of reflection objects to JSON.
|
|
671
692
|
* @param array Object array
|
|
693
|
+
* @param [toJSONOptions] JSON conversion options
|
|
672
694
|
* @returns JSON object or `undefined` when array is empty
|
|
673
695
|
*/
|
|
674
|
-
public static arrayToJSON(array: ReflectionObject[]): ({ [k: string]: any }|undefined);
|
|
696
|
+
public static arrayToJSON(array: ReflectionObject[], toJSONOptions?: IToJSONOptions): ({ [k: string]: any }|undefined);
|
|
675
697
|
|
|
676
698
|
/**
|
|
677
699
|
* Tests if the specified id is reserved.
|
|
@@ -701,9 +723,10 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
701
723
|
|
|
702
724
|
/**
|
|
703
725
|
* Converts this namespace to a namespace descriptor.
|
|
726
|
+
* @param [toJSONOptions] JSON conversion options
|
|
704
727
|
* @returns Namespace descriptor
|
|
705
728
|
*/
|
|
706
|
-
public toJSON(): INamespace;
|
|
729
|
+
public toJSON(toJSONOptions?: IToJSONOptions): INamespace;
|
|
707
730
|
|
|
708
731
|
/**
|
|
709
732
|
* Adds nested objects to this namespace from nested object descriptors.
|
|
@@ -920,8 +943,9 @@ export class OneOf extends ReflectionObject {
|
|
|
920
943
|
* @param name Oneof name
|
|
921
944
|
* @param [fieldNames] Field names
|
|
922
945
|
* @param [options] Declared options
|
|
946
|
+
* @param [comment] Comment associated with this field
|
|
923
947
|
*/
|
|
924
|
-
constructor(name: string, fieldNames?: (string[]|{ [k: string]: any }), options?: { [k: string]: any });
|
|
948
|
+
constructor(name: string, fieldNames?: (string[]|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
|
|
925
949
|
|
|
926
950
|
/** Field names that belong to this oneof. */
|
|
927
951
|
public oneof: string[];
|
|
@@ -929,6 +953,9 @@ export class OneOf extends ReflectionObject {
|
|
|
929
953
|
/** Fields that belong to this oneof as an array for iteration. */
|
|
930
954
|
public readonly fieldsArray: Field[];
|
|
931
955
|
|
|
956
|
+
/** Comment for this field. */
|
|
957
|
+
public comment: (string|null);
|
|
958
|
+
|
|
932
959
|
/**
|
|
933
960
|
* Constructs a oneof from a oneof descriptor.
|
|
934
961
|
* @param name Oneof name
|
|
@@ -940,9 +967,10 @@ export class OneOf extends ReflectionObject {
|
|
|
940
967
|
|
|
941
968
|
/**
|
|
942
969
|
* Converts this oneof to a oneof descriptor.
|
|
970
|
+
* @param [toJSONOptions] JSON conversion options
|
|
943
971
|
* @returns Oneof descriptor
|
|
944
972
|
*/
|
|
945
|
-
public toJSON(): IOneOf;
|
|
973
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IOneOf;
|
|
946
974
|
|
|
947
975
|
/**
|
|
948
976
|
* Adds a field to this oneof and removes it from its current parent, if any.
|
|
@@ -1015,6 +1043,16 @@ export interface IParseOptions {
|
|
|
1015
1043
|
|
|
1016
1044
|
/** Keeps field casing instead of converting to camel case */
|
|
1017
1045
|
keepCase?: boolean;
|
|
1046
|
+
|
|
1047
|
+
/** Recognize double-slash comments in addition to doc-block comments. */
|
|
1048
|
+
alternateCommentMode?: boolean;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/** Options modifying the behavior of JSON serialization. */
|
|
1052
|
+
export interface IToJSONOptions {
|
|
1053
|
+
|
|
1054
|
+
/** Serializes comments. */
|
|
1055
|
+
keepComments?: boolean;
|
|
1018
1056
|
}
|
|
1019
1057
|
|
|
1020
1058
|
/**
|
|
@@ -1344,9 +1382,10 @@ export class Service extends NamespaceBase {
|
|
|
1344
1382
|
|
|
1345
1383
|
/**
|
|
1346
1384
|
* Converts this service to a service descriptor.
|
|
1385
|
+
* @param [toJSONOptions] JSON conversion options
|
|
1347
1386
|
* @returns Service descriptor
|
|
1348
1387
|
*/
|
|
1349
|
-
public toJSON(): IService;
|
|
1388
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IService;
|
|
1350
1389
|
|
|
1351
1390
|
/** Methods of this service as an array for iteration. */
|
|
1352
1391
|
public readonly methodsArray: Method[];
|
|
@@ -1427,9 +1466,10 @@ export interface ITokenizerHandle {
|
|
|
1427
1466
|
/**
|
|
1428
1467
|
* Tokenizes the given .proto source and returns an object with useful utility functions.
|
|
1429
1468
|
* @param source Source contents
|
|
1469
|
+
* @param alternateCommentMode Whether we should activate alternate comment parsing mode.
|
|
1430
1470
|
* @returns Tokenizer handle
|
|
1431
1471
|
*/
|
|
1432
|
-
export function tokenize(source: string): ITokenizerHandle;
|
|
1472
|
+
export function tokenize(source: string, alternateCommentMode: boolean): ITokenizerHandle;
|
|
1433
1473
|
|
|
1434
1474
|
export namespace tokenize {
|
|
1435
1475
|
|
|
@@ -1495,9 +1535,10 @@ export class Type extends NamespaceBase {
|
|
|
1495
1535
|
|
|
1496
1536
|
/**
|
|
1497
1537
|
* Converts this message type to a message type descriptor.
|
|
1538
|
+
* @param [toJSONOptions] JSON conversion options
|
|
1498
1539
|
* @returns Message type descriptor
|
|
1499
1540
|
*/
|
|
1500
|
-
public toJSON(): IType;
|
|
1541
|
+
public toJSON(toJSONOptions?: IToJSONOptions): IType;
|
|
1501
1542
|
|
|
1502
1543
|
/**
|
|
1503
1544
|
* Adds a nested object to this type.
|