shiplightai 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/fixture.cjs +91 -91
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/reporter.cjs +4 -3
- package/dist/cli.js +3 -2
- package/dist/fixture.d.ts +14 -2
- package/dist/fixture.js +1 -1
- package/dist/index.js +1 -1
- package/dist/reporter.js +7 -6
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -4516,7 +4516,7 @@ ${m.join(`
|
|
|
4516
4516
|
`)}function Dj(r,e){let t=[],n=e?.version||"unknown";t.push(`// @generated by shiplightai v${n}`),t.push(...bk()),t.push(""),e?.use&&Object.keys(e.use).length>0&&(t.push(`test.use(${JSON.stringify(e.use,null,2)});`),t.push(""));let i=new Set,s={imports:i},a=e?.testName||"Test Suite",o=Pb(e?.tags);t.push(`test.describe.serial('${o}${fs(a)}', () => {`),r.beforeAll&&r.beforeAll.length>0&&(t.push(...If("beforeAll",r.beforeAll,s,1)),t.push("")),r.beforeEach&&r.beforeEach.length>0&&(t.push(...If("beforeEach",r.beforeEach,s,1)),t.push(""));for(let c=0;c<r.tests.length;c++){let d=r.tests[c],h=d.timeout||d.skip!==void 0||d.fail!==void 0||d.only||d.slow?{timeout:d.timeout,skip:d.skip,fail:d.fail,only:d.only,slow:d.slow}:void 0;if(d.parameters&&d.parameters.length>0)for(let m of d.parameters){let f=yk(d.testFlow,m.values);t.push(...Of(f,`${fs(d.name)} [${fs(m.name)}]`,s,1,h)),t.push("")}else t.push(...Of(d.testFlow,fs(d.name),s,1,h)),(c<r.tests.length-1||r.afterEach||r.afterAll)&&t.push("")}return r.afterEach&&r.afterEach.length>0&&(t.push(...If("afterEach",r.afterEach,s,1)),t.push("")),r.afterAll&&r.afterAll.length>0&&t.push(...If("afterAll",r.afterAll,s,1)),t.push("});"),wk(t,i),t.join(`
|
|
4517
4517
|
`)}function Pb(r){return r&&r.length>0?r.map(e=>`@${e}`).join(" ")+" ":""}function Of(r,e,t,n=0,i){let s=" ".repeat(n),a=[],o=i?.only?"test.only":"test";a.push(`${s}${o}('${e}', async ({ page, agent }) => {`),i?.skip===!0?a.push(`${s} test.skip();`):typeof i?.skip=="string"&&a.push(`${s} test.skip(true, '${fs(i.skip)}');`),i?.fail===!0?a.push(`${s} test.fail();`):typeof i?.fail=="string"&&a.push(`${s} test.fail(true, '${fs(i.fail)}');`),i?.slow&&a.push(`${s} test.slow();`),i?.timeout&&a.push(`${s} test.setTimeout(${i.timeout});`);let l=r.teardown&&r.teardown.length>0,c=n+1;if(l){if(a.push(`${s} try {`),r.statements&&r.statements.length>0){a.push(`${s} // Test steps`);let h=Si(r.statements,c+1,t);a.push(...h)}a.push(`${s} } finally {`),a.push(`${s} // Teardown`);let d=Si(r.teardown,c+1,t,"teardown");a.push(...d),a.push(`${s} }`)}else if(r.statements&&r.statements.length>0){a.push(`${s} // Test steps`);let d=Si(r.statements,c,t);a.push(...d)}return a.push(`${s}});`),a}function pk(r,e,t){let n=[],i=gk(e);return n.push(`test.${r}(async ({ page, agent }) => {`),n.push(...Si(i,1,t,r)),n.push("});"),n}function If(r,e,t,n){let i=" ".repeat(n),s=[],a=gk(e);if(r==="beforeAll"||r==="afterAll"){let l={...t,noAgent:!0};s.push(`${i}test.${r}(async ({ browser }, workerInfo) => {`),s.push(`${i} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),s.push(...Si(a,n+1,l,r)),s.push(`${i} await page.close();`),s.push(`${i}});`)}else s.push(`${i}test.${r}(async ({ page, agent }) => {`),s.push(...Si(a,n+1,t,r)),s.push(`${i}});`);return s}function gk(r){let t=(0,mk.stringify)({goal:"_hook",statements:r});return _i(t).statements??[]}function yk(r,e){let t=Ab(r);for(let[n,i]of Object.entries(e))t=t.split(`<<${n}>>`).join(String(i));return _i(t)}function bk(){return["import { test, expect } from 'shiplightai/fixture';"]}function wk(r,e){if(e.size>0){let t=0;for(let i=0;i<r.length;i++)r[i].startsWith("import ")&&(t=i+1);let n=Array.from(e);r.splice(t,0,...n)}}var fk=5;function xk(r,e){let t={expandingPaths:new Set([(0,Ju.resolve)(e)]),depth:0,referencedPaths:new Set},n={...r};Array.isArray(n.statements)&&(n.statements=la(n.statements,e,t)),Array.isArray(n.teardown)&&(n.teardown=la(n.teardown,e,t));for(let i of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[i])&&(n[i]=la(n[i],e,t));return{doc:n,referencedTemplatePaths:Array.from(t.referencedPaths)}}function la(r,e,t){let n=[];for(let i of r)if(Lj(i)){let s=$j(i,e,t);n.push(...s)}else n.push(Fj(i,e,t));return n}function Lj(r){return typeof r=="object"&&r!==null&&typeof r.template=="string"}function $j(r,e,t){if(t.depth>=fk)throw new Error(`Template expansion exceeded maximum depth of ${fk}. Check for deeply nested or circular template references.`);let n=(0,Ju.resolve)((0,Ju.dirname)(e),r.template);if(t.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(t.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);t.referencedPaths.add(n);let i;try{i=(0,vk.readFileSync)(n,"utf-8")}catch(d){throw new Error(`Failed to read template file: ${n} (referenced from ${e}): ${d.message}`)}let s=(0,zu.parse)(i);if(!s||typeof s!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let a=s.params||[],o=r.params||{};for(let d of a)if(!(d in o))throw new Error(`Template ${r.template} requires param "${d}" but it was not provided. Required params: [${a.join(", ")}]`);let l=s.statements;if(!Array.isArray(l))throw new Error(`Template ${r.template} must have a "statements" array`);if(Object.keys(o).length>0){let h=(0,zu.stringify)(l);for(let[m,f]of Object.entries(o))h=h.split(`<<${m}>>`).join(String(f));l=(0,zu.parse)(h)}let c={expandingPaths:new Set([...t.expandingPaths,n]),depth:t.depth+1,referencedPaths:t.referencedPaths};return la(l,n,c)}function Fj(r,e,t){if(typeof r!="object"||r===null)return r;let n={...r};return Array.isArray(n.statements)&&(n.statements=la(n.statements,e,t)),Array.isArray(n.THEN)&&(n.THEN=la(n.THEN,e,t)),Array.isArray(n.ELSE)&&(n.ELSE=la(n.ELSE,e,t)),Array.isArray(n.DO)&&(n.DO=la(n.DO,e,t)),n}function Nb(r,e){let t=(0,Ku.parse)(r),n=t?.name,i=t?.tags,s=t?.use;if(t&&(t.name!==void 0||t.tags!==void 0||t.use!==void 0)&&(delete t.name,delete t.tags,delete t.use),t?.suite){if(t.goal||t.statements)throw new Error('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Bj(t,n,i,s,e)}return jj(t,n,i,s,e)}function jj(r,e,t,n,i){let s=r?.beforeEach,a=r?.afterEach,o=_k(r?.parameters),l=r?.timeout,c=r?.skip,d=r?.fail,h=r?.only,m=r?.slow;r&&(delete r.beforeEach,delete r.afterEach,delete r.parameters,delete r.timeout,delete r.skip,delete r.fail,delete r.only,delete r.slow),r&&!r.goal&&e&&(r.goal=e);let f=[];if(i&&r&&typeof r=="object"){let _=xk(r,i);r=_.doc,f=_.referencedTemplatePaths}let g=(0,Ku.stringify)(r);return{testFlow:_i(g),name:e,tags:t,use:n,beforeEach:s,afterEach:a,parameters:o,timeout:l,skip:c,fail:d,only:h,slow:m,referencedTemplatePaths:f}}function Bj(r,e,t,n,i){let s=r.suite;if(!Array.isArray(s.tests)||s.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let a=s.beforeAll,o=s.afterAll,l=s.beforeEach,c=s.afterEach,d=[],h=s.tests.map(g=>{if(!g.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(g.statements)||g.statements.length===0)throw new Error(`Suite test "${g.name}" must have a non-empty "statements" array.`);let b={goal:g.name,statements:g.statements};g.teardown&&(b.teardown=g.teardown);let _=[],x=b;if(i&&typeof b=="object"){let I=xk(b,i);x=I.doc,_=I.referencedTemplatePaths,d.push(..._)}let S=(0,Ku.stringify)(x),D=_i(S),F=_k(g.parameters);return{testFlow:D,name:g.name,parameters:F,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),m=s.base_url,f=m?{...n,baseURL:m}:n;return{suite:{beforeAll:a,afterAll:o,beforeEach:l,afterEach:c,tests:h},name:e,tags:t,use:f,referencedTemplatePaths:d}}function _k(r){if(!(!Array.isArray(r)||r.length===0))return r.map((e,t)=>{if(!e.name)throw new Error(`Parameter set at index ${t} must have a "name" field.`);if(!e.values||typeof e.values!="object")throw new Error(`Parameter set "${e.name}" must have a "values" object.`);return{name:e.name,values:e.values}})}function Tk(r,e,t){let n=/\btemplate:\s/.test(r),i=/^suite:/m.test(r),s=n||i?null:Cb(r);if(s&&!s.valid)return{valid:!1,errors:s.errors,warnings:[],stats:s.stats};let a,o,l=[];try{let c=Nb(r,e);l=c.referencedTemplatePaths;let d={version:t?.version},h=c.testFlow?.baseURL?{...c.use,baseURL:c.testFlow.baseURL}:c.use;c.suite?a=Dj(c.suite,{...d,testName:c.name,tags:c.tags,use:c.use}):a=Mj(c.testFlow,{...d,testName:c.name,tags:c.tags,use:h,beforeEach:c.beforeEach,afterEach:c.afterEach,parameters:c.parameters,timeout:c.timeout,skip:c.skip,fail:c.fail,only:c.only,slow:c.slow});let m=a.split(`
|
|
4518
4518
|
`).filter(f=>!f.startsWith("import ")).join(`
|
|
4519
|
-
`);new Function(m),o=e.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,Yu.mkdirSync)((0,Sk.dirname)(o),{recursive:!0}),(0,Yu.writeFileSync)(o,a)}catch(c){let d=c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:s?.stats??{total:0,withLocator:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:s?.warnings??[],stats:s?.stats??{total:0,withLocator:0,coverage:0},specFile:o,referencedTemplatePaths:l}}var Ob="0.1.
|
|
4519
|
+
`);new Function(m),o=e.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,Yu.mkdirSync)((0,Sk.dirname)(o),{recursive:!0}),(0,Yu.writeFileSync)(o,a)}catch(c){let d=c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:s?.stats??{total:0,withLocator:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:s?.warnings??[],stats:s?.stats??{total:0,withLocator:0,coverage:0},specFile:o,referencedTemplatePaths:l}}var Ob="0.1.26";function Ek(r){try{return(0,ca.statSync)(r).mtimeMs}catch{return 0}}var Uj=`// @generated by shiplightai v${Ob}`;function Hj(r,e){if(!(0,ca.existsSync)(r)||(0,ca.readFileSync)(r,"utf-8").split(`
|
|
4520
4520
|
`,1)[0]!==Uj)return!1;let n=Ek(r);for(let i of e)if(Ek(i)>n)return!1;return!0}function qj(r){let e=process.argv.slice(2),t=[],n=(0,Rf.resolve)(r);for(let i of e){if(i.startsWith("-"))continue;let s=i.endsWith(".yaml.spec.ts")?i.replace(/\.yaml\.spec\.ts$/,".test.yaml"):i;if(!s.endsWith(".test.yaml"))continue;let a=(0,Rf.resolve)(r,s);(0,ca.existsSync)(a)&&t.push(a.startsWith(n)?a.slice(n.length+1):s)}return t.length>0?t:null}function kk(r){let e=qj(r.cwd),t=e??(0,Ak.globSync)("**/*.test.yaml",{cwd:r.cwd,ignore:["**/node_modules/**"]}),n=[];for(let i of t){let s=(0,Rf.resolve)(r.cwd,i),a=s.replace(/\.test\.yaml$/,".yaml.spec.ts"),o=(0,ca.readFileSync)(s,"utf-8");try{let l=Nb(o,s);if(Hj(a,[s,...l.referencedTemplatePaths]))continue;let c=Tk(o,s,{version:Ob});if(!c.valid)throw new Error(c.errors.join("; "))}catch(l){console.error(`[shiplight] Failed to transpile ${i}:`,l),n.push({file:i,error:l})}}if(n.length>0){let i=`[shiplight] Transpilation failed for ${n.length} file(s):
|
|
4521
4521
|
`+n.map(s=>` - ${s.file}`).join(`
|
|
4522
4522
|
`);if(e)throw new Error(i);console.warn(i+" (skipped)")}}function Pk(r={}){r.dotenv!==!1&&Wj(r.scanDir||process.cwd());let e=r.scanDir||process.cwd();return kk({cwd:e}),r.apiKey&&(process.env.__SHIPLIGHT_API_KEY=r.apiKey),{reporter:[["list"],["shiplightai/reporter",{outputFolder:"shiplight-report",open:"never"}]]}}function Wj(r){let e=[],t=co.resolve(r),n=co.resolve(process.cwd());for(;;){let i=co.join(t,".env");if(Ck.existsSync(i)&&e.push(i),t===n)break;let s=co.dirname(t);if(s===t)break;t=s}for(let i of e)Ik.default.config({path:i})}Kt();Kt();Lh();fc();var UT=require("zod"),Mte=UT.z.object({instruction:UT.z.string().describe('The instruction of the operation to perform. Can only include one operation. Do not inlcude element indexes just describe the element, e.g. "select the text "Hello, world!" in "Hello, world!""')});function zL(r){r.register({name:"perform_accurate_operation",description:"Perform an operation that requires accurate interaction like dragging or interacting with a specific area of an element. Only use this action when neccecary.",schema:Mte,usesElementIndex:!1,async execute(e,t){let{instruction:n}=e,i={page:t.page,agentServices:t.agentServices,domService:t.domService},s=await pc(n,i,{});if(s.status==="error"||!s.actionEntity)return{success:!1,actionEntity:{action_description:n,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:n}}},error:s.error||"Failed to generate action"};let{actionEntity:a}=s,o=await Mh(a,i);return{success:o.success,actionEntity:a,message:o.success?`Successfully executed action: ${a.action_data?.action_name}`:void 0,error:o.error}}})}Ha();Kt();Ah();var _t;(function(r){r.Root="root",r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"})(_t||(_t={}));function KL(r){return r.type===_t.Tag||r.type===_t.Script||r.type===_t.Style}var JL=_t.Root,YL=_t.Text,XL=_t.Directive,ZL=_t.Comment,QL=_t.Script,e5=_t.Style,t5=_t.Tag,r5=_t.CDATA,n5=_t.Doctype;var py=class{constructor(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}get parentNode(){return this.parent}set parentNode(e){this.parent=e}get previousSibling(){return this.prev}set previousSibling(e){this.prev=e}get nextSibling(){return this.next}set nextSibling(e){this.next=e}cloneNode(e=!1){return a5(this,e)}},Tp=class extends py{constructor(e){super(),this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e}},_u=class extends Tp{constructor(){super(...arguments),this.type=_t.Text}get nodeType(){return 3}},Ep=class extends Tp{constructor(){super(...arguments),this.type=_t.Comment}get nodeType(){return 8}},Ap=class extends Tp{constructor(e,t){super(t),this.name=e,this.type=_t.Directive}get nodeType(){return 1}},kp=class extends py{constructor(e){super(),this.children=e}get firstChild(){var e;return(e=this.children[0])!==null&&e!==void 0?e:null}get lastChild(){return this.children.length>0?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(e){this.children=e}},Cp=class extends kp{constructor(){super(...arguments),this.type=_t.CDATA}get nodeType(){return 4}},Su=class extends kp{constructor(){super(...arguments),this.type=_t.Root}get nodeType(){return 9}},Ip=class extends kp{constructor(e,t,n=[],i=e==="script"?_t.Script:e==="style"?_t.Style:_t.Tag){super(n),this.name=e,this.attribs=t,this.type=i}get nodeType(){return 1}get tagName(){return this.name}set tagName(e){this.name=e}get attributes(){return Object.keys(this.attribs).map(e=>{var t,n;return{name:e,value:this.attribs[e],namespace:(t=this["x-attribsNamespace"])===null||t===void 0?void 0:t[e],prefix:(n=this["x-attribsPrefix"])===null||n===void 0?void 0:n[e]}})}};function Js(r){return KL(r)}function qT(r){return r.type===_t.CDATA}function fy(r){return r.type===_t.Text}function WT(r){return r.type===_t.Comment}function Dte(r){return r.type===_t.Directive}function s5(r){return r.type===_t.Root}function a5(r,e=!1){let t;if(fy(r))t=new _u(r.data);else if(WT(r))t=new Ep(r.data);else if(Js(r)){let n=e?HT(r.children):[],i=new Ip(r.name,{...r.attribs},n);n.forEach(s=>s.parent=i),r.namespace!=null&&(i.namespace=r.namespace),r["x-attribsNamespace"]&&(i["x-attribsNamespace"]={...r["x-attribsNamespace"]}),r["x-attribsPrefix"]&&(i["x-attribsPrefix"]={...r["x-attribsPrefix"]}),t=i}else if(qT(r)){let n=e?HT(r.children):[],i=new Cp(n);n.forEach(s=>s.parent=i),t=i}else if(s5(r)){let n=e?HT(r.children):[],i=new Su(n);n.forEach(s=>s.parent=i),r["x-mode"]&&(i["x-mode"]=r["x-mode"]),t=i}else if(Dte(r)){let n=new Ap(r.name,r.data);r["x-name"]!=null&&(n["x-name"]=r["x-name"],n["x-publicId"]=r["x-publicId"],n["x-systemId"]=r["x-systemId"]),t=n}else throw new Error(`Not implemented yet: ${r.type}`);return t.startIndex=r.startIndex,t.endIndex=r.endIndex,r.sourceCodeLocation!=null&&(t.sourceCodeLocation=r.sourceCodeLocation),t}function HT(r){let e=r.map(t=>a5(t,!0));for(let t=1;t<e.length;t++)e[t].prev=e[t-1],e[t-1].next=e[t];return e}var o5={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},Tu=class{constructor(e,t,n){this.dom=[],this.root=new Su(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof t=="function"&&(n=t,t=o5),typeof e=="object"&&(t=e,e=void 0),this.callback=e??null,this.options=t??o5,this.elementCB=n??null}onparserinit(e){this.parser=e}onreset(){this.dom=[],this.root=new Su(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null}onend(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))}onerror(e){this.handleCallback(e)}onclosetag(){this.lastNode=null;let e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)}onopentag(e,t){let n=this.options.xmlMode?_t.Tag:void 0,i=new Ip(e,t,void 0,n);this.addNode(i),this.tagStack.push(i)}ontext(e){let{lastNode:t}=this;if(t&&t.type===_t.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{let n=new _u(e);this.addNode(n),this.lastNode=n}}oncomment(e){if(this.lastNode&&this.lastNode.type===_t.Comment){this.lastNode.data+=e;return}let t=new Ep(e);this.addNode(t),this.lastNode=t}oncommentend(){this.lastNode=null}oncdatastart(){let e=new _u(""),t=new Cp([e]);this.addNode(t),e.parent=t,this.lastNode=e}oncdataend(){this.lastNode=null}onprocessinginstruction(e,t){let n=new Ap(e,t);this.addNode(n)}handleCallback(e){if(typeof this.callback=="function")this.callback(e,this.dom);else if(e)throw e}addNode(e){let t=this.tagStack[this.tagStack.length-1],n=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),n&&(e.prev=n,n.next=e),e.parent=t,this.lastNode=null}};var Lte=/\n/g;function $te(r){let e=[...r.matchAll(Lte)].map(n=>n.index||0);e.unshift(-1);let t=GT(e,0,e.length);return n=>c5(t,n)}function GT(r,e,t){if(t-e==1)return{offset:r[e],index:e+1};let n=Math.ceil((e+t)/2),i=GT(r,e,n),s=GT(r,n,t);return{offset:i.offset,low:i,high:s}}function c5(r,e){return function(t){return Object.prototype.hasOwnProperty.call(t,"index")}(r)?{line:r.index,column:e-r.offset}:c5(r.high.offset<e?r.high:r.low,e)}function VT(r,e="",t={}){let n=typeof e!="string"?e:t,i=typeof e=="string"?e:"",s=r.map(Fte),a=!!n.lineNumbers;return function(o,l=0){let c=a?$te(o):()=>({line:0,column:0}),d=l,h=[];e:for(;d<o.length;){let m=!1;for(let f of s){f.regex.lastIndex=d;let g=f.regex.exec(o);if(g&&g[0].length>0){if(!f.discard){let b=c(d),_=typeof f.replace=="string"?g[0].replace(new RegExp(f.regex.source,f.regex.flags),f.replace):g[0];h.push({state:i,name:f.name,text:_,offset:d,len:g[0].length,line:b.line,column:b.column})}if(d=f.regex.lastIndex,m=!0,f.push){let b=f.push(o,d);h.push(...b.tokens),d=b.offset}if(f.pop)break e;break}}if(!m)break}return{tokens:h,offset:d,complete:o.length<=d}}}function Fte(r,e){return{...r,regex:jte(r,e)}}function jte(r,e){if(r.name.length===0)throw new Error(`Rule #${e} has empty name, which is not allowed.`);if(function(t){return Object.prototype.hasOwnProperty.call(t,"regex")}(r))return function(t){if(t.global)throw new Error(`Regular expression /${t.source}/${t.flags} contains the global flag, which is not allowed.`);return t.sticky?t:new RegExp(t.source,t.flags+"y")}(r.regex);if(function(t){return Object.prototype.hasOwnProperty.call(t,"str")}(r)){if(r.str.length===0)throw new Error(`Rule #${e} ("${r.name}") has empty "str" property, which is not allowed.`);return new RegExp(l5(r.str),"y")}return new RegExp(l5(r.name),"y")}function l5(r){return r.replace(/[-[\]{}()*+!<=:?./\\^$|#\s,]/g,"\\$&")}function ss(r,e){return(t,n)=>{let i=n,s;return n<t.tokens.length?(s=r(t.tokens[n],t,n),s!==void 0&&i++):e?.(t,n),s===void 0?{matched:!1}:{matched:!0,position:i,value:s}}}function zT(r,e){return r.matched?{matched:!0,position:r.position,value:e(r.value,r.position)}:r}function my(r,e){return r.matched?e(r):r}function Cr(r,e){return(t,n)=>zT(r(t,n),(i,s)=>e(i,t,n,s))}function Pp(r,e){return(t,n)=>{let i=r(t,n);return i.matched?i:{matched:!0,position:n,value:e}}}function Eu(...r){return(e,t)=>{for(let n of r){let i=n(e,t);if(i.matched)return i}return{matched:!1}}}function Xa(r,e){return(t,n)=>{let i=r(t,n);return i.matched?i:e(t,n)}}function Bte(r,e){return(t,n)=>{let i=[],s=!0;do{let a=r(t,n);a.matched&&e(a.value,i.length+1,t,n,a.position)?(i.push(a.value),n=a.position):s=!1}while(s);return{matched:!0,position:n,value:i}}}function gy(r){return Bte(r,()=>!0)}function u5(r){return Mr(r,gy(r),(e,t)=>[e,...t])}function Mr(r,e,t){return(n,i)=>my(r(n,i),s=>zT(e(n,s.position),(a,o)=>t(s.value,a,n,i,o)))}function d5(r,e){return Mr(r,e,t=>t)}function KT(r,e){return Mr(r,e,(t,n)=>n)}function yy(r,e,t,n){return(i,s)=>my(r(i,s),a=>my(e(i,a.position),o=>zT(t(i,o.position),(l,c)=>n(a.value,o.value,l,i,s,c))))}function JT(r,e,t){return yy(r,e,t,(n,i)=>i)}function Ute(...r){return(e,t)=>{let n=[],i=t;for(let s of r){let a=s(e,i);if(a.matched)n.push(a.value),i=a.position;else return{matched:!1}}return{matched:!0,position:i,value:n}}}function h5(...r){return Hte(Ute(...r))}function Hte(r){return Cr(r,e=>e.flatMap(t=>t))}function qte(r,e){return(t,n)=>{let i=!0,s=r,a=n;do{let o=e(s,t,a)(t,a);o.matched?(s=o.value,a=o.position):i=!1}while(i);return{matched:!0,position:a,value:s}}}function Wte(r,e,t){return qte(r,n=>Cr(e,(i,s,a,o)=>t(n,i,s,a,o)))}function YT(r,e,t){return Gte(r,n=>Wte(n,Mr(e,t,(i,s)=>[i,s]),(i,[s,a])=>s(i,a)))}function Gte(r,e){return(t,n)=>my(r(t,n),i=>e(i.value,t,n,i.position)(t,i.position))}var zte="(?:[ \\t\\r\\n\\f]*)",b5="(?:\\n|\\r\\n|\\r|\\f)",vy="[^\\x00-\\x7F]",Rp="(?:\\\\[0-9a-f]{1,6}(?:\\r\\n|[ \\n\\r\\t\\f])?)",Mp="(?:\\\\[^\\n\\r\\f0-9a-f])",Kte=`(?:[_a-z]|${vy}|${Rp}|${Mp})`,w5=`(?:[_a-z0-9-]|${vy}|${Rp}|${Mp})`,Jte=`(?:${w5}+)`,Yte=`(?:[-]?${Kte}${w5}*)`,Xte=`'([^\\n\\r\\f\\\\']|\\\\${b5}|${vy}|${Rp}|${Mp})*'`,Zte=`"([^\\n\\r\\f\\\\"]|\\\\${b5}|${vy}|${Rp}|${Mp})*"`,Qte=VT([{name:"ws",regex:new RegExp(zte)},{name:"hash",regex:new RegExp(`#${Jte}`,"i")},{name:"ident",regex:new RegExp(Yte,"i")},{name:"str1",regex:new RegExp(Xte,"i")},{name:"str2",regex:new RegExp(Zte,"i")},{name:"*"},{name:"."},{name:","},{name:"["},{name:"]"},{name:"="},{name:">"},{name:"|"},{name:"+"},{name:"~"},{name:"^"},{name:"$"}]),ere=VT([{name:"unicode",regex:new RegExp(Rp,"i")},{name:"escape",regex:new RegExp(Mp,"i")},{name:"any",regex:new RegExp("[\\s\\S]","i")}]);function v5([r,e,t],[n,i,s]){return[r+n,e+i,t+s]}function tre(r){return r.reduce(v5,[0,0,0])}var rre=ss(r=>r.name==="unicode"?String.fromCodePoint(parseInt(r.text.slice(1),16)):void 0),nre=ss(r=>r.name==="escape"?r.text.slice(1):void 0),ire=ss(r=>r.name==="any"?r.text:void 0),sre=Cr(gy(Eu(rre,nre,ire)),r=>r.join(""));function QT(r){let e=ere(r);return sre({tokens:e.tokens,options:void 0},0).value}function Gt(r){return ss(e=>e.name===r?!0:void 0)}var eE=ss(r=>r.name==="ws"?null:void 0),XT=Pp(eE,null);function ku(r){return JT(XT,r,XT)}var Op=ss(r=>r.name==="ident"?QT(r.text):void 0),are=ss(r=>r.name==="hash"?QT(r.text.slice(1)):void 0),ore=ss(r=>r.name.startsWith("str")?QT(r.text.slice(1,-1)):void 0),x5=d5(Pp(Op,""),Gt("|")),tE=Xa(Mr(x5,Op,(r,e)=>({name:e,namespace:r})),Cr(Op,r=>({name:r,namespace:null}))),lre=Xa(Mr(x5,Gt("*"),r=>({type:"universal",namespace:r,specificity:[0,0,0]})),Cr(Gt("*"),()=>({type:"universal",namespace:null,specificity:[0,0,0]}))),cre=Cr(tE,({name:r,namespace:e})=>({type:"tag",name:r,namespace:e,specificity:[0,0,1]})),ure=Mr(Gt("."),Op,(r,e)=>({type:"class",name:e,specificity:[0,1,0]})),dre=Cr(are,r=>({type:"id",name:r,specificity:[1,0,0]})),p5=ss(r=>{if(r.name==="ident"){if(r.text==="i"||r.text==="I")return"i";if(r.text==="s"||r.text==="S")return"s"}}),hre=Xa(Mr(ore,Pp(KT(XT,p5),null),(r,e)=>({value:r,modifier:e})),Mr(Op,Pp(KT(eE,p5),null),(r,e)=>({value:r,modifier:e}))),pre=Eu(Cr(Gt("="),()=>"="),Mr(Gt("~"),Gt("="),()=>"~="),Mr(Gt("|"),Gt("="),()=>"|="),Mr(Gt("^"),Gt("="),()=>"^="),Mr(Gt("$"),Gt("="),()=>"$="),Mr(Gt("*"),Gt("="),()=>"*=")),fre=yy(Gt("["),ku(tE),Gt("]"),(r,{name:e,namespace:t})=>({type:"attrPresence",name:e,namespace:t,specificity:[0,1,0]})),mre=JT(Gt("["),yy(ku(tE),pre,ku(hre),({name:r,namespace:e},t,{value:n,modifier:i})=>({type:"attrValue",name:r,namespace:e,matcher:t,value:n,modifier:i,specificity:[0,1,0]})),Gt("]")),gre=Xa(fre,mre),yre=Xa(lre,cre),f5=Eu(dre,ure,gre),m5=Cr(Xa(h5(yre,gy(f5)),u5(f5)),r=>({type:"compound",list:r,specificity:tre(r.map(e=>e.specificity))})),bre=Eu(Cr(Gt(">"),()=>">"),Cr(Gt("+"),()=>"+"),Cr(Gt("~"),()=>"~"),Mr(Gt("|"),Gt("|"),()=>"||")),wre=Xa(ku(bre),Cr(eE,()=>" ")),ZT=YT(m5,Cr(wre,r=>(e,t)=>({type:"compound",list:[...t.list,{type:"combinator",combinator:r,left:e,specificity:e.specificity}],specificity:v5(e.specificity,t.specificity)})),m5),mCe=YT(Cr(ZT,r=>({type:"list",list:[r]})),Cr(ku(Gt(",")),()=>(r,e)=>({type:"list",list:[...r.list,e]})),ZT);function vre(r,e){if(!(typeof e=="string"||e instanceof String))throw new Error("Expected a selector string. Actual input is not a string!");let t=Qte(e);if(!t.complete)throw new Error(`The input "${e}" was only partially tokenized, stopped at offset ${t.offset}!
|
package/dist/cjs/reporter.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var Se=Object.create;var W=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var i in t)W(e,i,{get:t[i],enumerable:!0})},J=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ke(t))!Ae.call(e,o)&&o!==i&&W(e,o,{get:()=>t[o],enumerable:!(r=xe(t,o))||r.enumerable});return e};var H=(e,t,i)=>(i=e!=null?Se(Te(e)):{},J(t||!e||!e.__esModule?W(i,"default",{value:e,enumerable:!0}):i,e)),Pe=e=>J(W({},"__esModule",{value:!0}),e);var ot={};Me(ot,{default:()=>ve});module.exports=Pe(ot);var w=H(require("fs"),1),m=H(require("path"),1);var Y=112;var $e=1080-Y;var X={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}};var q={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},L=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),q[e].map(r=>X[r]).filter(r=>r.defaultBrowserType&&i.includes(r.defaultBrowserType))};var Oe={desktop:{label:"Desktop",type:"desktop",devices:L("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:L("mobile")}},Le={desktop:{label:"Desktop",type:"desktop",devices:L("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:L("mobile",!0)}};var n=require("zod"),Z=n.z.enum(["JS_CODE","AI_MODE"]),R=n.z.object({type:Z,expression:n.z.string()}),Q=n.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),O=n.z.object({uid:n.z.string(),type:Q}),ee=n.z.object({action_data:n.z.object({action_name:n.z.string(),kwargs:n.z.record(n.z.any()).optional(),args:n.z.array(n.z.any()).optional()}),action_description:n.z.string().optional(),url:n.z.string().optional(),xpath:n.z.string().nullable().optional(),locator:n.z.string().nullable().optional(),css_selector:n.z.string().nullable().optional(),unique_selector:n.z.string().nullable().optional(),element_index:n.z.number().nullable().optional(),frame_path:n.z.array(n.z.any()).optional(),artifacts:n.z.record(n.z.any()).optional(),feedback:n.z.string().optional(),original_browser_use_action:n.z.any().optional()}).passthrough(),te=O.extend({type:n.z.literal("DRAFT"),description:n.z.string()}),ie=O.extend({type:n.z.literal("ACTION"),description:n.z.string(),action_entity:ee.optional(),locator:n.z.string().optional(),use_pure_vision:n.z.boolean().optional()}),v=n.z.lazy(()=>n.z.union([te,ie,O.extend({type:n.z.literal("STEP"),description:n.z.string().optional().default(""),statements:n.z.array(v),reference_id:n.z.number().optional()}),O.extend({type:n.z.literal("IF_ELSE"),description:n.z.string().optional(),condition:R,then:n.z.array(v),else:n.z.array(v).optional()}),O.extend({type:n.z.literal("WHILE_LOOP"),description:n.z.string().optional(),condition:R,body:n.z.array(v),timeout_ms:n.z.number().optional()})])),re=n.z.object({name:n.z.string(),statements:n.z.array(v),teardown:n.z.array(v).optional(),skip:n.z.union([n.z.boolean(),n.z.string()]).optional(),timeout:n.z.number().optional(),fail:n.z.union([n.z.boolean(),n.z.string()]).optional(),only:n.z.boolean().optional(),slow:n.z.boolean().optional()}),F=n.z.object({tests:n.z.array(re).min(1),beforeAll:n.z.array(v).optional(),afterAll:n.z.array(v).optional(),beforeEach:n.z.array(v).optional(),afterEach:n.z.array(v).optional()}),z=n.z.object({version:n.z.string().optional(),goal:n.z.string().optional(),url:n.z.string().optional(),baseURL:n.z.string().optional(),final_feedback:n.z.string().optional(),completed:n.z.boolean().optional(),success:n.z.boolean().optional(),statements:n.z.array(v).optional(),teardown:n.z.array(v).optional(),last_modified_at:n.z.string().optional(),testGroup:F.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"});var G=require("yaml"),S=require("uuid");var oe=1024*1024;function P(e){if(e.length>oe)throw new Error(`YAML input too large (${e.length} bytes, max ${oe})`);let t=(0,G.parse)(e);if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Ie(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:x(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=x(t.teardown));let r=z.safeParse(i);if(!r.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(r.error.errors)}`);return r.data}function Ie(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let o={tests:i.map(s=>{if(!s.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(s.statements)||s.statements.length===0)throw new Error(`Suite test "${s.name}" must have a non-empty "statements" array`);let c={name:s.name,statements:x(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(c.teardown=x(s.teardown)),s.skip!==void 0&&(c.skip=s.skip),typeof s.timeout=="number"&&(c.timeout=s.timeout),s.fail!==void 0&&(c.fail=s.fail),s.only===!0&&(c.only=!0),s.slow===!0&&(c.slow=!0),c})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(o.beforeAll=x(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(o.afterAll=x(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(o.beforeEach=x(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(o.afterEach=x(t.afterEach));let a=F.safeParse(o);if(!a.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(a.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:a.data}}function x(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Ce)}function Ce(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use "intent: ${e}" instead.`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return De(t);if("WHILE"in t)return Ne(t);if("STEP"in t)return We(t);if("VERIFY"in t){let i=t.VERIFY,r={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(r.code=t.js),{uid:(0,S.v4)(),type:"ACTION",description:`Verify: ${i}`,action_entity:{action_description:`Verify: ${i}`,action_data:{action_name:"verify",kwargs:r}}}}if("URL"in t){let i=t.URL,r=t.new_tab===!0?!0:void 0,o=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,a={url:typeof i=="string"?i:String(i)};return r&&(a.new_tab=!0),o!==void 0&&(a.timeout_seconds=o),{uid:(0,S.v4)(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:a}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,r=typeof t.timeout_seconds=="number"?t.timeout_seconds:30;return{uid:(0,S.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:r}}}}}if("WAIT"in t){let i=t.WAIT,r=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,S.v4)(),type:"ACTION",description:typeof i=="string"?i:`Wait ${r}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${r}s`,action_data:{action_name:"wait",kwargs:{seconds:r}}}}}if("CODE"in t){let i=t.CODE;return{uid:(0,S.v4)(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&("intent"in t||"desc"in t)&&!("VERIFY"in t)){let i=t.js,r=typeof t.intent=="string"?t.intent:typeof t.desc=="string"?t.desc:"";return{uid:(0,S.v4)(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...r}=t;return ne({...r,action:"function",functionName:i})}if("action"in t)return ne(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,S.v4)(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function ae(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function De(e){let t=ae(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let r={uid:(0,S.v4)(),type:"IF_ELSE",condition:t,then:x(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(r.else=x(e.ELSE)),r}function Ne(e){let t=ae(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let r={uid:(0,S.v4)(),type:"WHILE_LOOP",condition:t,body:x(i)};return typeof e.timeout_ms=="number"&&(r.timeout_ms=e.timeout_ms),r}function We(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:(0,S.v4)(),type:"STEP",description:t,statements:x(e.statements)};return typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),i}var Fe=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function ne(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",r=typeof e.locator=="string"?e.locator:void 0,o=typeof e.xpath=="string"?e.xpath:void 0,a=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,l={};for(let[d,p]of Object.entries(e))Fe.has(d)||(l[d]=p);let s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(l).length>0?l:{}}};r&&(s.locator=r),o&&(s.xpath=o);let c={uid:(0,S.v4)(),type:"ACTION",description:i,action_entity:s};return a&&(c.use_pure_vision=!0),c}var se=require("yaml");var E=(e,t,i)=>{e.forEach((r,o)=>{let a=`${t}.${o}`;r.type==="DRAFT"?i[a]={description:r.description||"Draft",action_entity:void 0}:r.type==="ACTION"?i[a]={description:r.description||"Action",action_entity:r.action_entity}:r.type==="STEP"&&r.statements?E(r.statements,a,i):r.type==="IF_ELSE"?(i[a]={description:"IF "+(r.condition?.expression||""),action_entity:void 0},r.then&&E(r.then,`${a}.then`,i),r.else&&E(r.else,`${a}.else`,i)):r.type==="WHILE_LOOP"&&(i[a]={description:"WHILE "+(r.condition?.expression||""),action_entity:void 0},r.body&&E(r.body,`${a}.body`,i))})};function B(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return E(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&E(e.teardown,"teardown",t),t}var Ue=require("yaml");var C=require("yaml");var pe=require("fs"),D=require("path"),I=require("yaml");var ue=1e4;function Ve(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function je(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function de(e){let t=Ve(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let r=je(e);if(r){let o=JSON.stringify(r);return`${t}.locator(${o}).first()`}return null}var b=new Map;function u(e,t){b.set(e,t)}function $(e,t,i=[]){let r=[...i];return t.locator?r.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&r.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(t.frame_path)}`),r.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...r.map(o=>` ${o},`),"});"]}u("click",e=>{let t=de(e);return t?[`await ${t}.click({ timeout: ${ue} });`]:['await agent.execAction("click", page, {});']});u("click_element",b.get("click"));u("click_element_by_index",b.get("click"));u("double_click",e=>$("double_click",e));u("double_click_on_element",b.get("double_click"));u("right_click",e=>$("right_click",e));u("right_click_on_element",b.get("right_click"));u("hover",e=>$("hover",e));u("hover_element_by_index",b.get("hover"));u("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return $("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});u("fill",b.get("input_text"));u("clear_input",e=>$("clear_input",e));u("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});u("send_keys",b.get("press"));u("send_keys_on_element",e=>{let t=de(e),i=e.action_data?.kwargs?.keys||"";return t?[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${ue} });`]:['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(i)} } },`,"});"]});u("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return $("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});u("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});u("scroll_down",b.get("scroll"));u("scroll_up",b.get("scroll"));u("scroll_element",b.get("scroll"));u("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});u("scroll_on_element",e=>$("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));u("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});u("open_tab",b.get("go_to_url"));u("go_back",()=>['await agent.execAction("go_back", page, {});']);u("reload_page",()=>['await agent.execAction("reload_page", page, {});']);u("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);u("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);u("verify",(e,t)=>{let i=e.action_data?.kwargs,r=typeof i?.code=="string",o=r?i?.statement||e.action_description:e.action_description||i?.statement;if(r&&o){let l=i.code.split(`
|
|
1
|
+
"use strict";var Se=Object.create;var W=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var i in t)W(e,i,{get:t[i],enumerable:!0})},J=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ke(t))!Ae.call(e,o)&&o!==i&&W(e,o,{get:()=>t[o],enumerable:!(r=xe(t,o))||r.enumerable});return e};var H=(e,t,i)=>(i=e!=null?Se(Te(e)):{},J(t||!e||!e.__esModule?W(i,"default",{value:e,enumerable:!0}):i,e)),Pe=e=>J(W({},"__esModule",{value:!0}),e);var ot={};Me(ot,{default:()=>ve});module.exports=Pe(ot);var w=H(require("fs"),1),m=H(require("path"),1);var Y=112;var Ee=1080-Y;var X={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}};var q={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},L=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),q[e].map(r=>X[r]).filter(r=>r.defaultBrowserType&&i.includes(r.defaultBrowserType))};var Oe={desktop:{label:"Desktop",type:"desktop",devices:L("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:L("mobile")}},Le={desktop:{label:"Desktop",type:"desktop",devices:L("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:L("mobile",!0)}};var n=require("zod"),Z=n.z.enum(["JS_CODE","AI_MODE"]),R=n.z.object({type:Z,expression:n.z.string()}),Q=n.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),O=n.z.object({uid:n.z.string(),type:Q}),ee=n.z.object({action_data:n.z.object({action_name:n.z.string(),kwargs:n.z.record(n.z.any()).optional(),args:n.z.array(n.z.any()).optional()}),action_description:n.z.string().optional(),url:n.z.string().optional(),xpath:n.z.string().nullable().optional(),locator:n.z.string().nullable().optional(),css_selector:n.z.string().nullable().optional(),unique_selector:n.z.string().nullable().optional(),element_index:n.z.number().nullable().optional(),frame_path:n.z.array(n.z.any()).optional(),artifacts:n.z.record(n.z.any()).optional(),feedback:n.z.string().optional(),original_browser_use_action:n.z.any().optional()}).passthrough(),te=O.extend({type:n.z.literal("DRAFT"),description:n.z.string()}),ie=O.extend({type:n.z.literal("ACTION"),description:n.z.string(),action_entity:ee.optional(),locator:n.z.string().optional(),use_pure_vision:n.z.boolean().optional()}),v=n.z.lazy(()=>n.z.union([te,ie,O.extend({type:n.z.literal("STEP"),description:n.z.string().optional().default(""),statements:n.z.array(v),reference_id:n.z.number().optional()}),O.extend({type:n.z.literal("IF_ELSE"),description:n.z.string().optional(),condition:R,then:n.z.array(v),else:n.z.array(v).optional()}),O.extend({type:n.z.literal("WHILE_LOOP"),description:n.z.string().optional(),condition:R,body:n.z.array(v),timeout_ms:n.z.number().optional()})])),re=n.z.object({name:n.z.string(),statements:n.z.array(v),teardown:n.z.array(v).optional(),skip:n.z.union([n.z.boolean(),n.z.string()]).optional(),timeout:n.z.number().optional(),fail:n.z.union([n.z.boolean(),n.z.string()]).optional(),only:n.z.boolean().optional(),slow:n.z.boolean().optional()}),F=n.z.object({tests:n.z.array(re).min(1),beforeAll:n.z.array(v).optional(),afterAll:n.z.array(v).optional(),beforeEach:n.z.array(v).optional(),afterEach:n.z.array(v).optional()}),z=n.z.object({version:n.z.string().optional(),goal:n.z.string().optional(),url:n.z.string().optional(),baseURL:n.z.string().optional(),final_feedback:n.z.string().optional(),completed:n.z.boolean().optional(),success:n.z.boolean().optional(),statements:n.z.array(v).optional(),teardown:n.z.array(v).optional(),last_modified_at:n.z.string().optional(),testGroup:F.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"});var G=require("yaml"),S=require("uuid");var oe=1024*1024;function P(e){if(e.length>oe)throw new Error(`YAML input too large (${e.length} bytes, max ${oe})`);let t=(0,G.parse)(e);if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Ie(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:x(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=x(t.teardown));let r=z.safeParse(i);if(!r.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(r.error.errors)}`);return r.data}function Ie(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let o={tests:i.map(s=>{if(!s.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(s.statements)||s.statements.length===0)throw new Error(`Suite test "${s.name}" must have a non-empty "statements" array`);let c={name:s.name,statements:x(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(c.teardown=x(s.teardown)),s.skip!==void 0&&(c.skip=s.skip),typeof s.timeout=="number"&&(c.timeout=s.timeout),s.fail!==void 0&&(c.fail=s.fail),s.only===!0&&(c.only=!0),s.slow===!0&&(c.slow=!0),c})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(o.beforeAll=x(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(o.afterAll=x(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(o.beforeEach=x(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(o.afterEach=x(t.afterEach));let a=F.safeParse(o);if(!a.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(a.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:a.data}}function x(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(De)}function De(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use "intent: ${e}" instead.`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return Ce(t);if("WHILE"in t)return Ne(t);if("STEP"in t)return We(t);if("VERIFY"in t){let i=t.VERIFY,r={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(r.code=t.js),{uid:(0,S.v4)(),type:"ACTION",description:`Verify: ${i}`,action_entity:{action_description:`Verify: ${i}`,action_data:{action_name:"verify",kwargs:r}}}}if("URL"in t){let i=t.URL,r=t.new_tab===!0?!0:void 0,o=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,a={url:typeof i=="string"?i:String(i)};return r&&(a.new_tab=!0),o!==void 0&&(a.timeout_seconds=o),{uid:(0,S.v4)(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:a}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,r=typeof t.timeout_seconds=="number"?t.timeout_seconds:30;return{uid:(0,S.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:r}}}}}if("WAIT"in t){let i=t.WAIT,r=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,S.v4)(),type:"ACTION",description:typeof i=="string"?i:`Wait ${r}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${r}s`,action_data:{action_name:"wait",kwargs:{seconds:r}}}}}if("CODE"in t){let i=t.CODE;return{uid:(0,S.v4)(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&("intent"in t||"desc"in t)&&!("VERIFY"in t)){let i=t.js,r=typeof t.intent=="string"?t.intent:typeof t.desc=="string"?t.desc:"";return{uid:(0,S.v4)(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...r}=t;return ne({...r,action:"function",functionName:i})}if("action"in t)return ne(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,S.v4)(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function ae(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function Ce(e){let t=ae(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let r={uid:(0,S.v4)(),type:"IF_ELSE",condition:t,then:x(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(r.else=x(e.ELSE)),r}function Ne(e){let t=ae(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let r={uid:(0,S.v4)(),type:"WHILE_LOOP",condition:t,body:x(i)};return typeof e.timeout_ms=="number"&&(r.timeout_ms=e.timeout_ms),r}function We(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:(0,S.v4)(),type:"STEP",description:t,statements:x(e.statements)};return typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),i}var Fe=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function ne(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",r=typeof e.locator=="string"?e.locator:void 0,o=typeof e.xpath=="string"?e.xpath:void 0,a=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,l={};for(let[d,p]of Object.entries(e))Fe.has(d)||(l[d]=p);let s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(l).length>0?l:{}}};r&&(s.locator=r),o&&(s.xpath=o);let c={uid:(0,S.v4)(),type:"ACTION",description:i,action_entity:s};return a&&(c.use_pure_vision=!0),c}var se=require("yaml");var $=(e,t,i)=>{e.forEach((r,o)=>{let a=`${t}.${o}`;r.type==="DRAFT"?i[a]={description:r.description||"Draft",action_entity:void 0}:r.type==="ACTION"?i[a]={description:r.description||"Action",action_entity:r.action_entity}:r.type==="STEP"&&r.statements?$(r.statements,a,i):r.type==="IF_ELSE"?(i[a]={description:"IF "+(r.condition?.expression||""),action_entity:void 0},r.then&&$(r.then,`${a}.then`,i),r.else&&$(r.else,`${a}.else`,i)):r.type==="WHILE_LOOP"&&(i[a]={description:"WHILE "+(r.condition?.expression||""),action_entity:void 0},r.body&&$(r.body,`${a}.body`,i))})};function B(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return $(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&$(e.teardown,"teardown",t),t}var Ue=require("yaml");var D=require("yaml");var pe=require("fs"),C=require("path"),I=require("yaml");var ue=1e4;function Ve(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function je(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function de(e){let t=Ve(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let r=je(e);if(r){let o=JSON.stringify(r);return`${t}.locator(${o}).first()`}return null}var b=new Map;function u(e,t){b.set(e,t)}function E(e,t,i=[]){let r=[...i];return t.locator?r.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&r.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(t.frame_path)}`),r.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...r.map(o=>` ${o},`),"});"]}u("click",e=>{let t=de(e);return t?[`await ${t}.click({ timeout: ${ue} });`]:['await agent.execAction("click", page, {});']});u("click_element",b.get("click"));u("click_element_by_index",b.get("click"));u("double_click",e=>E("double_click",e));u("double_click_on_element",b.get("double_click"));u("right_click",e=>E("right_click",e));u("right_click_on_element",b.get("right_click"));u("hover",e=>E("hover",e));u("hover_element_by_index",b.get("hover"));u("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return E("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});u("fill",b.get("input_text"));u("clear_input",e=>E("clear_input",e));u("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});u("send_keys",b.get("press"));u("send_keys_on_element",e=>{let t=de(e),i=e.action_data?.kwargs?.keys||"";return t?[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${ue} });`]:['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(i)} } },`,"});"]});u("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return E("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});u("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});u("scroll_down",b.get("scroll"));u("scroll_up",b.get("scroll"));u("scroll_element",b.get("scroll"));u("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});u("scroll_on_element",e=>E("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));u("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});u("open_tab",b.get("go_to_url"));u("go_back",()=>['await agent.execAction("go_back", page, {});']);u("reload_page",()=>['await agent.execAction("reload_page", page, {});']);u("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);u("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);u("verify",(e,t)=>{let i=e.action_data?.kwargs,r=typeof i?.code=="string",o=r?i?.statement||e.action_description:e.action_description||i?.statement;if(r&&o){let l=i.code.split(`
|
|
2
2
|
`),s=JSON.stringify(o);return["{ const _t = Date.now(); try {",...l.map(c=>` ${c}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${s}\`);`,"} catch (_e) {",` console.log(\`[VERIFY:JS\u2192AI] JS failed \${((Date.now()-_t)/1000).toFixed(1)}s: (\${_e instanceof Error ? _e.message : String(_e)}), falling back to AI: ${s}\`);`,` await agent.assert(page, ${s}, ${JSON.stringify(t||"")});`,"} }"]}return r?i.code.split(`
|
|
3
3
|
`):o?[`await agent.assert(page, ${JSON.stringify(o)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});u("ai_assert",b.get("verify"));u("assert",b.get("verify"));u("ai_action",(e,t)=>{let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let r=JSON.stringify(i),o=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${r}, '${t||""}', ${o});`]});u("ai_step",(e,t)=>{let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});u("ai_extract",(e,t)=>{let i=e.action_data?.kwargs?.element_description,r=e.action_data?.kwargs?.variable_name;if(!i||!r)return["// Skipping ai_extract: missing element_description or variable_name"];let o=JSON.stringify(i),a=JSON.stringify(r);return[`await agent.extract(page, ${o}, ${a}, '${t||""}');`]});u("ai_wait_until",(e,t)=>{let i=e.action_data?.kwargs?.condition,r=e.action_data?.kwargs?.timeout_seconds||60;return i?[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${r}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});u("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]});u("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let i=["{"],r=t.split(`
|
|
4
4
|
`);for(let o of r)i.push(` ${o}`);return i.push("}"),i});u("function",(e,t,i)=>{let r=e.action_data?.kwargs||{},o=r.functionName;if(o&&o.includes("#")){let[l,s]=o.split("#");if(l&&s){let c=l.replace(/\.(ts|js|mjs)$/,""),d=`import { ${s} } from '${c}';`;i?.imports?.add(d);let p={...r,functionName:s},f=le(p);return f?[f.endsWith(";")?f:`${f};`]:["// Skipping function: invalid export pattern"]}}let a=le(r);return a?[a.endsWith(";")?a:`${a};`]:["// Skipping function: missing functionName"]});u("generate_2fa_code",e=>{let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]});u("upload_file",e=>{let t=e.action_data?.kwargs||{},i=[],r={};return t.paths?r.paths=t.paths:t.path&&(r.path=t.path),t.use_file_input&&(r.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(r)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(o=>` ${o},`),"});"]});u("wait_for_download_complete",e=>['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]);u("switch_tab",e=>['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]);u("close_tab",e=>{let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]});u("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",i=[];return i.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...i.map(r=>` ${r},`),"});"]});u("done",()=>["// Done - no action needed"]);u("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
5
|
-
`):["// Skipping js_action: missing code"]});function le(e){let t=e.functionName;if(!t)return null;let i=Array.isArray(e.args)?e.args.map(String):[];if(i.length===0)return`await ${t}()`;let r=["page","testContext","request","agent"],o=["undefined","null","true","false"],a=i.map(l=>r.includes(l)||o.includes(l)||/^-?\d+(\.\d+)?$/.test(l)?l:l.startsWith("$")?`agent.agentServices.readVariable('${l.substring(1)}')`:`"${l}"`);return`await ${t}(${a.join(", ")})`}var ce=5;function he(e,t){let i={expandingPaths:new Set([(0,
|
|
5
|
+
`):["// Skipping js_action: missing code"]});function le(e){let t=e.functionName;if(!t)return null;let i=Array.isArray(e.args)?e.args.map(String):[];if(i.length===0)return`await ${t}()`;let r=["page","testContext","request","agent"],o=["undefined","null","true","false"],a=i.map(l=>r.includes(l)||o.includes(l)||/^-?\d+(\.\d+)?$/.test(l)?l:l.startsWith("$")?`agent.agentServices.readVariable('${l.substring(1)}')`:`"${l}"`);return`await ${t}(${a.join(", ")})`}var ce=5;function he(e,t){let i={expandingPaths:new Set([(0,C.resolve)(t)]),depth:0,referencedPaths:new Set},r={...e};Array.isArray(r.statements)&&(r.statements=M(r.statements,t,i)),Array.isArray(r.teardown)&&(r.teardown=M(r.teardown,t,i));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(r[o])&&(r[o]=M(r[o],t,i));return{doc:r,referencedTemplatePaths:Array.from(i.referencedPaths)}}function M(e,t,i){let r=[];for(let o of e)if(Je(o)){let a=Ye(o,t,i);r.push(...a)}else r.push(Xe(o,t,i));return r}function Je(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Ye(e,t,i){if(i.depth>=ce)throw new Error(`Template expansion exceeded maximum depth of ${ce}. Check for deeply nested or circular template references.`);let r=(0,C.resolve)((0,C.dirname)(t),e.template);if(i.expandingPaths.has(r))throw new Error(`Circular template reference detected: ${r} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${r}`);i.referencedPaths.add(r);let o;try{o=(0,pe.readFileSync)(r,"utf-8")}catch(p){throw new Error(`Failed to read template file: ${r} (referenced from ${t}): ${p.message}`)}let a=(0,I.parse)(o);if(!a||typeof a!="object")throw new Error(`Invalid template file: ${r} \u2014 expected a YAML object`);let l=a.params||[],s=e.params||{};for(let p of l)if(!(p in s))throw new Error(`Template ${e.template} requires param "${p}" but it was not provided. Required params: [${l.join(", ")}]`);let c=a.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(s).length>0){let f=(0,I.stringify)(c);for(let[g,A]of Object.entries(s))f=f.split(`<<${g}>>`).join(String(A));c=(0,I.parse)(f)}let d={expandingPaths:new Set([...i.expandingPaths,r]),depth:i.depth+1,referencedPaths:i.referencedPaths};return M(c,r,d)}function Xe(e,t,i){if(typeof e!="object"||e===null)return e;let r={...e};return Array.isArray(r.statements)&&(r.statements=M(r.statements,t,i)),Array.isArray(r.THEN)&&(r.THEN=M(r.THEN,t,i)),Array.isArray(r.ELSE)&&(r.ELSE=M(r.ELSE,t,i)),Array.isArray(r.DO)&&(r.DO=M(r.DO,t,i)),r}function fe(e,t){let i=(0,D.parse)(e),r=i?.name,o=i?.tags,a=i?.use;if(i&&(i.name!==void 0||i.tags!==void 0||i.use!==void 0)&&(delete i.name,delete i.tags,delete i.use),i?.suite){if(i.goal||i.statements)throw new Error('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Ze(i,r,o,a,t)}return qe(i,r,o,a,t)}function qe(e,t,i,r,o){let a=e?.beforeEach,l=e?.afterEach,s=ge(e?.parameters),c=e?.timeout,d=e?.skip,p=e?.fail,f=e?.only,g=e?.slow;e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow),e&&!e.goal&&t&&(e.goal=t);let A=[];if(o&&e&&typeof e=="object"){let T=he(e,o);e=T.doc,A=T.referencedTemplatePaths}let h=(0,D.stringify)(e);return{testFlow:P(h),name:t,tags:i,use:r,beforeEach:a,afterEach:l,parameters:s,timeout:c,skip:d,fail:p,only:f,slow:g,referencedTemplatePaths:A}}function Ze(e,t,i,r,o){let a=e.suite;if(!Array.isArray(a.tests)||a.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let l=a.beforeAll,s=a.afterAll,c=a.beforeEach,d=a.afterEach,p=[],f=a.tests.map(h=>{if(!h.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(h.statements)||h.statements.length===0)throw new Error(`Suite test "${h.name}" must have a non-empty "statements" array.`);let k={goal:h.name,statements:h.statements};h.teardown&&(k.teardown=h.teardown);let T=[],_=k;if(o&&typeof k=="object"){let j=he(k,o);_=j.doc,T=j.referencedTemplatePaths,p.push(...T)}let K=(0,D.stringify)(_),N=P(K),_e=ge(h.parameters);return{testFlow:N,name:h.name,parameters:_e,timeout:h.timeout,skip:h.skip,fail:h.fail,only:h.only,slow:h.slow}}),g=a.base_url,A=g?{...r,baseURL:g}:r;return{suite:{beforeAll:l,afterAll:s,beforeEach:c,afterEach:d,tests:f},name:t,tags:i,use:A,referencedTemplatePaths:p}}function ge(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,i)=>{if(!t.name)throw new Error(`Parameter set at index ${i} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function y(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function U(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),i=(e%6e4/1e3).toFixed(0);return`${t}m ${i}s`}function me(e){switch(e){case"passed":case"success":return'<span class="status-icon passed">✔</span>';case"failed":case"failure":case"timedOut":return'<span class="status-icon failed">✘</span>';case"skipped":return'<span class="status-icon skipped">─</span>';case"interrupted":return'<span class="status-icon failed">⚠</span>';default:return'<span class="status-icon pending">○</span>'}}function Qe(e){return`<span class="badge badge-${e}">${e}</span>`}function et(e){let t=e.duration!=null?`<span class="step-duration">${U(e.duration)}</span>`:"",i=me(e.status);if(e.screenshot||e.message||e.error){let o="";e.screenshot&&(o=`<img src="${y(e.screenshot)}" alt="Step screenshot" class="step-screenshot" />`);let a="";e.error&&(a=`<div class="step-error"><pre>${y(e.error)}</pre></div>`);let l="";e.message&&!e.error&&(l=`<div class="step-message">${y(e.message)}</div>`);let s=e.status==="failure"?" open":"";return`
|
|
6
6
|
<details class="step-details step step-${e.status}"${s}>
|
|
7
7
|
<summary class="step-header">
|
|
8
8
|
${i}
|
|
@@ -597,6 +597,7 @@
|
|
|
597
597
|
${i>0?`<span class="summary-stat failed">${i} failed</span>`:""}
|
|
598
598
|
${r>0?`<span class="summary-stat skipped">${r} skipped</span>`:""}
|
|
599
599
|
<span class="summary-stat">${U(e.totalDuration)}</span>
|
|
600
|
+
${e.timestamp?`<span class="summary-stat" style="margin-left:auto;color:var(--color-text-secondary)">${new Date(e.timestamp).toLocaleString()}</span>`:""}
|
|
600
601
|
</div>
|
|
601
602
|
</div>
|
|
602
603
|
<div class="test-list">
|
|
@@ -719,7 +720,7 @@
|
|
|
719
720
|
});
|
|
720
721
|
</script>
|
|
721
722
|
</body>
|
|
722
|
-
</html>`}var it={before:0,main:1,teardown:2,after:3};function we(e){let t=e.split(".")[0];return it[t]??1}function be(e){return e.split(".").map(t=>{let i=Number(t);return Number.isNaN(i)?0:i})}function rt(e){return[...e].sort(([t],[i])=>{let r=we(t),o=we(i);if(r!==o)return r-o;let a=be(t),l=be(i);for(let s=0;s<Math.max(a.length,l.length);s++){let c=a[s]??-1,d=l[s]??-1;if(c!==d)return c-d}return 0})}var V=class{outputFolder;openMode;collected=[];config;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure"}onBegin(t,i){this.config=t}onTestEnd(t,i){this.collected.push({test:t,result:i})}async onEnd(t){if(this.collected.length===0)return;let i=[];for(let{test:d,result:p}of this.collected){let f=d.location.file,g=await this.buildReportTest(d,p,f);i.push(g)}let r={tests:i,totalDuration:t.duration},o=m.isAbsolute(this.outputFolder)?this.outputFolder:m.join(process.cwd(),this.outputFolder);w.mkdirSync(o,{recursive:!0});let a=m.join(o,"screenshots"),l=!1;for(let d of r.tests)for(let p of d.steps)if(p.screenshot&&m.isAbsolute(p.screenshot))try{l||(w.mkdirSync(a,{recursive:!0}),l=!0);let f=`${p.stepId.replace(/\./g,"-")}.png`,g=m.join(a,f);w.copyFileSync(p.screenshot,g),p.screenshot=`screenshots/${f}`}catch{}let s=m.join(o,"report-data.json");w.writeFileSync(s,JSON.stringify(r,null,2),"utf-8");let c=m.join(o,"index.html");w.writeFileSync(c,ye(r),"utf-8");for(let{result:d}of this.collected)for(let p of d.attachments)if(p.path&&(p.name==="video"||p.name==="trace")){let f=m.basename(p.path),g=m.join(o,f);try{w.copyFileSync(p.path,g)}catch{}}if(console.log(`
|
|
723
|
+
</html>`}var it={before:0,main:1,teardown:2,after:3};function we(e){let t=e.split(".")[0];return it[t]??1}function be(e){return e.split(".").map(t=>{let i=Number(t);return Number.isNaN(i)?0:i})}function rt(e){return[...e].sort(([t],[i])=>{let r=we(t),o=we(i);if(r!==o)return r-o;let a=be(t),l=be(i);for(let s=0;s<Math.max(a.length,l.length);s++){let c=a[s]??-1,d=l[s]??-1;if(c!==d)return c-d}return 0})}var V=class{outputFolder;openMode;collected=[];config;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure"}onBegin(t,i){this.config=t}onTestEnd(t,i){this.collected.push({test:t,result:i})}async onEnd(t){if(this.collected.length===0)return;let i=[];for(let{test:d,result:p}of this.collected){let f=d.location.file,g=await this.buildReportTest(d,p,f);i.push(g)}let r={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString()},o=m.isAbsolute(this.outputFolder)?this.outputFolder:m.join(process.cwd(),this.outputFolder);w.mkdirSync(o,{recursive:!0});let a=m.join(o,"screenshots"),l=!1;for(let d of r.tests)for(let p of d.steps)if(p.screenshot&&m.isAbsolute(p.screenshot))try{l||(w.mkdirSync(a,{recursive:!0}),l=!0);let f=`${p.stepId.replace(/\./g,"-")}.png`,g=m.join(a,f);w.copyFileSync(p.screenshot,g),p.screenshot=`screenshots/${f}`}catch{}let s=m.join(o,"report-data.json");w.writeFileSync(s,JSON.stringify(r,null,2),"utf-8");let c=m.join(o,"index.html");w.writeFileSync(c,ye(r),"utf-8");for(let{result:d}of this.collected)for(let p of d.attachments)if(p.path&&(p.name==="video"||p.name==="trace")){let f=m.basename(p.path),g=m.join(o,f);try{w.copyFileSync(p.path,g)}catch{}}if(console.log(`
|
|
723
724
|
Shiplight report written to: ${c}`),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let d=(await import("open")).default;await d(c)}catch{}}printsToStdio(){return!1}async buildReportTest(t,i,r){let o={title:t.title,file:m.relative(process.cwd(),r),status:i.status,duration:i.duration,steps:[]};i.errors.length>0&&(o.error=i.errors.map(d=>d.message||d.stack||String(d)).join(`
|
|
724
725
|
|
|
725
726
|
`));for(let d of i.attachments)d.name==="video"&&d.path&&(o.videoPath=m.basename(d.path)),d.name==="trace"&&d.path&&(o.tracePath=m.basename(d.path));let a=i.attachments.find(d=>d.name==="shiplight-results"),l=null;if(a)try{if(a.body)l=JSON.parse(a.body.toString("utf-8"));else if(a.path){let d=w.readFileSync(a.path,"utf-8");l=JSON.parse(d)}}catch{}let s=r.replace(/\.yaml\.spec\.ts$/,".test.yaml"),c={};if(w.existsSync(s))try{let d=w.readFileSync(s,"utf-8"),p=fe(d,s);if(p.suite){let f=p.suite.tests.find(g=>g.name===t.title);f&&(c=B(f.testFlow))}else p.testFlow&&(c=B(p.testFlow))}catch{}if(l||Object.keys(c).length>0){let d=new Set([...Object.keys(c),...Object.keys(l||{})]),p=Array.from(d).map(g=>[g,null]),f=rt(p);for(let[g]of f){let A=c[g],h=l?.[g],k=A?.description;if(!k||k==="Action"||k==="Draft"){let _=A?.action_entity;k=_?.action_description||_?.action_data?.kwargs?.description||h?.description||g}let T={stepId:g,description:k,status:h?.status||"pending",duration:h?.duration};if(h?.message){let _=typeof h.message=="string"?h.message:JSON.stringify(h.message,null,2);h.status==="failure"?T.error=_:T.message=_}if(h?.screenshot){let _=h.screenshot,K=a?.path?m.dirname(a.path):"",N=m.isAbsolute(_)?_:m.join(K,_);w.existsSync(N)&&(T.screenshot=N)}o.steps.push(T)}}return o}},ve=V;
|
package/dist/cli.js
CHANGED
|
@@ -9391,6 +9391,7 @@ statements:
|
|
|
9391
9391
|
${r>0?`<span class="summary-stat failed">${r} failed</span>`:""}
|
|
9392
9392
|
${n>0?`<span class="summary-stat skipped">${n} skipped</span>`:""}
|
|
9393
9393
|
<span class="summary-stat">${R2r(e.totalDuration)}</span>
|
|
9394
|
+
${e.timestamp?`<span class="summary-stat" style="margin-left:auto;color:var(--color-text-secondary)">${new Date(e.timestamp).toLocaleString()}</span>`:""}
|
|
9394
9395
|
</div>
|
|
9395
9396
|
</div>
|
|
9396
9397
|
<div class="test-list">
|
|
@@ -9513,9 +9514,9 @@ statements:
|
|
|
9513
9514
|
});
|
|
9514
9515
|
</script>
|
|
9515
9516
|
</body>
|
|
9516
|
-
</html>`}var _Yi=le(()=>{"use strict"});var AYi={};bh(AYi,{runReport:()=>_4c});import*as QTe from"fs";import*as LTe from"path";async function _4c(e){(e.includes("--help")||e.includes("-h"))&&(console.log("Usage: shiplight report [folder] [options]"),console.log(""),console.log("Regenerates index.html from report-data.json in the given folder."),console.log(""),console.log("Options:"),console.log(" --open Open the report in the default browser after generating"),console.log(""),console.log("Examples:"),console.log(" shiplight report # regenerate ./shiplight-report/index.html"),console.log(" shiplight report my-report --open # regenerate and open"),process.exit(0));let t=e.includes("--open"),r=e.find(f=>!f.startsWith("--"))||"shiplight-report",n=LTe.isAbsolute(r)?r:LTe.join(process.cwd(),r),s=LTe.join(n,"report-data.json");QTe.existsSync(s)||(console.error(`Error: ${s} not found.`),console.error("Run a test first to generate report artifacts, then use this command to regenerate the HTML."),process.exit(1));let a;try{a=JSON.parse(QTe.readFileSync(s,"utf-8"))}catch(f){console.error(`Error: Failed to parse ${s}`),console.error(f instanceof Error?f.message:String(f)),process.exit(1)}let u=LTe.join(n,"index.html");if(QTe.writeFileSync(u,gYi(a),"utf-8"),console.log(`Shiplight report regenerated: ${u}`),t)try{let f=(await import("open")).default;await f(u)}catch{}}var yYi=le(()=>{"use strict";_Yi()});var bYi,vYi=le(()=>{"use strict";bYi="0.1.
|
|
9517
|
+
</html>`}var _Yi=le(()=>{"use strict"});var AYi={};bh(AYi,{runReport:()=>_4c});import*as QTe from"fs";import*as LTe from"path";async function _4c(e){(e.includes("--help")||e.includes("-h"))&&(console.log("Usage: shiplight report [folder] [options]"),console.log(""),console.log("Regenerates index.html from report-data.json in the given folder."),console.log(""),console.log("Options:"),console.log(" --open Open the report in the default browser after generating"),console.log(""),console.log("Examples:"),console.log(" shiplight report # regenerate ./shiplight-report/index.html"),console.log(" shiplight report my-report --open # regenerate and open"),process.exit(0));let t=e.includes("--open"),r=e.find(f=>!f.startsWith("--"))||"shiplight-report",n=LTe.isAbsolute(r)?r:LTe.join(process.cwd(),r),s=LTe.join(n,"report-data.json");QTe.existsSync(s)||(console.error(`Error: ${s} not found.`),console.error("Run a test first to generate report artifacts, then use this command to regenerate the HTML."),process.exit(1));let a;try{a=JSON.parse(QTe.readFileSync(s,"utf-8"))}catch(f){console.error(`Error: Failed to parse ${s}`),console.error(f instanceof Error?f.message:String(f)),process.exit(1)}let u=LTe.join(n,"index.html");if(QTe.writeFileSync(u,gYi(a),"utf-8"),console.log(`Shiplight report regenerated: ${u}`),t)try{let f=(await import("open")).default;await f(u)}catch{}}var yYi=le(()=>{"use strict";_Yi()});var bYi,vYi=le(()=>{"use strict";bYi="0.1.26"});var EYi={};bh(EYi,{runTranspile:()=>y4c});import*as Rxt from"path";import{glob as A4c}from"glob";async function y4c(e){(e.includes("--help")||e.includes("-h"))&&(console.log("Usage: shiplight transpile [glob]"),console.log(""),console.log("Transpiles YAML test files to Playwright spec files (.yaml.spec.ts)."),console.log("Validates syntax and reports locator coverage warnings."),console.log("Default glob: **/*.test.yaml"),console.log(""),console.log("Examples:"),console.log(" shiplight transpile # transpile all YAML tests"),console.log(' shiplight transpile "tests/**/*.test.yaml" # transpile specific directory'),console.log(" shiplight transpile tests/login.test.yaml # transpile a single file"),process.exit(0));let t=e[0]||"**/*.test.yaml",r=process.cwd(),n=await A4c(t,{cwd:r,ignore:["node_modules/**","*.yaml.spec.ts"]});n.length===0&&(console.log(`No files matched: ${t}`),process.exit(0));let s=0,a=0,u=0;for(let f of n.sort()){let p=Rxt.resolve(r,f),m=yKe(p,{version:bYi});if(!m.valid){s++,console.log(`
|
|
9517
9518
|
\u2717 ${f}`);for(let v of m.errors)console.log(` ERROR: ${v}`);continue}u++;let y=Rxt.basename(m.specFile);if(m.warnings.length>0){a++,console.log(`\u26A0 ${f} \u2192 ${y}`);for(let v of m.warnings)console.log(` WARNING: ${v}`)}else console.log(`\u2713 ${f} \u2192 ${y}`)}console.log(`
|
|
9518
|
-
${n.length} file(s): ${u} transpiled, ${s} error(s), ${a} warning(s)`),process.exit(s>0?1:0)}var CYi=le(()=>{"use strict";bKe();vYi()});var SYi={};bh(SYi,{runInspect:()=>b4c});import*as Oxt from"fs";import*as wYi from"path";async function b4c(e){(e.includes("--help")||e.includes("-h")||e.length===0)&&(console.log("Usage: shiplight inspect <file.test.yaml> [options]"),console.log(""),console.log("Parse a YAML test file and output the resulting TestFlow JSON."),console.log("Useful for verifying YAML \u2192 JSON conversion."),console.log(""),console.log("Options:"),console.log(" --pretty Pretty-print JSON (default)"),console.log(" --compact Compact JSON output"),console.log(" --stats Show statement statistics only"),console.log(""),console.log("Examples:"),console.log(" shiplight inspect tests/login.test.yaml"),console.log(" shiplight inspect tests/suite.test.yaml --stats"),console.log(" shiplight inspect tests/login.test.yaml --compact | jq ."),process.exit(e.length===0?1:0));let t=e.includes("--compact"),r=e.includes("--stats"),n=e.find(u=>!u.startsWith("--"));n||(console.error("Error: no file specified"),process.exit(1));let s=wYi.resolve(process.cwd(),n);Oxt.existsSync(s)||(console.error(`Error: file not found: ${s}`),process.exit(1));let a=Oxt.readFileSync(s,"utf-8");try{let u=Xte(a),f=q2(a);if(r)v4c(f,u);else{let p={...u.test_case_id!==void 0?{test_case_id:u.test_case_id}:{},...u.name?{name:u.name}:{},testFlow:f};console.log(JSON.stringify(p,null,t?0:2))}}catch(u){console.error(`Error parsing ${n}: ${u.message}`),process.exit(1)}}function v4c(e,t){if(console.log(`File: ${t.name||"(unnamed)"}`),t.test_case_id!==void 0&&console.log(`Cloud ID: ${t.test_case_id}`),console.log(`Version: ${e.version||"unknown"}`),e.testGroup){let r=e.testGroup;console.log("Type: suite (testGroup)"),console.log(`Tests: ${r.tests.length}`);for(let n of r.tests){let s=n.skip?` [SKIP${typeof n.skip=="string"?`: ${n.skip}`:""}]`:"";console.log(` - ${n.name}: ${n.statements.length} statements${n.teardown?`, ${n.teardown.length} teardown`:""}${s}`)}r.beforeAll?.length&&console.log(`Hooks: beforeAll (${r.beforeAll.length})`),r.afterAll?.length&&console.log(`Hooks: afterAll (${r.afterAll.length})`),r.beforeEach?.length&&console.log(`Hooks: beforeEach (${r.beforeEach.length})`),r.afterEach?.length&&console.log(`Hooks: afterEach (${r.afterEach.length})`)}else{console.log("Type: single test"),console.log(`Goal: ${e.goal}`),e.url&&console.log(`URL: ${e.url}`),e.baseURL&&console.log(`Base URL: ${e.baseURL}`),console.log(`Statements: ${e.statements?.length??0}`),e.teardown?.length&&console.log(`Teardown: ${e.teardown.length}`);let r=xYi(e.statements??[]);console.log(` DRAFT: ${r.drafts}, ACTION: ${r.actions}, STEP: ${r.steps}`)}}function xYi(e){let t={drafts:0,actions:0,steps:0};for(let r of e)if(r.type==="DRAFT")t.drafts++;else if(r.type==="ACTION")t.actions++;else if(r.type==="STEP"){t.steps++;let n=xYi(r.statements??[]);t.drafts+=n.drafts,t.actions+=n.actions,t.steps+=n.steps}return t}var TYi=le(()=>{"use strict";wA()});var IYi=se((pGu,E4c)=>{E4c.exports={name:"shiplightai",version:"0.1.
|
|
9519
|
+
${n.length} file(s): ${u} transpiled, ${s} error(s), ${a} warning(s)`),process.exit(s>0?1:0)}var CYi=le(()=>{"use strict";bKe();vYi()});var SYi={};bh(SYi,{runInspect:()=>b4c});import*as Oxt from"fs";import*as wYi from"path";async function b4c(e){(e.includes("--help")||e.includes("-h")||e.length===0)&&(console.log("Usage: shiplight inspect <file.test.yaml> [options]"),console.log(""),console.log("Parse a YAML test file and output the resulting TestFlow JSON."),console.log("Useful for verifying YAML \u2192 JSON conversion."),console.log(""),console.log("Options:"),console.log(" --pretty Pretty-print JSON (default)"),console.log(" --compact Compact JSON output"),console.log(" --stats Show statement statistics only"),console.log(""),console.log("Examples:"),console.log(" shiplight inspect tests/login.test.yaml"),console.log(" shiplight inspect tests/suite.test.yaml --stats"),console.log(" shiplight inspect tests/login.test.yaml --compact | jq ."),process.exit(e.length===0?1:0));let t=e.includes("--compact"),r=e.includes("--stats"),n=e.find(u=>!u.startsWith("--"));n||(console.error("Error: no file specified"),process.exit(1));let s=wYi.resolve(process.cwd(),n);Oxt.existsSync(s)||(console.error(`Error: file not found: ${s}`),process.exit(1));let a=Oxt.readFileSync(s,"utf-8");try{let u=Xte(a),f=q2(a);if(r)v4c(f,u);else{let p={...u.test_case_id!==void 0?{test_case_id:u.test_case_id}:{},...u.name?{name:u.name}:{},testFlow:f};console.log(JSON.stringify(p,null,t?0:2))}}catch(u){console.error(`Error parsing ${n}: ${u.message}`),process.exit(1)}}function v4c(e,t){if(console.log(`File: ${t.name||"(unnamed)"}`),t.test_case_id!==void 0&&console.log(`Cloud ID: ${t.test_case_id}`),console.log(`Version: ${e.version||"unknown"}`),e.testGroup){let r=e.testGroup;console.log("Type: suite (testGroup)"),console.log(`Tests: ${r.tests.length}`);for(let n of r.tests){let s=n.skip?` [SKIP${typeof n.skip=="string"?`: ${n.skip}`:""}]`:"";console.log(` - ${n.name}: ${n.statements.length} statements${n.teardown?`, ${n.teardown.length} teardown`:""}${s}`)}r.beforeAll?.length&&console.log(`Hooks: beforeAll (${r.beforeAll.length})`),r.afterAll?.length&&console.log(`Hooks: afterAll (${r.afterAll.length})`),r.beforeEach?.length&&console.log(`Hooks: beforeEach (${r.beforeEach.length})`),r.afterEach?.length&&console.log(`Hooks: afterEach (${r.afterEach.length})`)}else{console.log("Type: single test"),console.log(`Goal: ${e.goal}`),e.url&&console.log(`URL: ${e.url}`),e.baseURL&&console.log(`Base URL: ${e.baseURL}`),console.log(`Statements: ${e.statements?.length??0}`),e.teardown?.length&&console.log(`Teardown: ${e.teardown.length}`);let r=xYi(e.statements??[]);console.log(` DRAFT: ${r.drafts}, ACTION: ${r.actions}, STEP: ${r.steps}`)}}function xYi(e){let t={drafts:0,actions:0,steps:0};for(let r of e)if(r.type==="DRAFT")t.drafts++;else if(r.type==="ACTION")t.actions++;else if(r.type==="STEP"){t.steps++;let n=xYi(r.statements??[]);t.drafts+=n.drafts,t.actions+=n.actions,t.steps+=n.steps}return t}var TYi=le(()=>{"use strict";wA()});var IYi=se((pGu,E4c)=>{E4c.exports={name:"shiplightai",version:"0.1.26",type:"module",description:"Shiplight CLI for running and debugging .test.yaml files",main:"dist/index.js",types:"dist/index.d.ts",bin:{shiplight:"dist/cli.js"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/cjs/index.cjs",default:"./dist/index.js"},"./fixture":{types:"./dist/fixture.d.ts",import:"./dist/fixture.js",require:"./dist/cjs/fixture.cjs",default:"./dist/fixture.js"},"./debugger-pw":{types:"./dist/debugger-pw.d.ts",import:"./dist/debugger-pw.js",require:"./dist/cjs/debugger-pw.cjs",default:"./dist/debugger-pw.js"},"./reporter":{types:"./dist/reporter.d.ts",import:"./dist/reporter.js",require:"./dist/cjs/reporter.cjs",default:"./dist/reporter.js"}},files:["dist","README.md"],publishConfig:{registry:"https://registry.npmjs.org",access:"public"},scripts:{build:"tsup && cd ../frontend && npx vite build --config vite.debugger.config.ts","build:cli":"tsup",pack:"tsup && cd ../frontend && npx vite build --config vite.debugger.config.ts && pnpm pack",clean:"rm -rf dist",dev:"tsup --watch",test:"playwright test",typecheck:"tsc --noEmit"},dependencies:{"@babel/plugin-transform-typescript":"^7.27.0","@babel/preset-env":"^7.26.9","@babel/preset-typescript":"^7.27.0","@anthropic-ai/claude-agent-sdk":"^0.1.72","@modelcontextprotocol/sdk":"^0.5.0",axios:"^1.6.0",dotenv:"^16.0.3",express:"^4.21.0",glob:"^13.0.0",open:"^10.1.0",sharp:"^0.34.5",uuid:"^11.1.0",yaml:"^2.8.0",zod:"^3.22.0","zod-to-json-schema":"^3.24.6"},devDependencies:{"@playwright/test":"1.58.2","@types/express":"^4.17.21","@types/node":"^24.0.0",copilot3:"workspace:*","mcp-tools":"workspace:*","sdk-core":"workspace:*","sdk-internal":"workspace:*","shiplight-tools":"workspace:*","shiplight-types":"workspace:*",tsup:"^8.3.5",typescript:"5.5.4","web-session":"workspace:*"},peerDependencies:{"@playwright/test":"1.58.2"},engines:{node:">=22.0.0"},keywords:["playwright","yaml","testing","automation","ai","shiplight","mcp"],author:"Shiplight",license:"MIT"}});import C4c from"dotenv";C4c.config();function DYi(){console.log(`
|
|
9519
9520
|
Usage: shiplight <command> [options]
|
|
9520
9521
|
|
|
9521
9522
|
Commands:
|
package/dist/fixture.d.ts
CHANGED
|
@@ -2,8 +2,20 @@ import * as _playwright_test from '@playwright/test';
|
|
|
2
2
|
export { expect } from '@playwright/test';
|
|
3
3
|
import { WebAgent } from './agent/webAgent.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Per-test account: auth_login path + arbitrary credentials passed to the login function.
|
|
7
|
+
* auth_login is resolved relative to process.cwd() (the project root where `playwright test` runs).
|
|
8
|
+
* The login module must export a login(credentials) function that spawns its own browser,
|
|
9
|
+
* performs the login flow, caches the storageState, and returns the file path.
|
|
10
|
+
*/
|
|
11
|
+
interface AccountSpec {
|
|
12
|
+
auth_login: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
type ShiplightFixtures = {
|
|
6
16
|
agent: WebAgent;
|
|
7
|
-
|
|
17
|
+
account: AccountSpec | undefined;
|
|
18
|
+
};
|
|
19
|
+
declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & ShiplightFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
|
|
8
20
|
|
|
9
21
|
export { test };
|
package/dist/fixture.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
|
-
import"./chunk-CSINHOOD.js";import*as
|
|
3
|
+
import"./chunk-CSINHOOD.js";import*as u from"path";import{test as v,expect as S}from"@playwright/test";async function m(o){let c=await import(u.resolve(process.cwd(),o.auth_login)),i=c.login||c.default;if(typeof i!="function")throw new Error(`auth_login module "${o.auth_login}" must export a login(account) function that returns a storageState file path`);let{auth_login:n,...a}=o,s=await i(a);if(typeof s!="string")throw new Error(`auth_login module "${o.auth_login}" login() must return a storageState file path (got ${typeof s})`);return s}var p;async function _(){return p||(p=await import("./dist-TC3HQUYV.js"),p)}var b=v.extend({account:[void 0,{option:!0}],context:async({browser:o,account:e},c,i)=>{let n={...i.project.use};if(e){if(!e.auth_login)throw new Error('Test declares "account" but missing "auth_login" path. Provide auth_login in the account spec: use: { account: { auth_login: ./auth.login.ts, ... } }');n.storageState=await m(e)}n.video&&!n.recordVideo&&(n.recordVideo={dir:i.outputDir});let a=await o.newContext(n);await c(a);for(let s of a.pages()){let l=await s.video()?.path()?.catch(()=>null);l&&await i.attach("video",{path:l,contentType:"video/webm"})}await a.close()},agent:async({},o,e)=>{let{WebAgent:c,createAgentContext:i,configureSdk:n,VariableStore:a}=await _();n({env:{GOOGLE_API_KEY:process.env.GOOGLE_API_KEY??"",ANTHROPIC_API_KEY:process.env.ANTHROPIC_API_KEY??""}});let{resolveModelFromEnv:s}=await import("./dist-72K3TMRS.js"),l=s(process.env);if(!l)throw new Error("No AI model configured. Set WEB_AGENT_MODEL, ANTHROPIC_API_KEY, or GOOGLE_API_KEY.");let h=new a,g=e.project.use.variables;if(g)for(let[r,t]of Object.entries(g))typeof t=="string"?h.set(r,t,!1):t&&typeof t=="object"&&"value"in t&&h.set(r,t.value,t.sensitive===!0);let d=i({model:l,variableStore:h,autoDisableModal:!0}),w=u.join(e.outputDir,"artifacts");d.stepTracking={results:{},artifactsDir:w};let f=new c(d);await o(f);try{let r=e.outputDir;await f.writeExecutionResults(r);let t=u.join(r,"test-results.json");await(await import("fs/promises")).stat(t).catch(()=>null)&&await e.attach("shiplight-results",{path:t,contentType:"application/json"})}catch(r){console.error("[Shiplight] Failed to attach step results:",r)}}});export{S as expect,b as test};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
|
-
import{r as w,s as R}from"./chunk-YTXNWA2O.js";import{l as I}from"./chunk-BDIWRQLE.js";import"./chunk-XQZ4FULT.js";import"./chunk-AZT2TSHD.js";import"./chunk-YHOTGR6H.js";import"./chunk-7TAH76YI.js";import"./chunk-YDR4P3GA.js";import"./chunk-YU3XZJIJ.js";import"./chunk-S6IZG6S3.js";import{a as v}from"./chunk-DJDHFWEV.js";import{a as g,b as h}from"./chunk-KHL5KPVQ.js";import"./chunk-OLZMN3WB.js";import"./chunk-CSINHOOD.js";import*as S from"fs";import*as o from"path";import H from"dotenv";import{readFileSync as u,statSync as E,existsSync as y}from"fs";import{resolve as p}from"path";import{globSync as A}from"glob";var c="0.1.
|
|
3
|
+
import{r as w,s as R}from"./chunk-YTXNWA2O.js";import{l as I}from"./chunk-BDIWRQLE.js";import"./chunk-XQZ4FULT.js";import"./chunk-AZT2TSHD.js";import"./chunk-YHOTGR6H.js";import"./chunk-7TAH76YI.js";import"./chunk-YDR4P3GA.js";import"./chunk-YU3XZJIJ.js";import"./chunk-S6IZG6S3.js";import{a as v}from"./chunk-DJDHFWEV.js";import{a as g,b as h}from"./chunk-KHL5KPVQ.js";import"./chunk-OLZMN3WB.js";import"./chunk-CSINHOOD.js";import*as S from"fs";import*as o from"path";import H from"dotenv";import{readFileSync as u,statSync as E,existsSync as y}from"fs";import{resolve as p}from"path";import{globSync as A}from"glob";var c="0.1.26";function d(t){try{return E(t).mtimeMs}catch{return 0}}var T=`// @generated by shiplightai v${c}`;function b(t,s){if(!y(t)||u(t,"utf-8").split(`
|
|
4
4
|
`,1)[0]!==T)return!1;let i=d(t);for(let e of s)if(d(e)>i)return!1;return!0}function x(t){let s=process.argv.slice(2),n=[],i=p(t);for(let e of s){if(e.startsWith("-"))continue;let r=e.endsWith(".yaml.spec.ts")?e.replace(/\.yaml\.spec\.ts$/,".test.yaml"):e;if(!r.endsWith(".test.yaml"))continue;let l=p(t,r);y(l)&&n.push(l.startsWith(i)?l.slice(i.length+1):r)}return n.length>0?n:null}function _(t){let s=x(t.cwd),n=s??A("**/*.test.yaml",{cwd:t.cwd,ignore:["**/node_modules/**"]}),i=[];for(let e of n){let r=p(t.cwd,e),l=r.replace(/\.test\.yaml$/,".yaml.spec.ts"),f=u(r,"utf-8");try{let a=g(f,r);if(b(l,[r,...a.referencedTemplatePaths]))continue;let m=h(f,r,{version:c});if(!m.valid)throw new Error(m.errors.join("; "))}catch(a){console.error(`[shiplight] Failed to transpile ${e}:`,a),i.push({file:e,error:a})}}if(i.length>0){let e=`[shiplight] Transpilation failed for ${i.length} file(s):
|
|
5
5
|
`+i.map(r=>` - ${r.file}`).join(`
|
|
6
6
|
`);if(s)throw new Error(e);console.warn(e+" (skipped)")}}function O(t={}){t.dotenv!==!1&&P(t.scanDir||process.cwd());let s=t.scanDir||process.cwd();return _({cwd:s}),t.apiKey&&(process.env.__SHIPLIGHT_API_KEY=t.apiKey),{reporter:[["list"],["shiplightai/reporter",{outputFolder:"shiplight-report",open:"never"}]]}}function P(t){let s=[],n=o.resolve(t),i=o.resolve(process.cwd());for(;;){let e=o.join(n,".env");if(S.existsSync(e)&&s.push(e),n===i)break;let r=o.dirname(n);if(r===n)break;n=r}for(let e of s)H.config({path:e})}export{I as VariableStore,w as WebAgent,v as configureSdk,R as createAgentContext,O as shiplightConfig};
|
package/dist/reporter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
|
-
import{a as
|
|
3
|
+
import{a as I}from"./chunk-KHL5KPVQ.js";import{Aa as b}from"./chunk-OLZMN3WB.js";import"./chunk-CSINHOOD.js";import*as u from"fs";import*as c from"path";function p(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function k(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let r=Math.floor(e/6e4),s=(e%6e4/1e3).toFixed(0);return`${r}m ${s}s`}function T(e){switch(e){case"passed":case"success":return'<span class="status-icon passed">✔</span>';case"failed":case"failure":case"timedOut":return'<span class="status-icon failed">✘</span>';case"skipped":return'<span class="status-icon skipped">─</span>';case"interrupted":return'<span class="status-icon failed">⚠</span>';default:return'<span class="status-icon pending">○</span>'}}function D(e){return`<span class="badge badge-${e}">${e}</span>`}function F(e){let r=e.duration!=null?`<span class="step-duration">${k(e.duration)}</span>`:"",s=T(e.status);if(e.screenshot||e.message||e.error){let l="";e.screenshot&&(l=`<img src="${p(e.screenshot)}" alt="Step screenshot" class="step-screenshot" />`);let i="";e.error&&(i=`<div class="step-error"><pre>${p(e.error)}</pre></div>`);let o="";e.message&&!e.error&&(o=`<div class="step-message">${p(e.message)}</div>`);let d=e.status==="failure"?" open":"";return`
|
|
4
4
|
<details class="step-details step step-${e.status}"${d}>
|
|
5
5
|
<summary class="step-header">
|
|
6
6
|
${s}
|
|
@@ -22,7 +22,7 @@ import{a as T}from"./chunk-KHL5KPVQ.js";import{Aa as b}from"./chunk-OLZMN3WB.js"
|
|
|
22
22
|
<span class="step-description">${p(e.description)}</span>
|
|
23
23
|
${r}
|
|
24
24
|
</div>
|
|
25
|
-
</div>`}function
|
|
25
|
+
</div>`}function B(e,r){let s=T(e.status),g=e.steps.map(F).join(`
|
|
26
26
|
`),l="";e.error&&!e.steps.some(a=>a.error)&&(l=`<div class="test-error"><pre>${p(e.error)}</pre></div>`);let i=[];e.videoPath&&i.push(`
|
|
27
27
|
<details class="artifact-section">
|
|
28
28
|
<summary class="artifact-summary">Video</summary>
|
|
@@ -61,7 +61,7 @@ import{a as T}from"./chunk-KHL5KPVQ.js";import{Aa as b}from"./chunk-OLZMN3WB.js"
|
|
|
61
61
|
${s}
|
|
62
62
|
<span class="test-title">${p(e.title)}</span>
|
|
63
63
|
<span class="test-file">${p(e.file)}</span>
|
|
64
|
-
${
|
|
64
|
+
${D(e.status)}
|
|
65
65
|
<span class="test-duration">${k(e.duration)}</span>
|
|
66
66
|
</summary>
|
|
67
67
|
<div class="test-body">
|
|
@@ -71,7 +71,7 @@ import{a as T}from"./chunk-KHL5KPVQ.js";import{Aa as b}from"./chunk-OLZMN3WB.js"
|
|
|
71
71
|
</div>
|
|
72
72
|
${d}
|
|
73
73
|
</div>
|
|
74
|
-
</details>`}function R(e){let r=e.tests.filter(o=>o.status==="passed").length,s=e.tests.filter(o=>o.status==="failed"||o.status==="timedOut").length,g=e.tests.filter(o=>o.status==="skipped").length,l=e.tests.length,i=e.tests.map((o,d)=>
|
|
74
|
+
</details>`}function R(e){let r=e.tests.filter(o=>o.status==="passed").length,s=e.tests.filter(o=>o.status==="failed"||o.status==="timedOut").length,g=e.tests.filter(o=>o.status==="skipped").length,l=e.tests.length,i=e.tests.map((o,d)=>B(o,d)).join(`
|
|
75
75
|
`);return`<!DOCTYPE html>
|
|
76
76
|
<html lang="en">
|
|
77
77
|
<head>
|
|
@@ -595,6 +595,7 @@ import{a as T}from"./chunk-KHL5KPVQ.js";import{Aa as b}from"./chunk-OLZMN3WB.js"
|
|
|
595
595
|
${s>0?`<span class="summary-stat failed">${s} failed</span>`:""}
|
|
596
596
|
${g>0?`<span class="summary-stat skipped">${g} skipped</span>`:""}
|
|
597
597
|
<span class="summary-stat">${k(e.totalDuration)}</span>
|
|
598
|
+
${e.timestamp?`<span class="summary-stat" style="margin-left:auto;color:var(--color-text-secondary)">${new Date(e.timestamp).toLocaleString()}</span>`:""}
|
|
598
599
|
</div>
|
|
599
600
|
</div>
|
|
600
601
|
<div class="test-list">
|
|
@@ -717,7 +718,7 @@ import{a as T}from"./chunk-KHL5KPVQ.js";import{Aa as b}from"./chunk-OLZMN3WB.js"
|
|
|
717
718
|
});
|
|
718
719
|
</script>
|
|
719
720
|
</body>
|
|
720
|
-
</html>`}var C={before:0,main:1,teardown:2,after:3};function z(e){let r=e.split(".")[0];return C[r]??1}function E(e){return e.split(".").map(r=>{let s=Number(r);return Number.isNaN(s)?0:s})}function A(e){return[...e].sort(([r],[s])=>{let g=z(r),l=z(s);if(g!==l)return g-l;let i=E(r),o=E(s);for(let d=0;d<Math.max(i.length,o.length);d++){let a=i[d]??-1,t=o[d]??-1;if(a!==t)return a-t}return 0})}var w=class{outputFolder;openMode;collected=[];config;constructor(r={}){this.outputFolder=r.outputFolder||"shiplight-report",this.openMode=r.open||"on-failure"}onBegin(r,s){this.config=r}onTestEnd(r,s){this.collected.push({test:r,result:s})}async onEnd(r){if(this.collected.length===0)return;let s=[];for(let{test:t,result:n}of this.collected){let y=t.location.file,m=await this.buildReportTest(t,n,y);s.push(m)}let g={tests:s,totalDuration:r.duration},l=c.isAbsolute(this.outputFolder)?this.outputFolder:c.join(process.cwd(),this.outputFolder);u.mkdirSync(l,{recursive:!0});let i=c.join(l,"screenshots"),o=!1;for(let t of g.tests)for(let n of t.steps)if(n.screenshot&&c.isAbsolute(n.screenshot))try{o||(u.mkdirSync(i,{recursive:!0}),o=!0);let y=`${n.stepId.replace(/\./g,"-")}.png`,m=c.join(i,y);u.copyFileSync(n.screenshot,m),n.screenshot=`screenshots/${y}`}catch{}let d=c.join(l,"report-data.json");u.writeFileSync(d,JSON.stringify(g,null,2),"utf-8");let a=c.join(l,"index.html");u.writeFileSync(a,R(g),"utf-8");for(let{result:t}of this.collected)for(let n of t.attachments)if(n.path&&(n.name==="video"||n.name==="trace")){let y=c.basename(n.path),m=c.join(l,y);try{u.copyFileSync(n.path,m)}catch{}}if(console.log(`
|
|
721
|
+
</html>`}var C={before:0,main:1,teardown:2,after:3};function z(e){let r=e.split(".")[0];return C[r]??1}function E(e){return e.split(".").map(r=>{let s=Number(r);return Number.isNaN(s)?0:s})}function A(e){return[...e].sort(([r],[s])=>{let g=z(r),l=z(s);if(g!==l)return g-l;let i=E(r),o=E(s);for(let d=0;d<Math.max(i.length,o.length);d++){let a=i[d]??-1,t=o[d]??-1;if(a!==t)return a-t}return 0})}var w=class{outputFolder;openMode;collected=[];config;constructor(r={}){this.outputFolder=r.outputFolder||"shiplight-report",this.openMode=r.open||"on-failure"}onBegin(r,s){this.config=r}onTestEnd(r,s){this.collected.push({test:r,result:s})}async onEnd(r){if(this.collected.length===0)return;let s=[];for(let{test:t,result:n}of this.collected){let y=t.location.file,m=await this.buildReportTest(t,n,y);s.push(m)}let g={tests:s,totalDuration:r.duration,timestamp:new Date().toISOString()},l=c.isAbsolute(this.outputFolder)?this.outputFolder:c.join(process.cwd(),this.outputFolder);u.mkdirSync(l,{recursive:!0});let i=c.join(l,"screenshots"),o=!1;for(let t of g.tests)for(let n of t.steps)if(n.screenshot&&c.isAbsolute(n.screenshot))try{o||(u.mkdirSync(i,{recursive:!0}),o=!0);let y=`${n.stepId.replace(/\./g,"-")}.png`,m=c.join(i,y);u.copyFileSync(n.screenshot,m),n.screenshot=`screenshots/${y}`}catch{}let d=c.join(l,"report-data.json");u.writeFileSync(d,JSON.stringify(g,null,2),"utf-8");let a=c.join(l,"index.html");u.writeFileSync(a,R(g),"utf-8");for(let{result:t}of this.collected)for(let n of t.attachments)if(n.path&&(n.name==="video"||n.name==="trace")){let y=c.basename(n.path),m=c.join(l,y);try{u.copyFileSync(n.path,m)}catch{}}if(console.log(`
|
|
721
722
|
Shiplight report written to: ${a}`),this.openMode==="always"||this.openMode==="on-failure"&&r.status!=="passed")try{let t=(await import("open")).default;await t(a)}catch{}}printsToStdio(){return!1}async buildReportTest(r,s,g){let l={title:r.title,file:c.relative(process.cwd(),g),status:s.status,duration:s.duration,steps:[]};s.errors.length>0&&(l.error=s.errors.map(t=>t.message||t.stack||String(t)).join(`
|
|
722
723
|
|
|
723
|
-
`));for(let t of s.attachments)t.name==="video"&&t.path&&(l.videoPath=c.basename(t.path)),t.name==="trace"&&t.path&&(l.tracePath=c.basename(t.path));let i=s.attachments.find(t=>t.name==="shiplight-results"),o=null;if(i)try{if(i.body)o=JSON.parse(i.body.toString("utf-8"));else if(i.path){let t=u.readFileSync(i.path,"utf-8");o=JSON.parse(t)}}catch{}let d=g.replace(/\.yaml\.spec\.ts$/,".test.yaml"),a={};if(u.existsSync(d))try{let t=u.readFileSync(d,"utf-8"),n=
|
|
724
|
+
`));for(let t of s.attachments)t.name==="video"&&t.path&&(l.videoPath=c.basename(t.path)),t.name==="trace"&&t.path&&(l.tracePath=c.basename(t.path));let i=s.attachments.find(t=>t.name==="shiplight-results"),o=null;if(i)try{if(i.body)o=JSON.parse(i.body.toString("utf-8"));else if(i.path){let t=u.readFileSync(i.path,"utf-8");o=JSON.parse(t)}}catch{}let d=g.replace(/\.yaml\.spec\.ts$/,".test.yaml"),a={};if(u.existsSync(d))try{let t=u.readFileSync(d,"utf-8"),n=I(t,d);if(n.suite){let y=n.suite.tests.find(m=>m.name===r.title);y&&(a=b(y.testFlow))}else n.testFlow&&(a=b(n.testFlow))}catch{}if(o||Object.keys(a).length>0){let t=new Set([...Object.keys(a),...Object.keys(o||{})]),n=Array.from(t).map(m=>[m,null]),y=A(n);for(let[m]of y){let $=a[m],f=o?.[m],h=$?.description;if(!h||h==="Action"||h==="Draft"){let v=$?.action_entity;h=v?.action_description||v?.action_data?.kwargs?.description||f?.description||m}let x={stepId:m,description:h,status:f?.status||"pending",duration:f?.duration};if(f?.message){let v=typeof f.message=="string"?f.message:JSON.stringify(f.message,null,2);f.status==="failure"?x.error=v:x.message=v}if(f?.screenshot){let v=f.screenshot,O=i?.path?c.dirname(i.path):"",S=c.isAbsolute(v)?v:c.join(O,v);u.existsSync(S)&&(x.screenshot=S)}l.steps.push(x)}}return l}},j=w;export{j as default};
|