@@ -76,19 +76,18 @@ export default class Queue {
7676 // Process mobile configurations if they exist
7777 if ( config . mobile ) {
7878 const devices = config . mobile . devices || [ ] ;
79- const orientation = config . mobile . orientation || "portrait" ; // Default to portrait if not provided
80- const fullPage = config . mobile . fullPage ?? true ; // FullPage defaults to true if not defined
81-
79+ const orientation = config . mobile . orientation || constants . MOBILE_ORIENTATION_PORTRAIT ;
80+
8281 for ( const device of devices ) {
83- const variant = `${ snapshot . name } _${ device } _${ orientation } _ ${ fullPage ? 'fullPage' : 'noFullPage' } ` ;
82+ const variant = `${ snapshot . name } _${ device } _${ orientation } ` ;
8483 this . variants . push ( variant ) ;
8584 }
8685 }
8786 }
8887
8988
9089 private generateWebVariants ( snapshot : Snapshot , webConfig : any ) : void {
91- const browsers = webConfig . browsers ?? this . ctx . config . web ?. browsers ?? [ "chrome" , "edge" , "firefox" , "safari" ] ;
90+ const browsers = webConfig . browsers ?? this . ctx . config . web ?. browsers ?? [ constants . CHROME , constants . EDGE , constants . FIREFOX , constants . SAFARI ] ;
9291 const viewports = webConfig . viewports || [ ] ;
9392
9493 for ( const browser of browsers ) {
@@ -103,14 +102,14 @@ export default class Queue {
103102
104103 private generateMobileVariants ( snapshot : Snapshot , mobileConfig : any ) : void {
105104 const devices = mobileConfig . devices || [ ] ;
106- const orientation = mobileConfig . orientation ?? this . ctx . config . mobile ?. orientation ?? "portrait" ;
107- const fullPage = mobileConfig . fullPage ?? this . ctx . config . mobile ?. fullPage ?? true ;
105+ const orientation = mobileConfig . orientation ?? this . ctx . config . mobile ?. orientation ?? constants . MOBILE_ORIENTATION_PORTRAIT ;
108106
109107 for ( const device of devices ) {
110- const variant = `${ snapshot . name } _${ device } _${ orientation } _ ${ fullPage ? 'fullPage' : 'noFullPage' } ` ;
108+ const variant = `${ snapshot . name } _${ device } _${ orientation } ` ;
111109 this . variants . push ( variant ) ;
112110 }
113111 }
112+
114113
115114 private filterExistingVariants ( snapshot : Snapshot , config : any ) : boolean {
116115
@@ -178,31 +177,31 @@ export default class Queue {
178177 // Process mobile configurations if they exist in config
179178 if ( config . mobile ) {
180179 const devices = config . mobile . devices || [ ] ;
181- const orientation = config . mobile . orientation || "portrait" ;
180+ const orientation = config . mobile . orientation || constants . MOBILE_ORIENTATION_PORTRAIT ;
182181 const fullPage = config . mobile . fullPage || true ;
183-
182+
184183 for ( const device of devices ) {
185- const variant = `${ snapshot . name } _${ device } _${ orientation } _ ${ fullPage ? 'fullPage' : 'noFullPage' } ` ;
186-
184+ const variant = `${ snapshot . name } _${ device } _${ orientation } ` ;
185+
187186 if ( ! this . variants . includes ( variant ) ) {
188187 allVariantsDropped = false ; // Found a variant that needs processing
189188 if ( ! snapshot . options ) snapshot . options = { } ;
190- if ( ! snapshot . options . mobile ) snapshot . options . mobile = { devices : [ ] , orientation : "portrait" , fullPage : true } ;
189+ if ( ! snapshot . options . mobile ) snapshot . options . mobile = { devices : [ ] , orientation : constants . MOBILE_ORIENTATION_PORTRAIT } ;
191190
192191 if ( ! snapshot . options . mobile . devices . includes ( device ) ) {
193192 snapshot . options . mobile . devices . push ( device ) ;
194193 }
195194 snapshot . options . mobile . orientation = orientation ;
196- snapshot . options . mobile . fullPage = fullPage ;
197195 }
198196 }
199197 }
198+
200199
201200 return allVariantsDropped ;
202201 }
203202
204203 private filterWebVariants ( snapshot : Snapshot , webConfig : any ) : boolean {
205- const browsers = webConfig . browsers ?? this . ctx . config . web ?. browsers ?? [ "chrome" , "edge" , "firefox" , "safari" ] ;
204+ const browsers = webConfig . browsers ?? this . ctx . config . web ?. browsers ?? [ constants . CHROME , constants . EDGE , constants . FIREFOX , constants . SAFARI ] ;
206205 const viewports = webConfig . viewports || [ ] ;
207206 let allVariantsDropped = true ;
208207
@@ -246,28 +245,25 @@ export default class Queue {
246245 if ( ! snapshot . options ) {
247246 snapshot . options = { } ;
248247 }
249-
250- snapshot . options . mobile = { devices : [ ] , orientation : "portrait" , fullPage : true } ;
251-
248+
249+ snapshot . options . mobile = { devices : [ ] , orientation : constants . MOBILE_ORIENTATION_PORTRAIT } ;
250+
252251 const devices = mobileConfig . devices || [ ] ;
253- const orientation = mobileConfig . orientation ?? this . ctx . config . mobile ?. orientation ?? "portrait" ;
252+ const orientation = mobileConfig . orientation ?? this . ctx . config . mobile ?. orientation ?? constants . MOBILE_ORIENTATION_PORTRAIT ;
254253 const fullPage = mobileConfig . fullPage ?? this . ctx . config . mobile ?. fullPage ?? true ;
255254 let allVariantsDropped = true ;
256255
257256 for ( const device of devices ) {
258- const variant = `${ snapshot . name } _${ device } _${ orientation } _ ${ fullPage ? 'fullPage' : 'noFullPage' } ` ;
257+ const variant = `${ snapshot . name } _${ device } _${ orientation } ` ;
259258
260259 if ( ! this . variants . includes ( variant ) ) {
261260 allVariantsDropped = false ; // Found a variant that needs processing
262261 snapshot . options . mobile . devices . push ( device ) ;
263262 snapshot . options . mobile . orientation = orientation ;
264- snapshot . options . mobile . fullPage = fullPage ;
265263 }
266264 }
267265 return allVariantsDropped ;
268266 }
269-
270-
271267
272268 private async processNext ( ) : Promise < void > {
273269 if ( ! this . isEmpty ( ) ) {
@@ -497,6 +493,45 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record
497493 return false ;
498494 }
499495
496+ if ( options . web && Object . keys ( options . web ) . length ) {
497+ processedOptions . web = { } ;
498+
499+ // Check and process viewports in web
500+ if ( options . web . viewports && options . web . viewports . length > 0 ) {
501+ processedOptions . web . viewports = options . web . viewports . filter ( viewport =>
502+ Array . isArray ( viewport ) && viewport . length > 0
503+ ) ;
504+ }
505+
506+ // Check and process browsers in web
507+ if ( options . web . browsers && options . web . browsers . length > 0 ) {
508+ processedOptions . web . browsers = options . web . browsers ;
509+ }
510+ }
511+
512+ if ( options . mobile && Object . keys ( options . mobile ) . length ) {
513+ processedOptions . mobile = { } ;
514+
515+ // Check and process devices in mobile
516+ if ( options . mobile . devices && options . mobile . devices . length > 0 ) {
517+ processedOptions . mobile . devices = options . mobile . devices ;
518+ }
519+
520+ // Check if 'fullPage' is provided and is a boolean, otherwise set default to true
521+ if ( options . mobile . hasOwnProperty ( 'fullPage' ) && typeof options . mobile . fullPage === 'boolean' ) {
522+ processedOptions . mobile . fullPage = options . mobile . fullPage ;
523+ } else {
524+ processedOptions . mobile . fullPage = true ; // Default value for fullPage
525+ }
526+
527+ // Check if 'orientation' is provided and is valid, otherwise set default to 'portrait'
528+ if ( options . mobile . hasOwnProperty ( 'orientation' ) && ( options . mobile . orientation === constants . MOBILE_ORIENTATION_PORTRAIT || options . mobile . orientation === constants . MOBILE_ORIENTATION_LANDSCAPE ) ) {
529+ processedOptions . mobile . orientation = options . mobile . orientation ;
530+ } else {
531+ processedOptions . mobile . orientation = constants . MOBILE_ORIENTATION_PORTRAIT ; // Default value for orientation
532+ }
533+ }
534+
500535 if ( options . element && Object . keys ( options . element ) . length ) {
501536 if ( options . element . id ) processedOptions . element = '#' + options . element . id ;
502537 else if ( options . element . class ) processedOptions . element = '.' + options . element . class ;
0 commit comments