-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9be5305
commit 8fd07e8
Showing
11 changed files
with
1,359 additions
and
1,378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Removes leading comments from code | ||
*/ | ||
export function removeLeadingComments(code: string): string { | ||
const lines = code.split('\n') | ||
let index = 0 | ||
while (index < lines.length) { | ||
const line = lines[index].trim() | ||
if (line.startsWith('//') || line.startsWith('/*') || line.startsWith('*') || line === '') { | ||
index++ | ||
} | ||
else { | ||
break | ||
} | ||
} | ||
return lines.slice(index).join('\n') | ||
} | ||
|
||
/** | ||
* Clean single line comments and whitespace from a string | ||
*/ | ||
export function cleanComments(input: string): string { | ||
return input | ||
// Remove single line comments | ||
.replace(/\/\/[^\n]*/g, '') | ||
// Clean up empty lines that may be left after comment removal | ||
.split('\n') | ||
.map(line => line.trim()) | ||
.filter(Boolean) | ||
.join('\n') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { ImportTrackingState, ProcessingState } from './types' | ||
|
||
/** | ||
* Creates initial processing state with empty collections | ||
*/ | ||
export function createProcessingState(): ProcessingState { | ||
return { | ||
dtsLines: [], | ||
imports: [], | ||
usedTypes: new Set(), | ||
typeSources: new Map(), | ||
defaultExport: null, | ||
exportAllStatements: [], | ||
currentDeclaration: '', | ||
lastCommentBlock: '', | ||
bracketCount: 0, | ||
isMultiLineDeclaration: false, | ||
moduleImports: new Map(), | ||
availableTypes: new Map(), | ||
availableValues: new Map(), | ||
currentIndentation: '', | ||
declarationBuffer: null, | ||
importTracking: createImportTrackingState(), | ||
defaultExports: new Set(), | ||
debug: { | ||
exports: { | ||
default: [], | ||
named: [], | ||
all: [], | ||
}, | ||
declarations: [], | ||
currentProcessing: '', | ||
}, | ||
} | ||
} | ||
|
||
/** | ||
* Creates initial import tracking state | ||
*/ | ||
function createImportTrackingState(): ImportTrackingState { | ||
return { | ||
typeImports: new Map(), | ||
valueImports: new Map(), | ||
usedTypes: new Set(), | ||
usedValues: new Set(), | ||
} | ||
} |
Oops, something went wrong.