@depup/apollo__protobufjs 1.2.7-depup.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 (113) hide show
  1. package/LICENSE +39 -0
  2. package/README.md +32 -0
  3. package/bin/pbjs +6 -0
  4. package/bin/pbts +6 -0
  5. package/changes.json +14 -0
  6. package/cli/LICENSE +33 -0
  7. package/cli/README.md +11 -0
  8. package/cli/bin/pbjs +6 -0
  9. package/cli/bin/pbts +6 -0
  10. package/cli/index.d.ts +3 -0
  11. package/cli/index.js +3 -0
  12. package/cli/lib/tsd-jsdoc/LICENSE +21 -0
  13. package/cli/lib/tsd-jsdoc/README.md +23 -0
  14. package/cli/lib/tsd-jsdoc/plugin.js +21 -0
  15. package/cli/lib/tsd-jsdoc/publish.js +693 -0
  16. package/cli/lib/tsd-jsdoc.json +18 -0
  17. package/cli/package.json +7 -0
  18. package/cli/package.standalone.json +32 -0
  19. package/cli/pbjs.d.ts +9 -0
  20. package/cli/pbjs.js +331 -0
  21. package/cli/pbts.d.ts +9 -0
  22. package/cli/pbts.js +198 -0
  23. package/cli/targets/json-module.js +38 -0
  24. package/cli/targets/json.js +8 -0
  25. package/cli/targets/proto.js +326 -0
  26. package/cli/targets/proto2.js +10 -0
  27. package/cli/targets/proto3.js +10 -0
  28. package/cli/targets/static-module.js +29 -0
  29. package/cli/targets/static.js +709 -0
  30. package/cli/util.js +183 -0
  31. package/cli/wrappers/amd.js +7 -0
  32. package/cli/wrappers/closure.js +7 -0
  33. package/cli/wrappers/commonjs.js +7 -0
  34. package/cli/wrappers/default.js +15 -0
  35. package/cli/wrappers/es6.js +5 -0
  36. package/dist/README.md +31 -0
  37. package/dist/light/README.md +31 -0
  38. package/dist/light/protobuf.js +7198 -0
  39. package/dist/light/protobuf.js.map +1 -0
  40. package/dist/light/protobuf.min.js +7 -0
  41. package/dist/light/protobuf.min.js.map +1 -0
  42. package/dist/minimal/README.md +31 -0
  43. package/dist/minimal/protobuf.js +2675 -0
  44. package/dist/minimal/protobuf.js.map +1 -0
  45. package/dist/minimal/protobuf.min.js +7 -0
  46. package/dist/minimal/protobuf.min.js.map +1 -0
  47. package/dist/protobuf.js +8775 -0
  48. package/dist/protobuf.js.map +1 -0
  49. package/dist/protobuf.min.js +7 -0
  50. package/dist/protobuf.min.js.map +1 -0
  51. package/ext/debug/README.md +4 -0
  52. package/ext/debug/index.js +71 -0
  53. package/ext/descriptor/README.md +72 -0
  54. package/ext/descriptor/index.d.ts +191 -0
  55. package/ext/descriptor/index.js +1052 -0
  56. package/ext/descriptor/test.js +54 -0
  57. package/google/LICENSE +27 -0
  58. package/google/README.md +1 -0
  59. package/google/api/annotations.json +83 -0
  60. package/google/api/annotations.proto +11 -0
  61. package/google/api/http.json +86 -0
  62. package/google/api/http.proto +31 -0
  63. package/google/protobuf/api.json +118 -0
  64. package/google/protobuf/api.proto +34 -0
  65. package/google/protobuf/descriptor.json +739 -0
  66. package/google/protobuf/descriptor.proto +286 -0
  67. package/google/protobuf/source_context.json +20 -0
  68. package/google/protobuf/source_context.proto +7 -0
  69. package/google/protobuf/type.json +202 -0
  70. package/google/protobuf/type.proto +89 -0
  71. package/index.d.ts +2628 -0
  72. package/index.js +4 -0
  73. package/light.d.ts +2 -0
  74. package/light.js +4 -0
  75. package/minimal.d.ts +2 -0
  76. package/minimal.js +4 -0
  77. package/package.json +147 -0
  78. package/scripts/postinstall.js +35 -0
  79. package/src/common.js +399 -0
  80. package/src/converter.js +304 -0
  81. package/src/decoder.js +106 -0
  82. package/src/encoder.js +119 -0
  83. package/src/enum.js +181 -0
  84. package/src/field.js +379 -0
  85. package/src/index-light.js +104 -0
  86. package/src/index-minimal.js +36 -0
  87. package/src/index.js +12 -0
  88. package/src/mapfield.js +126 -0
  89. package/src/message.js +139 -0
  90. package/src/method.js +151 -0
  91. package/src/namespace.js +433 -0
  92. package/src/object.js +200 -0
  93. package/src/oneof.js +203 -0
  94. package/src/parse.js +761 -0
  95. package/src/reader.js +405 -0
  96. package/src/reader_buffer.js +44 -0
  97. package/src/root.js +353 -0
  98. package/src/roots.js +18 -0
  99. package/src/rpc/service.js +142 -0
  100. package/src/rpc.js +36 -0
  101. package/src/service.js +167 -0
  102. package/src/tokenize.js +397 -0
  103. package/src/type.js +589 -0
  104. package/src/types.js +196 -0
  105. package/src/typescript.jsdoc +22 -0
  106. package/src/util/longbits.js +200 -0
  107. package/src/util/minimal.js +406 -0
  108. package/src/util.js +178 -0
  109. package/src/verifier.js +191 -0
  110. package/src/wrappers.js +83 -0
  111. package/src/writer.js +459 -0
  112. package/src/writer_buffer.js +81 -0
  113. package/tsconfig.json +7 -0
@@ -0,0 +1,693 @@
1
+ "use strict";
2
+
3
+ var fs = require("fs");
4
+
5
+ // output stream
6
+ var out = null;
7
+
8
+ // documentation data
9
+ var data = null;
10
+
11
+ // already handled objects, by name
12
+ var seen = {};
13
+
14
+ // indentation level
15
+ var indent = 0;
16
+
17
+ // whether indent has been written for the current line yet
18
+ var indentWritten = false;
19
+
20
+ // provided options
21
+ var options = {};
22
+
23
+ // queued interfaces
24
+ var queuedInterfaces = [];
25
+
26
+ // whether writing the first line
27
+ var firstLine = true;
28
+
29
+ // JSDoc hook
30
+ exports.publish = function publish(taffy, opts) {
31
+ options = opts || {};
32
+
33
+ // query overrides options
34
+ if (options.query)
35
+ Object.keys(options.query).forEach(function(key) {
36
+ if (key !== "query")
37
+ switch (options[key] = options.query[key]) {
38
+ case "true":
39
+ options[key] = true;
40
+ break;
41
+ case "false":
42
+ options[key] = false;
43
+ break;
44
+ case "null":
45
+ options[key] = null;
46
+ break;
47
+ }
48
+ });
49
+
50
+ // remove undocumented
51
+ taffy({ undocumented: true }).remove();
52
+ taffy({ ignore: true }).remove();
53
+ taffy({ inherited: true }).remove();
54
+
55
+ // remove private
56
+ if (!options.private)
57
+ taffy({ access: "private" }).remove();
58
+
59
+ // setup output
60
+ out = options.destination
61
+ ? fs.createWriteStream(options.destination)
62
+ : process.stdout;
63
+
64
+ try {
65
+ // setup environment
66
+ data = taffy().get();
67
+ indent = 0;
68
+ indentWritten = false;
69
+ firstLine = true;
70
+
71
+ // wrap everything in a module if configured
72
+ if (options.module) {
73
+ writeln("export = ", options.module, ";");
74
+ writeln();
75
+ writeln("declare namespace ", options.module, " {");
76
+ writeln();
77
+ ++indent;
78
+ }
79
+
80
+ // handle all
81
+ getChildrenOf(undefined).forEach(function(child) {
82
+ handleElement(child, null);
83
+ });
84
+
85
+ // process queued
86
+ while (queuedInterfaces.length) {
87
+ var element = queuedInterfaces.shift();
88
+ begin(element);
89
+ writeInterface(element);
90
+ writeln(";");
91
+ }
92
+
93
+ // end wrap
94
+ if (options.module) {
95
+ --indent;
96
+ writeln("}");
97
+ }
98
+
99
+ // close file output
100
+ if (out !== process.stdout)
101
+ out.end();
102
+
103
+ } finally {
104
+ // gc environment objects
105
+ out = data = null;
106
+ seen = options = {};
107
+ queuedInterfaces = [];
108
+ }
109
+ };
110
+
111
+ //
112
+ // Utility
113
+ //
114
+
115
+ // writes one or multiple strings
116
+ function write() {
117
+ var s = Array.prototype.slice.call(arguments).join("");
118
+ if (!indentWritten) {
119
+ for (var i = 0; i < indent; ++i)
120
+ s = " " + s;
121
+ indentWritten = true;
122
+ }
123
+ out.write(s);
124
+ firstLine = false;
125
+ }
126
+
127
+ // writes zero or multiple strings, followed by a new line
128
+ function writeln() {
129
+ var s = Array.prototype.slice.call(arguments).join("");
130
+ if (s.length)
131
+ write(s, "\n");
132
+ else if (!firstLine)
133
+ out.write("\n");
134
+ indentWritten = false;
135
+ }
136
+
137
+ var keepTags = [
138
+ "param",
139
+ "returns",
140
+ "throws",
141
+ "see"
142
+ ];
143
+
144
+ // parses a comment into text and tags
145
+ function parseComment(comment) {
146
+ var lines = comment.replace(/^ *\/\*\* *|^ *\*\/| *\*\/ *$|^ *\* */mg, "").trim().split(/\r?\n|\r/g); // property.description has just "\r" ?!
147
+ var desc;
148
+ var text = [];
149
+ var tags = null;
150
+ for (var i = 0; i < lines.length; ++i) {
151
+ var match = /^@(\w+)\b/.exec(lines[i]);
152
+ if (match) {
153
+ if (!tags) {
154
+ tags = [];
155
+ desc = text;
156
+ }
157
+ text = [];
158
+ tags.push({ name: match[1], text: text });
159
+ lines[i] = lines[i].substring(match[1].length + 1).trim();
160
+ }
161
+ if (lines[i].length || text.length)
162
+ text.push(lines[i]);
163
+ }
164
+ return {
165
+ text: desc || text,
166
+ tags: tags || []
167
+ };
168
+ }
169
+
170
+ // writes a comment
171
+ function writeComment(comment, otherwiseNewline) {
172
+ if (!comment || options.comments === false) {
173
+ if (otherwiseNewline)
174
+ writeln();
175
+ return;
176
+ }
177
+ if (typeof comment !== "object")
178
+ comment = parseComment(comment);
179
+ comment.tags = comment.tags.filter(function(tag) {
180
+ return keepTags.indexOf(tag.name) > -1 && (tag.name !== "returns" || tag.text[0] !== "{undefined}");
181
+ });
182
+ writeln();
183
+ if (!comment.tags.length && comment.text.length < 2) {
184
+ writeln("/** " + comment.text[0] + " */");
185
+ return;
186
+ }
187
+ writeln("/**");
188
+ comment.text.forEach(function(line) {
189
+ if (line.length)
190
+ writeln(" * ", line);
191
+ else
192
+ writeln(" *");
193
+ });
194
+ comment.tags.forEach(function(tag) {
195
+ var started = false;
196
+ if (tag.text.length) {
197
+ tag.text.forEach(function(line, i) {
198
+ if (i > 0)
199
+ write(" * ");
200
+ else if (tag.name !== "throws")
201
+ line = line.replace(/^\{[^\s]*} ?/, "");
202
+ if (!line.length)
203
+ return;
204
+ if (!started) {
205
+ write(" * @", tag.name, " ");
206
+ started = true;
207
+ }
208
+ writeln(line);
209
+ });
210
+ }
211
+ });
212
+ writeln(" */");
213
+ }
214
+
215
+ // recursively replaces all occurencies of re's match
216
+ function replaceRecursive(name, re, fn) {
217
+ var found;
218
+
219
+ function replacer() {
220
+ found = true;
221
+ return fn.apply(null, arguments);
222
+ }
223
+
224
+ do {
225
+ found = false;
226
+ name = name.replace(re, replacer);
227
+ } while (found);
228
+ return name;
229
+ }
230
+
231
+ // tests if an element is considered to be a class or class-like
232
+ function isClassLike(element) {
233
+ return isClass(element) || isInterface(element);
234
+ }
235
+
236
+ // tests if an element is considered to be a class
237
+ function isClass(element) {
238
+ return element && element.kind === "class";
239
+ }
240
+
241
+ // tests if an element is considered to be an interface
242
+ function isInterface(element) {
243
+ return element && (element.kind === "interface" || element.kind === "mixin");
244
+ }
245
+
246
+ // tests if an element is considered to be a namespace
247
+ function isNamespace(element) {
248
+ return element && (element.kind === "namespace" || element.kind === "module");
249
+ }
250
+
251
+ // gets all children of the specified parent
252
+ function getChildrenOf(parent) {
253
+ var memberof = parent ? parent.longname : undefined;
254
+ return data.filter(function(element) {
255
+ return element.memberof === memberof;
256
+ });
257
+ }
258
+
259
+ // gets the literal type of an element
260
+ function getTypeOf(element) {
261
+ if (element.tsType)
262
+ return element.tsType.replace(/\r?\n|\r/g, "\n");
263
+ var name = "any";
264
+ var type = element.type;
265
+ if (type && type.names && type.names.length) {
266
+ if (type.names.length === 1)
267
+ name = element.type.names[0].trim();
268
+ else
269
+ name = "(" + element.type.names.join("|") + ")";
270
+ } else
271
+ return name;
272
+
273
+ // Replace catchalls with any
274
+ name = name.replace(/\*|\bmixed\b/g, "any");
275
+
276
+ // Ensure upper case Object for map expressions below
277
+ name = name.replace(/\bobject\b/g, "Object");
278
+
279
+ // Correct Something.<Something> to Something<Something>
280
+ name = replaceRecursive(name, /\b(?!Object|Array)([\w$]+)\.<([^>]*)>/gi, function($0, $1, $2) {
281
+ return $1 + "<" + $2 + ">";
282
+ });
283
+
284
+ // Replace Array.<string> with string[]
285
+ name = replaceRecursive(name, /\bArray\.?<([^>]*)>/gi, function($0, $1) {
286
+ return $1 + "[]";
287
+ });
288
+
289
+ // Replace Object.<string,number> with { [k: string]: number }
290
+ name = replaceRecursive(name, /\bObject\.?<([^,]*), *([^>]*)>/gi, function($0, $1, $2) {
291
+ return "{ [k: " + $1 + "]: " + $2 + " }";
292
+ });
293
+
294
+ // Replace functions (there are no signatures) with Function
295
+ name = name.replace(/\bfunction(?:\(\))?\b/g, "Function");
296
+
297
+ // Convert plain Object back to just object
298
+ name = name.replace(/\b(Object\b(?!\.))/g, function($0, $1) {
299
+ return $1.toLowerCase();
300
+ });
301
+
302
+ return name;
303
+ }
304
+
305
+ // begins writing the definition of the specified element
306
+ function begin(element, is_interface) {
307
+ if (!seen[element.longname]) {
308
+ if (isClass(element)) {
309
+ var comment = parseComment(element.comment);
310
+ var classdesc = comment.tags.find(function(tag) { return tag.name === "classdesc"; });
311
+ if (classdesc) {
312
+ comment.text = classdesc.text;
313
+ comment.tags = [];
314
+ }
315
+ writeComment(comment, true);
316
+ } else
317
+ writeComment(element.comment, is_interface || isClassLike(element) || isNamespace(element) || element.isEnum || element.scope === "global");
318
+ seen[element.longname] = element;
319
+ } else
320
+ writeln();
321
+ if (element.scope !== "global" || options.module)
322
+ return;
323
+ write("export ");
324
+ }
325
+
326
+ // writes the function signature describing element
327
+ function writeFunctionSignature(element, isConstructor, isTypeDef) {
328
+ write("(");
329
+
330
+ var params = {};
331
+
332
+ // this type
333
+ if (element.this)
334
+ params["this"] = {
335
+ type: element.this.replace(/^{|}$/g, ""),
336
+ optional: false
337
+ };
338
+
339
+ // parameter types
340
+ if (element.params)
341
+ element.params.forEach(function(param) {
342
+ var path = param.name.split(/\./g);
343
+ if (path.length === 1)
344
+ params[param.name] = {
345
+ type: getTypeOf(param),
346
+ variable: param.variable === true,
347
+ optional: param.optional === true,
348
+ defaultValue: param.defaultvalue // Not used yet (TODO)
349
+ };
350
+ else // Property syntax (TODO)
351
+ params[path[0]].type = "{ [k: string]: any }";
352
+ });
353
+
354
+ var paramNames = Object.keys(params);
355
+ paramNames.forEach(function(name, i) {
356
+ var param = params[name];
357
+ var type = param.type;
358
+ if (param.variable) {
359
+ name = "..." + name;
360
+ type = param.type.charAt(0) === "(" ? "any[]" : param.type + "[]";
361
+ }
362
+ write(name, !param.variable && param.optional ? "?: " : ": ", type);
363
+ if (i < paramNames.length - 1)
364
+ write(", ");
365
+ });
366
+
367
+ write(")");
368
+
369
+ // return type
370
+ if (!isConstructor) {
371
+ write(isTypeDef ? " => " : ": ");
372
+ var typeName;
373
+ if (element.returns && element.returns.length && (typeName = getTypeOf(element.returns[0])) !== "undefined")
374
+ write(typeName);
375
+ else
376
+ write("void");
377
+ }
378
+ }
379
+
380
+ // writes (a typedef as) an interface
381
+ function writeInterface(element) {
382
+ write("interface ", element.name);
383
+ writeInterfaceBody(element);
384
+ writeln();
385
+ }
386
+
387
+ function writeInterfaceBody(element) {
388
+ writeln("{");
389
+ ++indent;
390
+ if (element.tsType)
391
+ writeln(element.tsType.replace(/\r?\n|\r/g, "\n"));
392
+ else if (element.properties && element.properties.length)
393
+ element.properties.forEach(writeProperty);
394
+ --indent;
395
+ write("}");
396
+ }
397
+
398
+ function writeProperty(property, declare) {
399
+ writeComment(property.description);
400
+ if (declare)
401
+ write("let ");
402
+ write(property.name);
403
+ if (property.optional)
404
+ write("?");
405
+ writeln(": ", getTypeOf(property), ";");
406
+ }
407
+
408
+ //
409
+ // Handlers
410
+ //
411
+
412
+ // handles a single element of any understood type
413
+ function handleElement(element, parent) {
414
+ if (element.scope === "inner")
415
+ return false;
416
+
417
+ if (element.optional !== true && element.type && element.type.names && element.type.names.length) {
418
+ for (var i = 0; i < element.type.names.length; i++) {
419
+ if (element.type.names[i].toLowerCase() === "undefined") {
420
+ // This element is actually optional. Set optional to true and
421
+ // remove the 'undefined' type
422
+ element.optional = true;
423
+ element.type.names.splice(i, 1);
424
+ i--;
425
+ }
426
+ }
427
+ }
428
+
429
+ if (seen[element.longname])
430
+ return true;
431
+ if (isClassLike(element))
432
+ handleClass(element, parent);
433
+ else switch (element.kind) {
434
+ case "module":
435
+ case "namespace":
436
+ handleNamespace(element, parent);
437
+ break;
438
+ case "constant":
439
+ case "member":
440
+ handleMember(element, parent);
441
+ break;
442
+ case "function":
443
+ handleFunction(element, parent);
444
+ break;
445
+ case "typedef":
446
+ handleTypeDef(element, parent);
447
+ break;
448
+ case "package":
449
+ break;
450
+ }
451
+ seen[element.longname] = element;
452
+ return true;
453
+ }
454
+
455
+ // handles (just) a namespace
456
+ function handleNamespace(element/*, parent*/) {
457
+ var children = getChildrenOf(element);
458
+ if (!children.length)
459
+ return;
460
+ var first = true;
461
+ if (element.properties)
462
+ element.properties.forEach(function(property) {
463
+ if (!/^[$\w]+$/.test(property.name)) // incompatible in namespace
464
+ return;
465
+ if (first) {
466
+ begin(element);
467
+ writeln("namespace ", element.name, " {");
468
+ ++indent;
469
+ first = false;
470
+ }
471
+ writeProperty(property, true);
472
+ });
473
+ children.forEach(function(child) {
474
+ if (child.scope === "inner" || seen[child.longname])
475
+ return;
476
+ if (first) {
477
+ begin(element);
478
+ writeln("namespace ", element.name, " {");
479
+ ++indent;
480
+ first = false;
481
+ }
482
+ handleElement(child, element);
483
+ });
484
+ if (!first) {
485
+ --indent;
486
+ writeln("}");
487
+ }
488
+ }
489
+
490
+ // a filter function to remove any module references
491
+ function notAModuleReference(ref) {
492
+ return ref.indexOf("module:") === -1;
493
+ }
494
+
495
+ // handles a class or class-like
496
+ function handleClass(element, parent) {
497
+ var is_interface = isInterface(element);
498
+ begin(element, is_interface);
499
+ if (is_interface)
500
+ write("interface ");
501
+ else {
502
+ if (element.virtual)
503
+ write("abstract ");
504
+ write("class ");
505
+ }
506
+ write(element.name);
507
+ if (element.templates && element.templates.length)
508
+ write("<", element.templates.join(", "), ">");
509
+ write(" ");
510
+
511
+ // extended classes
512
+ if (element.augments) {
513
+ var augments = element.augments.filter(notAModuleReference);
514
+ if (augments.length)
515
+ write("extends ", augments[0], " ");
516
+ }
517
+
518
+ // implemented interfaces
519
+ var impls = [];
520
+ if (element.implements)
521
+ Array.prototype.push.apply(impls, element.implements);
522
+ if (element.mixes)
523
+ Array.prototype.push.apply(impls, element.mixes);
524
+ impls = impls.filter(notAModuleReference);
525
+ if (impls.length)
526
+ write("implements ", impls.join(", "), " ");
527
+
528
+ writeln("{");
529
+ ++indent;
530
+
531
+ if (element.tsType)
532
+ writeln(element.tsType.replace(/\r?\n|\r/g, "\n"));
533
+
534
+ // constructor
535
+ if (!is_interface && !element.virtual)
536
+ handleFunction(element, parent, true);
537
+
538
+ // properties
539
+ if (is_interface && element.properties)
540
+ element.properties.forEach(function(property) {
541
+ writeProperty(property);
542
+ });
543
+
544
+ // class-compatible members
545
+ var incompatible = [];
546
+ getChildrenOf(element).forEach(function(child) {
547
+ if (isClassLike(child) || child.kind === "module" || child.kind === "typedef" || child.isEnum) {
548
+ incompatible.push(child);
549
+ return;
550
+ }
551
+ handleElement(child, element);
552
+ });
553
+
554
+ --indent;
555
+ writeln("}");
556
+
557
+ // class-incompatible members
558
+ if (incompatible.length) {
559
+ writeln();
560
+ if (element.scope === "global" && !options.module)
561
+ write("export ");
562
+ writeln("namespace ", element.name, " {");
563
+ ++indent;
564
+ incompatible.forEach(function(child) {
565
+ handleElement(child, element);
566
+ });
567
+ --indent;
568
+ writeln("}");
569
+ }
570
+ }
571
+
572
+ // handles a namespace or class member
573
+ function handleMember(element, parent) {
574
+ begin(element);
575
+
576
+ if (element.isEnum) {
577
+ var stringEnum = false;
578
+ element.properties.forEach(function(property) {
579
+ if (isNaN(property.defaultvalue)) {
580
+ stringEnum = true;
581
+ }
582
+ });
583
+ if (stringEnum) {
584
+ writeln("type ", element.name, " =");
585
+ ++indent;
586
+ element.properties.forEach(function(property, i) {
587
+ write(i === 0 ? "" : "| ", JSON.stringify(property.defaultvalue));
588
+ });
589
+ --indent;
590
+ writeln(";");
591
+ } else {
592
+ writeln("enum ", element.name, " {");
593
+ ++indent;
594
+ element.properties.forEach(function(property, i) {
595
+ write(property.name);
596
+ if (property.defaultvalue !== undefined)
597
+ write(" = ", JSON.stringify(property.defaultvalue));
598
+ if (i < element.properties.length - 1)
599
+ writeln(",");
600
+ else
601
+ writeln();
602
+ });
603
+ --indent;
604
+ writeln("}");
605
+ }
606
+
607
+ } else {
608
+
609
+ var inClass = isClassLike(parent);
610
+ if (inClass) {
611
+ write(element.access || "public", " ");
612
+ if (element.scope === "static")
613
+ write("static ");
614
+ if (element.readonly)
615
+ write("readonly ");
616
+ } else
617
+ write(element.kind === "constant" ? "const " : "let ");
618
+
619
+ write(element.name);
620
+ if (element.optional)
621
+ write("?");
622
+ write(": ");
623
+
624
+ if (element.type && element.type.names && /^Object\b/i.test(element.type.names[0]) && element.properties) {
625
+ writeln("{");
626
+ ++indent;
627
+ element.properties.forEach(function(property, i) {
628
+ writeln(JSON.stringify(property.name), ": ", getTypeOf(property), i < element.properties.length - 1 ? "," : "");
629
+ });
630
+ --indent;
631
+ writeln("};");
632
+ } else
633
+ writeln(getTypeOf(element), ";");
634
+ }
635
+ }
636
+
637
+ // handles a function or method
638
+ function handleFunction(element, parent, isConstructor) {
639
+ var insideClass = true;
640
+ if (isConstructor) {
641
+ writeComment(element.comment);
642
+ write("constructor");
643
+ } else {
644
+ begin(element);
645
+ insideClass = isClassLike(parent);
646
+ if (insideClass) {
647
+ write(element.access || "public", " ");
648
+ if (element.scope === "static")
649
+ write("static ");
650
+ } else
651
+ write("function ");
652
+ write(element.name);
653
+ if (element.templates && element.templates.length)
654
+ write("<", element.templates.join(", "), ">");
655
+ }
656
+ writeFunctionSignature(element, isConstructor, false);
657
+ writeln(";");
658
+ if (!insideClass)
659
+ handleNamespace(element);
660
+ }
661
+
662
+ // handles a type definition (not a real type)
663
+ function handleTypeDef(element, parent) {
664
+ if (isInterface(element)) {
665
+ if (isClassLike(parent))
666
+ queuedInterfaces.push(element);
667
+ else {
668
+ begin(element);
669
+ writeInterface(element);
670
+ }
671
+ } else {
672
+ writeComment(element.comment, true);
673
+ write("type ", element.name);
674
+ if (element.templates && element.templates.length)
675
+ write("<", element.templates.join(", "), ">");
676
+ write(" = ");
677
+ if (element.tsType)
678
+ write(element.tsType.replace(/\r?\n|\r/g, "\n"));
679
+ else {
680
+ var type = getTypeOf(element);
681
+ if (element.type && element.type.names.length === 1 && element.type.names[0] === "function")
682
+ writeFunctionSignature(element, false, true);
683
+ else if (type === "object") {
684
+ if (element.properties && element.properties.length)
685
+ writeInterfaceBody(element);
686
+ else
687
+ write("{}");
688
+ } else
689
+ write(type);
690
+ }
691
+ writeln(";");
692
+ }
693
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "tags": {
3
+ "allowUnknownTags": false
4
+ },
5
+ "plugins": [
6
+ "./tsd-jsdoc/plugin"
7
+ ],
8
+ "opts": {
9
+ "encoding" : "utf8",
10
+ "recurse" : true,
11
+ "lenient" : true,
12
+ "template" : "./tsd-jsdoc",
13
+
14
+ "private" : false,
15
+ "comments" : true,
16
+ "destination" : false
17
+ }
18
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": "6.7.0",
3
+ "dependencies": {
4
+ "jsdoc": "^3.6.3",
5
+ "minimist": "^1.2.0"
6
+ }
7
+ }