@@ -642,33 +642,28 @@ export async function CapsuleSpineFactory({
642642 const rootInstance = await capsule . makeInstance ( )
643643 const capsuleInstances : Record < string , { capsuleName : string , capsuleSourceUriLineRef : string , parentCapsuleSourceUriLineRefInstanceId : string } > = { }
644644
645- // If the root instance has a sit with pre-populated capsuleInstances, use it directly
646- if ( rootInstance . sit ?. capsuleInstances && Object . keys ( rootInstance . sit . capsuleInstances ) . length > 0 ) {
647- Object . assign ( capsuleInstances , rootInstance . sit . capsuleInstances )
648- } else {
649- // Iterative stack-based collection from instance tree
650- const stack : Array < { instance : any , parentId : string } > = [ { instance : rootInstance , parentId : '' } ]
651- const visited = new Set < string > ( )
652- while ( stack . length > 0 ) {
653- const { instance, parentId } = stack . pop ( ) !
654- if ( ! instance ?. capsuleSourceUriLineRefInstanceId ) continue
655- const id = instance . capsuleSourceUriLineRefInstanceId
656- if ( visited . has ( id ) ) continue
657- visited . add ( id )
658-
659- capsuleInstances [ id ] = {
660- capsuleName : instance . capsuleName || '' ,
661- capsuleSourceUriLineRef : instance . capsuleSourceUriLineRef || '' ,
662- parentCapsuleSourceUriLineRefInstanceId : parentId
663- }
645+ // Iterative stack-based collection from instance tree
646+ const stack : Array < { instance : any , parentId : string } > = [ { instance : rootInstance , parentId : '' } ]
647+ const visited = new Set < string > ( )
648+ while ( stack . length > 0 ) {
649+ const { instance, parentId } = stack . pop ( ) !
650+ if ( ! instance ?. capsuleSourceUriLineRefInstanceId ) continue
651+ const id = instance . capsuleSourceUriLineRefInstanceId
652+ if ( visited . has ( id ) ) continue
653+ visited . add ( id )
654+
655+ capsuleInstances [ id ] = {
656+ capsuleName : instance . capsuleName || '' ,
657+ capsuleSourceUriLineRef : instance . capsuleSourceUriLineRef || '' ,
658+ parentCapsuleSourceUriLineRefInstanceId : parentId
659+ }
664660
665- if ( instance . extendedCapsuleInstance ) {
666- stack . push ( { instance : instance . extendedCapsuleInstance , parentId : id } )
667- }
668- if ( instance . mappedCapsuleInstances ) {
669- for ( const mapped of instance . mappedCapsuleInstances ) {
670- stack . push ( { instance : mapped , parentId : id } )
671- }
661+ if ( instance . extendedCapsuleInstance ) {
662+ stack . push ( { instance : instance . extendedCapsuleInstance , parentId : id } )
663+ }
664+ if ( instance . mappedCapsuleInstances ) {
665+ for ( const mapped of instance . mappedCapsuleInstances ) {
666+ stack . push ( { instance : mapped , parentId : id } )
672667 }
673668 }
674669 }
0 commit comments