File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * Removes leading comments from code
3+ */
4+ export function removeLeadingComments ( code : string ) : string {
5+ const lines = code . split ( '\n' )
6+ let index = 0
7+ while ( index < lines . length ) {
8+ const line = lines [ index ] . trim ( )
9+ if ( line . startsWith ( '//' ) || line . startsWith ( '/*' ) || line . startsWith ( '*' ) || line === '' ) {
10+ index ++
11+ }
12+ else {
13+ break
14+ }
15+ }
16+ return lines . slice ( index ) . join ( '\n' )
17+ }
18+
19+ /**
20+ * Clean single line comments and whitespace from a string
21+ */
22+ export function cleanComments ( input : string ) : string {
23+ return input
24+ // Remove single line comments
25+ . replace ( / \/ \/ [ ^ \n ] * / g, '' )
26+ // Clean up empty lines that may be left after comment removal
27+ . split ( '\n' )
28+ . map ( line => line . trim ( ) )
29+ . filter ( Boolean )
30+ . join ( '\n' )
31+ }
Original file line number Diff line number Diff line change 1+ import type { ImportTrackingState , ProcessingState } from './types'
2+
3+ /**
4+ * Creates initial processing state with empty collections
5+ */
6+ export function createProcessingState ( ) : ProcessingState {
7+ return {
8+ dtsLines : [ ] ,
9+ imports : [ ] ,
10+ usedTypes : new Set ( ) ,
11+ typeSources : new Map ( ) ,
12+ defaultExport : null ,
13+ exportAllStatements : [ ] ,
14+ currentDeclaration : '' ,
15+ lastCommentBlock : '' ,
16+ bracketCount : 0 ,
17+ isMultiLineDeclaration : false ,
18+ moduleImports : new Map ( ) ,
19+ availableTypes : new Map ( ) ,
20+ availableValues : new Map ( ) ,
21+ currentIndentation : '' ,
22+ declarationBuffer : null ,
23+ importTracking : createImportTrackingState ( ) ,
24+ defaultExports : new Set ( ) ,
25+ debug : {
26+ exports : {
27+ default : [ ] ,
28+ named : [ ] ,
29+ all : [ ] ,
30+ } ,
31+ declarations : [ ] ,
32+ currentProcessing : '' ,
33+ } ,
34+ }
35+ }
36+
37+ /**
38+ * Creates initial import tracking state
39+ */
40+ function createImportTrackingState ( ) : ImportTrackingState {
41+ return {
42+ typeImports : new Map ( ) ,
43+ valueImports : new Map ( ) ,
44+ usedTypes : new Set ( ) ,
45+ usedValues : new Set ( ) ,
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments