versioned-d.ts-tools 0.1.0 → 0.2.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.
@@ -1,306 +1,333 @@
1
- "use strict";
2
- var __importStar = (this && this.__importStar) || function (mod) {
3
- if (mod && mod.__esModule) return mod;
4
- var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
7
- return result;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const ts = __importStar(require("typescript"));
11
- // capturing these because of eccentricities with the compiler ordering
12
- let topClass = null;
13
- let lastItem = null;
14
- var ClassType;
15
- (function (ClassType) {
16
- ClassType["Class"] = "Class";
17
- ClassType["Interface"] = "Interface";
18
- ClassType["Enum"] = "Enum";
19
- })(ClassType || (ClassType = {}));
20
- var FieldType;
21
- (function (FieldType) {
22
- FieldType["Property"] = "Property";
23
- FieldType["Method"] = "Method";
24
- FieldType["Event"] = "Event";
25
- FieldType["Enum"] = "Enum";
26
- })(FieldType || (FieldType = {}));
27
- class FieldStruct {
28
- constructor(decString, commentString, fieldType, fieldName) {
29
- this.declarationString = decString;
30
- this.comment = commentString;
31
- this.type = fieldType;
32
- this.name = fieldName;
33
- }
34
- }
35
- class ClassStruct {
36
- constructor(decString, commentString, classType) {
37
- this.declarationString = decString;
38
- this.comment = commentString;
39
- this.type = classType;
40
- this.fields = [];
41
- }
42
- copyWithoutFields() {
43
- return new ClassStruct(this.declarationString, this.comment, this.type);
44
- }
45
- sortFields() {
46
- this.fields.sort((a, b) => {
47
- if (a.declarationString === b.declarationString) {
48
- return 0;
49
- }
50
- else {
51
- return a.declarationString.replace("readonly ", "") < b.declarationString.replace("readonly ", "") ? -1 : 1;
52
- }
53
- });
54
- }
55
- getClassName() {
56
- return this.declarationString.substring(this.declarationString.lastIndexOf(" ") + 1);
57
- }
58
- }
59
- class APISet {
60
- constructor() {
61
- this.api = [];
62
- }
63
- addClass(clas) {
64
- this.api.push(clas);
65
- }
66
- containsClass(clas) {
67
- let found = false;
68
- this.api.forEach((element) => {
69
- if (element.declarationString === clas.declarationString) {
70
- found = true;
71
- }
72
- });
73
- return found;
74
- }
75
- containsField(clas, field) {
76
- let found = false;
77
- this.api.forEach((element) => {
78
- if (element.declarationString === clas.declarationString) {
79
- element.fields.forEach((thisField) => {
80
- if (thisField.declarationString === field.declarationString) {
81
- found = true;
82
- }
83
- });
84
- }
85
- });
86
- return found;
87
- }
88
- // finds the new fields and classes
89
- diff(other) {
90
- const diffAPI = new APISet();
91
- this.api.forEach((element) => {
92
- if (other.containsClass(element)) {
93
- let classShell = null;
94
- element.fields.forEach((field) => {
95
- if (!other.containsField(element, field)) {
96
- if (classShell === null) {
97
- classShell = element.copyWithoutFields();
98
- diffAPI.addClass(classShell);
99
- }
100
- classShell.fields.push(field);
101
- }
102
- });
103
- }
104
- else {
105
- diffAPI.addClass(element);
106
- }
107
- });
108
- return diffAPI;
109
- }
110
- getAsDTS() {
111
- this.sort();
112
- const output = [];
113
- this.api.forEach((clas) => {
114
- output.push(clas.comment.trim());
115
- output.push(clas.declarationString + " {");
116
- clas.fields.forEach((field) => {
117
- output.push(" " + field.comment);
118
- if (field.type === FieldType.Enum) {
119
- output.push(" " + field.declarationString + ",");
120
- }
121
- else {
122
- output.push(" " + field.declarationString);
123
- }
124
- });
125
- output.push("}");
126
- });
127
- return output.join("\n");
128
- }
129
- getAsMarkdown(relativePath) {
130
- this.sort();
131
- // table header
132
- let output = "| Class | Fields | Description |\n|:---|:---|:---|\n";
133
- this.api.forEach((clas) => {
134
- // Ignore the following:
135
- // - Enums.
136
- // - LoadOptions interfaces
137
- // - *Data classes for set/load methods
138
- if (clas.type !== ClassType.Enum &&
139
- !clas.getClassName().endsWith("LoadOptions") &&
140
- !clas.getClassName().endsWith("Data")) {
141
- const className = clas.getClassName();
142
- output += "|[" + className + "](/"
143
- + relativePath + className.toLowerCase() + ")|";
144
- // Ignore the following:
145
- // - String literal overloads.
146
- // - `load`, `set`, `track`, `untrack`, and `toJSON` methods
147
- // - The `context` property.
148
- // - Static fields.
149
- let filteredFields = clas.fields.filter((field) => {
150
- let isLiteral = field.declarationString.search(/([a-zA-Z]+)(\??:)([\n]?([ |]*\"[\w]*\"[|,\n]*)+?)([ ]*[\),])/g) >= 0;
151
- return (!isLiteral &&
152
- field.name !== "load" &&
153
- field.name !== "set" &&
154
- field.name !== "toJSON" &&
155
- field.name !== "context" &&
156
- field.name !== "track" &&
157
- field.name !== "untrack" &&
158
- !field.declarationString.includes("static "));
159
- });
160
- let first = true;
161
- if (filteredFields.length > 0) {
162
- filteredFields.forEach((field) => {
163
- if (first) {
164
- first = false;
165
- }
166
- else {
167
- output += "||";
168
- }
169
- // remove unnecessary parts of the declaration string
170
- let newItemText = field.declarationString.replace(/;/g, "");
171
- if (field.type === FieldType.Property) {
172
- // Remove the optional modifier and type.
173
- newItemText = newItemText.replace(/\?/g, "");
174
- newItemText = newItemText.substring(0, newItemText.indexOf(":"));
175
- }
176
- else {
177
- // Remove the return type.
178
- newItemText = newItemText.substring(0, newItemText.lastIndexOf(":"));
179
- }
180
- newItemText = newItemText.replace("readonly ", "");
181
- newItemText = newItemText.replace(/\|/g, "\\|").replace(/\n|\t/gm, "");
182
- newItemText = newItemText.replace(/[\s][\s]+/g, " ").replace(/\( /g, "(").replace(/ \)/g, ")").replace(/,\)/g, ")").replace(/([\w]\??: )\\\| /g, "$1"); // dprint formatting quirks
183
- newItemText = newItemText.replace(/\<any\>/g, "");
184
- let tableLine = "[" + newItemText + "]("
185
- + buildFieldLink(relativePath, className, field) + ")|";
186
- tableLine += removeAtLink(extractFirstSentenceFromComment(field.comment));
187
- output += tableLine + "|\n";
188
- });
189
- }
190
- else {
191
- output += "||\n";
192
- }
193
- }
194
- });
195
- return output;
196
- }
197
- sort() {
198
- this.api.forEach((element) => {
199
- element.sortFields();
200
- });
201
- this.api.sort((a, b) => {
202
- if (a.getClassName() === b.getClassName()) {
203
- return 0;
204
- }
205
- else {
206
- return a.getClassName() < b.getClassName() ? -1 : 1;
207
- }
208
- });
209
- }
210
- }
211
- exports.APISet = APISet;
212
- function extractFirstSentenceFromComment(commentText) {
213
- const firstSentenceIndex = commentText.indexOf("* ") + 2;
214
- const multiSentenceEndIndex = commentText.indexOf(". ", firstSentenceIndex);
215
- const lineBreakEndIndex = commentText.indexOf("\n", firstSentenceIndex);
216
- const singleLineEndIndex = commentText.indexOf("\*/", firstSentenceIndex);
217
- let endIndex;
218
- if (multiSentenceEndIndex > 0 && lineBreakEndIndex > 0) {
219
- endIndex = Math.min(multiSentenceEndIndex + 1, lineBreakEndIndex);
220
- }
221
- else if (multiSentenceEndIndex === -1 && lineBreakEndIndex === -1) {
222
- endIndex = singleLineEndIndex;
223
- }
224
- else {
225
- endIndex = Math.max(multiSentenceEndIndex + 1, lineBreakEndIndex);
226
- }
227
- return commentText.substring(firstSentenceIndex, endIndex).trim();
228
- }
229
- function removeAtLink(commentText) {
230
- // Replace links with the format "{@link Foo}" with "Foo".
231
- commentText = commentText.replace(/{@link ([^|]*?)}/gm, "$1");
232
- // Replace links with the format "{@link Foo | URL}" with "[Foo](URL)".
233
- commentText = commentText.replace(/{@link ([^}]*?) \| (http.*?)}/gm, "[$1]($2)");
234
- return commentText;
235
- }
236
- function buildFieldLink(relativePath, className, field) {
237
- // Build the standard link anchor format based on host.
238
- let anchorPrefix = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
239
- anchorPrefix = (relativePath.indexOf("outlook") > 0 ? "outlook" : anchorPrefix) + "-" + anchorPrefix + "-";
240
- let fieldLink = "/" + relativePath.replace("api/outlook/outlook", "api/outlook/office") + className.toLowerCase() + "#" + anchorPrefix + className.toLowerCase() + "-" + field.name.toLowerCase() + (field.type === FieldType.Method ? "-member(1)" : "-member");
241
- return fieldLink;
242
- }
243
- function parseDTS(fileName, fileContents) {
244
- const node = ts.createSourceFile(fileName, fileContents, ts.ScriptTarget.ES2015, true);
245
- const allClasses = new APISet();
246
- parseDTSInternal(node, allClasses);
247
- return allClasses;
248
- }
249
- exports.parseDTS = parseDTS;
250
- function parseDTSInternal(node, allClasses) {
251
- switch (node.kind) {
252
- case ts.SyntaxKind.InterfaceDeclaration:
253
- parseDTSTopLevelItem(node, allClasses, ClassType.Interface);
254
- break;
255
- case ts.SyntaxKind.ClassDeclaration:
256
- parseDTSTopLevelItem(node, allClasses, ClassType.Class);
257
- break;
258
- case ts.SyntaxKind.EnumDeclaration:
259
- parseDTSTopLevelItem(node, allClasses, ClassType.Enum);
260
- break;
261
- case ts.SyntaxKind.PropertySignature:
262
- parseDTSFieldItem(node, FieldType.Property);
263
- break;
264
- case ts.SyntaxKind.PropertyDeclaration:
265
- parseDTSFieldItem(node, FieldType.Property);
266
- break;
267
- case ts.SyntaxKind.EnumMember:
268
- parseDTSFieldItem(node, FieldType.Enum);
269
- break;
270
- case ts.SyntaxKind.MethodSignature:
271
- parseDTSFieldItem(node, FieldType.Method);
272
- break;
273
- case ts.SyntaxKind.MethodDeclaration:
274
- parseDTSFieldItem(node, FieldType.Method);
275
- break;
276
- case ts.SyntaxKind.TypeLiteral:
277
- return;
278
- default:
279
- // the compiler parses comments after the class/field, therefore this connects to the previous item
280
- if (node.getText().indexOf("/**") >= 0 &&
281
- node.getText().indexOf("*/") >= 0 &&
282
- lastItem !== null &&
283
- lastItem.comment === "") {
284
- // clean up spacing as best we can for the diffed d.ts
285
- lastItem.comment = node.getText().replace(/ \*/g, "*");
286
- if (lastItem.comment.indexOf("@eventproperty") >= 0) {
287
- // events are indistinguishable from properties aside from this tag
288
- lastItem.type = FieldType.Event;
289
- }
290
- }
291
- }
292
- node.getChildren().forEach((element) => {
293
- parseDTSInternal(element, allClasses);
294
- });
295
- }
296
- function parseDTSTopLevelItem(node, allClasses, type) {
297
- topClass = new ClassStruct("export " + type.toLowerCase() + " " + node.name.text, "", type);
298
- allClasses.addClass(topClass);
299
- lastItem = topClass;
300
- }
301
- function parseDTSFieldItem(node, type) {
302
- const newField = new FieldStruct(node.getText(), "", type, node.name.getText());
303
- topClass.fields.push(newField);
304
- lastItem = newField;
305
- }
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.APISet = void 0;
37
+ exports.parseDTS = parseDTS;
38
+ const ts = __importStar(require("typescript"));
39
+ // capturing these because of eccentricities with the compiler ordering
40
+ let topClass = null;
41
+ let lastItem = null;
42
+ var ClassType;
43
+ (function (ClassType) {
44
+ ClassType["Class"] = "Class";
45
+ ClassType["Interface"] = "Interface";
46
+ ClassType["Enum"] = "Enum";
47
+ })(ClassType || (ClassType = {}));
48
+ var FieldType;
49
+ (function (FieldType) {
50
+ FieldType["Property"] = "Property";
51
+ FieldType["Method"] = "Method";
52
+ FieldType["Event"] = "Event";
53
+ FieldType["Enum"] = "Enum";
54
+ })(FieldType || (FieldType = {}));
55
+ class FieldStruct {
56
+ constructor(decString, commentString, fieldType, fieldName) {
57
+ this.declarationString = decString;
58
+ this.comment = commentString;
59
+ this.type = fieldType;
60
+ this.name = fieldName;
61
+ }
62
+ }
63
+ class ClassStruct {
64
+ constructor(decString, commentString, classType) {
65
+ this.declarationString = decString;
66
+ this.comment = commentString;
67
+ this.type = classType;
68
+ this.fields = [];
69
+ }
70
+ copyWithoutFields() {
71
+ return new ClassStruct(this.declarationString, this.comment, this.type);
72
+ }
73
+ sortFields() {
74
+ this.fields.sort((a, b) => {
75
+ if (a.declarationString === b.declarationString) {
76
+ return 0;
77
+ }
78
+ else {
79
+ return a.declarationString.replace("readonly ", "") < b.declarationString.replace("readonly ", "") ? -1 : 1;
80
+ }
81
+ });
82
+ }
83
+ getClassName() {
84
+ return this.declarationString.substring(this.declarationString.lastIndexOf(" ") + 1);
85
+ }
86
+ }
87
+ class APISet {
88
+ constructor() {
89
+ this.api = [];
90
+ }
91
+ addClass(clas) {
92
+ this.api.push(clas);
93
+ }
94
+ containsClass(clas) {
95
+ let found = false;
96
+ this.api.forEach((element) => {
97
+ if (element.declarationString === clas.declarationString) {
98
+ found = true;
99
+ }
100
+ });
101
+ return found;
102
+ }
103
+ containsField(clas, field) {
104
+ let found = false;
105
+ this.api.forEach((element) => {
106
+ if (element.declarationString === clas.declarationString) {
107
+ element.fields.forEach((thisField) => {
108
+ if (thisField.declarationString === field.declarationString) {
109
+ found = true;
110
+ }
111
+ });
112
+ }
113
+ });
114
+ return found;
115
+ }
116
+ // finds the new fields and classes
117
+ diff(other) {
118
+ const diffAPI = new APISet();
119
+ this.api.forEach((element) => {
120
+ if (other.containsClass(element)) {
121
+ let classShell = null;
122
+ element.fields.forEach((field) => {
123
+ if (!other.containsField(element, field)) {
124
+ if (classShell === null) {
125
+ classShell = element.copyWithoutFields();
126
+ diffAPI.addClass(classShell);
127
+ }
128
+ classShell.fields.push(field);
129
+ }
130
+ });
131
+ }
132
+ else {
133
+ diffAPI.addClass(element);
134
+ }
135
+ });
136
+ return diffAPI;
137
+ }
138
+ getAsDTS() {
139
+ this.sort();
140
+ const output = [];
141
+ this.api.forEach((clas) => {
142
+ output.push(clas.comment.trim());
143
+ output.push(clas.declarationString + " {");
144
+ clas.fields.forEach((field) => {
145
+ output.push(" " + field.comment);
146
+ if (field.type === FieldType.Enum) {
147
+ output.push(" " + field.declarationString + ",");
148
+ }
149
+ else {
150
+ output.push(" " + field.declarationString);
151
+ }
152
+ });
153
+ output.push("}");
154
+ });
155
+ return output.join("\n");
156
+ }
157
+ getAsMarkdown(relativePath) {
158
+ this.sort();
159
+ // table header
160
+ let output = "| Class | Fields | Description |\n|:---|:---|:---|\n";
161
+ this.api.forEach((clas) => {
162
+ // Ignore the following:
163
+ // - Enums.
164
+ // - LoadOptions interfaces
165
+ // - *Data classes for set/load methods
166
+ if (clas.type !== ClassType.Enum &&
167
+ !clas.getClassName().endsWith("LoadOptions") &&
168
+ !clas.getClassName().endsWith("Data")) {
169
+ const className = clas.getClassName();
170
+ output += "|[" + className + "](/"
171
+ + relativePath + className.toLowerCase() + ")|";
172
+ // Ignore the following:
173
+ // - String literal overloads.
174
+ // - `load`, `set`, `track`, `untrack`, and `toJSON` methods
175
+ // - The `context` property.
176
+ // - Static fields.
177
+ let filteredFields = clas.fields.filter((field) => {
178
+ let isLiteral = field.declarationString.search(/([a-zA-Z]+)(\??:)([\n]?([ |]*\"[\w]*\"[|,\n]*)+?)([ ]*[\),])/g) >= 0;
179
+ return (!isLiteral &&
180
+ field.name !== "load" &&
181
+ field.name !== "set" &&
182
+ field.name !== "toJSON" &&
183
+ field.name !== "context" &&
184
+ field.name !== "track" &&
185
+ field.name !== "untrack" &&
186
+ !field.declarationString.includes("static "));
187
+ });
188
+ let first = true;
189
+ if (filteredFields.length > 0) {
190
+ filteredFields.forEach((field) => {
191
+ if (first) {
192
+ first = false;
193
+ }
194
+ else {
195
+ output += "||";
196
+ }
197
+ // remove unnecessary parts of the declaration string
198
+ let newItemText = field.declarationString.replace(/;/g, "");
199
+ if (field.type === FieldType.Property) {
200
+ // Remove the optional modifier and type.
201
+ newItemText = newItemText.replace(/\?/g, "");
202
+ newItemText = newItemText.substring(0, newItemText.indexOf(":"));
203
+ }
204
+ else {
205
+ // Remove the return type.
206
+ newItemText = newItemText.substring(0, newItemText.lastIndexOf(":"));
207
+ }
208
+ newItemText = newItemText.replace("readonly ", "");
209
+ newItemText = newItemText.replace(/\|/g, "\\|").replace(/\n|\t/gm, "");
210
+ newItemText = newItemText.replace(/[\s][\s]+/g, " ").replace(/\( /g, "(").replace(/ \)/g, ")").replace(/,\)/g, ")").replace(/([\w]\??: )\\\| /g, "$1"); // dprint formatting quirks
211
+ newItemText = newItemText.replace(/\<any\>/g, "");
212
+ let tableLine = "[" + newItemText + "]("
213
+ + buildFieldLink(relativePath, className, field) + ")|";
214
+ tableLine += removeAtLink(extractFirstSentenceFromComment(field.comment));
215
+ output += tableLine + "|\n";
216
+ });
217
+ }
218
+ else {
219
+ output += "||\n";
220
+ }
221
+ }
222
+ });
223
+ return output;
224
+ }
225
+ sort() {
226
+ this.api.forEach((element) => {
227
+ element.sortFields();
228
+ });
229
+ this.api.sort((a, b) => {
230
+ if (a.getClassName() === b.getClassName()) {
231
+ return 0;
232
+ }
233
+ else {
234
+ return a.getClassName() < b.getClassName() ? -1 : 1;
235
+ }
236
+ });
237
+ }
238
+ }
239
+ exports.APISet = APISet;
240
+ function extractFirstSentenceFromComment(commentText) {
241
+ const firstSentenceIndex = commentText.indexOf("* ") + 2;
242
+ const multiSentenceEndIndex = commentText.indexOf(". ", firstSentenceIndex);
243
+ const lineBreakEndIndex = commentText.indexOf("\n", firstSentenceIndex);
244
+ const singleLineEndIndex = commentText.indexOf("\*/", firstSentenceIndex);
245
+ let endIndex;
246
+ if (multiSentenceEndIndex > 0 && lineBreakEndIndex > 0) {
247
+ endIndex = Math.min(multiSentenceEndIndex + 1, lineBreakEndIndex);
248
+ }
249
+ else if (multiSentenceEndIndex === -1 && lineBreakEndIndex === -1) {
250
+ endIndex = singleLineEndIndex;
251
+ }
252
+ else {
253
+ endIndex = Math.max(multiSentenceEndIndex + 1, lineBreakEndIndex);
254
+ }
255
+ return commentText.substring(firstSentenceIndex, endIndex).trim();
256
+ }
257
+ function removeAtLink(commentText) {
258
+ // Replace links with the format "{@link Foo}" with "Foo".
259
+ commentText = commentText.replace(/{@link ([^|]*?)}/gm, "$1");
260
+ // Replace links with the format "{@link Foo | URL}" with "[Foo](URL)".
261
+ commentText = commentText.replace(/{@link ([^}]*?) \| (http.*?)}/gm, "[$1]($2)");
262
+ return commentText;
263
+ }
264
+ function buildFieldLink(relativePath, className, field) {
265
+ // Build the standard link anchor format based on host.
266
+ let anchorPrefix = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
267
+ anchorPrefix = (relativePath.indexOf("outlook") > 0 ? "outlook" : anchorPrefix) + "-" + anchorPrefix + "-";
268
+ let fieldLink = "/" + relativePath.replace("api/outlook/outlook", "api/outlook/office") + className.toLowerCase() + "#" + anchorPrefix + className.toLowerCase() + "-" + field.name.toLowerCase() + (field.type === FieldType.Method ? "-member(1)" : "-member");
269
+ return fieldLink;
270
+ }
271
+ function parseDTS(fileName, fileContents) {
272
+ const node = ts.createSourceFile(fileName, fileContents, ts.ScriptTarget.ES2015, true);
273
+ const allClasses = new APISet();
274
+ parseDTSInternal(node, allClasses);
275
+ return allClasses;
276
+ }
277
+ function parseDTSInternal(node, allClasses) {
278
+ switch (node.kind) {
279
+ case ts.SyntaxKind.InterfaceDeclaration:
280
+ parseDTSTopLevelItem(node, allClasses, ClassType.Interface);
281
+ break;
282
+ case ts.SyntaxKind.ClassDeclaration:
283
+ parseDTSTopLevelItem(node, allClasses, ClassType.Class);
284
+ break;
285
+ case ts.SyntaxKind.EnumDeclaration:
286
+ parseDTSTopLevelItem(node, allClasses, ClassType.Enum);
287
+ break;
288
+ case ts.SyntaxKind.PropertySignature:
289
+ parseDTSFieldItem(node, FieldType.Property);
290
+ break;
291
+ case ts.SyntaxKind.PropertyDeclaration:
292
+ parseDTSFieldItem(node, FieldType.Property);
293
+ break;
294
+ case ts.SyntaxKind.EnumMember:
295
+ parseDTSFieldItem(node, FieldType.Enum);
296
+ break;
297
+ case ts.SyntaxKind.MethodSignature:
298
+ parseDTSFieldItem(node, FieldType.Method);
299
+ break;
300
+ case ts.SyntaxKind.MethodDeclaration:
301
+ parseDTSFieldItem(node, FieldType.Method);
302
+ break;
303
+ case ts.SyntaxKind.TypeLiteral:
304
+ return;
305
+ default:
306
+ // the compiler parses comments after the class/field, therefore this connects to the previous item
307
+ if (node.getText().indexOf("/**") >= 0 &&
308
+ node.getText().indexOf("*/") >= 0 &&
309
+ lastItem !== null &&
310
+ lastItem.comment === "") {
311
+ // clean up spacing as best we can for the diffed d.ts
312
+ lastItem.comment = node.getText().replace(/ \*/g, "*");
313
+ if (lastItem.comment.indexOf("@eventproperty") >= 0) {
314
+ // events are indistinguishable from properties aside from this tag
315
+ lastItem.type = FieldType.Event;
316
+ }
317
+ }
318
+ }
319
+ node.getChildren().forEach((element) => {
320
+ parseDTSInternal(element, allClasses);
321
+ });
322
+ }
323
+ function parseDTSTopLevelItem(node, allClasses, type) {
324
+ topClass = new ClassStruct("export " + type.toLowerCase() + " " + node.name.text, "", type);
325
+ allClasses.addClass(topClass);
326
+ lastItem = topClass;
327
+ }
328
+ function parseDTSFieldItem(node, type) {
329
+ const newField = new FieldStruct(node.getText(), "", type, node.name.getText());
330
+ topClass.fields.push(newField);
331
+ lastItem = newField;
332
+ }
306
333
  //# sourceMappingURL=dts-utilities.js.map