also looking at this
chore(deps): update all non-major dependencies
#2997
29 files
+1047
-444
| @@ -235,49 +235,8 @@ export function isBuiltInType(typeName: string): boolean { | ||
| 235 | 235 | return BUILT_IN_TYPES.has(typeName) |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | /** | |
| 239 | * Extract triple-slash directives from the beginning of source code | |
| 240 | * These are special comments like /// <reference types="..." /> | |
| 241 | */ | |
| 242 | export function extractTripleSlashDirectives(sourceCode: string): string[] { | |
| 243 | const directives: string[] = [] | |
| 244 | let lineStart = 0 | |
| 245 | ||
| 246 | // Scan line-by-line without splitting the entire source (stops early for large files) | |
| 247 | for (let i = 0; i <= sourceCode.length; i++) { | |
| 248 | if (i === sourceCode.length || sourceCode[i] === '\n') { | |
| 249 | // Extract and trim the current line | |
| 250 | let start = lineStart | |
| 251 | let end = i | |
| 252 | while (start < end && (sourceCode[start] === ' ' || sourceCode[start] === '\t' || sourceCode[start] === '\r')) start++ | |
| 253 | while (end > start && (sourceCode[end - 1] === ' ' || sourceCode[end - 1] === '\t' || sourceCode[end - 1] === '\r')) end-- | |
| 254 | const trimmed = sourceCode.slice(start, end) | |
| 255 | lineStart = i + 1 | |
| 256 | ||
| 257 | // Triple-slash directives must be at the very beginning of the file | |
| 258 | // (only whitespace and other triple-slash directives can precede them) | |
| 259 | if (trimmed.startsWith('///')) { | |
| 260 | if (trimmed.match(/^\/\/\/\s*<reference\s+(path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/)) { | |
| 261 | directives.push(trimmed) | |
| 262 | } | |
| 263 | else if (trimmed.match(/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/)) { | |
| 264 | directives.push(trimmed) | |
| 265 | } | |
| 266 | else if (trimmed.match(/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/)) { | |
| 267 | directives.push(trimmed) | |
| 268 | } | |
| 269 | } | |
| 270 | else if (trimmed === '' || trimmed.startsWith('//')) { | |
| 271 | continue | |
| 272 | } | |
| 273 | else { | |
| 274 | break | |
| 275 | } | |
| 276 | } | |
| 277 | } | |
| 278 | ||
| 279 | return directives | |
| 280 | } | |
| 238 | // Re-exported from directives.ts for backward compatibility | |
| 239 | export { extractTripleSlashDirectives } from './directives' | |
| 281 | 240 | |
| 282 | 241 | /** |
| 283 | 242 | * Extract type names from module/namespace text |