@@ -393,9 +393,11 @@ async function exportCurrentWallpaper() {
393393
394394 try {
395395 const exportObject = {
396- version : "1.1 " ,
396+ version : "1.2 " ,
397397 type : "guraatmos" ,
398398 isSlideshow : ! ! current . isSlideshow ,
399+ slideshowInterval : current . slideshowInterval || 600000 ,
400+ shuffle : ! ! current . shuffle ,
399401 clockStyles : current . clockStyles ,
400402 widgetLayout : current . widgetLayout ,
401403 items : [ ]
@@ -410,20 +412,22 @@ async function exportCurrentWallpaper() {
410412 const base64Data = await new Promise ( ( resolve ) => {
411413 const reader = new FileReader ( ) ;
412414 reader . onloadend = ( ) => resolve ( reader . result ) ;
413- reader . readAsDataURL ( dbRecord . blob || dataURLtoBlob ( dbRecord . dataUrl ) ) ;
415+ const source = dbRecord . blob || dataURLtoBlob ( dbRecord . dataUrl ) ;
416+ reader . readAsDataURL ( source ) ;
414417 } ) ;
415418
416419 exportObject . items . push ( {
417- wallpaperType : item . type ,
420+ wallpaperType : dbRecord . type ,
418421 isVideo : item . isVideo ,
419422 depthEnabled : item . depthEnabled ,
420423 depthDataUrl : dbRecord . depthDataUrl ,
424+ dominantColor : dbRecord . dominantColor ,
421425 imageData : base64Data
422426 } ) ;
423427 }
424428
425- // Backward compatibility for older importers
426- if ( ! current . isSlideshow && exportObject . items . length > 0 ) {
429+ // Provide single imageData at root for legacy compatibility
430+ if ( exportObject . items . length > 0 ) {
427431 exportObject . imageData = exportObject . items [ 0 ] . imageData ;
428432 exportObject . wallpaperType = exportObject . items [ 0 ] . wallpaperType ;
429433 exportObject . isVideo = exportObject . items [ 0 ] . isVideo ;
@@ -479,61 +483,67 @@ async function processWallpaperFiles(files) {
479483 continue ;
480484 }
481485
482- if ( data . type !== 'guraatmos' || ! data . imageData ) {
483- continue ; // Skip invalid files
484- }
486+ if ( data . type !== 'guraatmos' ) continue ;
485487
486- const wallpaperId = `guraatmos_${ Date . now ( ) } _${ Math . random ( ) } ` ;
487-
488- // Convert Base64 back to Blob
489- const imageBlob = dataURLtoBlob ( data . imageData ) ;
490- const isVideo = data . isVideo || file . type . startsWith ( 'video' ) ;
488+ const itemsToImport = ( data . items && data . items . length > 0 ) ? data . items : [ data ] ;
489+ const reconstructedItems = [ ] ;
491490
492- let dominantColor = null ;
493- let firstFrame = null ;
494-
495- if ( data . wallpaperType . startsWith ( 'image/gif' ) || data . wallpaperType . startsWith ( 'image/webp' ) ) {
496- try { firstFrame = await extractFirstFrame ( imageBlob ) ; } catch ( e ) { }
497- }
491+ for ( const item of itemsToImport ) {
492+ const wallpaperId = `guraatmos_${ Date . now ( ) } _${ Math . random ( ) } ` ;
493+ const imageBlob = dataURLtoBlob ( item . imageData ) ;
494+ let firstFrame = null ;
495+ let dominantColor = item . dominantColor || null ;
498496
499- try {
500- if ( data . wallpaperType . startsWith ( 'video/' ) ) {
497+ if ( item . wallpaperType . startsWith ( 'video/' ) ) {
501498 firstFrame = await extractVideoFrame ( imageBlob ) ;
502- dominantColor = await extractWallpaperColor ( firstFrame ) ;
503- } else {
504- if ( data . wallpaperType . startsWith ( 'image/gif' ) ) {
505- firstFrame = await extractFirstFrame ( imageBlob ) ;
506- dominantColor = await extractWallpaperColor ( firstFrame ) ;
507- } else {
508- dominantColor = await extractWallpaperColor ( imageBlob ) ;
509- }
499+ } else if ( item . wallpaperType . includes ( 'gif' ) || item . wallpaperType . includes ( 'webp' ) ) {
500+ firstFrame = await extractFirstFrame ( imageBlob ) ;
510501 }
511- } catch ( e ) { console . warn ( "Color extract on import failed" , e ) ; }
512-
513- const dbData = {
514- blob : imageBlob ,
515- type : data . wallpaperType ,
516- clockStyles : data . clockStyles || { } ,
517- widgetLayout : data . widgetLayout || [ ] ,
518- depthDataUrl : data . depthDataUrl || null ,
519- depthEnabled : data . depthEnabled || false ,
520- firstFrameDataUrl : firstFrame ,
521- dominantColor : dominantColor ,
522- timestamp : Date . now ( )
523- } ;
524502
525- await storeWallpaper ( wallpaperId , dbData ) ;
503+ if ( ! dominantColor ) {
504+ dominantColor = await extractWallpaperColor ( firstFrame || imageBlob ) ;
505+ }
526506
527- wallpaperObject = {
528- id : wallpaperId ,
529- type : data . wallpaperType ,
530- isVideo : data . isVideo ,
531- timestamp : Date . now ( ) ,
532- clockStyles : data . clockStyles ,
533- widgetLayout : data . widgetLayout ,
534- depthEnabled : data . depthEnabled ,
535- dominantColor : dominantColor
536- } ;
507+ const dbData = {
508+ blob : imageBlob ,
509+ type : item . wallpaperType ,
510+ clockStyles : data . clockStyles || { } ,
511+ widgetLayout : data . widgetLayout || [ ] ,
512+ depthDataUrl : item . depthDataUrl || null ,
513+ depthEnabled : item . depthEnabled || false ,
514+ firstFrameDataUrl : firstFrame ,
515+ dominantColor : dominantColor ,
516+ timestamp : Date . now ( )
517+ } ;
518+
519+ await storeWallpaper ( wallpaperId , dbData ) ;
520+
521+ reconstructedItems . push ( {
522+ id : wallpaperId ,
523+ type : item . wallpaperType ,
524+ isVideo : item . isVideo ,
525+ timestamp : Date . now ( ) ,
526+ clockStyles : data . clockStyles ,
527+ widgetLayout : data . widgetLayout ,
528+ depthEnabled : item . depthEnabled ,
529+ dominantColor : dominantColor
530+ } ) ;
531+ }
532+
533+ if ( reconstructedItems . length > 1 || data . isSlideshow ) {
534+ wallpaperObject = {
535+ id : `slideshow_${ Date . now ( ) } ` ,
536+ isSlideshow : true ,
537+ slideshowInterval : data . slideshowInterval || 600000 ,
538+ shuffle : ! ! data . shuffle ,
539+ items : reconstructedItems ,
540+ clockStyles : data . clockStyles ,
541+ widgetLayout : data . widgetLayout ,
542+ dominantColor : reconstructedItems [ 0 ] . dominantColor
543+ } ;
544+ } else {
545+ wallpaperObject = reconstructedItems [ 0 ] ;
546+ }
537547 }
538548 // --- Existing Logic for Standard Images/Videos ---
539549 else if ( file . type . startsWith ( 'image/' ) || file . type . startsWith ( 'video/' ) ) {
0 commit comments