UNPKG

2 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var util_1 = require("../util");
4var Printer_1 = require("../Printer");
5var WellKnown_1 = require("../WellKnown");
6var message_1 = require("./message");
7var enum_1 = require("./enum");
8var extensions_1 = require("./extensions");
9function printFileDescriptorTSD(fileDescriptor, exportMap) {
10 var fileName = fileDescriptor.getName() || util_1.throwError("Missing file descriptor name");
11 var packageName = fileDescriptor.getPackage();
12 var printer = new Printer_1.Printer(0);
13 printer.printLn("// package: " + packageName);
14 printer.printLn("// file: " + fileDescriptor.getName());
15 var upToRoot = util_1.getPathToRoot(fileName);
16 printer.printEmptyLn();
17 printer.printLn("import * as jspb from \"google-protobuf\";");
18 fileDescriptor.getDependencyList().forEach(function (dependency) {
19 var pseudoNamespace = util_1.filePathToPseudoNamespace(dependency);
20 if (dependency in WellKnown_1.WellKnownTypesMap) {
21 printer.printLn("import * as " + pseudoNamespace + " from \"" + WellKnown_1.WellKnownTypesMap[dependency] + "\";");
22 }
23 else {
24 var filePath = util_1.replaceProtoSuffix(dependency);
25 printer.printLn("import * as " + pseudoNamespace + " from \"" + upToRoot + filePath + "\";");
26 }
27 });
28 fileDescriptor.getMessageTypeList().forEach(function (enumType) {
29 printer.print(message_1.printMessage(fileName, exportMap, enumType, 0, fileDescriptor));
30 });
31 fileDescriptor.getExtensionList().forEach(function (extension) {
32 printer.print(extensions_1.printExtension(fileName, exportMap, extension, 0));
33 });
34 fileDescriptor.getEnumTypeList().forEach(function (enumType) {
35 printer.print(enum_1.printEnum(enumType, 0));
36 });
37 printer.printEmptyLn();
38 return printer.getOutput();
39}
40exports.printFileDescriptorTSD = printFileDescriptorTSD;
41//# sourceMappingURL=fileDescriptorTSD.js.map
\No newline at end of file