@@ -324,6 +324,63 @@ export namespace omarchy {
324324 }
325325}
326326
327+ export namespace template {
328+ export class ColorRoles {
329+ background : string ;
330+ foreground : string ;
331+ black : string ;
332+ red : string ;
333+ green : string ;
334+ yellow : string ;
335+ blue : string ;
336+ magenta : string ;
337+ cyan : string ;
338+ white : string ;
339+ bright_black : string ;
340+ bright_red : string ;
341+ bright_green : string ;
342+ bright_yellow : string ;
343+ bright_blue : string ;
344+ bright_magenta : string ;
345+ bright_cyan : string ;
346+ bright_white : string ;
347+ accent : string ;
348+ cursor : string ;
349+ selection_foreground : string ;
350+ selection_background : string ;
351+
352+ static createFrom ( source : any = { } ) {
353+ return new ColorRoles ( source ) ;
354+ }
355+
356+ constructor ( source : any = { } ) {
357+ if ( 'string' === typeof source ) source = JSON . parse ( source ) ;
358+ this . background = source [ 'background' ] ;
359+ this . foreground = source [ 'foreground' ] ;
360+ this . black = source [ 'black' ] ;
361+ this . red = source [ 'red' ] ;
362+ this . green = source [ 'green' ] ;
363+ this . yellow = source [ 'yellow' ] ;
364+ this . blue = source [ 'blue' ] ;
365+ this . magenta = source [ 'magenta' ] ;
366+ this . cyan = source [ 'cyan' ] ;
367+ this . white = source [ 'white' ] ;
368+ this . bright_black = source [ 'bright_black' ] ;
369+ this . bright_red = source [ 'bright_red' ] ;
370+ this . bright_green = source [ 'bright_green' ] ;
371+ this . bright_yellow = source [ 'bright_yellow' ] ;
372+ this . bright_blue = source [ 'bright_blue' ] ;
373+ this . bright_magenta = source [ 'bright_magenta' ] ;
374+ this . bright_cyan = source [ 'bright_cyan' ] ;
375+ this . bright_white = source [ 'bright_white' ] ;
376+ this . accent = source [ 'accent' ] ;
377+ this . cursor = source [ 'cursor' ] ;
378+ this . selection_foreground = source [ 'selection_foreground' ] ;
379+ this . selection_background = source [ 'selection_background' ] ;
380+ }
381+ }
382+ }
383+
327384export namespace theme {
328385 export class ApplyResult {
329386 success : boolean ;
@@ -365,6 +422,57 @@ export namespace theme {
365422 this . videoCpuMode = source [ 'videoCpuMode' ] ;
366423 }
367424 }
425+ export class StateSnapshot {
426+ palette : string [ ] ;
427+ wallpaperPath : string ;
428+ lightMode : boolean ;
429+ lockedColors : Record < number , boolean > ;
430+ colorRoles : template . ColorRoles ;
431+ extendedColors : Record < string , string > ;
432+ extractionMode : string ;
433+ additionalImages : string [ ] ;
434+ appOverrides : Record < string , any > ;
435+
436+ static createFrom ( source : any = { } ) {
437+ return new StateSnapshot ( source ) ;
438+ }
439+
440+ constructor ( source : any = { } ) {
441+ if ( 'string' === typeof source ) source = JSON . parse ( source ) ;
442+ this . palette = source [ 'palette' ] ;
443+ this . wallpaperPath = source [ 'wallpaperPath' ] ;
444+ this . lightMode = source [ 'lightMode' ] ;
445+ this . lockedColors = source [ 'lockedColors' ] ;
446+ this . colorRoles = this . convertValues (
447+ source [ 'colorRoles' ] ,
448+ template . ColorRoles
449+ ) ;
450+ this . extendedColors = source [ 'extendedColors' ] ;
451+ this . extractionMode = source [ 'extractionMode' ] ;
452+ this . additionalImages = source [ 'additionalImages' ] ;
453+ this . appOverrides = source [ 'appOverrides' ] ;
454+ }
455+
456+ convertValues ( a : any , classs : any , asMap : boolean = false ) : any {
457+ if ( ! a ) {
458+ return a ;
459+ }
460+ if ( a . slice && a . map ) {
461+ return ( a as any [ ] ) . map ( elem =>
462+ this . convertValues ( elem , classs )
463+ ) ;
464+ } else if ( 'object' === typeof a ) {
465+ if ( asMap ) {
466+ for ( const key of Object . keys ( a ) ) {
467+ a [ key ] = new classs ( a [ key ] ) ;
468+ }
469+ return a ;
470+ }
471+ return new classs ( a ) ;
472+ }
473+ return a ;
474+ }
475+ }
368476}
369477
370478export namespace wallhaven {
0 commit comments