ReviewOS

also looking at this

stacks/dtsx

chore(deps): update all non-major dependencies

#2997
Closed renovate[bot] wants to merge renovate/all-minor-patch into main
29 files +1047 -444
packages/dtsx/src/extractor/scanner.tsmodified+589-181
Changes to packages/dtsx/src/extractor/scanner.ts
@@ -95,6 +95,47 @@ export function scanDeclarations(source: string, filename: string, keepComments:
9595 }
9696 }
9797
98 /** Strip trailing comments from a line, preserving leading whitespace */
99 function stripTrailingComment(line: string): string {
100 const lineLen = line.length
101 let inString = 0 // 0=none, quote char code when in string
102 let end = lineLen
103 for (let i = 0; i < lineLen; i++) {
104 const c = line.charCodeAt(i)
105 if (inString) {
106 if (c === CH_BACKSLASH) { i++; continue }
107 if (c === inString) inString = 0
108 continue
109 }
110 if (c === CH_SQUOTE || c === CH_DQUOTE || c === CH_BACKTICK) {
111 inString = c
112 continue
113 }
114 if (c === CH_SLASH && i + 1 < lineLen) {
115 const next = line.charCodeAt(i + 1)
116 if (next === CH_SLASH) {
117 // Trim trailing whitespace before //
118 end = i
119 while (end > 0 && (line.charCodeAt(end - 1) === CH_SPACE || line.charCodeAt(end - 1) === CH_TAB)) end--
120 return line.slice(0, end)
121 }
122 if (next === CH_STAR) {
123 // Inline /* ... */ — find closing and replace with space
124 const closeIdx = line.indexOf('*/', i + 2)
125 if (closeIdx !== -1) {
126 line = line.slice(0, i) + ' ' + line.slice(closeIdx + 2)
127 i-- // re-scan
128 continue
129 }
130 }
131 }
132 }
133 // Trim trailing whitespace
134 end = lineLen
135 while (end > 0 && (line.charCodeAt(end - 1) === CH_SPACE || line.charCodeAt(end - 1) === CH_TAB || line.charCodeAt(end - 1) === CH_CR)) end--
136 return end < lineLen ? line.slice(0, end) : line
137 }
138
98139 function skipString(quote: number): void {
99140 pos++ // skip opening quote
100141 while (pos < len) {
@@ -165,10 +206,72 @@ export function scanDeclarations(source: string, filename: string, keepComments:
165206 pos += 2
166207 return true
167208 }
209 // Check for regex literal: / not followed by / or *, preceded by non-expression char
210 if (isRegexStart()) {
211 skipRegex()
212 return true
213 }
168214 }
169215 return false
170216 }
171217
218 /** Check if `/` at current pos is the start of a regex literal (not division) */
219 function isRegexStart(): boolean {
220 // Look backward for the previous non-whitespace character
221 let p = pos - 1
222 while (p >= 0 && (source.charCodeAt(p) === CH_SPACE || source.charCodeAt(p) === CH_TAB || source.charCodeAt(p) === CH_LF || source.charCodeAt(p) === CH_CR)) p--
223 if (p < 0)
224 return true // start of file
225 const prev = source.charCodeAt(p)
226 // After these chars, `/` starts a regex (not division)
227 // = ( [ ! & | ? : , ; { } ^ ~ + - * % < > \n
228 if (prev === CH_EQUAL || prev === CH_LPAREN || prev === CH_LBRACKET
229 || prev === 33 /* ! */ || prev === 38 /* & */ || prev === 124 /* | */
230 || prev === CH_QUESTION || prev === CH_COLON || prev === CH_COMMA
231 || prev === CH_SEMI || prev === CH_LBRACE || prev === CH_RBRACE
232 || prev === 94 /* ^ */ || prev === 126 /* ~ */
233 || prev === 43 /* + */ || prev === 45 /* - */ || prev === CH_STAR
234 || prev === 37 /* % */ || prev === CH_LANGLE || prev === CH_RANGLE) {
235 return true
236 }
237 // After keywords like return, typeof, void, delete, throw, new, in, of, case
238 if (isIdentChar(prev)) {
239 let wp = p
240 while (wp >= 0 && isIdentChar(source.charCodeAt(wp))) wp--
241 const word = source.slice(wp + 1, p + 1)
242 if (word === 'return' || word === 'typeof' || word === 'void'
243 || word === 'delete' || word === 'throw' || word === 'new'
244 || word === 'in' || word === 'of' || word === 'case'
245 || word === 'instanceof' || word === 'yield' || word === 'await') {
246 return true
247 }
248 }
249 return false
250 }
251
252 /** Skip a regex literal /.../ including flags */
253 function skipRegex(): void {
254 pos++ // skip opening /
255 let inCharClass = false
256 while (pos < len) {
257 const ch = source.charCodeAt(pos)
258 if (ch === CH_BACKSLASH) { pos += 2; continue } // skip escaped char
259 if (inCharClass) {
260 if (ch === CH_RBRACKET)
261 inCharClass = false
262 pos++
263 continue
264 }
265 if (ch === CH_LBRACKET) { inCharClass = true; pos++; continue }
266 if (ch === CH_SLASH) { pos++; break } // closing /
267 if (ch === CH_LF || ch === CH_CR)
268 break // unterminated regex
269 pos++
270 }
271 // Skip flags (g, i, m, s, u, y, d, v)
272 while (pos < len && isIdentChar(source.charCodeAt(pos))) pos++
273 }
274
172275 /** Read an identifier at current position */
173276 function readIdent(): string {
174277 const start = pos
@@ -192,12 +295,22 @@ export function scanDeclarations(source: string, filename: string, keepComments:
192295
193296 /** Check if current position is at a top-level statement-starting keyword */
194297 function isTopLevelKeyword(): boolean {
195 return matchWord('export') || matchWord('import') || matchWord('function')
196 || matchWord('class') || matchWord('interface') || matchWord('type')
197 || matchWord('enum') || matchWord('const') || matchWord('let')
198 || matchWord('var') || matchWord('declare') || matchWord('module')
199 || matchWord('namespace') || matchWord('abstract') || matchWord('async')
200 || matchWord('default')
298 if (pos >= len) return false
299 const ch = source.charCodeAt(pos)
300 switch (ch) {
301 case 101: /* e */ return matchWord('export') || matchWord('enum')
302 case 105: /* i */ return matchWord('import') || matchWord('interface')
303 case 102: /* f */ return matchWord('function')
304 case 99: /* c */ return matchWord('class') || matchWord('const')
305 case 116: /* t */ return matchWord('type')
306 case 108: /* l */ return matchWord('let')
307 case 118: /* v */ return matchWord('var')
308 case 100: /* d */ return matchWord('declare') || matchWord('default')
309 case 109: /* m */ return matchWord('module')
310 case 110: /* n */ return matchWord('namespace')
311 case 97: /* a */ return matchWord('abstract') || matchWord('async')
312 default: return false
313 }
201314 }
202315
203316 /**
@@ -215,12 +328,24 @@ export function scanDeclarations(source: string, filename: string, keepComments:
215328 while (pos < len) {
216329 const c = source.charCodeAt(pos)
217330 if (c === CH_SPACE || c === CH_TAB || c === CH_CR || c === CH_LF) { pos++; continue }
218 if (c === CH_SLASH && pos + 1 < len && source.charCodeAt(pos + 1) === CH_SLASH) {
219 pos += 2
220 while (pos < len && source.charCodeAt(pos) !== CH_LF) pos++
221 if (pos < len)
222 pos++
223 continue
331 if (c === CH_SLASH && pos + 1 < len) {
332 const next = source.charCodeAt(pos + 1)
333 if (next === CH_SLASH) {
334 // Skip line comment
335 pos += 2
336 while (pos < len && source.charCodeAt(pos) !== CH_LF) pos++
337 if (pos < len)
338 pos++
339 continue
340 }
341 if (next === CH_STAR) {
342 // Skip block/JSDoc comment
343 pos += 2
344 while (pos < len - 1 && !(source.charCodeAt(pos) === CH_STAR && source.charCodeAt(pos + 1) === CH_SLASH)) pos++
345 if (pos < len - 1)
346 pos += 2
347 continue
348 }
224349 }
225350 break
226351 }
@@ -331,10 +456,11 @@ export function scanDeclarations(source: string, filename: string, keepComments:
331456 */
332457 function skipExportBraces(): void {
333458 findMatchingClose(CH_LBRACE, CH_RBRACE)
334 skipWhitespaceAndComments()
459 // Only skip whitespace (not comments) to find 'from' — comments belong to next declaration
460 while (pos < len && isWhitespace(source.charCodeAt(pos))) pos++
335461 if (matchWord('from')) {
336462 pos += 4
337 skipWhitespaceAndComments()
463 while (pos < len && isWhitespace(source.charCodeAt(pos))) pos++
338464 if (pos < len) {
339465 const ch = source.charCodeAt(pos)
340466 if (ch === CH_SQUOTE || ch === CH_DQUOTE)
@@ -352,16 +478,16 @@ export function scanDeclarations(source: string, filename: string, keepComments:
352478 */
353479 function skipExportStar(): void {
354480 pos++ // skip *
355 skipWhitespaceAndComments()
481 while (pos < len && isWhitespace(source.charCodeAt(pos))) pos++
356482 if (matchWord('as')) {
357483 pos += 2
358 skipWhitespaceAndComments()
484 while (pos < len && isWhitespace(source.charCodeAt(pos))) pos++
359485 readIdent()
360 skipWhitespaceAndComments()
486 while (pos < len && isWhitespace(source.charCodeAt(pos))) pos++
361487 }
362488 if (matchWord('from')) {
363489 pos += 4
364 skipWhitespaceAndComments()
490 while (pos < len && isWhitespace(source.charCodeAt(pos))) pos++
365491 if (pos < len) {
366492 const ch = source.charCodeAt(pos)
367493 if (ch === CH_SQUOTE || ch === CH_DQUOTE)
@@ -387,8 +513,10 @@ export function scanDeclarations(source: string, filename: string, keepComments:
387513 return undefined
388514
389515 const comments: string[] = []
516 let hasBlockComment = false
390517
391518 // Scan backwards for consecutive comment blocks
519 // Use push() + reverse at end (O(1) per append vs O(n) for unshift)
392520 while (p >= 0) {
393521 // Check for block comment ending with */
394522 if (p >= 1 && source.charCodeAt(p) === CH_SLASH && source.charCodeAt(p - 1) === CH_STAR) {
@@ -396,7 +524,8 @@ export function scanDeclarations(source: string, filename: string, keepComments:
396524 let start = p - 2
397525 while (start >= 1 && !(source.charCodeAt(start) === CH_SLASH && source.charCodeAt(start + 1) === CH_STAR)) start--
398526 if (start >= 0 && source.charCodeAt(start) === CH_SLASH && source.charCodeAt(start + 1) === CH_STAR) {
399 comments.unshift(source.slice(start, p + 1))
527 comments.push(source.slice(start, p + 1))
528 hasBlockComment = true
400529 p = start - 1
401530 while (p >= 0 && isWhitespace(source.charCodeAt(p))) p--
402531 continue
@@ -411,7 +540,11 @@ export function scanDeclarations(source: string, filename: string, keepComments:
411540 const lineText = source.slice(lineStart, p + 1).trim()
412541
413542 if (lineText.startsWith('//')) {
414 // Collect consecutive single-line comments
543 // Don't include // comments above block comments (they're section headers, not doc comments)
544 if (hasBlockComment)
545 break
546
547 // Collect consecutive single-line comments (push + reverse)
415548 const singleLines: string[] = [lineText]
416549 p = lineStart - 1
417550 while (p >= 0 && (source.charCodeAt(p) === CH_LF || source.charCodeAt(p) === CH_CR)) p--
@@ -421,7 +554,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
421554 while (ls > 0 && source.charCodeAt(ls - 1) !== CH_LF) ls--
422555 const lt = source.slice(ls, p + 1).trim()
423556 if (lt.startsWith('//')) {
424 singleLines.unshift(lt)
557 singleLines.push(lt)
425558 p = ls - 1
426559 while (p >= 0 && (source.charCodeAt(p) === CH_LF || source.charCodeAt(p) === CH_CR)) p--
427560 }
@@ -433,7 +566,8 @@ export function scanDeclarations(source: string, filename: string, keepComments:
433566 break
434567 }
435568 }
436 comments.unshift(singleLines.join('\n'))
569 singleLines.reverse()
570 comments.push(singleLines.join('\n'))
437571 continue
438572 }
439573
@@ -441,7 +575,9 @@ export function scanDeclarations(source: string, filename: string, keepComments:
441575 break
442576 }
443577
444 return comments.length > 0 ? comments : undefined
578 if (comments.length === 0) return undefined
579 comments.reverse()
580 return comments
445581 }
446582
447583 // --- High-level extraction ---
@@ -471,15 +607,50 @@ export function scanDeclarations(source: string, filename: string, keepComments:
471607 }
472608
473609 const text = source.slice(stmtStart, pos).trim()
474 const isTypeOnly = text.startsWith('import type ') || text.startsWith('import type{')
475
476 // Detect side-effect imports
477 const isSideEffect = !text.includes('{') && !text.includes(' as ') && !/import\s+\w/.test(text.replace(/import\s+type\s/, 'import ').replace(/import\s+['"]/, 'import_str '))
478 const isSideEffectImport = /^import\s+['"]/.test(text) || /^import\s+type\s+['"]/.test(text.replace('type ', ''))
479
480 // Extract source module
481 const sourceMatch = text.match(/from\s+['"]([^'"]+)['"]/) || text.match(/import\s+['"]([^'"]+)['"]/)
482 const moduleSrc = sourceMatch ? sourceMatch[1] : ''
610 const isTypeOnly = text.charCodeAt(7) === 116 /* t */ && (text.startsWith('import type ') || text.startsWith('import type{'))
611
612 // Detect side-effect imports: import 'foo' or import "foo" (no names imported)
613 // After 'import' + optional 'type', next non-ws must be a quote
614 let isSideEffectImport = false
615 {
616 let si = 6 // skip 'import'
617 while (si < text.length && (text.charCodeAt(si) === CH_SPACE || text.charCodeAt(si) === CH_TAB)) si++
618 if (si < text.length && text.charCodeAt(si) === 116 /* t */ && text.startsWith('type', si)) {
619 si += 4
620 while (si < text.length && (text.charCodeAt(si) === CH_SPACE || text.charCodeAt(si) === CH_TAB)) si++
621 }
622 if (si < text.length) {
623 const qc = text.charCodeAt(si)
624 isSideEffectImport = qc === CH_SQUOTE || qc === CH_DQUOTE
625 }
626 }
627
628 // Extract source module: find 'from' or direct quote after import
629 let moduleSrc = ''
630 {
631 const fromIdx = text.indexOf('from ')
632 if (fromIdx !== -1) {
633 let mi = fromIdx + 5
634 while (mi < text.length && (text.charCodeAt(mi) === CH_SPACE || text.charCodeAt(mi) === CH_TAB)) mi++
635 if (mi < text.length) {
636 const q = text.charCodeAt(mi)
637 if (q === CH_SQUOTE || q === CH_DQUOTE) {
638 const end = text.indexOf(String.fromCharCode(q), mi + 1)
639 if (end !== -1) moduleSrc = text.slice(mi + 1, end)
640 }
641 }
642 }
643 else if (isSideEffectImport) {
644 // import 'module' — find the quote
645 let mi = 6
646 while (mi < text.length && text.charCodeAt(mi) !== CH_SQUOTE && text.charCodeAt(mi) !== CH_DQUOTE) mi++
647 if (mi < text.length) {
648 const q = text.charCodeAt(mi)
649 const end = text.indexOf(String.fromCharCode(q), mi + 1)
650 if (end !== -1) moduleSrc = text.slice(mi + 1, end)
651 }
652 }
653 }
483654
484655 const comments = extractLeadingComments(stmtStart)
485656
@@ -509,34 +680,87 @@ export function scanDeclarations(source: string, filename: string, keepComments:
509680
510681 /** Strip inline comments from a brace block and normalize indentation */
511682 function cleanBraceBlock(raw: string): string {
512 // Remove inline // and /** */ comments, normalize indentation
683 // Strip standalone comment lines and inline trailing comments, preserve relative indentation
684 // Pass 1: filter + compute min indent simultaneously
513685 const lines = raw.split('\n')
514 const cleaned: string[] = []
515 for (const line of lines) {
516 // Strip full-line comments
517 const trimmed = line.trim()
518 if (trimmed.startsWith('//') || trimmed.startsWith('/**') || trimmed.startsWith('/*') || trimmed.startsWith('*'))
519 continue
520 if (trimmed === '' || trimmed === '{' || trimmed === '}') {
521 cleaned.push(trimmed)
686 const filtered: string[] = []
687 const trimCache: string[] = [] // cache trimmed versions
688 const indentCache: number[] = [] // cache indent levels
689 let inBlockComment = false
690 let minIndent = Infinity
691
692 for (let i = 0; i < lines.length; i++) {
693 const line = lines[i]
694 if (inBlockComment) {
695 if (line.includes('*/'))
696 inBlockComment = false
522697 continue
523698 }
524 // Remove trailing inline comments
525 const result = trimmed.replace(/\s*\/\/.*$/, '').replace(/\s*\/\*.*?\*\/\s*/g, ' ').trim()
526 if (result)
527 cleaned.push(result)
699
700 const trimmed = line.trim()
701
702 // Skip standalone comment lines
703 if (trimmed.length === 0) continue
704 const ch0 = trimmed.charCodeAt(0)
705 if (ch0 === CH_SLASH) {
706 const ch1 = trimmed.charCodeAt(1)
707 if (ch1 === CH_SLASH) continue // //
708 if (ch1 === CH_STAR) { // /* or /**
709 if (!trimmed.includes('*/'))
710 inBlockComment = true
711 continue
712 }
713 }
714 if (ch0 === CH_STAR) continue
715
716 // Remove trailing inline comments without regex
717 let cleaned = stripTrailingComment(line)
718 // Strip trailing semicolons from member lines (DTS convention for interfaces)
719 if (cleaned.charCodeAt(cleaned.length - 1) === CH_SEMI)
720 cleaned = cleaned.slice(0, -1)
721 const ct = cleaned.trim()
722 if (!ct) continue
723
724 filtered.push(cleaned)
725 trimCache.push(ct)
726
727 // Compute indent simultaneously (pass 1 + 2 merged)
728 if (ct !== '{' && ct !== '}') {
729 const indent = cleaned.length - cleaned.trimStart().length
730 if (indent < minIndent) minIndent = indent
731 }
732 indentCache.push(cleaned.length - cleaned.trimStart().length)
528733 }
529 // Rebuild with consistent 2-space indent
530 const members: string[] = []
531 for (const line of cleaned) {
532 if (line === '{' || line === '}')
734
735 if (filtered.length === 0)
736 return '{}'
737
738 if (minIndent === Infinity || minIndent <= 2)
739 return filtered.join('\n') // Already at correct indent
740
741 // Pass 2: re-indent using cached values
742 const offset = minIndent - 2
743 const rebased: string[] = new Array(filtered.length)
744 for (let i = 0; i < filtered.length; i++) {
745 const t = trimCache[i]
746 if (t === '{') {
747 rebased[i] = t
533748 continue
534 if (line)
535 members.push(` ${line}`)
749 }
750 const currentIndent = indentCache[i]
751 if (currentIndent > minIndent) {
752 rebased[i] = filtered[i]
753 }
754 else if (currentIndent === minIndent && (t.charCodeAt(0) === CH_RBRACE || t.charCodeAt(0) === CH_RBRACKET || t.charCodeAt(0) === CH_RPAREN)) {
755 rebased[i] = filtered[i]
756 }
757 else {
758 const newIndent = Math.max(0, currentIndent - offset)
759 rebased[i] = ' '.repeat(newIndent) + t
760 }
536761 }
537 if (members.length === 0)
538 return '{}'
539 return `{\n${members.join('\n')}\n}`
762
763 return rebased.join('\n')
540764 }
541765
542766 /** Extract type parameters <...> (normalized to single line) */
@@ -546,9 +770,25 @@ export function scanDeclarations(source: string, filename: string, keepComments:
546770 const start = pos
547771 findMatchingClose(CH_LANGLE, CH_RANGLE)
548772 const raw = source.slice(start, pos)
549 // Normalize multi-line generics to single line
773 // Normalize multi-line generics to single line (avoid regex)
550774 if (raw.includes('\n')) {
551 return raw.replace(/\s*\n\s*/g, ' ').replace(/\s+/g, ' ').replace(/^<\s+/, '<').replace(/\s+>$/, '>')
775 // Collapse whitespace/newlines to single spaces
776 let result = ''
777 let prevSpace = false
778 for (let i = 0; i < raw.length; i++) {
779 const c = raw.charCodeAt(i)
780 if (c === 32 || c === 9 || c === 10 || c === 13) {
781 if (!prevSpace && result.length > 0) { result += ' '; prevSpace = true }
782 }
783 else {
784 result += raw[i]
785 prevSpace = false
786 }
787 }
788 // Trim spaces around < and >
789 if (result.charCodeAt(1) === 32) result = '<' + result.slice(2)
790 if (result.charCodeAt(result.length - 2) === 32) result = result.slice(0, -2) + '>'
791 return result
552792 }
553793 return raw
554794 }
@@ -618,6 +858,86 @@ export function scanDeclarations(source: string, filename: string, keepComments:
618858 return `(${dtsParams.join(', ')})`
619859 }
620860
861 /** Clean a destructured parameter name: strip defaults and rest operators */
862 function cleanDestructuredName(name: string): string {
863 if (!name.startsWith('{') && !name.startsWith('['))
864 return name
865
866 let result = ''
867 let i = 0
868 let depth = 0
869 let inStr = false
870 let strCh = 0
871
872 while (i < name.length) {
873 const ch = name.charCodeAt(i)
874
875 if (inStr) {
876 if (ch === CH_BACKSLASH && i + 1 < name.length) { result += name[i] + name[i + 1]; i += 2; continue }
877 if (ch === strCh)
878 inStr = false
879 result += name[i]; i++; continue
880 }
881 if (ch === CH_SQUOTE || ch === CH_DQUOTE || ch === CH_BACKTICK) {
882 inStr = true; strCh = ch
883 result += name[i]; i++; continue
884 }
885
886 if (ch === CH_LBRACE || ch === CH_LBRACKET || ch === CH_LPAREN)
887 depth++
888 else if (ch === CH_RBRACE || ch === CH_RBRACKET || ch === CH_RPAREN)
889 depth--
890
891 // At depth 1+, strip `= <default>` by skipping until , or closing bracket
892 if (depth >= 1 && ch === CH_EQUAL
893 && (i + 1 >= name.length || (name.charCodeAt(i + 1) !== CH_EQUAL && name.charCodeAt(i + 1) !== CH_RANGLE))) {
894 // Also strip preceding whitespace
895 while (result.length > 0 && (result[result.length - 1] === ' ' || result[result.length - 1] === '\t' || result[result.length - 1] === '\n'))
896 result = result.slice(0, -1)
897 // Skip the default value
898 i++
899 let skipDepth = 0
900 while (i < name.length) {
901 const sc = name.charCodeAt(i)
902 if (sc === CH_SQUOTE || sc === CH_DQUOTE || sc === CH_BACKTICK) {
903 const q = sc; i++
904 while (i < name.length) {
905 if (name.charCodeAt(i) === CH_BACKSLASH) { i += 2; continue }
906 if (name.charCodeAt(i) === q) { i++; break }
907 i++
908 }
909 continue
910 }
911 if (sc === CH_LBRACE || sc === CH_LBRACKET || sc === CH_LPAREN) {
912 skipDepth++
913 }
914 else if (sc === CH_RBRACE || sc === CH_RBRACKET || sc === CH_RPAREN) {
915 if (skipDepth === 0)
916 break
917 skipDepth--
918 }
919 else if (sc === CH_COMMA && skipDepth === 0) {
920 break
921 }
922 i++
923 }
924 continue
925 }
926
927 // At depth 1, strip `...` rest operator
928 if (depth === 1 && ch === CH_DOT && i + 2 < name.length
929 && name.charCodeAt(i + 1) === CH_DOT && name.charCodeAt(i + 2) === CH_DOT) {
930 i += 3
931 continue
932 }
933
934 result += name[i]
935 i++
936 }
937
938 return result
939 }
940
621941 /** Build a single DTS parameter from raw source text */
622942 function buildSingleDtsParam(raw: string): string {
623943 let p = raw.trim()
@@ -720,6 +1040,28 @@ export function scanDeclarations(source: string, filename: string, keepComments:
7201040 type = 'unknown'
7211041 }
7221042
1043 // Clean destructured parameter names (strip defaults, rest operators)
1044 name = cleanDestructuredName(name)
1045 if ((name.startsWith('{') || name.startsWith('[')) && name.includes('\n')) {
1046 // Collapse to single line only if short enough, otherwise normalize indent
1047 const collapsed = name.replace(/\s*\n\s*/g, ' ').replace(/\s+/g, ' ')
1048 if (collapsed.length <= 40) {
1049 name = collapsed
1050 }
1051 else {
1052 // Normalize to 2-space indent per line, keep braces unindented
1053 const lines = name.split('\n')
1054 name = lines.map((l) => {
1055 const t = l.trim()
1056 if (!t)
1057 return ''
1058 if (t === '{' || t === '}' || t === '[' || t === ']' || t.startsWith('}') || t.startsWith(']'))
1059 return t
1060 return ` ${t}`
1061 }).join('\n')
1062 }
1063 }
1064
7231065 // Handle optional marker
7241066 const isOptional = name.endsWith('?') || hasDefault
7251067 if (name.endsWith('?'))
@@ -732,12 +1074,28 @@ export function scanDeclarations(source: string, filename: string, keepComments:
7321074 return `${name}${optionalMarker}: ${type}`
7331075 }
7341076
1077 /** Check if string is a numeric literal (integer or decimal, optionally negative) */
1078 function isNumericLiteral(v: string): boolean {
1079 let i = 0
1080 if (i < v.length && v.charCodeAt(i) === 45 /* - */) i++
1081 if (i >= v.length) return false
1082 const c = v.charCodeAt(i)
1083 if (c < 48 || c > 57) return false // not a digit
1084 while (i < v.length && v.charCodeAt(i) >= 48 && v.charCodeAt(i) <= 57) i++
1085 if (i < v.length && v.charCodeAt(i) === 46 /* . */) {
1086 i++
1087 if (i >= v.length || v.charCodeAt(i) < 48 || v.charCodeAt(i) > 57) return false
1088 while (i < v.length && v.charCodeAt(i) >= 48 && v.charCodeAt(i) <= 57) i++
1089 }
1090 return i === v.length
1091 }
1092
7351093 /** Infer type from a default value expression (simple cases) */
7361094 function inferTypeFromDefault(value: string): string {
7371095 const v = value.trim()
7381096 if (v === 'true' || v === 'false')
7391097 return 'boolean'
740 if (/^-?\d+(\.\d+)?$/.test(v))
1098 if (isNumericLiteral(v))
7411099 return 'number'
7421100 if ((v.startsWith('\'') && v.endsWith('\'')) || (v.startsWith('"') && v.endsWith('"')))
7431101 return 'string'
@@ -753,7 +1111,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
7531111 const v = value.trim()
7541112 if (v === 'true' || v === 'false')
7551113 return v
756 if (/^-?\d+(\.\d+)?$/.test(v))
1114 if (isNumericLiteral(v))
7571115 return v
7581116 if ((v.startsWith('\'') && v.endsWith('\'')) || (v.startsWith('"') && v.endsWith('"')))
7591117 return v
@@ -764,8 +1122,11 @@ export function scanDeclarations(source: string, filename: string, keepComments:
7641122 function extractAssertion(initText: string): string | null {
7651123 if (initText.endsWith('as const'))
7661124 return null
767 const m = initText.match(/\bas\s+(.+)$/)
768 return m ? m[1].trim() : null
1125 // Find last ' as ' — the spaces already serve as word boundaries
1126 const asIdx = initText.lastIndexOf(' as ')
1127 if (asIdx === -1) return null
1128 const afterAs = initText.slice(asIdx + 4).trim()
1129 return afterAs || null
7691130 }
7701131
7711132 /** Extract return type annotation `: ReturnType` after params, before `{` or `;` */
@@ -877,16 +1238,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
8771238
8781239 // Build DTS text
8791240 const dtsParams = buildDtsParams(rawParams)
880 const parts: string[] = []
881 if (isExported)
882 parts.push('export ')
883 parts.push('declare function ')
884 parts.push(name || 'default')
885 parts.push(generics)
886 parts.push(dtsParams)
887 parts.push(': ', returnType, ';')
888
889 const text = parts.join('')
1241 const text = (isExported ? 'export ' : '') + 'declare function ' + (name || 'default') + generics + dtsParams + ': ' + returnType + ';'
8901242 const comments = extractLeadingComments(declStart)
8911243
8921244 // Record index if this function had a body (implementation signature for overloads)
@@ -1077,16 +1429,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
10771429 const body = cleanBraceBlock(rawBody)
10781430
10791431 // Build DTS text
1080 const parts: string[] = []
1081 if (isExported)
1082 parts.push('export ')
1083 parts.push('declare interface ', name)
1084 parts.push(generics)
1085 if (extendsClause)
1086 parts.push(' extends ', extendsClause)
1087 parts.push(' ', body)
1088
1089 const text = parts.join('')
1432 const text = (isExported ? 'export ' : '') + 'declare interface ' + name + generics + (extendsClause ? ' extends ' + extendsClause : '') + ' ' + body
10901433 const comments = extractLeadingComments(declStart)
10911434
10921435 return {
@@ -1143,12 +1486,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
11431486 pos++
11441487
11451488 // Build DTS text
1146 const parts: string[] = []
1147 if (isExported)
1148 parts.push('export ')
1149 parts.push('type ', name, generics, ' = ', typeBody)
1150
1151 const text = parts.join('')
1489 const text = (isExported ? 'export ' : '') + 'type ' + name + generics + ' = ' + typeBody
11521490 const comments = extractLeadingComments(declStart)
11531491
11541492 return {
@@ -1262,20 +1600,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
12621600 const classBody = buildClassBodyDts()
12631601
12641602 // Build DTS text
1265 const parts: string[] = []
1266 if (isExported)
1267 parts.push('export ')
1268 parts.push('declare ')
1269 if (isAbstract)
1270 parts.push('abstract ')
1271 parts.push('class ', name, generics)
1272 if (extendsClause)
1273 parts.push(' extends ', extendsClause)
1274 if (implementsList && implementsList.length > 0)
1275 parts.push(' implements ', implementsList.join(', '))
1276 parts.push(' ', classBody)
1277
1278 const text = parts.join('')
1603 const text = (isExported ? 'export ' : '') + 'declare ' + (isAbstract ? 'abstract ' : '') + 'class ' + name + generics + (extendsClause ? ' extends ' + extendsClause : '') + (implementsList && implementsList.length > 0 ? ' implements ' + implementsList.join(', ') : '') + ' ' + classBody
12791604 const comments = extractLeadingComments(declStart)
12801605
12811606 return {
@@ -1958,7 +2283,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
19582283 skipWhitespaceAndComments()
19592284 const nname = readIdent()
19602285 skipWhitespaceAndComments()
1961 const body = buildNamespaceBodyDts(`${indent} `)
2286 const body = buildNamespaceBodyDts(indent)
19622287 lines.push(`${indent}${prefix}${kw} ${nname} ${body}`)
19632288 }
19642289 else if (matchWord('abstract')) {
@@ -1995,7 +2320,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
19952320 skipToStatementEnd()
19962321 const defText = source.slice(defStart, pos).trim().replace(/;$/, '')
19972322 if (defText) {
1998 lines.push(`${indent}export default ${defText}`)
2323 lines.push(`${indent}export default ${defText};`)
19992324 }
20002325 }
20012326 else if (!hasExport && (source.charCodeAt(pos) === CH_SQUOTE || source.charCodeAt(pos) === CH_DQUOTE || source.charCodeAt(pos) === CH_BACKTICK)) {
@@ -2055,13 +2380,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
20552380 const body = pos < len && source.charCodeAt(pos) === CH_LBRACE ? buildNamespaceBodyDts() : '{}'
20562381
20572382 // Build DTS text
2058 const parts: string[] = []
2059 if (isExported)
2060 parts.push('export ')
2061 parts.push('declare ')
2062 parts.push(keyword, ' ', name, ' ', body)
2063
2064 const text = parts.join('')
2383 const text = (isExported ? 'export ' : '') + 'declare ' + keyword + ' ' + name + ' ' + body
20652384 const comments = extractLeadingComments(declStart)
20662385 const isAmbient = name.startsWith('\'') || name.startsWith('"')
20672386
@@ -2077,7 +2396,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
20772396 }
20782397 }
20792398
2080 // --- Main scan loop ---
2399 // --- Main scan loop (first-char dispatch for speed) ---
20812400
20822401 while (pos < len) {
20832402 skipWhitespaceAndComments()
@@ -2085,25 +2404,28 @@ export function scanDeclarations(source: string, filename: string, keepComments:
20852404 break
20862405
20872406 const stmtStart = pos
2407 const ch0 = source.charCodeAt(pos)
20882408
2089 // Detect keywords at top level
2090 if (matchWord('import')) {
2409 // Fast dispatch on first character of keyword
2410 if (ch0 === 105 /* i */ && matchWord('import')) {
20912411 declarations.push(extractImport(stmtStart))
20922412 }
2093 else if (matchWord('export')) {
2413 else if (ch0 === 101 /* e */ && matchWord('export')) {
20942414 pos += 6 // skip 'export'
20952415 skipWhitespaceAndComments()
2416 const ech = source.charCodeAt(pos)
20962417
2097 if (matchWord('default')) {
2418 if (ech === 100 /* d */ && matchWord('default')) {
20982419 pos += 7
20992420 skipWhitespaceAndComments()
2421 const dch = source.charCodeAt(pos)
21002422
2101 if (matchWord('function')) {
2423 if (dch === 102 /* f */ && matchWord('function')) {
21022424 const decl = extractFunction(stmtStart, true, false, true)
21032425 if (decl)
21042426 declarations.push(decl)
21052427 }
2106 else if (matchWord('async') && peekAfterWord('async') !== CH_SEMI) {
2428 else if (dch === 97 /* a */ && matchWord('async') && peekAfterWord('async') !== CH_SEMI) {
21072429 pos += 5
21082430 skipWhitespaceAndComments()
21092431 if (matchWord('function')) {
@@ -2113,7 +2435,6 @@ export function scanDeclarations(source: string, filename: string, keepComments:
21132435 }
21142436 else {
21152437 // export default async expression
2116 const text = source.slice(stmtStart, pos).trim()
21172438 skipToStatementEnd()
21182439 const fullText = source.slice(stmtStart, pos).trim()
21192440 declarations.push({
@@ -2127,11 +2448,11 @@ export function scanDeclarations(source: string, filename: string, keepComments:
21272448 })
21282449 }
21292450 }
2130 else if (matchWord('class')) {
2451 else if (dch === 99 /* c */ && matchWord('class')) {
21312452 const decl = extractClass(stmtStart, true, false)
21322453 declarations.push(decl)
21332454 }
2134 else if (matchWord('abstract')) {
2455 else if (dch === 97 /* a */ && matchWord('abstract')) {
21352456 pos += 8
21362457 skipWhitespaceAndComments()
21372458 if (matchWord('class')) {
@@ -2156,7 +2477,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
21562477 })
21572478 }
21582479 }
2159 else if (matchWord('type')) {
2480 else if (ech === 116 /* t */ && matchWord('type')) {
21602481 // Could be `export type Name = ...` or `export type { ... }`
21612482 const savedPos = pos
21622483 pos += 4
@@ -2199,16 +2520,16 @@ export function scanDeclarations(source: string, filename: string, keepComments:
21992520 declarations.push(decl)
22002521 }
22012522 }
2202 else if (matchWord('interface')) {
2523 else if (ech === 105 /* i */ && matchWord('interface')) {
22032524 const decl = extractInterface(stmtStart, true)
22042525 declarations.push(decl)
22052526 }
2206 else if (matchWord('function')) {
2527 else if (ech === 102 /* f */ && matchWord('function')) {
22072528 const decl = extractFunction(stmtStart, true, false, false)
22082529 if (decl)
22092530 declarations.push(decl)
22102531 }
2211 else if (matchWord('async')) {
2532 else if (ech === 97 /* a */ && matchWord('async')) {
22122533 pos += 5
22132534 skipWhitespaceAndComments()
22142535 if (matchWord('function')) {
@@ -2220,62 +2541,67 @@ export function scanDeclarations(source: string, filename: string, keepComments:
22202541 skipToStatementEnd()
22212542 }
22222543 }
2223 else if (matchWord('class')) {
2224 const decl = extractClass(stmtStart, true, false)
2225 declarations.push(decl)
2226 }
2227 else if (matchWord('abstract')) {
2228 pos += 8
2229 skipWhitespaceAndComments()
2544 else if (ech === 99 /* c */) {
22302545 if (matchWord('class')) {
2231 const decl = extractClass(stmtStart, true, true)
2546 const decl = extractClass(stmtStart, true, false)
22322547 declarations.push(decl)
22332548 }
2234 }
2235 else if (matchWord('const')) {
2236 // Could be 'export const enum' or 'export const ...'
2237 const savedPos = pos
2238 pos += 5
2239 skipWhitespaceAndComments()
2240 if (matchWord('enum')) {
2241 pos = savedPos + 5
2549 else if (matchWord('const')) {
2550 // Could be 'export const enum' or 'export const ...'
2551 const savedPos = pos
2552 pos += 5
22422553 skipWhitespaceAndComments()
2243 const decl = extractEnum(stmtStart, true, true)
2244 declarations.push(decl)
2554 if (matchWord('enum')) {
2555 pos = savedPos + 5
2556 skipWhitespaceAndComments()
2557 const decl = extractEnum(stmtStart, true, true)
2558 declarations.push(decl)
2559 }
2560 else {
2561 pos = savedPos
2562 const decls = extractVariable(stmtStart, 'const', true)
2563 declarations.push(...decls)
2564 }
22452565 }
22462566 else {
2247 pos = savedPos
2248 const decls = extractVariable(stmtStart, 'const', true)
2249 declarations.push(...decls)
2567 skipToStatementEnd()
2568 }
2569 }
2570 else if (ech === 97 /* a */ && matchWord('abstract')) {
2571 pos += 8
2572 skipWhitespaceAndComments()
2573 if (matchWord('class')) {
2574 const decl = extractClass(stmtStart, true, true)
2575 declarations.push(decl)
22502576 }
22512577 }
2252 else if (matchWord('let')) {
2578 else if (ech === 108 /* l */ && matchWord('let')) {
22532579 const decls = extractVariable(stmtStart, 'let', true)
22542580 declarations.push(...decls)
22552581 }
2256 else if (matchWord('var')) {
2582 else if (ech === 118 /* v */ && matchWord('var')) {
22572583 const decls = extractVariable(stmtStart, 'var', true)
22582584 declarations.push(...decls)
22592585 }
2260 else if (matchWord('enum')) {
2586 else if (ech === 101 /* e */ && matchWord('enum')) {
22612587 const decl = extractEnum(stmtStart, true, false)
22622588 declarations.push(decl)
22632589 }
2264 else if (matchWord('declare')) {
2590 else if (ech === 100 /* d */ && matchWord('declare')) {
22652591 pos += 7
22662592 skipWhitespaceAndComments()
22672593 // export declare ...
22682594 handleDeclare(stmtStart, true)
22692595 }
2270 else if (matchWord('namespace')) {
2596 else if (ech === 110 /* n */ && matchWord('namespace')) {
22712597 const decl = extractModule(stmtStart, true, 'namespace')
22722598 declarations.push(decl)
22732599 }
2274 else if (matchWord('module')) {
2600 else if (ech === 109 /* m */ && matchWord('module')) {
22752601 const decl = extractModule(stmtStart, true, 'module')
22762602 declarations.push(decl)
22772603 }
2278 else if (source.charCodeAt(pos) === CH_LBRACE) {
2604 else if (ech === CH_LBRACE) {
22792605 // export { ... } or export { ... } from '...'
22802606 skipExportBraces()
22812607 const text = source.slice(stmtStart, pos).trim()
@@ -2292,7 +2618,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
22922618 end: pos,
22932619 })
22942620 }
2295 else if (source.charCodeAt(pos) === CH_STAR) {
2621 else if (ech === CH_STAR) {
22962622 // export * from '...'
22972623 skipExportStar()
22982624 const text = source.slice(stmtStart, pos).trim()
@@ -2326,56 +2652,96 @@ export function scanDeclarations(source: string, filename: string, keepComments:
23262652 }
23272653 }
23282654 }
2329 else if (matchWord('declare')) {
2655 else if (ch0 === 100 /* d */ && matchWord('declare')) {
23302656 pos += 7
23312657 skipWhitespaceAndComments()
23322658 handleDeclare(stmtStart, false)
23332659 }
2334 else if (matchWord('interface')) {
2660 else if (ch0 === 105 /* i */ && matchWord('interface')) {
23352661 // Non-exported interface
23362662 const decl = extractInterface(stmtStart, false)
23372663 nonExportedTypes.set(decl.name, decl)
23382664 }
2339 else if (matchWord('type')) {
2665 else if (ch0 === 116 /* t */ && matchWord('type')) {
23402666 // Non-exported type alias
23412667 const decl = extractTypeAlias(stmtStart, false)
23422668 nonExportedTypes.set(decl.name, decl)
23432669 declarations.push(decl)
23442670 }
2345 else if (matchWord('function') || matchWord('async')) {
2671 else if (ch0 === 102 /* f */ && matchWord('function')) {
23462672 // Non-exported function — skip for DTS
23472673 skipToStatementEnd()
23482674 }
2349 else if (matchWord('class') || matchWord('abstract')) {
2350 // Non-exported class
2351 if (matchWord('abstract')) {
2675 else if (ch0 === 97 /* a */) {
2676 if (matchWord('async')) {
2677 // Non-exported async function — skip for DTS
2678 skipToStatementEnd()
2679 }
2680 else if (matchWord('abstract')) {
23522681 pos += 8
23532682 skipWhitespaceAndComments()
2683 if (matchWord('class')) {
2684 const decl = extractClass(stmtStart, false, false)
2685 nonExportedTypes.set(decl.name, decl)
2686 declarations.push(decl)
2687 }
2688 else {
2689 skipToStatementEnd()
2690 }
2691 }
2692 else {
2693 pos++
2694 skipToStatementEnd()
23542695 }
2696 }
2697 else if (ch0 === 99 /* c */) {
23552698 if (matchWord('class')) {
23562699 const decl = extractClass(stmtStart, false, false)
23572700 nonExportedTypes.set(decl.name, decl)
23582701 declarations.push(decl)
23592702 }
2703 else if (matchWord('const')) {
2704 // Check for 'const enum' before skipping as variable
2705 const savedPos = pos
2706 pos += 5
2707 skipWhitespaceAndComments()
2708 if (matchWord('enum')) {
2709 pos = savedPos + 5
2710 skipWhitespaceAndComments()
2711 const decl = extractEnum(stmtStart, false, true)
2712 nonExportedTypes.set(decl.name, decl)
2713 declarations.push(decl)
2714 }
2715 else {
2716 // Non-exported const variable — skip for DTS
2717 pos = savedPos
2718 skipToStatementEnd()
2719 }
2720 }
23602721 else {
2722 pos++
23612723 skipToStatementEnd()
23622724 }
23632725 }
2364 else if (matchWord('enum')) {
2726 else if (ch0 === 101 /* e */ && matchWord('enum')) {
23652727 // Non-exported enum
23662728 const decl = extractEnum(stmtStart, false, false)
23672729 nonExportedTypes.set(decl.name, decl)
23682730 declarations.push(decl)
23692731 }
2370 else if (matchWord('const') || matchWord('let') || matchWord('var')) {
2732 else if (ch0 === 108 /* l */ && matchWord('let')) {
23712733 // Non-exported variable — skip for DTS
23722734 skipToStatementEnd()
23732735 }
2374 else if (matchWord('module')) {
2736 else if (ch0 === 118 /* v */ && matchWord('var')) {
2737 // Non-exported variable — skip for DTS
2738 skipToStatementEnd()
2739 }
2740 else if (ch0 === 109 /* m */ && matchWord('module')) {
23752741 const decl = extractModule(stmtStart, false, 'module')
23762742 declarations.push(decl)
23772743 }
2378 else if (matchWord('namespace')) {
2744 else if (ch0 === 110 /* n */ && matchWord('namespace')) {
23792745 const decl = extractModule(stmtStart, false, 'namespace')
23802746 declarations.push(decl)
23812747 }
@@ -2539,7 +2905,7 @@ export function scanDeclarations(source: string, filename: string, keepComments:
25392905 // declare global { ... }
25402906 pos += 6
25412907 skipWhitespaceAndComments()
2542 const body = pos < len && source.charCodeAt(pos) === CH_LBRACE ? extractBraceBlock() : '{}'
2908 const body = pos < len && source.charCodeAt(pos) === CH_LBRACE ? buildNamespaceBodyDts() : '{}'
25432909 const text = `declare global ${body}`
25442910 const comments = extractLeadingComments(stmtStart)
25452911 declarations.push({
@@ -2558,27 +2924,69 @@ export function scanDeclarations(source: string, filename: string, keepComments:
25582924 }
25592925}
25602926
2927/** Check if name appears as a whole word in text (fast includes + boundary check) */
2928function isWordInText(name: string, text: string): boolean {
2929 let searchFrom = 0
2930 const nameLen = name.length
2931 while (searchFrom < text.length) {
2932 const idx = text.indexOf(name, searchFrom)
2933 if (idx === -1) return false
2934 // Check word boundaries
2935 const before = idx > 0 ? text.charCodeAt(idx - 1) : 32
2936 const after = idx + nameLen < text.length ? text.charCodeAt(idx + nameLen) : 32
2937 const beforeOk = !((before >= 65 && before <= 90) || (before >= 97 && before <= 122) || (before >= 48 && before <= 57) || before === 95 || before === 36)
2938 const afterOk = !((after >= 65 && after <= 90) || (after >= 97 && after <= 122) || (after >= 48 && after <= 57) || after === 95 || after === 36)
2939 if (beforeOk && afterOk) return true
2940 searchFrom = idx + 1
2941 }
2942 return false
2943}
2944
25612945/** Resolve non-exported types that are referenced by exported declarations */
25622946function resolveReferencedTypes(declarations: Declaration[], nonExportedTypes: Map<string, Declaration>): void {
2563 // Build combined text of all exported declarations
2564 const exportedTexts: string[] = []
2565 for (const decl of declarations) {
2566 if (decl.isExported && decl.kind !== 'import') {
2567 exportedTexts.push(decl.text)
2947 // Iteratively resolve referenced non-exported types (transitive closure)
2948 const resolved = new Set<string>()
2949 const declNames = new Set<string>()
2950 for (const d of declarations) declNames.add(d.name)
2951
2952 for (;;) {
2953 // Build combined text of all current declarations (excluding imports)
2954 let combinedText = ''
2955 for (let i = 0; i < declarations.length; i++) {
2956 if (declarations[i].kind !== 'import') {
2957 combinedText += declarations[i].text
2958 combinedText += '\n'
2959 }
25682960 }
2569 }
2570 const combinedText = exportedTexts.join('\n')
2571
2572 // Check each non-exported type
2573 for (const [name, decl] of nonExportedTypes) {
2574 // Simple word-boundary check
2575 const re = new RegExp(`\\b${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`)
2576 if (re.test(combinedText)) {
2577 // Check it's not already in declarations
2578 const existing = declarations.find(d => d.name === name)
2579 if (!existing) {
2580 declarations.push(decl)
2961
2962 // Collect referenced non-exported types not yet resolved
2963 const toInsert: Declaration[] = []
2964 for (const [name, decl] of nonExportedTypes) {
2965 if (resolved.has(name))
2966 continue
2967 // Fast path: includes() check first (avoids RegExp entirely for non-matches)
2968 if (combinedText.includes(name) && isWordInText(name, combinedText)) {
2969 if (!declNames.has(name)) {
2970 toInsert.push(decl)
2971 declNames.add(name)
2972 }
2973 resolved.add(name)
2974 }
2975 }
2976
2977 if (toInsert.length === 0)
2978 break
2979
2980 // Insert at correct source positions to preserve declaration order
2981 for (const decl of toInsert) {
2982 let insertIdx = declarations.length
2983 for (let i = 0; i < declarations.length; i++) {
2984 if (declarations[i].start > decl.start) {
2985 insertIdx = i
2986 break
2987 }
25812988 }
2989 declarations.splice(insertIdx, 0, decl)
25822990 }
25832991 }
25842992}