11import { injectable , inject } from 'inversify' ;
22import { StringDecoder } from 'string_decoder' ;
33import { MigrationAdapter , SectionIdentifier , FileReaderAdapter } from '@ci-dokumentor/core' ;
4- import { ReadableContentHandler } from '@ci-dokumentor/core' ;
5- import type { FormatterAdapter , MigrateDocumentationPayload , ReadableContent , ReadableContentHandler , ReaderAdapter } from '@ci-dokumentor/core' ;
4+ import { ReadableContent } from '@ci-dokumentor/core' ;
5+ import type { FormatterAdapter , MigrateDocumentationPayload , ReadableContent , ReadableContent , ReaderAdapter } from '@ci-dokumentor/core' ;
66
77/**
88 * Abstract base class for migration adapters in the github-actions package.
@@ -89,14 +89,14 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
8989 await rendererAdapter . replaceContent ( content ) ;
9090 }
9191
92- protected abstract migrateContent ( content : ReadableContent , ReadableContentHandler , formatterAdapter : FormatterAdapter ) : ReadableContent ;
92+ protected abstract migrateContent ( content : ReadableContent , ReadableContent , formatterAdapter : FormatterAdapter ) : ReadableContent ;
9393
9494 /**
9595 * Generic helper that replaces tool-specific start/end markers inside a
9696 * content fragment with the standardized ci-dokumentor markers using the
9797 * configured patterns and section mappings.
9898 */
99- protected processMarkerMappings ( content : ReadableContent , ReadableContentHandler , formatterAdapter : FormatterAdapter ) : ReadableContent {
99+ protected processMarkerMappings ( content : ReadableContent , ReadableContent , formatterAdapter : FormatterAdapter ) : ReadableContent {
100100 // Process the fragment line-by-line to avoid allocating a single large
101101 // string for the entire fragment. We still perform replacements on each
102102 // line using the configured start/end patterns, but the scope is the
@@ -125,9 +125,9 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
125125 // Alternate between start and end on successive matches
126126 seenToggle = ! seenToggle ;
127127 if ( seenToggle ) {
128- return ReadableContentHandler . append ( formatterAdapter . sectionStart ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
128+ return ReadableContent . append ( formatterAdapter . sectionStart ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
129129 }
130- return ReadableContentHandler . append ( formatterAdapter . lineBreak ( ) , formatterAdapter . sectionEnd ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
130+ return ReadableContent . append ( formatterAdapter . lineBreak ( ) , formatterAdapter . sectionEnd ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
131131 } ) ;
132132 } else {
133133 // Replace end then start to avoid nested replacement issues when
@@ -138,7 +138,7 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
138138 if ( ! standardSection ) {
139139 return '' ;
140140 }
141- return ReadableContentHandler . append ( formatterAdapter . lineBreak ( ) , formatterAdapter . sectionEnd ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
141+ return ReadableContent . append ( formatterAdapter . lineBreak ( ) , formatterAdapter . sectionEnd ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
142142 } ) ;
143143 }
144144
@@ -148,12 +148,12 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
148148 if ( ! standardSection ) {
149149 return '' ;
150150 }
151- return ReadableContentHandler . append ( formatterAdapter . sectionStart ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
151+ return ReadableContent . append ( formatterAdapter . sectionStart ( standardSection ) , formatterAdapter . lineBreak ( ) ) . toString ( 'utf-8' ) ;
152152 } ) ;
153153 }
154154 }
155155
156- parts . push ( ReadableContentHandler . from ( out ) ) ;
156+ parts . push ( ReadableContent . from ( out ) ) ;
157157
158158 if ( addNewline ) {
159159 parts . push ( formatterAdapter . lineBreak ( ) ) ;
@@ -180,7 +180,7 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
180180 processLine ( rem , false ) ;
181181 }
182182
183- return ReadableContentHandler . append ( ...parts ) ;
183+ return ReadableContent . append ( ...parts ) ;
184184 }
185185
186186 protected mapToStandardSection ( sectionName : string ) {
@@ -191,7 +191,7 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
191191 /**
192192 * Merge consecutive sections that map to the same target section
193193 */
194- private mergeConsecutiveSections ( content : ReadableContent , ReadableContentHandler , formatterAdapter : FormatterAdapter ) : ReadableContent {
194+ private mergeConsecutiveSections ( content : ReadableContent , ReadableContent , formatterAdapter : FormatterAdapter ) : ReadableContent {
195195 let result = content . toString ( 'utf-8' ) ;
196196
197197 // Pattern to match section start and end markers
@@ -253,20 +253,20 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
253253 const mergedContent = group . contents . join ( '' ) . replace ( / ^ \s * \n | \n \s * $ / g, '' ) . trim ( ) ;
254254 const replacement = formatterAdapter . section (
255255 group . type ,
256- ReadableContentHandler . from ( mergedContent )
256+ ReadableContent . from ( mergedContent )
257257 ) . toString ( 'utf-8' ) ;
258258
259259 result = result . substring ( 0 , group . start ) + replacement . trim ( ) + result . substring ( group . end ) ;
260260 }
261261 } ) ;
262262
263- return ReadableContentHandler . from ( result ) ;
263+ return ReadableContent . from ( result ) ;
264264 }
265265
266266 /**
267267 * Add missing supported section markers in the appropriate positions
268268 */
269- private addMissingSections ( content : ReadableContent , ReadableContentHandler , formatterAdapter : FormatterAdapter ) : ReadableContent {
269+ private addMissingSections ( content : ReadableContent , ReadableContent , formatterAdapter : FormatterAdapter ) : ReadableContent {
270270
271271 const expectedSections : SectionIdentifier [ ] = Object . values ( SectionIdentifier ) ;
272272
@@ -338,20 +338,20 @@ export abstract class AbstractMigrationAdapter implements MigrationAdapter {
338338
339339 // If before doesn't end with a newline, add one
340340 const sep = / \n $ / . test ( before ) ? '' : '\n' ;
341- content = ReadableContentHandler . append (
342- ReadableContentHandler . from ( before ) ,
343- ReadableContentHandler . from ( sep ) ,
341+ content = ReadableContent . append (
342+ ReadableContent . from ( before ) ,
343+ ReadableContent . from ( sep ) ,
344344 formatterAdapter . lineBreak ( ) ,
345345 sectionContent ,
346- after . trim ( ) . length > 0 ? ReadableContentHandler . from ( after ) : Buffer . alloc ( 0 )
346+ after . trim ( ) . length > 0 ? ReadableContent . from ( after ) : Buffer . alloc ( 0 )
347347 ) ;
348348 } else {
349349 // No suitable anchor, append at end with a preceding newline
350350 const sep = / \n $ / . test ( contentString ) ? '' : '\n' ;
351351
352- content = ReadableContentHandler . append (
352+ content = ReadableContent . append (
353353 content ,
354- ReadableContentHandler . from ( sep ) ,
354+ ReadableContent . from ( sep ) ,
355355 formatterAdapter . lineBreak ( ) ,
356356 sectionContent ,
357357 ) ;
0 commit comments