@@ -130,19 +130,40 @@ export function hideAppLoadingIndicator() {
130130}
131131
132132export function mergeObjects (
133- ...objects : Record < string , any > [ ]
133+ lowerPriority : Record < string , any > ,
134+ higherPriority : Record < string , any >
134135) : Record < string , any > {
135- const result : Record < string , any > = { } ;
136- for ( const obj of objects ) {
137- for ( const [ key , value ] of Object . entries ( obj ) ) {
138- if ( value !== null && value !== undefined ) {
139- result [ key ] = value ;
136+ const result : Record < string , any > = { ...lowerPriority } ;
137+
138+ for ( const key of Object . keys ( higherPriority ) ) {
139+ const highVal = higherPriority [ key ] ;
140+ const lowVal = lowerPriority [ key ] ;
141+
142+ // If higher is null or undefined, keep lower if it exists
143+ if ( highVal === null || highVal === undefined ) {
144+ if ( lowVal !== null && lowVal !== undefined ) {
145+ result [ key ] = lowVal ;
140146 }
147+ continue ;
148+ }
149+
150+ // Deep merge plain objects
151+ if ( isPlainObject ( lowVal ) && isPlainObject ( highVal ) ) {
152+ result [ key ] = mergeObjects ( lowVal , highVal ) ;
153+ continue ;
141154 }
155+
156+ // Otherwise, higher priority wins
157+ result [ key ] = highVal ;
142158 }
159+
143160 return result ;
144161}
145162
163+ function isPlainObject ( value : any ) : value is Record < string , any > {
164+ return value !== null && typeof value === 'object' && ! Array . isArray ( value ) ;
165+ }
166+
146167export function getSpectaAssetUrl ( path : string ) : string {
147168 const labExtension = PageConfig . getOption ( 'fullLabextensionsUrl' ) ;
148169 const url = URLExt . join ( labExtension , 'jupyter-specta' , 'static' , path ) ;
0 commit comments