@briklab/parsee 0.1.1
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/LICENSE +201 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +47 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/parser.d.ts +139 -0
- package/dist/parser.js +320 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const parser_1 = require("./parser");
|
|
9
|
+
function readStdin() {
|
|
10
|
+
return new Promise((res, rej) => {
|
|
11
|
+
let s = '';
|
|
12
|
+
process.stdin.setEncoding('utf8');
|
|
13
|
+
process.stdin.on('data', (c) => (s += c));
|
|
14
|
+
process.stdin.on('end', () => res(s));
|
|
15
|
+
process.stdin.on('error', rej);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async function main() {
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
21
|
+
try {
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
24
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
|
|
25
|
+
console.log(pkg.version);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
console.log('0.0.0');
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const fp = args[0];
|
|
33
|
+
let src = '';
|
|
34
|
+
if (!fp || fp === '-') {
|
|
35
|
+
src = await readStdin();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
src = fs_1.default.readFileSync(fp, 'utf8');
|
|
39
|
+
}
|
|
40
|
+
const out = (0, parser_1.parseWithTsMorph)(src, fp || 'stdin.ts');
|
|
41
|
+
console.log(JSON.stringify(out, null, 2));
|
|
42
|
+
}
|
|
43
|
+
main().catch((err) => {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.error(err);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = exports.parseWithTsMorph = void 0;
|
|
4
|
+
var parser_1 = require("./parser");
|
|
5
|
+
Object.defineProperty(exports, "parseWithTsMorph", { enumerable: true, get: function () { return parser_1.parseWithTsMorph; } });
|
|
6
|
+
Object.defineProperty(exports, "parser", { enumerable: true, get: function () { return parser_1.parser; } });
|
|
7
|
+
const parser_2 = require("./parser");
|
|
8
|
+
exports.default = parser_2.parser;
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export type ExportKind = "normal" | "default" | "none";
|
|
2
|
+
export interface Position {
|
|
3
|
+
line: number;
|
|
4
|
+
column: number;
|
|
5
|
+
}
|
|
6
|
+
export interface Range {
|
|
7
|
+
start: Position;
|
|
8
|
+
end: Position;
|
|
9
|
+
}
|
|
10
|
+
export interface DecoratorInfo {
|
|
11
|
+
name: string;
|
|
12
|
+
arguments?: string[];
|
|
13
|
+
text?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ParamInfo {
|
|
16
|
+
name: string;
|
|
17
|
+
isJSType: boolean;
|
|
18
|
+
type?: string;
|
|
19
|
+
default?: string;
|
|
20
|
+
defaultParsed?: string | number | boolean | null;
|
|
21
|
+
typeAst?: any;
|
|
22
|
+
decorators?: DecoratorInfo[];
|
|
23
|
+
loc?: Range;
|
|
24
|
+
}
|
|
25
|
+
export interface TypeParameterInfo {
|
|
26
|
+
name: string;
|
|
27
|
+
constraint?: string;
|
|
28
|
+
default?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface BaseItem {
|
|
31
|
+
name: string | null;
|
|
32
|
+
type: string;
|
|
33
|
+
level: "top" | "sub";
|
|
34
|
+
exports?: ExportKind;
|
|
35
|
+
jsdoc?: string;
|
|
36
|
+
decorators?: DecoratorInfo[];
|
|
37
|
+
loc?: Range;
|
|
38
|
+
}
|
|
39
|
+
export interface VariableItem extends BaseItem {
|
|
40
|
+
subtype?: "constant" | "let" | "var";
|
|
41
|
+
value?: string | number | boolean | null;
|
|
42
|
+
valueText?: string;
|
|
43
|
+
valueParsed?: any;
|
|
44
|
+
arguments?: any[];
|
|
45
|
+
}
|
|
46
|
+
export interface FunctionItem extends BaseItem {
|
|
47
|
+
arguments: ParamInfo[];
|
|
48
|
+
typeParameters?: TypeParameterInfo[];
|
|
49
|
+
returnType?: string;
|
|
50
|
+
returnTypeAst?: any;
|
|
51
|
+
}
|
|
52
|
+
export interface ClassMemberProperty {
|
|
53
|
+
name: string;
|
|
54
|
+
private?: boolean;
|
|
55
|
+
static?: boolean;
|
|
56
|
+
readonly?: boolean;
|
|
57
|
+
value?: string | number | boolean | null;
|
|
58
|
+
type?: string;
|
|
59
|
+
decorators?: DecoratorInfo[];
|
|
60
|
+
loc?: Range;
|
|
61
|
+
}
|
|
62
|
+
export interface ClassMemberConstructor {
|
|
63
|
+
type: "constructor";
|
|
64
|
+
for: string;
|
|
65
|
+
function: FunctionItem;
|
|
66
|
+
}
|
|
67
|
+
export interface MethodParamInfo extends ParamInfo {
|
|
68
|
+
optional?: boolean;
|
|
69
|
+
default?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface MethodItem {
|
|
72
|
+
name: string;
|
|
73
|
+
accessibility?: "public" | "private" | "protected";
|
|
74
|
+
static?: boolean;
|
|
75
|
+
async?: boolean;
|
|
76
|
+
abstract?: boolean;
|
|
77
|
+
isGetter?: boolean;
|
|
78
|
+
isSetter?: boolean;
|
|
79
|
+
readonly?: boolean;
|
|
80
|
+
arguments: MethodParamInfo[];
|
|
81
|
+
typeParameters?: TypeParameterInfo[];
|
|
82
|
+
returnType?: string;
|
|
83
|
+
returnTypeAst?: any;
|
|
84
|
+
decorators?: DecoratorInfo[];
|
|
85
|
+
loc?: Range;
|
|
86
|
+
jsdoc?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ClassMemberMethod extends MethodItem {
|
|
89
|
+
}
|
|
90
|
+
export interface IndexSignature {
|
|
91
|
+
keyType?: string;
|
|
92
|
+
returnType?: string;
|
|
93
|
+
readonly?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface TypeAliasItem extends BaseItem {
|
|
96
|
+
target?: string;
|
|
97
|
+
typeParameters?: TypeParameterInfo[];
|
|
98
|
+
}
|
|
99
|
+
export interface EnumMember {
|
|
100
|
+
name: string;
|
|
101
|
+
value?: string | number | boolean | null;
|
|
102
|
+
jsdoc?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface EnumItem extends BaseItem {
|
|
105
|
+
const?: boolean;
|
|
106
|
+
members: EnumMember[];
|
|
107
|
+
}
|
|
108
|
+
export interface NamespaceItem extends BaseItem {
|
|
109
|
+
members: ParsedItem[];
|
|
110
|
+
}
|
|
111
|
+
export interface InterfaceMemberProperty {
|
|
112
|
+
name: string;
|
|
113
|
+
optional?: boolean;
|
|
114
|
+
readonly?: boolean;
|
|
115
|
+
type?: string;
|
|
116
|
+
jsdoc?: string;
|
|
117
|
+
loc?: Range;
|
|
118
|
+
}
|
|
119
|
+
export interface InterfaceMemberMethod {
|
|
120
|
+
name: string;
|
|
121
|
+
arguments: ParamInfo[];
|
|
122
|
+
returnType?: string;
|
|
123
|
+
optional?: boolean;
|
|
124
|
+
jsdoc?: string;
|
|
125
|
+
loc?: Range;
|
|
126
|
+
}
|
|
127
|
+
export interface InterfaceItem extends BaseItem {
|
|
128
|
+
members: Array<InterfaceMemberProperty | InterfaceMemberMethod | IndexSignature>;
|
|
129
|
+
}
|
|
130
|
+
export interface ClassItem extends BaseItem {
|
|
131
|
+
items: Array<ClassMemberConstructor | ClassMemberProperty | ClassMemberMethod | IndexSignature>;
|
|
132
|
+
}
|
|
133
|
+
export type ParsedItem = VariableItem | FunctionItem | ClassItem | InterfaceItem | TypeAliasItem | EnumItem | NamespaceItem;
|
|
134
|
+
export declare function parseWithTsMorph(sourceText: string, fileName?: string): ParsedItem[];
|
|
135
|
+
export declare const parser: {
|
|
136
|
+
parse: typeof parseWithTsMorph;
|
|
137
|
+
parseWithTsMorph: typeof parseWithTsMorph;
|
|
138
|
+
};
|
|
139
|
+
export type Parser = typeof parser;
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
exports.parseWithTsMorph = parseWithTsMorph;
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
function getJsDocText(node) {
|
|
7
|
+
return (node.getJsDocs?.() ?? []).map((d) => d.getDescription?.() ?? d.getComment?.() ?? "").filter(Boolean).join("\n").trim();
|
|
8
|
+
}
|
|
9
|
+
function literalValueText(init) {
|
|
10
|
+
if (!init)
|
|
11
|
+
return undefined;
|
|
12
|
+
const k = init.getKind?.() ?? init.kind;
|
|
13
|
+
if (!k)
|
|
14
|
+
return undefined;
|
|
15
|
+
switch (k) {
|
|
16
|
+
case ts_morph_1.SyntaxKind.StringLiteral: return init.getLiteralText();
|
|
17
|
+
case ts_morph_1.SyntaxKind.NumericLiteral: return Number(init.getText());
|
|
18
|
+
case ts_morph_1.SyntaxKind.TrueKeyword: return true;
|
|
19
|
+
case ts_morph_1.SyntaxKind.FalseKeyword: return false;
|
|
20
|
+
case ts_morph_1.SyntaxKind.NullKeyword: return null;
|
|
21
|
+
default: return init.getText?.()?.slice?.(0, 200);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function paramInfo(param) {
|
|
25
|
+
const init = param.getInitializer?.();
|
|
26
|
+
return {
|
|
27
|
+
name: param.getName?.() ?? String(param.getText?.() ?? ""),
|
|
28
|
+
isJSType: Boolean(param.getTypeNode?.()),
|
|
29
|
+
type: param.getTypeNode?.()?.getText?.(),
|
|
30
|
+
default: init?.getText?.(),
|
|
31
|
+
defaultParsed: literalValueText(init),
|
|
32
|
+
typeAst: parseTypeNode(param.getTypeNode?.()),
|
|
33
|
+
decorators: parseDecorators(param) ?? undefined,
|
|
34
|
+
loc: locOf(param) ?? undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function methodParamInfo(param) {
|
|
38
|
+
return { ...paramInfo(param), optional: param.isOptional?.() ?? false };
|
|
39
|
+
}
|
|
40
|
+
function typeParamsOf(node) {
|
|
41
|
+
const tps = node.getTypeParameters?.() ?? [];
|
|
42
|
+
if (!tps.length)
|
|
43
|
+
return undefined;
|
|
44
|
+
return tps.map((tp) => ({ name: tp.getName?.() ?? "", constraint: tp.getConstraint?.()?.getText?.(), default: tp.getDefault?.()?.getText?.() }));
|
|
45
|
+
}
|
|
46
|
+
function locOf(node) {
|
|
47
|
+
try {
|
|
48
|
+
const src = node.getSourceFile?.() ?? node.getSourceFile?.();
|
|
49
|
+
const start = node.getStart?.() ?? node.getPos?.();
|
|
50
|
+
const end = node.getEnd?.() ?? node.getEnd?.();
|
|
51
|
+
if (!src || start == null || end == null)
|
|
52
|
+
return undefined;
|
|
53
|
+
const s = src.getLineAndColumnAtPos(start);
|
|
54
|
+
const e = src.getLineAndColumnAtPos(end);
|
|
55
|
+
return { start: { line: s.line, column: s.column }, end: { line: e.line, column: e.column } };
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function parseDecorators(node) {
|
|
62
|
+
const decs = node.getDecorators?.() ?? [];
|
|
63
|
+
if (!decs.length)
|
|
64
|
+
return undefined;
|
|
65
|
+
return decs.map((d) => ({ name: d.getName?.() ?? d.getExpression?.()?.getExpression?.()?.getText?.() ?? d.getExpression?.()?.getText?.(), arguments: (d.getArguments?.() ?? []).map((a) => a.getText?.() ?? String(a)), text: d.getText?.() }));
|
|
66
|
+
}
|
|
67
|
+
function parseTypeNode(node) {
|
|
68
|
+
if (!node)
|
|
69
|
+
return undefined;
|
|
70
|
+
const kind = node.getKindName?.() ?? node.getKind?.() ?? node.kind;
|
|
71
|
+
const text = node.getText?.() ?? String(node);
|
|
72
|
+
try {
|
|
73
|
+
const k = node.getKind?.() ?? node.kind;
|
|
74
|
+
const parseElements = (elts) => (elts ?? []).map((e) => {
|
|
75
|
+
try {
|
|
76
|
+
if (!e)
|
|
77
|
+
return undefined;
|
|
78
|
+
const name = e.getName?.()?.getText?.() ?? e.getText?.();
|
|
79
|
+
const txt = e.getText?.() ?? String(e);
|
|
80
|
+
return { name, optional: e.hasQuestionToken?.() ?? false, rest: txt.trim().startsWith('...'), type: parseTypeNode(e.getTypeNode?.() ?? e) };
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return parseTypeNode(e);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
switch (k) {
|
|
87
|
+
case ts_morph_1.SyntaxKind.UnionType:
|
|
88
|
+
return { kind: "union", text, types: (node.getTypeNodes?.() ?? node.types ?? []).map(parseTypeNode) };
|
|
89
|
+
case ts_morph_1.SyntaxKind.IntersectionType:
|
|
90
|
+
return { kind: "intersection", text, types: (node.getTypeNodes?.() ?? node.types ?? []).map(parseTypeNode) };
|
|
91
|
+
case ts_morph_1.SyntaxKind.ArrayType:
|
|
92
|
+
return { kind: "array", text, element: parseTypeNode(node.getElementTypeNode?.() ?? node.elementType) };
|
|
93
|
+
case ts_morph_1.SyntaxKind.TupleType:
|
|
94
|
+
return { kind: "tuple", text, elements: (node.getElements?.() ?? node.getElementTypes?.() ?? node.elementTypes ?? []).map(parseTypeNode) };
|
|
95
|
+
case ts_morph_1.SyntaxKind.OptionalType:
|
|
96
|
+
return { kind: "optional", text, type: parseTypeNode(node.getType?.() ?? node.elementType) };
|
|
97
|
+
case ts_morph_1.SyntaxKind.RestType:
|
|
98
|
+
return { kind: "rest", text, type: parseTypeNode(node.getType?.() ?? node.elementType) };
|
|
99
|
+
case ts_morph_1.SyntaxKind.LiteralType:
|
|
100
|
+
return { kind: "literal", text, value: node.getLiteral?.()?.getText?.() ?? text };
|
|
101
|
+
case ts_morph_1.SyntaxKind.TemplateLiteralType:
|
|
102
|
+
return { kind: "template-literal", text, spans: (node.getTemplateSpans?.() ?? []).map((s) => ({ type: parseTypeNode(s.getType?.()), literal: s.getLiteral?.()?.getText?.() })) };
|
|
103
|
+
case ts_morph_1.SyntaxKind.FunctionType:
|
|
104
|
+
return {
|
|
105
|
+
kind: "function",
|
|
106
|
+
text,
|
|
107
|
+
parameters: (node.getParameters?.() ?? []).map((p) => ({ name: p.getName?.(), type: p.getTypeNode?.()?.getText?.(), typeAst: parseTypeNode(p.getTypeNode?.()) })),
|
|
108
|
+
returnType: node.getReturnType?.()?.getText?.(),
|
|
109
|
+
returnTypeAst: parseTypeNode(node.getReturnType?.())
|
|
110
|
+
};
|
|
111
|
+
case ts_morph_1.SyntaxKind.ParenthesizedType:
|
|
112
|
+
return { kind: "parenthesized", text, type: parseTypeNode(node.getType?.()) };
|
|
113
|
+
case ts_morph_1.SyntaxKind.TypeReference: {
|
|
114
|
+
const typeName = node.getTypeName?.()?.getText?.() ?? node.getText?.();
|
|
115
|
+
return { kind: "reference", text, name: typeName, typeArguments: (node.getTypeArguments?.() ?? []).map(parseTypeNode) };
|
|
116
|
+
}
|
|
117
|
+
case ts_morph_1.SyntaxKind.TypeOperator:
|
|
118
|
+
return { kind: "type-operator", text, operator: node.getOperator?.()?.getText?.() ?? node.getOperator?.(), type: parseTypeNode(node.getType?.()) };
|
|
119
|
+
case ts_morph_1.SyntaxKind.IndexedAccessType:
|
|
120
|
+
return { kind: "indexed-access", text, objectType: parseTypeNode(node.getObjectType?.()), indexType: parseTypeNode(node.getIndexType?.()) };
|
|
121
|
+
case ts_morph_1.SyntaxKind.MappedType:
|
|
122
|
+
return { kind: "mapped", text, typeParameter: node.getTypeParameter?.()?.getText?.(), nameType: node.getNameType?.()?.getText?.(), optional: node.getQuestionToken?.()?.getText?.(), readonly: node.getReadonlyToken?.()?.getText?.(), type: parseTypeNode(node.getType?.()) };
|
|
123
|
+
case ts_morph_1.SyntaxKind.ConditionalType:
|
|
124
|
+
return { kind: "conditional", text, checkType: parseTypeNode(node.getCheckType?.()), extendsType: parseTypeNode(node.getExtendsType?.()), trueType: parseTypeNode(node.getTrueType?.()), falseType: parseTypeNode(node.getFalseType?.()) };
|
|
125
|
+
case ts_morph_1.SyntaxKind.TypePredicate:
|
|
126
|
+
return { kind: "predicate", text, parameterName: node.getParameterName?.()?.getText?.(), asserts: Boolean(node.getAssertKeyword?.()), type: parseTypeNode(node.getType?.()) };
|
|
127
|
+
case ts_morph_1.SyntaxKind.TypeQuery:
|
|
128
|
+
return { kind: "type-query", text, exprName: node.getExprName?.()?.getText?.() ?? node.getText?.() };
|
|
129
|
+
case ts_morph_1.SyntaxKind.InferType:
|
|
130
|
+
return { kind: "infer", text, typeParameter: node.getTypeParameter?.()?.getText?.() };
|
|
131
|
+
case ts_morph_1.SyntaxKind.TemplateLiteralType:
|
|
132
|
+
return { kind: "template-literal", text };
|
|
133
|
+
case ts_morph_1.SyntaxKind.TypeLiteral:
|
|
134
|
+
return { kind: "object", text, properties: (node.getMembers?.() ?? []).map((m) => ({ name: m.getName?.() ?? "", type: m.getTypeNode?.()?.getText?.(), typeAst: parseTypeNode(m.getTypeNode?.()), readonly: m.hasModifier?.("readonly") ?? false })) };
|
|
135
|
+
case ts_morph_1.SyntaxKind.TupleType:
|
|
136
|
+
return { kind: "tuple", text, elements: (node.getElementTypes?.() ?? []).map(parseTypeNode) };
|
|
137
|
+
case ts_morph_1.SyntaxKind.ImportType:
|
|
138
|
+
return { kind: "import", text, argument: node.getArgument?.()?.getText?.() ?? node.getText?.() };
|
|
139
|
+
default:
|
|
140
|
+
// fallback: include available shorthand text and preserve node.kindName when possible
|
|
141
|
+
return { kind: "unknown", kindName: kind, text };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
return { kind: "unknown", text, error: String(err) };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function functionLikeToItem(fn, level = "top") {
|
|
149
|
+
return {
|
|
150
|
+
name: fn.getName?.() ?? null,
|
|
151
|
+
type: "function",
|
|
152
|
+
level,
|
|
153
|
+
exports: fn.isDefaultExport?.() ? "default" : fn.isExported?.() ? "normal" : "none",
|
|
154
|
+
jsdoc: getJsDocText(fn),
|
|
155
|
+
decorators: parseDecorators(fn) ?? undefined,
|
|
156
|
+
loc: locOf(fn) ?? undefined,
|
|
157
|
+
arguments: (fn.getParameters?.() ?? []).map(paramInfo),
|
|
158
|
+
typeParameters: typeParamsOf(fn),
|
|
159
|
+
returnType: fn.getReturnTypeNode?.()?.getText?.(),
|
|
160
|
+
returnTypeAst: parseTypeNode(fn.getReturnTypeNode?.()),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function parseWithTsMorph(sourceText, fileName = "file.ts") {
|
|
164
|
+
const isProbablyTS = /\b(interface|type\s+\w+\s*=|:\s*\w|enum\s+\w+)\b/.test(sourceText);
|
|
165
|
+
const autoName = fileName === "file.ts" ? `file.${isProbablyTS ? "ts" : "js"}` : fileName;
|
|
166
|
+
const project = new ts_morph_1.Project({ useInMemoryFileSystem: true, compilerOptions: { allowJs: true, checkJs: false } });
|
|
167
|
+
const src = project.createSourceFile(autoName, sourceText, { overwrite: true });
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const stmt of src.getStatements()) {
|
|
170
|
+
const vs = stmt.asKind(ts_morph_1.SyntaxKind.VariableStatement);
|
|
171
|
+
if (vs) {
|
|
172
|
+
const kind = vs.getDeclarationKind?.();
|
|
173
|
+
for (const d of vs.getDeclarationList().getDeclarations()) {
|
|
174
|
+
const init = d.getInitializer?.();
|
|
175
|
+
out.push({ name: d.getName(), type: "variable", subtype: kind === "const" ? "constant" : kind === "let" ? "let" : "var", value: literalValueText(init), valueText: init?.getText?.(), valueParsed: literalValueText(init), exports: vs.isDefaultExport?.() ? "default" : vs.isExported?.() ? "normal" : "none", level: "top", jsdoc: getJsDocText(d), decorators: parseDecorators(d) ?? undefined, loc: locOf(d) ?? undefined, arguments: [] });
|
|
176
|
+
}
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const fd = stmt.asKind(ts_morph_1.SyntaxKind.FunctionDeclaration);
|
|
180
|
+
if (fd) {
|
|
181
|
+
out.push(functionLikeToItem(fd, "top"));
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const ta = stmt.asKind(ts_morph_1.SyntaxKind.TypeAliasDeclaration);
|
|
185
|
+
if (ta) {
|
|
186
|
+
out.push({ name: ta.getName?.() ?? null, type: "type-alias", level: "top", exports: ta.isDefaultExport?.() ? "default" : ta.isExported?.() ? "normal" : "none", jsdoc: getJsDocText(ta), target: ta.getTypeNode?.()?.getText?.() ?? ta.getType?.()?.getText?.(), typeParameters: typeParamsOf(ta) });
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const ed = stmt.asKind(ts_morph_1.SyntaxKind.EnumDeclaration);
|
|
190
|
+
if (ed) {
|
|
191
|
+
const members = [];
|
|
192
|
+
for (const m of ed.getMembers()) {
|
|
193
|
+
members.push({ name: m.getName?.() ?? "", value: literalValueText(m.getInitializer?.()), jsdoc: getJsDocText(m) });
|
|
194
|
+
}
|
|
195
|
+
out.push({ name: ed.getName?.() ?? null, type: "enum", level: "top", exports: ed.isDefaultExport?.() ? "default" : ed.isExported?.() ? "normal" : "none", jsdoc: getJsDocText(ed), const: ed.isConstEnum?.() ?? false, members });
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const ea = stmt.asKind(ts_morph_1.SyntaxKind.ExportAssignment);
|
|
199
|
+
if (ea) {
|
|
200
|
+
const expr = ea.getExpression?.();
|
|
201
|
+
if (!expr)
|
|
202
|
+
continue;
|
|
203
|
+
const k = expr.getKindName?.();
|
|
204
|
+
if (k === "FunctionExpression" || k === "ArrowFunction") {
|
|
205
|
+
const f = functionLikeToItem(expr, "top");
|
|
206
|
+
f.exports = "default";
|
|
207
|
+
out.push(f);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const id = expr.getText?.();
|
|
211
|
+
if (id) {
|
|
212
|
+
const vd = src.getVariableDeclaration(id);
|
|
213
|
+
if (vd)
|
|
214
|
+
out.push({ name: vd.getName(), type: "variable", subtype: "constant", value: literalValueText(vd.getInitializer?.()), exports: "default", level: "top", jsdoc: getJsDocText(vd), arguments: [] });
|
|
215
|
+
}
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const cd = stmt.asKind(ts_morph_1.SyntaxKind.ClassDeclaration);
|
|
219
|
+
if (cd) {
|
|
220
|
+
const members = [];
|
|
221
|
+
for (const m of cd.getMembers()) {
|
|
222
|
+
const ctor = m.asKind?.(ts_morph_1.SyntaxKind.Constructor);
|
|
223
|
+
if (ctor) {
|
|
224
|
+
members.push({ type: "constructor", for: cd.getName?.() ?? "", function: functionLikeToItem(ctor, "sub") });
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const meth = m.asKind?.(ts_morph_1.SyntaxKind.MethodDeclaration);
|
|
228
|
+
if (meth) {
|
|
229
|
+
members.push({
|
|
230
|
+
name: meth.getName?.() ?? "",
|
|
231
|
+
accessibility: meth.hasModifier?.("private") ? "private" : meth.hasModifier?.("protected") ? "protected" : undefined,
|
|
232
|
+
static: meth.isStatic?.() ?? false,
|
|
233
|
+
async: meth.isAsync?.() ?? false,
|
|
234
|
+
abstract: meth.isAbstract?.() ?? false,
|
|
235
|
+
decorators: parseDecorators(meth) ?? undefined,
|
|
236
|
+
arguments: (meth.getParameters?.() ?? []).map(methodParamInfo),
|
|
237
|
+
typeParameters: typeParamsOf(meth),
|
|
238
|
+
returnType: meth.getReturnTypeNode?.()?.getText?.(),
|
|
239
|
+
returnTypeAst: parseTypeNode(meth.getReturnTypeNode?.()),
|
|
240
|
+
jsdoc: getJsDocText(meth),
|
|
241
|
+
loc: locOf(meth) ?? undefined,
|
|
242
|
+
});
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
const getter = m.asKind?.(ts_morph_1.SyntaxKind.GetAccessor);
|
|
246
|
+
if (getter) {
|
|
247
|
+
members.push({ name: getter.getName?.() ?? "", isGetter: true, arguments: [], returnType: getter.getReturnTypeNode?.()?.getText?.(), jsdoc: getJsDocText(getter) });
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const setter = m.asKind?.(ts_morph_1.SyntaxKind.SetAccessor);
|
|
251
|
+
if (setter) {
|
|
252
|
+
members.push({ name: setter.getName?.() ?? "", isSetter: true, arguments: (setter.getParameters?.() ?? []).map(methodParamInfo), jsdoc: getJsDocText(setter) });
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const prop = m.asKind?.(ts_morph_1.SyntaxKind.PropertyDeclaration);
|
|
256
|
+
if (prop) {
|
|
257
|
+
const name = prop.getName?.() ?? "";
|
|
258
|
+
members.push({ name, private: prop.hasModifier?.("private") || name.startsWith("#"), static: prop.isStatic?.() ?? false, readonly: prop.isReadonly?.() ?? false, value: literalValueText(prop.getInitializer?.()) });
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const idx = m.asKind?.(ts_morph_1.SyntaxKind.IndexSignature);
|
|
262
|
+
if (idx) {
|
|
263
|
+
const txt = idx.getText?.() ?? "";
|
|
264
|
+
const mKey = txt.match(/\[\s*[^:]+:\s*([^\]]+)\]/);
|
|
265
|
+
const keyType = mKey ? mKey[1].trim() : undefined;
|
|
266
|
+
const returnType = idx.getReturnTypeNode?.()?.getText?.() ?? (txt.match(/:\s*([^;\]]+)$/)?.[1]?.trim());
|
|
267
|
+
members.push({ keyType, returnType, readonly: idx.hasModifier?.("readonly") ?? false });
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
out.push({ name: cd.getName?.() ?? null, type: "class", level: "top", exports: cd.isDefaultExport?.() ? "default" : cd.isExported?.() ? "normal" : "none", jsdoc: getJsDocText(cd), items: members, typeParameters: typeParamsOf(cd) });
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const id = stmt.asKind(ts_morph_1.SyntaxKind.InterfaceDeclaration);
|
|
275
|
+
if (id) {
|
|
276
|
+
const members = [];
|
|
277
|
+
for (const m of id.getMembers()) {
|
|
278
|
+
const prop = m.asKind?.(ts_morph_1.SyntaxKind.PropertySignature);
|
|
279
|
+
if (prop) {
|
|
280
|
+
members.push({ name: prop.getName?.() ?? "", optional: prop.hasQuestionToken?.() ?? false, readonly: prop.hasModifier?.("readonly") ?? false, type: prop.getTypeNode?.()?.getText?.(), jsdoc: getJsDocText(prop) });
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const ms = m.asKind?.(ts_morph_1.SyntaxKind.MethodSignature);
|
|
284
|
+
if (ms) {
|
|
285
|
+
members.push({ name: ms.getName?.() ?? "", arguments: (ms.getParameters?.() ?? []).map(paramInfo), returnType: ms.getReturnTypeNode?.()?.getText?.(), optional: ms.hasQuestionToken?.() ?? false, jsdoc: getJsDocText(ms) });
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const idx = m.asKind?.(ts_morph_1.SyntaxKind.IndexSignature);
|
|
289
|
+
if (idx) {
|
|
290
|
+
const txt = idx.getText?.() ?? "";
|
|
291
|
+
const mKey = txt.match(/\[\s*[^:]+:\s*([^\]]+)\]/);
|
|
292
|
+
const keyType = mKey ? mKey[1].trim() : undefined;
|
|
293
|
+
const returnType = idx.getReturnTypeNode?.()?.getText?.() ?? (txt.match(/:\s*([^;\]]+)$/)?.[1]?.trim());
|
|
294
|
+
members.push({ keyType, returnType, readonly: idx.hasModifier?.("readonly") ?? false });
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
out.push({ name: id.getName?.() ?? null, type: "interface", level: "top", exports: id.isDefaultExport?.() ? "default" : id.isExported?.() ? "normal" : "none", jsdoc: getJsDocText(id), members, typeParameters: typeParamsOf(id) });
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const md = stmt.asKind(ts_morph_1.SyntaxKind.ModuleDeclaration);
|
|
302
|
+
if (md) {
|
|
303
|
+
const body = md.getBody?.();
|
|
304
|
+
const members = [];
|
|
305
|
+
if (body && body.getStatements) {
|
|
306
|
+
for (const s of body.getStatements()) {
|
|
307
|
+
const tmp = ts_morph_1.Project.prototype.createSourceFile.call(src.getProject(), "__tmp.ts", s.getText(), { overwrite: true });
|
|
308
|
+
members.push(...parseWithTsMorph(tmp.getFullText(), "__tmp.ts").map((it) => ({ ...it, level: "sub" })));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
out.push({ name: md.getName?.() ?? null, type: "namespace", level: "top", exports: md.isExported?.() ? "normal" : "none", jsdoc: getJsDocText(md), members });
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return out;
|
|
316
|
+
}
|
|
317
|
+
exports.parser = {
|
|
318
|
+
parse: parseWithTsMorph,
|
|
319
|
+
parseWithTsMorph,
|
|
320
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@briklab/parsee",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Compact ts-morph-based parser that summarizes top-level exports and TypeScript type ASTs as JSON.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ts-morph",
|
|
15
|
+
"typescript",
|
|
16
|
+
"ast",
|
|
17
|
+
"parser",
|
|
18
|
+
"exports"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@types/node": "^25.2.0",
|
|
24
|
+
"ts-morph": "^27.0.2",
|
|
25
|
+
"ts-node": "^10.9.2",
|
|
26
|
+
"typescript": "^5.9.3"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=14"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"dev": "ts-node parser.ts",
|
|
34
|
+
"demo": "ts-node parser.ts",
|
|
35
|
+
"test": "node ./dist/cli.js --version || true"
|
|
36
|
+
}
|
|
37
|
+
}
|