@@ -220,7 +220,7 @@ class ApplePanelsProcessor extends BaseProcessor {
220220 async loadIntoTree ( filePathOrBuffer : ProcessorInput ) : Promise < AACTree > {
221221 const { readBinaryFromInput, readTextFromInput, pathExists, getFileSize, join } =
222222 this . options . fileAdapter ;
223- await Promise . resolve ( ) ;
223+
224224 const filename =
225225 typeof filePathOrBuffer === 'string' ? getBasename ( filePathOrBuffer ) : 'upload.plist' ;
226226 let buffer : Uint8Array ;
@@ -234,8 +234,8 @@ class ApplePanelsProcessor extends BaseProcessor {
234234 'Resources' ,
235235 'PanelDefinitions.plist'
236236 ) ;
237- if ( pathExists ( panelDefsPath ) ) {
238- buffer = readBinaryFromInput ( panelDefsPath ) ;
237+ if ( await pathExists ( panelDefsPath ) ) {
238+ buffer = await readBinaryFromInput ( panelDefsPath ) ;
239239 } else {
240240 const validation = buildValidationResultFromMessage ( {
241241 filename,
@@ -248,13 +248,13 @@ class ApplePanelsProcessor extends BaseProcessor {
248248 throw new ValidationFailureError ( 'Apple Panels file not found' , validation ) ;
249249 }
250250 } else {
251- buffer = readBinaryFromInput ( filePathOrBuffer ) ;
251+ buffer = await readBinaryFromInput ( filePathOrBuffer ) ;
252252 }
253253 } else {
254- buffer = readBinaryFromInput ( filePathOrBuffer ) ;
254+ buffer = await readBinaryFromInput ( filePathOrBuffer ) ;
255255 }
256256
257- const content = readTextFromInput ( buffer ) ;
257+ const content = await readTextFromInput ( buffer ) ;
258258 const parsedData = plist . parse ( content ) as ApplePanelsParsedDocument ;
259259
260260 let panelsData : ApplePanelsPanel [ ] = [ ] ;
@@ -393,10 +393,12 @@ class ApplePanelsProcessor extends BaseProcessor {
393393 filename,
394394 filesize :
395395 typeof filePathOrBuffer === 'string'
396- ? ( ( ) => {
397- return pathExists ( filePathOrBuffer ) ? getFileSize ( filePathOrBuffer ) : 0 ;
396+ ? await ( async ( ) => {
397+ return ( await pathExists ( filePathOrBuffer ) )
398+ ? await getFileSize ( filePathOrBuffer )
399+ : 0 ;
398400 } ) ( )
399- : readBinaryFromInput ( filePathOrBuffer ) . byteLength ,
401+ : ( await readBinaryFromInput ( filePathOrBuffer ) ) . byteLength ,
400402 format : 'applepanels' ,
401403 message : err ?. message || 'Failed to parse Apple Panels file' ,
402404 type : 'parse' ,
@@ -466,16 +468,16 @@ class ApplePanelsProcessor extends BaseProcessor {
466468 await this . saveFromTree ( tree , outputPath ) ;
467469
468470 if ( outputPath . endsWith ( '.plist' ) ) {
469- return readBinaryFromInput ( outputPath ) ;
471+ return await readBinaryFromInput ( outputPath ) ;
470472 }
471473 const configPath = outputPath . endsWith ( '.ascconfig' ) ? outputPath : `${ outputPath } .ascconfig` ;
472474 const panelDefsPath = join ( configPath , 'Contents' , 'Resources' , 'PanelDefinitions.plist' ) ;
473- return readBinaryFromInput ( panelDefsPath ) ;
475+ return await readBinaryFromInput ( panelDefsPath ) ;
474476 }
475477
476478 async saveFromTree ( tree : AACTree , outputPath : string ) : Promise < void > {
477479 const { writeTextToPath, pathExists, mkDir, join, dirname } = this . options . fileAdapter ;
478- await Promise . resolve ( ) ;
480+
479481 // Support two output modes:
480482 // 1) Single-file .plist (PanelDefinitions.plist content written directly)
481483 // 2) Apple Panels bundle folder (*.ascconfig) with Contents/Resources structure
@@ -490,9 +492,9 @@ class ApplePanelsProcessor extends BaseProcessor {
490492 contentsPath = join ( configPath , 'Contents' ) ;
491493 resourcesPath = join ( contentsPath , 'Resources' ) ;
492494
493- if ( ! pathExists ( configPath ) ) mkDir ( configPath , { recursive : true } ) ;
494- if ( ! pathExists ( contentsPath ) ) mkDir ( contentsPath , { recursive : true } ) ;
495- if ( ! pathExists ( resourcesPath ) ) mkDir ( resourcesPath , { recursive : true } ) ;
495+ if ( ! ( await pathExists ( configPath ) ) ) await mkDir ( configPath , { recursive : true } ) ;
496+ if ( ! ( await pathExists ( contentsPath ) ) ) await mkDir ( contentsPath , { recursive : true } ) ;
497+ if ( ! ( await pathExists ( resourcesPath ) ) ) await mkDir ( resourcesPath , { recursive : true } ) ;
496498
497499 // Create Info.plist (bundle mode only)
498500 const infoPlist = {
@@ -510,11 +512,11 @@ class ApplePanelsProcessor extends BaseProcessor {
510512 `Generated by AAC Processors${ tree . metadata ?. author ? ` - Author: ${ tree . metadata . author } ` : '' } ` ,
511513 } ;
512514 const infoPlistContent = plist . build ( infoPlist ) ;
513- writeTextToPath ( join ( contentsPath , 'Info.plist' ) , infoPlistContent ) ;
515+ await writeTextToPath ( join ( contentsPath , 'Info.plist' ) , infoPlistContent ) ;
514516
515517 // Create AssetIndex.plist (empty)
516518 const assetIndexContent = plist . build ( { } ) ;
517- writeTextToPath ( join ( resourcesPath , 'AssetIndex.plist' ) , assetIndexContent ) ;
519+ await writeTextToPath ( join ( resourcesPath , 'AssetIndex.plist' ) , assetIndexContent ) ;
518520 }
519521
520522 // Build PanelDefinitions content from tree
@@ -656,11 +658,11 @@ class ApplePanelsProcessor extends BaseProcessor {
656658 if ( isSinglePlist ) {
657659 // Write single PanelDefinitions.plist file directly
658660 const dir = dirname ( outputPath ) ;
659- if ( ! pathExists ( dir ) ) mkDir ( dir , { recursive : true } ) ;
660- writeTextToPath ( outputPath , panelDefsContent ) ;
661+ if ( ! ( await pathExists ( dir ) ) ) await mkDir ( dir , { recursive : true } ) ;
662+ await writeTextToPath ( outputPath , panelDefsContent ) ;
661663 } else {
662664 // Write into bundle structure
663- writeTextToPath ( join ( resourcesPath , 'PanelDefinitions.plist' ) , panelDefsContent ) ;
665+ await writeTextToPath ( join ( resourcesPath , 'PanelDefinitions.plist' ) , panelDefsContent ) ;
664666 }
665667 }
666668
0 commit comments