protobufjs 7.5.1 → 7.5.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.
- package/dist/light/protobuf.js +79 -18
- 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 +2 -2
- package/dist/minimal/protobuf.min.js +2 -2
- package/dist/protobuf.js +79 -18
- 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.js +179 -69
- package/google/protobuf/descriptor.json +659 -16
- package/google/protobuf/descriptor.proto +254 -6
- package/index.d.ts +3 -15
- package/package.json +1 -1
- package/src/namespace.js +43 -9
- package/src/object.js +4 -0
- package/src/root.js +26 -7
- package/src/service.js +2 -0
- package/src/type.js +2 -0
|
@@ -2,9 +2,35 @@ syntax = "proto2";
|
|
|
2
2
|
|
|
3
3
|
package google.protobuf;
|
|
4
4
|
|
|
5
|
+
option go_package = "google.golang.org/protobuf/types/descriptorpb";
|
|
6
|
+
option java_package = "com.google.protobuf";
|
|
7
|
+
option java_outer_classname = "DescriptorProtos";
|
|
8
|
+
option csharp_namespace = "Google.Protobuf.Reflection";
|
|
9
|
+
option objc_class_prefix = "GPB";
|
|
10
|
+
option cc_enable_arenas = true;
|
|
11
|
+
option optimize_for = "SPEED";
|
|
12
|
+
|
|
5
13
|
message FileDescriptorSet {
|
|
6
14
|
|
|
7
15
|
repeated FileDescriptorProto file = 1;
|
|
16
|
+
|
|
17
|
+
extensions 536000000;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum Edition {
|
|
21
|
+
|
|
22
|
+
EDITION_UNKNOWN = 0;
|
|
23
|
+
EDITION_LEGACY = 900;
|
|
24
|
+
EDITION_PROTO2 = 998;
|
|
25
|
+
EDITION_PROTO3 = 999;
|
|
26
|
+
EDITION_2023 = 1000;
|
|
27
|
+
EDITION_2024 = 1001;
|
|
28
|
+
EDITION_1_TEST_ONLY = 1;
|
|
29
|
+
EDITION_2_TEST_ONLY = 2;
|
|
30
|
+
EDITION_99997_TEST_ONLY = 99997;
|
|
31
|
+
EDITION_99998_TEST_ONLY = 99998;
|
|
32
|
+
EDITION_99999_TEST_ONLY = 99999;
|
|
33
|
+
EDITION_MAX = 2147483647;
|
|
8
34
|
}
|
|
9
35
|
|
|
10
36
|
message FileDescriptorProto {
|
|
@@ -14,6 +40,7 @@ message FileDescriptorProto {
|
|
|
14
40
|
repeated string dependency = 3;
|
|
15
41
|
repeated int32 public_dependency = 10;
|
|
16
42
|
repeated int32 weak_dependency = 11;
|
|
43
|
+
repeated string option_dependency = 15;
|
|
17
44
|
repeated DescriptorProto message_type = 4;
|
|
18
45
|
repeated EnumDescriptorProto enum_type = 5;
|
|
19
46
|
repeated ServiceDescriptorProto service = 6;
|
|
@@ -21,6 +48,7 @@ message FileDescriptorProto {
|
|
|
21
48
|
optional FileOptions options = 8;
|
|
22
49
|
optional SourceCodeInfo source_code_info = 9;
|
|
23
50
|
optional string syntax = 12;
|
|
51
|
+
optional Edition edition = 14;
|
|
24
52
|
}
|
|
25
53
|
|
|
26
54
|
message DescriptorProto {
|
|
@@ -35,11 +63,13 @@ message DescriptorProto {
|
|
|
35
63
|
optional MessageOptions options = 7;
|
|
36
64
|
repeated ReservedRange reserved_range = 9;
|
|
37
65
|
repeated string reserved_name = 10;
|
|
66
|
+
optional SymbolVisibility visibility = 11;
|
|
38
67
|
|
|
39
68
|
message ExtensionRange {
|
|
40
69
|
|
|
41
70
|
optional int32 start = 1;
|
|
42
71
|
optional int32 end = 2;
|
|
72
|
+
optional ExtensionRangeOptions options = 3;
|
|
43
73
|
}
|
|
44
74
|
|
|
45
75
|
message ReservedRange {
|
|
@@ -49,6 +79,33 @@ message DescriptorProto {
|
|
|
49
79
|
}
|
|
50
80
|
}
|
|
51
81
|
|
|
82
|
+
message ExtensionRangeOptions {
|
|
83
|
+
|
|
84
|
+
repeated UninterpretedOption uninterpreted_option = 999;
|
|
85
|
+
repeated Declaration declaration = 2 [retention="RETENTION_SOURCE"];
|
|
86
|
+
optional FeatureSet features = 50;
|
|
87
|
+
optional VerificationState verification = 3 [default=UNVERIFIED, retention="RETENTION_SOURCE"];
|
|
88
|
+
|
|
89
|
+
message Declaration {
|
|
90
|
+
|
|
91
|
+
optional int32 number = 1;
|
|
92
|
+
optional string full_name = 2;
|
|
93
|
+
optional string type = 3;
|
|
94
|
+
optional bool reserved = 5;
|
|
95
|
+
optional bool repeated = 6;
|
|
96
|
+
|
|
97
|
+
reserved 4;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
enum VerificationState {
|
|
101
|
+
|
|
102
|
+
DECLARATION = 0;
|
|
103
|
+
UNVERIFIED = 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
extensions 1000 to max;
|
|
107
|
+
}
|
|
108
|
+
|
|
52
109
|
message FieldDescriptorProto {
|
|
53
110
|
|
|
54
111
|
optional string name = 1;
|
|
@@ -61,6 +118,7 @@ message FieldDescriptorProto {
|
|
|
61
118
|
optional int32 oneof_index = 9;
|
|
62
119
|
optional string json_name = 10;
|
|
63
120
|
optional FieldOptions options = 8;
|
|
121
|
+
optional bool proto3_optional = 17;
|
|
64
122
|
|
|
65
123
|
enum Type {
|
|
66
124
|
|
|
@@ -87,8 +145,8 @@ message FieldDescriptorProto {
|
|
|
87
145
|
enum Label {
|
|
88
146
|
|
|
89
147
|
LABEL_OPTIONAL = 1;
|
|
90
|
-
LABEL_REQUIRED = 2;
|
|
91
148
|
LABEL_REPEATED = 3;
|
|
149
|
+
LABEL_REQUIRED = 2;
|
|
92
150
|
}
|
|
93
151
|
}
|
|
94
152
|
|
|
@@ -103,6 +161,15 @@ message EnumDescriptorProto {
|
|
|
103
161
|
optional string name = 1;
|
|
104
162
|
repeated EnumValueDescriptorProto value = 2;
|
|
105
163
|
optional EnumOptions options = 3;
|
|
164
|
+
repeated EnumReservedRange reserved_range = 4;
|
|
165
|
+
repeated string reserved_name = 5;
|
|
166
|
+
optional SymbolVisibility visibility = 6;
|
|
167
|
+
|
|
168
|
+
message EnumReservedRange {
|
|
169
|
+
|
|
170
|
+
optional int32 start = 1;
|
|
171
|
+
optional int32 end = 2;
|
|
172
|
+
}
|
|
106
173
|
}
|
|
107
174
|
|
|
108
175
|
message EnumValueDescriptorProto {
|
|
@@ -142,9 +209,15 @@ message FileOptions {
|
|
|
142
209
|
optional bool java_generic_services = 17;
|
|
143
210
|
optional bool py_generic_services = 18;
|
|
144
211
|
optional bool deprecated = 23;
|
|
145
|
-
optional bool cc_enable_arenas = 31;
|
|
212
|
+
optional bool cc_enable_arenas = 31 [default=true];
|
|
146
213
|
optional string objc_class_prefix = 36;
|
|
147
214
|
optional string csharp_namespace = 37;
|
|
215
|
+
optional string swift_prefix = 39;
|
|
216
|
+
optional string php_class_prefix = 40;
|
|
217
|
+
optional string php_namespace = 41;
|
|
218
|
+
optional string php_metadata_namespace = 44;
|
|
219
|
+
optional string ruby_package = 45;
|
|
220
|
+
optional FeatureSet features = 50;
|
|
148
221
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
149
222
|
|
|
150
223
|
enum OptimizeMode {
|
|
@@ -156,7 +229,7 @@ message FileOptions {
|
|
|
156
229
|
|
|
157
230
|
extensions 1000 to max;
|
|
158
231
|
|
|
159
|
-
reserved 38;
|
|
232
|
+
reserved 42, "php_generic_services", 38;
|
|
160
233
|
}
|
|
161
234
|
|
|
162
235
|
message MessageOptions {
|
|
@@ -165,11 +238,13 @@ message MessageOptions {
|
|
|
165
238
|
optional bool no_standard_descriptor_accessor = 2;
|
|
166
239
|
optional bool deprecated = 3;
|
|
167
240
|
optional bool map_entry = 7;
|
|
241
|
+
optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated=true];
|
|
242
|
+
optional FeatureSet features = 12;
|
|
168
243
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
169
244
|
|
|
170
245
|
extensions 1000 to max;
|
|
171
246
|
|
|
172
|
-
reserved 8;
|
|
247
|
+
reserved 4, 5, 6, 8, 9;
|
|
173
248
|
}
|
|
174
249
|
|
|
175
250
|
message FieldOptions {
|
|
@@ -178,8 +253,15 @@ message FieldOptions {
|
|
|
178
253
|
optional bool packed = 2;
|
|
179
254
|
optional JSType jstype = 6 [default=JS_NORMAL];
|
|
180
255
|
optional bool lazy = 5;
|
|
256
|
+
optional bool unverified_lazy = 15;
|
|
181
257
|
optional bool deprecated = 3;
|
|
182
|
-
optional bool weak = 10;
|
|
258
|
+
optional bool weak = 10 [deprecated=true];
|
|
259
|
+
optional bool debug_redact = 16;
|
|
260
|
+
optional OptionRetention retention = 17;
|
|
261
|
+
repeated OptionTargetType targets = 19;
|
|
262
|
+
repeated EditionDefault edition_defaults = 20;
|
|
263
|
+
optional FeatureSet features = 21;
|
|
264
|
+
optional FeatureSupport feature_support = 22;
|
|
183
265
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
184
266
|
|
|
185
267
|
enum CType {
|
|
@@ -196,13 +278,49 @@ message FieldOptions {
|
|
|
196
278
|
JS_NUMBER = 2;
|
|
197
279
|
}
|
|
198
280
|
|
|
281
|
+
enum OptionRetention {
|
|
282
|
+
|
|
283
|
+
RETENTION_UNKNOWN = 0;
|
|
284
|
+
RETENTION_RUNTIME = 1;
|
|
285
|
+
RETENTION_SOURCE = 2;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
enum OptionTargetType {
|
|
289
|
+
|
|
290
|
+
TARGET_TYPE_UNKNOWN = 0;
|
|
291
|
+
TARGET_TYPE_FILE = 1;
|
|
292
|
+
TARGET_TYPE_EXTENSION_RANGE = 2;
|
|
293
|
+
TARGET_TYPE_MESSAGE = 3;
|
|
294
|
+
TARGET_TYPE_FIELD = 4;
|
|
295
|
+
TARGET_TYPE_ONEOF = 5;
|
|
296
|
+
TARGET_TYPE_ENUM = 6;
|
|
297
|
+
TARGET_TYPE_ENUM_ENTRY = 7;
|
|
298
|
+
TARGET_TYPE_SERVICE = 8;
|
|
299
|
+
TARGET_TYPE_METHOD = 9;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
message EditionDefault {
|
|
303
|
+
|
|
304
|
+
optional Edition edition = 3;
|
|
305
|
+
optional string value = 2;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
message FeatureSupport {
|
|
309
|
+
|
|
310
|
+
optional Edition edition_introduced = 1;
|
|
311
|
+
optional Edition edition_deprecated = 2;
|
|
312
|
+
optional string deprecation_warning = 3;
|
|
313
|
+
optional Edition edition_removed = 4;
|
|
314
|
+
}
|
|
315
|
+
|
|
199
316
|
extensions 1000 to max;
|
|
200
317
|
|
|
201
|
-
reserved 4;
|
|
318
|
+
reserved 4, 18;
|
|
202
319
|
}
|
|
203
320
|
|
|
204
321
|
message OneofOptions {
|
|
205
322
|
|
|
323
|
+
optional FeatureSet features = 1;
|
|
206
324
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
207
325
|
|
|
208
326
|
extensions 1000 to max;
|
|
@@ -212,14 +330,21 @@ message EnumOptions {
|
|
|
212
330
|
|
|
213
331
|
optional bool allow_alias = 2;
|
|
214
332
|
optional bool deprecated = 3;
|
|
333
|
+
optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated=true];
|
|
334
|
+
optional FeatureSet features = 7;
|
|
215
335
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
216
336
|
|
|
217
337
|
extensions 1000 to max;
|
|
338
|
+
|
|
339
|
+
reserved 5;
|
|
218
340
|
}
|
|
219
341
|
|
|
220
342
|
message EnumValueOptions {
|
|
221
343
|
|
|
222
344
|
optional bool deprecated = 1;
|
|
345
|
+
optional FeatureSet features = 2;
|
|
346
|
+
optional bool debug_redact = 3;
|
|
347
|
+
optional FieldOptions.FeatureSupport feature_support = 4;
|
|
223
348
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
224
349
|
|
|
225
350
|
extensions 1000 to max;
|
|
@@ -227,6 +352,7 @@ message EnumValueOptions {
|
|
|
227
352
|
|
|
228
353
|
message ServiceOptions {
|
|
229
354
|
|
|
355
|
+
optional FeatureSet features = 34;
|
|
230
356
|
optional bool deprecated = 33;
|
|
231
357
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
232
358
|
|
|
@@ -236,8 +362,17 @@ message ServiceOptions {
|
|
|
236
362
|
message MethodOptions {
|
|
237
363
|
|
|
238
364
|
optional bool deprecated = 33;
|
|
365
|
+
optional IdempotencyLevel idempotency_level = 34 [default=IDEMPOTENCY_UNKNOWN];
|
|
366
|
+
optional FeatureSet features = 35;
|
|
239
367
|
repeated UninterpretedOption uninterpreted_option = 999;
|
|
240
368
|
|
|
369
|
+
enum IdempotencyLevel {
|
|
370
|
+
|
|
371
|
+
IDEMPOTENCY_UNKNOWN = 0;
|
|
372
|
+
NO_SIDE_EFFECTS = 1;
|
|
373
|
+
IDEMPOTENT = 2;
|
|
374
|
+
}
|
|
375
|
+
|
|
241
376
|
extensions 1000 to max;
|
|
242
377
|
}
|
|
243
378
|
|
|
@@ -258,6 +393,102 @@ message UninterpretedOption {
|
|
|
258
393
|
}
|
|
259
394
|
}
|
|
260
395
|
|
|
396
|
+
message FeatureSet {
|
|
397
|
+
|
|
398
|
+
optional FieldPresence field_presence = 1 [retention="RETENTION_RUNTIME", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2023", edition_defaults.edition="EDITION_2023", edition_defaults.value="EXPLICIT"];
|
|
399
|
+
optional EnumType enum_type = 2 [retention="RETENTION_RUNTIME", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2023", edition_defaults.edition="EDITION_PROTO3", edition_defaults.value="OPEN"];
|
|
400
|
+
optional RepeatedFieldEncoding repeated_field_encoding = 3 [retention="RETENTION_RUNTIME", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2023", edition_defaults.edition="EDITION_PROTO3", edition_defaults.value="PACKED"];
|
|
401
|
+
optional Utf8Validation utf8_validation = 4 [retention="RETENTION_RUNTIME", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2023", edition_defaults.edition="EDITION_PROTO3", edition_defaults.value="VERIFY"];
|
|
402
|
+
optional MessageEncoding message_encoding = 5 [retention="RETENTION_RUNTIME", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2023", edition_defaults.edition="EDITION_LEGACY", edition_defaults.value="LENGTH_PREFIXED"];
|
|
403
|
+
optional JsonFormat json_format = 6 [retention="RETENTION_RUNTIME", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2023", edition_defaults.edition="EDITION_PROTO3", edition_defaults.value="ALLOW"];
|
|
404
|
+
optional EnforceNamingStyle enforce_naming_style = 7 [retention="RETENTION_SOURCE", targets="TARGET_TYPE_METHOD", feature_support.edition_introduced="EDITION_2024", edition_defaults.edition="EDITION_2024", edition_defaults.value="STYLE2024"];
|
|
405
|
+
optional VisibilityFeature.DefaultSymbolVisibility default_symbol_visibility = 8 [retention="RETENTION_SOURCE", targets="TARGET_TYPE_FILE", feature_support.edition_introduced="EDITION_2024", edition_defaults.edition="EDITION_2024", edition_defaults.value="EXPORT_TOP_LEVEL"];
|
|
406
|
+
|
|
407
|
+
enum FieldPresence {
|
|
408
|
+
|
|
409
|
+
FIELD_PRESENCE_UNKNOWN = 0;
|
|
410
|
+
EXPLICIT = 1;
|
|
411
|
+
IMPLICIT = 2;
|
|
412
|
+
LEGACY_REQUIRED = 3;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
enum EnumType {
|
|
416
|
+
|
|
417
|
+
ENUM_TYPE_UNKNOWN = 0;
|
|
418
|
+
OPEN = 1;
|
|
419
|
+
CLOSED = 2;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
enum RepeatedFieldEncoding {
|
|
423
|
+
|
|
424
|
+
REPEATED_FIELD_ENCODING_UNKNOWN = 0;
|
|
425
|
+
PACKED = 1;
|
|
426
|
+
EXPANDED = 2;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
enum Utf8Validation {
|
|
430
|
+
|
|
431
|
+
UTF8_VALIDATION_UNKNOWN = 0;
|
|
432
|
+
VERIFY = 2;
|
|
433
|
+
NONE = 3;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
enum MessageEncoding {
|
|
437
|
+
|
|
438
|
+
MESSAGE_ENCODING_UNKNOWN = 0;
|
|
439
|
+
LENGTH_PREFIXED = 1;
|
|
440
|
+
DELIMITED = 2;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
enum JsonFormat {
|
|
444
|
+
|
|
445
|
+
JSON_FORMAT_UNKNOWN = 0;
|
|
446
|
+
ALLOW = 1;
|
|
447
|
+
LEGACY_BEST_EFFORT = 2;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
enum EnforceNamingStyle {
|
|
451
|
+
|
|
452
|
+
ENFORCE_NAMING_STYLE_UNKNOWN = 0;
|
|
453
|
+
STYLE2024 = 1;
|
|
454
|
+
STYLE_LEGACY = 2;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
message VisibilityFeature {
|
|
458
|
+
|
|
459
|
+
enum DefaultSymbolVisibility {
|
|
460
|
+
|
|
461
|
+
DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0;
|
|
462
|
+
EXPORT_ALL = 1;
|
|
463
|
+
EXPORT_TOP_LEVEL = 2;
|
|
464
|
+
LOCAL_ALL = 3;
|
|
465
|
+
STRICT = 4;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
reserved 1 to max;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
extensions 1000 to 9994, 9995 to 9999, 10000;
|
|
472
|
+
|
|
473
|
+
reserved 999;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
message FeatureSetDefaults {
|
|
477
|
+
|
|
478
|
+
repeated FeatureSetEditionDefault defaults = 1;
|
|
479
|
+
optional Edition minimum_edition = 4;
|
|
480
|
+
optional Edition maximum_edition = 5;
|
|
481
|
+
|
|
482
|
+
message FeatureSetEditionDefault {
|
|
483
|
+
|
|
484
|
+
optional Edition edition = 3;
|
|
485
|
+
optional FeatureSet overridable_features = 4;
|
|
486
|
+
optional FeatureSet fixed_features = 5;
|
|
487
|
+
|
|
488
|
+
reserved 1, 2, "features";
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
261
492
|
message SourceCodeInfo {
|
|
262
493
|
|
|
263
494
|
repeated Location location = 1;
|
|
@@ -270,6 +501,8 @@ message SourceCodeInfo {
|
|
|
270
501
|
optional string trailing_comments = 4;
|
|
271
502
|
repeated string leading_detached_comments = 6;
|
|
272
503
|
}
|
|
504
|
+
|
|
505
|
+
extensions 536000000;
|
|
273
506
|
}
|
|
274
507
|
|
|
275
508
|
message GeneratedCodeInfo {
|
|
@@ -282,5 +515,20 @@ message GeneratedCodeInfo {
|
|
|
282
515
|
optional string source_file = 2;
|
|
283
516
|
optional int32 begin = 3;
|
|
284
517
|
optional int32 end = 4;
|
|
518
|
+
optional Semantic semantic = 5;
|
|
519
|
+
|
|
520
|
+
enum Semantic {
|
|
521
|
+
|
|
522
|
+
NONE = 0;
|
|
523
|
+
SET = 1;
|
|
524
|
+
ALIAS = 2;
|
|
525
|
+
}
|
|
285
526
|
}
|
|
286
527
|
}
|
|
528
|
+
|
|
529
|
+
enum SymbolVisibility {
|
|
530
|
+
|
|
531
|
+
VISIBILITY_UNSET = 0;
|
|
532
|
+
VISIBILITY_LOCAL = 1;
|
|
533
|
+
VISIBILITY_EXPORT = 2;
|
|
534
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -753,6 +753,9 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
753
753
|
/** Whether or not objects contained in this namespace need feature resolution. */
|
|
754
754
|
protected _needsRecursiveFeatureResolution: boolean;
|
|
755
755
|
|
|
756
|
+
/** Whether or not objects contained in this namespace need a resolve. */
|
|
757
|
+
protected _needsRecursiveResolve: boolean;
|
|
758
|
+
|
|
756
759
|
/** Nested objects of this namespace as an array for iteration. */
|
|
757
760
|
public readonly nestedArray: ReflectionObject[];
|
|
758
761
|
|
|
@@ -900,21 +903,6 @@ export abstract class ReflectionObject {
|
|
|
900
903
|
/** Unique name within its namespace. */
|
|
901
904
|
public name: string;
|
|
902
905
|
|
|
903
|
-
/** The edition specified for this object. Only relevant for top-level objects. */
|
|
904
|
-
public _edition: string;
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* The default edition to use for this object if none is specified. For legacy reasons,
|
|
908
|
-
* this is proto2 except in the JSON parsing case where it was proto3.
|
|
909
|
-
*/
|
|
910
|
-
public _defaultEdition: string;
|
|
911
|
-
|
|
912
|
-
/** Resolved Features. */
|
|
913
|
-
public _features: object;
|
|
914
|
-
|
|
915
|
-
/** Whether or not features have been resolved. */
|
|
916
|
-
public _featuresResolved: boolean;
|
|
917
|
-
|
|
918
906
|
/** Parent namespace. */
|
|
919
907
|
public parent: (Namespace|null);
|
|
920
908
|
|
package/package.json
CHANGED
package/src/namespace.js
CHANGED
|
@@ -124,6 +124,13 @@ function Namespace(name, options) {
|
|
|
124
124
|
* @protected
|
|
125
125
|
*/
|
|
126
126
|
this._needsRecursiveFeatureResolution = true;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Whether or not objects contained in this namespace need a resolve.
|
|
130
|
+
* @type {boolean}
|
|
131
|
+
* @protected
|
|
132
|
+
*/
|
|
133
|
+
this._needsRecursiveResolve = true;
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
function clearCache(namespace) {
|
|
@@ -273,11 +280,13 @@ Namespace.prototype.add = function add(object) {
|
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
this._needsRecursiveFeatureResolution = true;
|
|
283
|
+
this._needsRecursiveResolve = true;
|
|
276
284
|
|
|
277
285
|
// Also clear parent caches, since they need to recurse down.
|
|
278
286
|
var parent = this;
|
|
279
287
|
while(parent = parent.parent) {
|
|
280
288
|
parent._needsRecursiveFeatureResolution = true;
|
|
289
|
+
parent._needsRecursiveResolve = true;
|
|
281
290
|
}
|
|
282
291
|
|
|
283
292
|
object.onAdd(this);
|
|
@@ -341,6 +350,10 @@ Namespace.prototype.define = function define(path, json) {
|
|
|
341
350
|
* @returns {Namespace} `this`
|
|
342
351
|
*/
|
|
343
352
|
Namespace.prototype.resolveAll = function resolveAll() {
|
|
353
|
+
if (!this._needsRecursiveResolve) return this;
|
|
354
|
+
|
|
355
|
+
this._resolveFeaturesRecursive(this._edition);
|
|
356
|
+
|
|
344
357
|
var nested = this.nestedArray, i = 0;
|
|
345
358
|
this.resolve();
|
|
346
359
|
while (i < nested.length)
|
|
@@ -348,6 +361,7 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
348
361
|
nested[i++].resolveAll();
|
|
349
362
|
else
|
|
350
363
|
nested[i++].resolve();
|
|
364
|
+
this._needsRecursiveResolve = false;
|
|
351
365
|
return this;
|
|
352
366
|
};
|
|
353
367
|
|
|
@@ -389,29 +403,47 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
389
403
|
} else if (!path.length)
|
|
390
404
|
return this;
|
|
391
405
|
|
|
406
|
+
var flatPath = path.join(".");
|
|
407
|
+
|
|
392
408
|
// Start at root if path is absolute
|
|
393
409
|
if (path[0] === "")
|
|
394
410
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
395
411
|
|
|
396
|
-
|
|
412
|
+
// Early bailout for objects with matching absolute paths
|
|
413
|
+
var found = this.root._fullyQualifiedObjects && this.root._fullyQualifiedObjects["." + flatPath];
|
|
397
414
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
398
415
|
return found;
|
|
399
416
|
}
|
|
400
417
|
|
|
401
|
-
//
|
|
402
|
-
|
|
418
|
+
// Do a regular lookup at this namespace and below
|
|
419
|
+
found = this._lookupImpl(path, flatPath);
|
|
420
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
421
|
+
return found;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (parentAlreadyChecked)
|
|
403
425
|
return null;
|
|
404
|
-
|
|
426
|
+
|
|
427
|
+
// If there hasn't been a match, walk up the tree and look more broadly
|
|
428
|
+
var current = this;
|
|
429
|
+
while (current.parent) {
|
|
430
|
+
found = current.parent._lookupImpl(path, flatPath);
|
|
431
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
432
|
+
return found;
|
|
433
|
+
}
|
|
434
|
+
current = current.parent;
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
405
437
|
};
|
|
406
438
|
|
|
407
439
|
/**
|
|
408
440
|
* Internal helper for lookup that handles searching just at this namespace and below along with caching.
|
|
409
441
|
* @param {string[]} path Path to look up
|
|
442
|
+
* @param {string} flatPath Flattened version of the path to use as a cache key
|
|
410
443
|
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
411
444
|
* @private
|
|
412
445
|
*/
|
|
413
|
-
Namespace.prototype._lookupImpl = function lookup(path) {
|
|
414
|
-
var flatPath = path.join(".");
|
|
446
|
+
Namespace.prototype._lookupImpl = function lookup(path, flatPath) {
|
|
415
447
|
if(Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
416
448
|
return this._lookupCache[flatPath];
|
|
417
449
|
}
|
|
@@ -422,13 +454,15 @@ Namespace.prototype._lookupImpl = function lookup(path) {
|
|
|
422
454
|
if (found) {
|
|
423
455
|
if (path.length === 1) {
|
|
424
456
|
exact = found;
|
|
425
|
-
} else if (found instanceof Namespace
|
|
426
|
-
|
|
457
|
+
} else if (found instanceof Namespace) {
|
|
458
|
+
path = path.slice(1);
|
|
459
|
+
exact = found._lookupImpl(path, path.join("."));
|
|
460
|
+
}
|
|
427
461
|
|
|
428
462
|
// Otherwise try each nested namespace
|
|
429
463
|
} else {
|
|
430
464
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
431
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path)))
|
|
465
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath)))
|
|
432
466
|
exact = found;
|
|
433
467
|
}
|
|
434
468
|
|
package/src/object.js
CHANGED
|
@@ -51,6 +51,7 @@ function ReflectionObject(name, options) {
|
|
|
51
51
|
/**
|
|
52
52
|
* The edition specified for this object. Only relevant for top-level objects.
|
|
53
53
|
* @type {string}
|
|
54
|
+
* @private
|
|
54
55
|
*/
|
|
55
56
|
this._edition = null;
|
|
56
57
|
|
|
@@ -58,18 +59,21 @@ function ReflectionObject(name, options) {
|
|
|
58
59
|
* The default edition to use for this object if none is specified. For legacy reasons,
|
|
59
60
|
* this is proto2 except in the JSON parsing case where it was proto3.
|
|
60
61
|
* @type {string}
|
|
62
|
+
* @private
|
|
61
63
|
*/
|
|
62
64
|
this._defaultEdition = "proto2";
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* Resolved Features.
|
|
66
68
|
* @type {object}
|
|
69
|
+
* @private
|
|
67
70
|
*/
|
|
68
71
|
this._features = {};
|
|
69
72
|
|
|
70
73
|
/**
|
|
71
74
|
* Whether or not features have been resolved.
|
|
72
75
|
* @type {boolean}
|
|
76
|
+
* @private
|
|
73
77
|
*/
|
|
74
78
|
this._featuresResolved = false;
|
|
75
79
|
|
package/src/root.js
CHANGED
|
@@ -36,8 +36,19 @@ function Root(options) {
|
|
|
36
36
|
*/
|
|
37
37
|
this.files = [];
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Edition, defaults to proto2 if unspecified.
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
40
44
|
this._edition = "proto2";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Global lookup cache of fully qualified names.
|
|
48
|
+
* @type {Object.<string,ReflectionObject>}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
this._fullyQualifiedObjects = {};
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
/**
|
|
@@ -51,7 +62,7 @@ Root.fromJSON = function fromJSON(json, root) {
|
|
|
51
62
|
root = new Root();
|
|
52
63
|
if (json.options)
|
|
53
64
|
root.setOptions(json.options);
|
|
54
|
-
return root.addJSON(json.nested).
|
|
65
|
+
return root.addJSON(json.nested).resolveAll();
|
|
55
66
|
};
|
|
56
67
|
|
|
57
68
|
/**
|
|
@@ -99,9 +110,6 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
99
110
|
|
|
100
111
|
// Finishes loading by calling the callback (exactly once)
|
|
101
112
|
function finish(err, root) {
|
|
102
|
-
if (root) {
|
|
103
|
-
root._resolveFeaturesRecursive();
|
|
104
|
-
}
|
|
105
113
|
/* istanbul ignore if */
|
|
106
114
|
if (!callback) {
|
|
107
115
|
return;
|
|
@@ -109,6 +117,9 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
109
117
|
if (sync) {
|
|
110
118
|
throw err;
|
|
111
119
|
}
|
|
120
|
+
if (root) {
|
|
121
|
+
root.resolveAll();
|
|
122
|
+
}
|
|
112
123
|
var cb = callback;
|
|
113
124
|
callback = null;
|
|
114
125
|
cb(err, root);
|
|
@@ -219,7 +230,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
219
230
|
if (resolved = self.resolvePath("", filename[i]))
|
|
220
231
|
fetch(resolved);
|
|
221
232
|
if (sync) {
|
|
222
|
-
self.
|
|
233
|
+
self.resolveAll();
|
|
223
234
|
return self;
|
|
224
235
|
}
|
|
225
236
|
if (!queued) {
|
|
@@ -268,11 +279,12 @@ Root.prototype.loadSync = function loadSync(filename, options) {
|
|
|
268
279
|
* @override
|
|
269
280
|
*/
|
|
270
281
|
Root.prototype.resolveAll = function resolveAll() {
|
|
282
|
+
if (!this._needsRecursiveResolve) return this;
|
|
283
|
+
|
|
271
284
|
if (this.deferred.length)
|
|
272
285
|
throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
|
|
273
286
|
return "'extend " + field.extend + "' in " + field.parent.fullName;
|
|
274
287
|
}).join(", "));
|
|
275
|
-
this._resolveFeaturesRecursive(this._edition);
|
|
276
288
|
return Namespace.prototype.resolveAll.call(this);
|
|
277
289
|
};
|
|
278
290
|
|
|
@@ -335,6 +347,11 @@ Root.prototype._handleAdd = function _handleAdd(object) {
|
|
|
335
347
|
object.parent[object.name] = object; // expose namespace as property of its parent
|
|
336
348
|
}
|
|
337
349
|
|
|
350
|
+
if (object instanceof Type || object instanceof Enum || object instanceof Field) {
|
|
351
|
+
// Only store types and enums for quick lookup during resolve.
|
|
352
|
+
this._fullyQualifiedObjects[object.fullName] = object;
|
|
353
|
+
}
|
|
354
|
+
|
|
338
355
|
// The above also adds uppercased (and thus conflict-free) nested types, services and enums as
|
|
339
356
|
// properties of namespaces just like static code does. This allows using a .d.ts generated for
|
|
340
357
|
// a static module with reflection-based solutions where the condition is met.
|
|
@@ -375,6 +392,8 @@ Root.prototype._handleRemove = function _handleRemove(object) {
|
|
|
375
392
|
delete object.parent[object.name]; // unexpose namespaces
|
|
376
393
|
|
|
377
394
|
}
|
|
395
|
+
|
|
396
|
+
delete this._fullyQualifiedObjects[object.fullName];
|
|
378
397
|
};
|
|
379
398
|
|
|
380
399
|
// Sets up cyclic dependencies (called in index-light)
|
package/src/service.js
CHANGED
|
@@ -110,6 +110,8 @@ Service.prototype.get = function get(name) {
|
|
|
110
110
|
* @override
|
|
111
111
|
*/
|
|
112
112
|
Service.prototype.resolveAll = function resolveAll() {
|
|
113
|
+
if (!this._needsRecursiveResolve) return this;
|
|
114
|
+
|
|
113
115
|
Namespace.prototype.resolve.call(this);
|
|
114
116
|
var methods = this.methodsArray;
|
|
115
117
|
for (var i = 0; i < methods.length; ++i)
|