import { iAction } from "../../crusher-shared/types/action" ; import { ActionsInTestEnum } from "../../crusher-shared/constants/recordedActions" ; import { Parser } from "./parser" ; import { BrowserEnum } from "../../crusher-shared/types/browser" ; interface iCodeGeneratorOptions { shouldRecordVideo ? : boolean ; defaultBrowserLaunchOptions ? : any ; browser ? : BrowserEnum ; assetsDir ? : string ; usePlaywrightChromium ? : boolean ; videoSavePath : string ; turnOnTracing ? : boolean ; tracePath ? : string ; persistentContextDir ? : string ; } export class CodeGenerator { options : iCodeGeneratorOptions ; actionsMap : Array < { type : ActionsInTestEnum ; code : Array < string > | string ; } > ; constructor ( options ) { this . options = options ; } getConfig ( ) { return this . options ; } getCode ( actions ) { const parser = new Parser ( { actions , shouldRecordVideo : this . options . shouldRecordVideo , browser : this . options . browser , assetsDir : this . options . assetsDir , shouldUsePlaywrightChromium : this . options . usePlaywrightChromium , videoSavePath : this . options . videoSavePath , turnOnTracing : this . options . turnOnTracing , tracePath : this . options . tracePath , defaultBrowserLaunchOptions : { headless : true , args : [ "--disable-shm-usage" , "--disable-gpu" ] , ... this . options . defaultBrowserLaunchOptions , } , persistentContextDir : this . options . persistentContextDir , } ) ; return parser . getCode ( ) ; } }