feat: support WRN imports and dynamic public shell
This commit is contained in:
@@ -89,6 +89,7 @@ function stripComments(source) {
|
||||
function maskLeadingTrivia(source) {
|
||||
const masked = [...source];
|
||||
let offset = 0;
|
||||
const importPattern = /import\s+(?:type\s+)?(?:[\s\S]*?\s+from\s+)?["'][^"'\r\n]+["']\s*;?/y;
|
||||
|
||||
while (offset < source.length) {
|
||||
if (/\s/u.test(source[offset])) {
|
||||
@@ -96,6 +97,17 @@ function maskLeadingTrivia(source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
importPattern.lastIndex = offset;
|
||||
const importStatement = importPattern.exec(source);
|
||||
if (importStatement) {
|
||||
const end = importPattern.lastIndex;
|
||||
while (offset < end) {
|
||||
if (source[offset] !== "\n" && source[offset] !== "\r") masked[offset] = " ";
|
||||
offset += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!source.startsWith("//", offset)) break;
|
||||
|
||||
while (offset < source.length && source[offset] !== "\n") {
|
||||
|
||||
Reference in New Issue
Block a user