@dev-blinq/cucumber_client 1.0.1707-dev → 1.0.1708-dev

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.
@@ -160,8 +160,8 @@ ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.pus
160
160
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
161
161
  `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(s){let i=s.items[s.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let c="end"in i.value?i.value.end:void 0;(Array.isArray(c)?c[c.length-1]:void 0)?.type==="comment"?c?.push(this.sourceToken):s.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)s.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,s.indent)){let c=s.items[s.items.length-2],f=c?.value?.end;if(Array.isArray(f))return Array.prototype.push.apply(f,i.start),f.push(this.sourceToken),void s.items.pop()}i.start.push(this.sourceToken)}return}if(this.indent>=s.indent){let c=!this.onKeyLine&&this.indent===s.indent,f=c&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",d=[];if(f&&i.sep&&!i.value){let g=[];for(let S=0;S<i.sep.length;++S){let k=i.sep[S];switch(k.type){case"newline":g.push(S);break;case"space":break;case"comment":k.indent>s.indent&&(g.length=0);break;default:g.length=0}}g.length>=2&&(d=i.sep.splice(g[1]))}switch(this.type){case"anchor":case"tag":return void(f||i.value?(d.push(this.sourceToken),s.items.push({start:d}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken));case"explicit-key-ind":return i.sep||i.explicitKey?f||i.value?(d.push(this.sourceToken),s.items.push({start:d,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(i.start.push(this.sourceToken),i.explicitKey=!0),void(this.onKeyLine=!0);case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)s.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ke(i.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:d,key:null,sep:[this.sourceToken]}]});else if(Si(i.key)&&!Ke(i.sep,"newline")){let g=gt(i.start),S=i.key,k=i.sep;k.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:g,key:S,sep:k}]})}else d.length>0?i.sep=i.sep.concat(d,this.sourceToken):i.sep.push(this.sourceToken);else if(Ke(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let g=gt(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:g,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||f?s.items.push({start:d,key:null,sep:[this.sourceToken]}):Ke(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return void(this.onKeyLine=!0);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let g=this.flowScalar(this.type);return void(f||i.value?(s.items.push({start:d,key:g,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(g):(Object.assign(i,{key:g,sep:[]}),this.onKeyLine=!0))}default:{let g=this.startBlockValue(s);if(g){if(g.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Ke(i.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else c&&s.items.push({start:d});return void this.stack.push(g)}}}}yield*this.pop(),yield*this.step()}*blockSequence(s){let i=s.items[s.items.length-1];switch(this.type){case"newline":if(i.value){let c="end"in i.value?i.value.end:void 0;(Array.isArray(c)?c[c.length-1]:void 0)?.type==="comment"?c?.push(this.sourceToken):s.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)s.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,s.indent)){let c=s.items[s.items.length-2],f=c?.value?.end;if(Array.isArray(f))return Array.prototype.push.apply(f,i.start),f.push(this.sourceToken),void s.items.pop()}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=s.indent)break;return void i.start.push(this.sourceToken);case"seq-item-ind":if(this.indent!==s.indent)break;return void(i.value||Ke(i.start,"seq-item-ind")?s.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken))}if(this.indent>s.indent){let c=this.startBlockValue(s);if(c)return void this.stack.push(c)}yield*this.pop(),yield*this.step()}*flowCollection(s){let i=s.items[s.items.length-1];if(this.type==="flow-error-end"){let c;do yield*this.pop(),c=this.peek(1);while(c&&c.type==="flow-collection")}else if(s.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":return void(!i||i.sep?s.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken));case"map-value-ind":return void(!i||i.value?s.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]}));case"space":case"comment":case"newline":case"anchor":case"tag":return void(!i||i.value?s.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let f=this.flowScalar(this.type);return void(!i||i.value?s.items.push({start:[],key:f,sep:[]}):i.sep?this.stack.push(f):Object.assign(i,{key:f,sep:[]}))}case"flow-map-end":case"flow-seq-end":return void s.end.push(this.sourceToken)}let c=this.startBlockValue(s);c?this.stack.push(c):(yield*this.pop(),yield*this.step())}else{let c=this.peek(2);if(c.type==="block-map"&&(this.type==="map-value-ind"&&c.indent===s.indent||this.type==="newline"&&!c.items[c.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&c.type!=="flow-collection"){let f=gt(On(c));xi(s);let d=s.end.splice(1,s.end.length);d.push(this.sourceToken);let g={type:"block-map",offset:s.offset,indent:s.indent,items:[{start:f,key:s,sep:d}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=g}else yield*this.lineEnd(s)}}flowScalar(s){if(this.onNewLine){let i=this.source.indexOf(`
162
162
  `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
163
- `,i)+1}return{type:s,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(s){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=gt(On(s));return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=gt(On(s));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(s,i){return this.type==="comment"&&!(this.indent<=i)&&s.every(c=>c.type==="newline"||c.type==="space")}*documentEnd(s){this.type!=="doc-mode"&&(s.end?s.end.push(this.sourceToken):s.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(s){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:s.end?s.end.push(this.sourceToken):s.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Ti(a){let s=a.prettyErrors!==!1;return{lineCounter:a.lineCounter||s&&new wi||null,prettyErrors:s}}function ki(a,s={}){let{lineCounter:i,prettyErrors:c}=Ti(s),f=new kr(i?.addNewLine),d=new Er(s),g=null;for(let S of d.compose(f.parse(a),!0,a.length))if(g){if(g.options.logLevel!=="silent"){g.errors.push(new Xe(S.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else g=S;return c&&i&&(g.errors.forEach(kn(a,i)),g.warnings.forEach(kn(a,i))),g}return e.Alias=U,e.CST=Ba,e.Composer=Er,e.Document=ft,e.Lexer=vi,e.LineCounter=wi,e.Pair=ve,e.Parser=kr,e.Scalar=G,e.Schema=Tn,e.YAMLError=gr,e.YAMLMap=_e,e.YAMLParseError=Xe,e.YAMLSeq=We,e.YAMLWarning=ii,e.isAlias=p,e.isCollection=A,e.isDocument=b,e.isMap=v,e.isNode=I,e.isPair=m,e.isScalar=y,e.isSeq=w,e.parse=function(a,s,i){let c;typeof s=="function"?c=s:i===void 0&&s&&typeof s=="object"&&(i=s);let f=ki(a,i);if(!f)return null;if(f.warnings.forEach(d=>Rs(f.options.logLevel,d)),f.errors.length>0){if(f.options.logLevel!=="silent")throw f.errors[0];f.errors=[]}return f.toJS(Object.assign({reviver:c},i))},e.parseAllDocuments=function(a,s={}){let{lineCounter:i,prettyErrors:c}=Ti(s),f=new kr(i?.addNewLine),d=new Er(s),g=Array.from(d.compose(f.parse(a)));if(c&&i)for(let S of g)S.errors.forEach(kn(a,i)),S.warnings.forEach(kn(a,i));return g.length>0?g:Object.assign([],{empty:!0},d.streamInfo())},e.parseDocument=ki,e.stringify=function(a,s,i){let c=null;if(typeof s=="function"||Array.isArray(s)?c=s:i===void 0&&s&&(i=s),typeof i=="string"&&(i=i.length),typeof i=="number"){let f=Math.round(i);i=f<1?void 0:f>8?{indent:8}:{indent:f}}if(a===void 0){let{keepUndefined:f}=i??s??{};if(!f)return}return b(a)&&!c?a.toString(i):new ft(a,c,i).toString(i)},e.visit=ee,e.visitAsync=Z,e}({}),As=du;var pu=Me.domUtils.closestCrossShadow,gu=Me.domUtils.isElementVisible,cn=class{deepEventTarget(t){return t.composedPath()[0]}deepActiveElement(t){let n=t.activeElement;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n}modifiersForEvent(t){return(t.altKey?1:0)|(t.ctrlKey?2:0)|(t.metaKey?4:0)|(t.shiftKey?8:0)}buttonForEvent(t){switch(t.which){case 1:return"left";case 2:return"middle";case 3:return"right"}return"left"}positionForEvent(t){if(t.target.nodeName==="CANVAS")return{x:t.offsetX,y:t.offsetY}}consumeEvent(t){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}asCheckbox(t){if(!t||t.nodeName!=="INPUT")return null;let n=t;return["checkbox","radio"].includes(n.type)?n:null}isRangeInput(t){return!t||t.nodeName!=="INPUT"?!1:t.type.toLowerCase()==="range"}addEventListener(t,n,r,o){return t.addEventListener(n,r,o),()=>{t.removeEventListener(n,r,o)}}removeEventListeners(t){for(let n of t)n();t.splice(0,t.length)}getNearestInteractiveElement(t,n=window.document){try{if(!t.matches("input,textarea,select")&&!t.isContentEditable){let r=pu(t,"button,select,input,[role=button],[role=checkbox],[role=radio],a,[role=link]",n);if(r&&gu(r))return r}return t}catch(r){return console.error(r),t}}shouldGenerateKeyPressFor(t){if(t.key==="Enter"&&(this.deepEventTarget(t).nodeName==="TEXTAREA"||this.deepEventTarget(t).isContentEditable)||["Backspace","Delete","AltGraph"].includes(t.key)||t.key==="@"&&t.code==="KeyL")return!1;if(navigator.platform.includes("Mac")){if(t.key==="v"&&t.metaKey)return!1}else if(t.key==="v"&&t.ctrlKey||t.key==="Insert"&&t.shiftKey)return!1;if(["Shift","Control","Meta","Alt","Process"].includes(t.key))return!1;let n=t.ctrlKey||t.altKey||t.metaKey;return t.key.length===1&&!n?!!this.asCheckbox(this.deepEventTarget(t)):!0}};var mu=Math.random().toString(36).substring(7),ba=0,Ns=()=>(ba++,`bvt_input_${ba}_${mu}`),yu=e=>{if(e instanceof HTMLInputElement&&(e.type==="button"||e.type==="submit"))return e.value?.length>0;if(e.innerText?.length>0){if(e.childNodes.length===0)return!0;for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];if(r.nodeType===Node.TEXT_NODE&&r.nodeValue.trim().length>0)return!0}}},nt={recordCommand:e=>__bvt_recordCommand(e),setMode:e=>__bvt_setMode(e),revertMode:()=>__bvt_revertMode(),recordPageClose:()=>__bvt_recordPageClose(),getMode:()=>__bvt_getMode(),log:e=>__bvt_log(e),sendObject:e=>__bvt_getObject(e)},va=null,Pe=class{constructor(t,n){this.name=t,this.getAction=n.getAction,this.getInterestedElement=n.getInterestedElement,this.hoverOutlineStyle=n.hoverOutlineStyle,this.start=n.start}},Cs=class{#t=null;#e="noop";contextElement=null;debugListener=!1;debugMouseOut=!1;debugMouseOver=!1;debugFocusOut=!1;debugFocusIn=!1;#n=Symbol("outline");#r=!1;toolbar=null;activeElement=null;cleanup=null;rect=null;offsetX=null;offsetY=null;popupHandlers=[];disableHighlight=!1;improviseLocators=!0;snapshotCapturer=new ma({excludeSelectors:["script","x-bvt-toolbar"]});injectedScript=pa();locatorGenerator=new ga(this.injectedScript);PW=Me;snapshotUtils=new ya;eventUtils=new cn;constructor(t={}){let{disableHighlight:n=!1,improviseLocators:r=!0,popupHandlers:o=[],testAttributes:u=[]}=t;this.disableHighlight=n,this.improviseLocators=r,this.popupHandlers=o,this.locatorGenerator.options.customAttributes=u,this.init()}init({mode:t="noop"}={}){this.addRecorderStates(),this.mode=t,this.addOverrides(),this.addListeners(),this.addHighlightListeners(window),window.addEventListener("DOMContentLoaded",async()=>{this.addToolbar(),this.mode=await nt.getMode()})}collectElementsFromAriaSnapshot(t,n){if(!(t.element&&t.element.tagName==="X-BVT-TOOL")){t.element&&n.add({element:t.element,snapshot:this.injectedScript.ariaSnapshot(t.element)});for(let r of t.children)typeof r!="string"&&this.collectElementsFromAriaSnapshot(r,n)}}addRecorderStates(){let t=new Pe("noop",{getAction:m=>{this.eventUtils.consumeEvent(m)},getInterestedElement:()=>{},hoverOutlineStyle:""}),n=new Pe("idle",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show()}),getAction:()=>null,getInterestedElement:()=>{},hoverOutlineStyle:""}),r=new Pe("running",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show()}),getAction:()=>null,getInterestedElement:()=>{},hoverOutlineStyle:""}),o=new Pe("inspecting",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show(),this.resetHighlight(this.activeElement)}),getInterestedElement:m=>m,hoverOutlineStyle:"2px solid red",getAction(m){if(l.eventUtils.consumeEvent(m),m.type==="pointerdown"){let y=l.eventUtils.deepEventTarget(m);return{details:{name:"click"},element:y}}}}),u=new Pe("multiInspecting",{start:()=>{this.toolbar?.hide();let m=document.getElementsByTagName("body")[0];this.pageSnapshot=this.injectedScript.ariaSnapshot(m),this.lastSnapshot=this.injectedScript._lastAriaSnapshot,this.snapshotElements=new Set,this.interestedElements=new Map,this.collectElementsFromAriaSnapshot(this.lastSnapshot.root,this.snapshotElements),this.elementSet=new Set;for(let{element:y}of this.snapshotElements)this.elementSet.add(y);return()=>{this.toolbar?.show();for(let y of this.interestedElements.keys())y.style.background=y.__originalBackground,delete y.__originalBackground}},getInterestedElement:m=>this.snapshotUtils.isSnapshotAvailable(m,this.elementSet),hoverOutlineStyle:"2px solid red",getAction:m=>{if(this.eventUtils.consumeEvent(m),m.type==="pointerdown"){let y=this.eventUtils.deepEventTarget(m),w=this.injectedScript.ariaSnapshot(y);if(this.snapshotUtils.isSnapshotAvailable(y,this.elementSet)){if(this.interestedElements.has(y)?(this.interestedElements.delete(y),y.style.background=y.__originalBackground,delete y.__originalBackground):(y.__originalBackground=y.style.background,y.style.background="rgba(255, 204, 0, 0.3)",this.interestedElements.set(y,w)),Array.from(this.interestedElements.keys()).length===0)return{details:{name:"click",value:""},element:y};let I=this.injectedScript.utils.parseAriaSnapshot(As,this.pageSnapshot).fragment,B=Array.from(this.interestedElements.values()).map(H=>this.injectedScript.utils.parseAriaSnapshot(As,H).fragment),q=this.snapshotUtils.filterParentToChildren(I,B);return w=this.snapshotUtils.serializeAriaSnapshot(q),{details:{name:"click",value:w},element:y}}}}}),l=this,h=new Pe("recordingText",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show(),this.resetHighlight(this.activeElement)}),getInterestedElement:m=>{if(yu(m))return m},hoverOutlineStyle:"2px solid red",getAction(m){if(l.eventUtils.consumeEvent(m),m.type==="pointerdown"){let y=l.eventUtils.deepEventTarget(m);if(this.getInterestedElement(y))return{details:{name:"click"},element:y}}}}),p=new Pe("recordingHover",{start:()=>(this.toolbar&&(this.toolbar.hoverTool.selected=!0),()=>{this.resetHighlight(this.activeElement),this.toolbar&&(this.toolbar.hoverTool.selected=!1)}),getAction:m=>{if(this.eventUtils.consumeEvent(m),m.type==="click")return{details:{name:"click"},element:this.eventUtils.deepEventTarget(m)}},getInterestedElement:m=>m,hoverOutlineStyle:"2px solid blue"}),b=new Pe("recordingInput",{start:()=>()=>{this.resetHighlight(this.activeElement)},getAction:m=>{switch(m.type){case"pointerdown":{if(m.button===2)return;let y=this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(m)),w=this.eventUtils.asCheckbox(y);return y.nodeName==="INPUT"&&y.type.toLowerCase()==="file"?void 0:w?{details:{name:w.checked?"uncheck":"check"},element:y}:{details:{name:"click",position:this.eventUtils.positionForEvent(m),button:this.eventUtils.buttonForEvent(m),modifiers:this.eventUtils.modifiersForEvent(m),clickCount:m.detail},element:y}}case"input":{let y=this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(m));return y.nodeName==="INPUT"&&y.type.toLowerCase()==="file"?{details:{name:"setInputFiles",files:[...y.files||[]].map(w=>w.name)},element:y}:this.eventUtils.isRangeInput(y)?{details:{name:"fill",text:y.value},element:y}:["INPUT","TEXTAREA"].includes(y.nodeName)||y.isContentEditable?y.nodeName==="INPUT"&&["checkbox","radio"].includes(y.type.toLowerCase())?void 0:{details:{name:"fill",text:y.isContentEditable?y.innerText:y.value},element:y}:y.nodeName==="SELECT"?{details:{name:"select",options:[...y.selectedOptions].map(A=>A.value)},element:y}:void 0}case"keydown":{let y=m.preventDefault.bind(m);if(m.preventDefault=()=>{if(m.key.length>=1&&!m.ctrlKey&&!m.metaKey&&!m.altKey){let w=this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(m));setTimeout(()=>{if(m.__bvt_recorded!==void 0)return;let I=w.value;this.recordEvent({details:{name:"fill",text:I},element:w},w,"input",m),m.__bvt_recorded=!0},20)}y()},!this.eventUtils.shouldGenerateKeyPressFor(m))return;if(m.key===" "){let w=this.eventUtils.asCheckbox(this.eventUtils.deepEventTarget(m));if(w)return{details:{name:w.checked?"uncheck":"check"},element:w}}return{details:{name:"press",key:m.key,modifiers:this.eventUtils.modifiersForEvent(m)},element:this.eventUtils.deepEventTarget(m)}}}},getInterestedElement:m=>{let y=this.eventUtils.getNearestInteractiveElement(m);return y||m},hoverOutlineStyle:"2px solid red"}),v={noop:t,idle:n,running:r,recordingText:h,recordingContext:h,recordingInput:b,recordingHover:p,inspecting:o,multiInspecting:u};this.RecorderStateMap=v}addOverrides(){let t=window.close.bind(window);window.close=async function(){nt.recordPageClose(),t()};let n=this,r=Element.prototype.attachShadow;Element.prototype.attachShadow=function(o){let u=r.call(this,o);return n.addHighlightListeners(u),u}}set mode(t){let n=this.RecorderStateMap[t];n&&(this.cleanup&&this.cleanup(),this.#t=n,this.#t.start&&(this.cleanup=this.#t.start()),this.#e=t)}get mode(){return this.#e}getFrameDetails(){return{url:window.location.href,title:window.document.title,isTop:window.top===window,viewport:{width:window.innerWidth,height:window.innerHeight}}}setHighlight(t){if(t.closest("x-bvt-toolbar"))return;let n=this.#t.getInterestedElement(t);n&&(this.activeElement=n,n[this.#n]===void 0&&(n[this.#n]=n.style.outline,n.style.outline=this.#t.hoverOutlineStyle,n.styleUpdateFn&&n.styleUpdateFn(n)))}resetHighlight(t){if(!t)return;let n=this.#t.getInterestedElement(t);n&&n[this.#n]!==void 0&&(n.style.outline=n[this.#n],n[this.#n]=void 0,n.styleUpdateFn&&n.styleUpdateFn(n))}addHighlightListeners(t){t.addEventListener("mouseover",n=>{if(this.debugMouseOver)debugger;let r=this.eventUtils.deepEventTarget(n);this.setHighlight(r)}),t.addEventListener("mouseout",n=>{if(this.debugMouseOut)debugger;let r=this.eventUtils.deepEventTarget(n);this.resetHighlight(r)}),t.addEventListener("focusin",n=>{if(this.debugFocusIn)debugger;let r=this.eventUtils.deepEventTarget(n);this.setHighlight(r)}),t.addEventListener("focusout",n=>{if(this.debugFocusOut)debugger;let r=this.eventUtils.deepEventTarget(n);this.resetHighlight(r)})}addToolbar(){if(window.top!==window)return;let t=document.createElement("x-bvt-toolbar");t.id="bvt-toolbar",this.toolbar=t,document.body.appendChild(t)}handleStateTransition(t){if(this.#e==="recordingContext"){this.contextElement=t,nt.revertMode();return}this.#e==="recordingHover"&&nt.revertMode(),this.contextElement=null}getElementProperties(t){if(!t||!(t instanceof HTMLElement||t instanceof SVGElement))throw new Error("Please provide a valid HTML element");let n={properties:{},attributes:{},dataset:{}},r={},o={},u={};for(let h in t)try{let p=t[h];typeof p!="function"&&typeof p!="object"&&p!==null&&p!==void 0&&!h.includes("_")&&(r[h]=p)}catch{r[h]="[Error accessing property]"}if(t.attributes)for(let h of t.attributes)h.name!=="data-input-id"&&h.name!=="data-blinq-id"&&(o[h.name]=h.value);if(t.dataset)for(let[h,p]of Object.entries(t.dataset))h!=="inputId"&&h!=="blinqId"&&(u[h]=p);let l=h=>Object.fromEntries(Object.entries(h).sort(([p],[b])=>p.localeCompare(b)));return n.properties=l(r),n.attributes=l(o),n.dataset=l(u),n}getElementDetails(t,n){(va!==t.dataset.inputId||n!=="input")&&(t.dataset.inputId=Ns(),va=t.dataset.inputId);let r=this.PW.roleUtils.getAriaRole(t),o=this.PW.roleUtils.getElementAccessibleName(t,!1)||this.PW.roleUtils.getElementAccessibleName(t,!0)||"",u=this.getElementProperties(t),l=this.PW.selectorUtils.elementText(new Map,t);return{role:r,label:o,inputID:t.dataset.inputId,tagName:t.tagName,type:t.type,text:l.full.trim(),textNormalized:l.normalized.trim(),parent:`tagname: ${t.parentElement?.tagName}
164
- innerText: ${t.parentElement?.innerText}`,attrs:{placeholder:t.getAttribute("placeholder"),src:t.getAttribute("src"),href:t.getAttribute("href"),alt:t.getAttribute("alt"),value:t.value,tagName:t.tagName,text:t.textContent,type:t.type,disabled:t.disabled,readOnly:t.readOnly,required:t.required,checked:t.checked,innerText:t.innerText},attributes:u.attributes,properties:u.properties,dataset:u.dataset}}handleEvent(t){if(!this.toolbar)return!0;let n=this.eventUtils.deepEventTarget(t);switch(t.type){case"pointerdown":{let r=n.closest("x-bvt-tool");if(r?.name==="drag")return this.rect=this.toolbar.getBoundingClientRect(),this.offsetX=t.clientX-this.rect.left,this.offsetY=t.clientY-this.rect.top,this.#r=!0,!1;if(r)return!1;break}case"pointerup":{if(this.#r)return this.#r=!1,!1;break}case"mousemove":{if(this.#r){let r=t.clientX-this.offsetX,o=t.clientY-this.offsetY;return r<0||o<0||r+this.rect.width>window.innerWidth||o+this.rect.height>window.innerHeight?void 0:(this.toolbar.style.left=`${r}px`,!1)}break}case"click":{let r=n.closest("x-bvt-tool");if(r?.name==="hover")return r.selected?nt.revertMode():nt.setMode("recordingHover"),!1;break}}return!0}isPopupCloseEvent(t){let n=t.type,r=n==="pointerdown",o=n==="keydown"&&t.key==="Enter";if(!r&&!o)return!1;let u=this.eventUtils.deepEventTarget(t);return this.popupHandlers.some(l=>{let h=l.locator.css,p=l.close_dialog_locator.css,b=document.querySelector(h);if(!b)return!1;let v=window.getComputedStyle(b);return v.display==="none"||v.visibility==="hidden"?!1:u.matches(p)})}getLocatorsObject(t,n={}){if(this.contextElement)return this.locatorGenerator.toContextLocators(t,this.contextElement,n);let r=this.#e==="recordingText";return this.locatorGenerator.getElementLocators(t,{excludeText:r,...n})}addListeners(){["input","keydown","click","pointerdown","pointerup","mousemove"].forEach(n=>{window.addEventListener(n,async r=>{if(this.debugListener)debugger;if(performance.mark("command-received"),!this.handleEvent(r))return;let u=this.#t.getAction(r);if(!u)return;let l=u.element,h=document.querySelector("[data-blinq-id]");h&&h.removeAttribute("data-blinq-id"),l.setAttribute("data-blinq-id",Ns());let p=document.querySelector("[data-blinq-context-id]");p&&p.removeAttribute("data-blinq-context-id"),this.contextElement&&this.contextElement.setAttribute("data-blinq-context-id",Ns()),performance.mark("command-send"),this.recordEvent(u,l,n,r),this.handleStateTransition(u.element)},{capture:!0})})}recordEvent(t,n,r,o){let u={mode:this.#e,action:t.details,element:this.getElementDetails(n,r),isPopupCloseClick:this.isPopupCloseEvent(o),frame:this.getFrameDetails(),statistics:{time:`${performance.measure("command-received","command-send").duration.toFixed(2)} ms`}},l={id:n.getAttribute("data-blinq-id"),contextId:this.contextElement?.getAttribute("data-blinq-context-id"),doc:this.snapshotCapturer.createSnapshot({excludeSelectors:["x-bvt-toolbar","script","style","link[rel=stylesheet]"]})};u.snapshotDetails=l,nt.recordCommand(u)}setPopupHandlers(t){this.popupHandlers=t}setDisableHighlight(t){this.disableHighlight=t}setImproviseLocators(t){this.improviseLocators=t}deselectAriaElements(){for(let t of this.interestedElements.keys())t.style.background=t.__originalBackground,delete t.__originalBackground;this.interestedElements.clear()}processAriaSnapshot(t){let n=this.snapshotUtils.findMatchingElements(t,this.snapshotElements);for(let r of n.values()){let o=r;o&&(o.__originalOutline=o.style.outline,o.style.outline="2px solid blue",setTimeout(()=>{o.style.outline=o.__originalOutline,delete o.__originalOutline},2e3))}}setTestAttributes(t){this.locatorGenerator.options.customAttributes=t}};window.__bvt_Recorder=new Cs(window.__bvt_Recorder_config);var Is=class extends HTMLElement{#t=!1;tooltipText=null;#e=null;#n=!1;constructor(t,n){super()}connectedCallback(){this.#n||(this.init(),this.addEventListener("mouseenter",this.showTooltip),this.addEventListener("mouseleave",this.hideTooltip),this.#n=!0)}init(){this.setAttribute("role","button"),this.style.cssText=`
163
+ `,i)+1}return{type:s,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(s){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=gt(On(s));return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=gt(On(s));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(s,i){return this.type==="comment"&&!(this.indent<=i)&&s.every(c=>c.type==="newline"||c.type==="space")}*documentEnd(s){this.type!=="doc-mode"&&(s.end?s.end.push(this.sourceToken):s.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(s){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:s.end?s.end.push(this.sourceToken):s.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Ti(a){let s=a.prettyErrors!==!1;return{lineCounter:a.lineCounter||s&&new wi||null,prettyErrors:s}}function ki(a,s={}){let{lineCounter:i,prettyErrors:c}=Ti(s),f=new kr(i?.addNewLine),d=new Er(s),g=null;for(let S of d.compose(f.parse(a),!0,a.length))if(g){if(g.options.logLevel!=="silent"){g.errors.push(new Xe(S.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else g=S;return c&&i&&(g.errors.forEach(kn(a,i)),g.warnings.forEach(kn(a,i))),g}return e.Alias=U,e.CST=Ba,e.Composer=Er,e.Document=ft,e.Lexer=vi,e.LineCounter=wi,e.Pair=ve,e.Parser=kr,e.Scalar=G,e.Schema=Tn,e.YAMLError=gr,e.YAMLMap=_e,e.YAMLParseError=Xe,e.YAMLSeq=We,e.YAMLWarning=ii,e.isAlias=p,e.isCollection=A,e.isDocument=b,e.isMap=v,e.isNode=I,e.isPair=m,e.isScalar=y,e.isSeq=w,e.parse=function(a,s,i){let c;typeof s=="function"?c=s:i===void 0&&s&&typeof s=="object"&&(i=s);let f=ki(a,i);if(!f)return null;if(f.warnings.forEach(d=>Rs(f.options.logLevel,d)),f.errors.length>0){if(f.options.logLevel!=="silent")throw f.errors[0];f.errors=[]}return f.toJS(Object.assign({reviver:c},i))},e.parseAllDocuments=function(a,s={}){let{lineCounter:i,prettyErrors:c}=Ti(s),f=new kr(i?.addNewLine),d=new Er(s),g=Array.from(d.compose(f.parse(a)));if(c&&i)for(let S of g)S.errors.forEach(kn(a,i)),S.warnings.forEach(kn(a,i));return g.length>0?g:Object.assign([],{empty:!0},d.streamInfo())},e.parseDocument=ki,e.stringify=function(a,s,i){let c=null;if(typeof s=="function"||Array.isArray(s)?c=s:i===void 0&&s&&(i=s),typeof i=="string"&&(i=i.length),typeof i=="number"){let f=Math.round(i);i=f<1?void 0:f>8?{indent:8}:{indent:f}}if(a===void 0){let{keepUndefined:f}=i??s??{};if(!f)return}return b(a)&&!c?a.toString(i):new ft(a,c,i).toString(i)},e.visit=ee,e.visitAsync=Z,e}({}),As=du;var pu=Me.domUtils.closestCrossShadow,gu=Me.domUtils.isElementVisible,cn=class{deepEventTarget(t){return t.composedPath()[0]}deepActiveElement(t){let n=t.activeElement;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n}modifiersForEvent(t){return(t.altKey?1:0)|(t.ctrlKey?2:0)|(t.metaKey?4:0)|(t.shiftKey?8:0)}buttonForEvent(t){switch(t.which){case 1:return"left";case 2:return"middle";case 3:return"right"}return"left"}positionForEvent(t){if(t.target.nodeName==="CANVAS")return{x:t.offsetX,y:t.offsetY}}consumeEvent(t){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}asCheckbox(t){if(!t||t.nodeName!=="INPUT")return null;let n=t;return["checkbox","radio"].includes(n.type)?n:null}isRangeInput(t){return!t||t.nodeName!=="INPUT"?!1:t.type.toLowerCase()==="range"}addEventListener(t,n,r,o){return t.addEventListener(n,r,o),()=>{t.removeEventListener(n,r,o)}}removeEventListeners(t){for(let n of t)n();t.splice(0,t.length)}getNearestInteractiveElement(t,n=window.document){try{if(!t.matches("input,textarea,select")&&!t.isContentEditable){let r=pu(t,"button,select,input,[role=button],[role=checkbox],[role=radio],a,[role=link]",n);if(r&&gu(r))return r}return t}catch(r){return console.error(r),t}}shouldGenerateKeyPressFor(t){if(t.key==="Enter"&&(this.deepEventTarget(t).nodeName==="TEXTAREA"||this.deepEventTarget(t).isContentEditable)||["Backspace","Delete","AltGraph"].includes(t.key)||t.key==="@"&&t.code==="KeyL")return!1;if(navigator.platform.includes("Mac")){if(t.key==="v"&&t.metaKey)return!1}else if(t.key==="v"&&t.ctrlKey||t.key==="Insert"&&t.shiftKey)return!1;if(["Shift","Control","Meta","Alt","Process"].includes(t.key))return!1;let n=t.ctrlKey||t.altKey||t.metaKey;return t.key.length===1&&!n?!!this.asCheckbox(this.deepEventTarget(t)):!0}};var mu=Math.random().toString(36).substring(7),ba=0,Ns=()=>(ba++,`bvt_input_${ba}_${mu}`),yu=e=>{if(e instanceof HTMLInputElement&&(e.type==="button"||e.type==="submit"))return e.value?.length>0;if(e.innerText?.length>0){if(e.childNodes.length===0)return!0;for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];if(r.nodeType===Node.TEXT_NODE&&r.nodeValue.trim().length>0)return!0}}},nt={recordCommand:e=>__bvt_recordCommand(e),setMode:e=>__bvt_setMode(e),revertMode:()=>__bvt_revertMode(),recordPageClose:()=>__bvt_recordPageClose(),getMode:()=>__bvt_getMode(),log:e=>__bvt_log(e),sendObject:e=>__bvt_getObject(e)},va=null,Pe=class{constructor(t,n){this.name=t,this.getAction=n.getAction,this.getInterestedElement=n.getInterestedElement,this.hoverOutlineStyle=n.hoverOutlineStyle,this.start=n.start}},Cs=class{#t=null;#e="noop";contextElement=null;debugListener=!1;debugMouseOut=!1;debugMouseOver=!1;debugFocusOut=!1;debugFocusIn=!1;#n=Symbol("outline");#r=!1;toolbar=null;activeElement=null;cleanup=null;rect=null;offsetX=null;offsetY=null;popupHandlers=[];disableHighlight=!1;improviseLocators=!0;snapshotCapturer=new ma({excludeSelectors:["script","x-bvt-toolbar"]});injectedScript=pa();locatorGenerator=new ga(this.injectedScript);PW=Me;snapshotUtils=new ya;eventUtils=new cn;constructor(t={}){let{disableHighlight:n=!1,improviseLocators:r=!0,popupHandlers:o=[],testAttributes:u=[]}=t;this.disableHighlight=n,this.improviseLocators=r,this.popupHandlers=o,this.locatorGenerator.options.customAttributes=u,this.init()}init({mode:t="noop"}={}){this.addRecorderStates(),this.mode=t,this.addOverrides(),this.addListeners(),this.addHighlightListeners(window),window.addEventListener("DOMContentLoaded",async()=>{this.addToolbar(),this.mode=await nt.getMode()})}collectElementsFromAriaSnapshot(t,n){if(!(t.element&&t.element.tagName==="X-BVT-TOOL")){t.element&&n.add({element:t.element,snapshot:this.injectedScript.ariaSnapshot(t.element)});for(let r of t.children)typeof r!="string"&&this.collectElementsFromAriaSnapshot(r,n)}}addRecorderStates(){let t=new Pe("noop",{getAction:m=>{this.eventUtils.consumeEvent(m)},getInterestedElement:()=>{},hoverOutlineStyle:""}),n=new Pe("idle",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show()}),getAction:()=>null,getInterestedElement:()=>{},hoverOutlineStyle:""}),r=new Pe("running",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show()}),getAction:()=>null,getInterestedElement:()=>{},hoverOutlineStyle:""}),o=new Pe("inspecting",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show(),this.resetHighlight(this.activeElement)}),getInterestedElement:m=>m,hoverOutlineStyle:"2px solid red",getAction(m){if(l.eventUtils.consumeEvent(m),m.type==="pointerdown"){let y=l.eventUtils.deepEventTarget(m);return{details:{name:"click"},element:y}}}}),u=new Pe("multiInspecting",{start:()=>{this.toolbar?.hide();let m=document.getElementsByTagName("body")[0];this.pageSnapshot=this.injectedScript.ariaSnapshot(m),this.lastSnapshot=this.injectedScript._lastAriaSnapshot,this.snapshotElements=new Set,this.interestedElements=new Map,this.collectElementsFromAriaSnapshot(this.lastSnapshot.root,this.snapshotElements),this.elementSet=new Set;for(let{element:y}of this.snapshotElements)this.elementSet.add(y);return()=>{this.toolbar?.show();for(let y of this.interestedElements.keys())y.style.background=y.__originalBackground,delete y.__originalBackground}},getInterestedElement:m=>this.snapshotUtils.isSnapshotAvailable(m,this.elementSet),hoverOutlineStyle:"2px solid red",getAction:m=>{if(this.eventUtils.consumeEvent(m),m.type==="pointerdown"){let y=this.eventUtils.deepEventTarget(m),w=this.injectedScript.ariaSnapshot(y);if(this.snapshotUtils.isSnapshotAvailable(y,this.elementSet)){if(this.interestedElements.has(y)?(this.interestedElements.delete(y),y.style.background=y.__originalBackground,delete y.__originalBackground):(y.__originalBackground=y.style.background,y.style.background="rgba(255, 204, 0, 0.3)",this.interestedElements.set(y,w)),Array.from(this.interestedElements.keys()).length===0)return{details:{name:"click",value:""},element:y};let I=this.injectedScript.utils.parseAriaSnapshot(As,this.pageSnapshot).fragment,B=Array.from(this.interestedElements.values()).map(H=>this.injectedScript.utils.parseAriaSnapshot(As,H).fragment),q=this.snapshotUtils.filterParentToChildren(I,B);return w=this.snapshotUtils.serializeAriaSnapshot(q),{details:{name:"click",value:w},element:y}}}}}),l=this,h=new Pe("recordingText",{start:()=>(this.toolbar?.hide(),()=>{this.toolbar?.show(),this.resetHighlight(this.activeElement)}),getInterestedElement:m=>{if(yu(m))return m},hoverOutlineStyle:"2px solid red",getAction(m){if(l.eventUtils.consumeEvent(m),m.type==="pointerdown"){let y=l.eventUtils.deepEventTarget(m);if(this.getInterestedElement(y))return{details:{name:"click"},element:y}}}}),p=new Pe("recordingHover",{start:()=>(this.toolbar&&(this.toolbar.hoverTool.selected=!0),()=>{this.resetHighlight(this.activeElement),this.toolbar&&(this.toolbar.hoverTool.selected=!1)}),getAction:m=>{if(this.eventUtils.consumeEvent(m),m.type==="click")return{details:{name:"click"},element:this.eventUtils.deepEventTarget(m)}},getInterestedElement:m=>m,hoverOutlineStyle:"2px solid blue"}),b=new Pe("recordingInput",{start:()=>()=>{this.resetHighlight(this.activeElement)},getAction:m=>{switch(m.type){case"pointerdown":{if(m.button===2)return;let y=this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(m)),w=this.eventUtils.asCheckbox(y);return y.nodeName==="INPUT"&&y.type.toLowerCase()==="file"?void 0:w?{details:{name:w.checked?"uncheck":"check"},element:y}:{details:{name:"click",position:this.eventUtils.positionForEvent(m),button:this.eventUtils.buttonForEvent(m),modifiers:this.eventUtils.modifiersForEvent(m),clickCount:m.detail},element:y}}case"input":{let y=this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(m));return y.nodeName==="INPUT"&&y.type.toLowerCase()==="file"?{details:{name:"setInputFiles",files:[...y.files||[]].map(w=>w.name)},element:y}:this.eventUtils.isRangeInput(y)?{details:{name:"fill",text:y.value},element:y}:["INPUT","TEXTAREA"].includes(y.nodeName)||y.isContentEditable?y.nodeName==="INPUT"&&["checkbox","radio"].includes(y.type.toLowerCase())?void 0:{details:{name:"fill",text:y.isContentEditable?y.innerText:y.value},element:y}:y.nodeName==="SELECT"?{details:{name:"select",options:[...y.selectedOptions].map(A=>A.value)},element:y}:void 0}case"keydown":{let y=m.preventDefault.bind(m);if(m.preventDefault=()=>{if(m.key.length>=1&&!m.ctrlKey&&!m.metaKey&&!m.altKey){let w=this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(m));setTimeout(()=>{if(m.__bvt_recorded!==void 0)return;let I=w.value;this.recordEvent({details:{name:"fill",text:I},element:w},w,"input",m),m.__bvt_recorded=!0},20)}y()},!this.eventUtils.shouldGenerateKeyPressFor(m))return;if(m.key===" "){let w=this.eventUtils.asCheckbox(this.eventUtils.deepEventTarget(m));if(w)return{details:{name:w.checked?"uncheck":"check"},element:w}}return{details:{name:"press",key:m.key,modifiers:this.eventUtils.modifiersForEvent(m)},element:this.eventUtils.deepEventTarget(m)}}}},getInterestedElement:m=>{let y=this.eventUtils.getNearestInteractiveElement(m);return y||m},hoverOutlineStyle:"2px solid red"}),v={noop:t,idle:n,running:r,recordingText:h,recordingContext:h,recordingInput:b,recordingHover:p,inspecting:o,multiInspecting:u};this.RecorderStateMap=v}addOverrides(){let t=window.close.bind(window);window.close=async function(){nt.recordPageClose(),t()};let n=this,r=Element.prototype.attachShadow;Element.prototype.attachShadow=function(o){let u=r.call(this,o);return n.addHighlightListeners(u),u}}set mode(t){let n=this.RecorderStateMap[t];n&&(this.cleanup&&this.cleanup(),this.#t=n,this.#t.start&&(this.cleanup=this.#t.start()),this.#e=t)}get mode(){return this.#e}getFrameDetails(){return{url:window.location.href,title:window.document.title,isTop:window.top===window,viewport:{width:window.innerWidth,height:window.innerHeight}}}setHighlight(t){if(t.closest("x-bvt-toolbar"))return;let n=this.#t.getInterestedElement(t);n&&(this.activeElement=n,n[this.#n]===void 0&&(n[this.#n]=n.style.outline,n.style.outline=this.#t.hoverOutlineStyle,n.styleUpdateFn&&n.styleUpdateFn(n)))}resetHighlight(t){if(!t)return;let n=this.#t.getInterestedElement(t);n&&n[this.#n]!==void 0&&(n.style.outline=n[this.#n],n[this.#n]=void 0,n.styleUpdateFn&&n.styleUpdateFn(n))}addHighlightListeners(t){t.addEventListener("mouseover",n=>{if(this.debugMouseOver)debugger;let r=this.eventUtils.deepEventTarget(n);this.setHighlight(r)}),t.addEventListener("mouseout",n=>{if(this.debugMouseOut)debugger;let r=this.eventUtils.deepEventTarget(n);this.resetHighlight(r)}),t.addEventListener("focusin",n=>{if(this.debugFocusIn)debugger;let r=this.eventUtils.deepEventTarget(n);this.setHighlight(r)}),t.addEventListener("focusout",n=>{if(this.debugFocusOut)debugger;let r=this.eventUtils.deepEventTarget(n);this.resetHighlight(r)})}addToolbar(){if(window.top!==window)return;let t=document.createElement("x-bvt-toolbar");t.id="bvt-toolbar",this.toolbar=t,document.body.appendChild(t)}handleStateTransition(t){if(this.#e==="recordingContext"){this.contextElement=t,nt.revertMode();return}this.#e==="recordingHover"&&nt.revertMode(),this.contextElement=null}getElementProperties(t){if(!t||!(t instanceof HTMLElement||t instanceof SVGElement))throw new Error("Please provide a valid HTML element");let n={properties:{},attributes:{},dataset:{}},r={},o={},u={};for(let h in t)try{let p=t[h];typeof p!="function"&&typeof p!="object"&&p!==null&&p!==void 0&&!h.includes("_")&&(r[h]=p)}catch{r[h]="[Error accessing property]"}if(t.attributes)for(let h of t.attributes)h.name!=="data-input-id"&&h.name!=="data-blinq-id"&&(o[h.name]=h.value);if(t.dataset)for(let[h,p]of Object.entries(t.dataset))h!=="inputId"&&h!=="blinqId"&&(u[h]=p);let l=h=>Object.fromEntries(Object.entries(h).sort(([p],[b])=>p.localeCompare(b)));return n.properties=l(r),n.attributes=l(o),n.dataset=l(u),n}getElementDetails(t,n){(va!==t.dataset.inputId||n!=="input")&&(t.dataset.inputId=Ns(),va=t.dataset.inputId,t.__locators=this.getLocatorsObject(t,{maxLocators:1}));let r=this.PW.roleUtils.getAriaRole(t),o=this.PW.roleUtils.getElementAccessibleName(t,!1)||this.PW.roleUtils.getElementAccessibleName(t,!0)||"",u=this.getElementProperties(t),l=this.PW.selectorUtils.elementText(new Map,t);return{role:r,label:o,inputID:t.dataset.inputId,tagName:t.tagName,type:t.type,text:l.full.trim(),textNormalized:l.normalized.trim(),parent:`tagname: ${t.parentElement?.tagName}
164
+ innerText: ${t.parentElement?.innerText}`,attrs:{placeholder:t.getAttribute("placeholder"),src:t.getAttribute("src"),href:t.getAttribute("href"),alt:t.getAttribute("alt"),value:t.value,tagName:t.tagName,text:t.textContent,type:t.type,disabled:t.disabled,readOnly:t.readOnly,required:t.required,checked:t.checked,innerText:t.innerText},attributes:u.attributes,properties:u.properties,dataset:u.dataset}}handleEvent(t){if(!this.toolbar)return!0;let n=this.eventUtils.deepEventTarget(t);switch(t.type){case"pointerdown":{let r=n.closest("x-bvt-tool");if(r?.name==="drag")return this.rect=this.toolbar.getBoundingClientRect(),this.offsetX=t.clientX-this.rect.left,this.offsetY=t.clientY-this.rect.top,this.#r=!0,!1;if(r)return!1;break}case"pointerup":{if(this.#r)return this.#r=!1,!1;break}case"mousemove":{if(this.#r){let r=t.clientX-this.offsetX,o=t.clientY-this.offsetY;return r<0||o<0||r+this.rect.width>window.innerWidth||o+this.rect.height>window.innerHeight?void 0:(this.toolbar.style.left=`${r}px`,!1)}break}case"click":{let r=n.closest("x-bvt-tool");if(r?.name==="hover")return r.selected?nt.revertMode():nt.setMode("recordingHover"),!1;break}}return!0}isPopupCloseEvent(t){let n=t.type,r=n==="pointerdown",o=n==="keydown"&&t.key==="Enter";if(!r&&!o)return!1;let u=this.eventUtils.deepEventTarget(t);return this.popupHandlers.some(l=>{let h=l.locator.css,p=l.close_dialog_locator.css,b=document.querySelector(h);if(!b)return!1;let v=window.getComputedStyle(b);return v.display==="none"||v.visibility==="hidden"?!1:u.matches(p)})}docHasShadowDOM(){for(let t of document.all)if(t.tagName.includes("-")){if(["x-bvt-toolbar","x-bvt-tool"].includes(t.tagName.toLowerCase()))continue;if(t.shadowRoot)return!0}return!1}getLocatorsObject(t,n={}){if(!this.docHasShadowDOM()){console.log("No custom elements detected, skipping locator generation");return}if(console.log("Custom elements detected locator generation"),this.contextElement)return this.locatorGenerator.toContextLocators(t,this.contextElement,n);let r=this.#e==="recordingText";return this.locatorGenerator.getElementLocators(t,{excludeText:r,...n})}addListeners(){["input","keydown","click","pointerdown","pointerup","mousemove"].forEach(n=>{window.addEventListener(n,async r=>{if(this.debugListener)debugger;if(performance.mark("command-received"),!this.handleEvent(r))return;let u=this.#t.getAction(r);if(!u)return;let l=u.element,h=document.querySelector("[data-blinq-id]");h&&h.removeAttribute("data-blinq-id"),l.setAttribute("data-blinq-id",Ns());let p=document.querySelector("[data-blinq-context-id]");p&&p.removeAttribute("data-blinq-context-id"),this.contextElement&&this.contextElement.setAttribute("data-blinq-context-id",Ns()),performance.mark("command-send"),this.recordEvent(u,l,n,r),this.handleStateTransition(u.element)},{capture:!0})})}recordEvent(t,n,r,o){let u={mode:this.#e,action:t.details,element:this.getElementDetails(n,r),isPopupCloseClick:this.isPopupCloseEvent(o),...n.__locators??this.getLocatorsObject(n,{maxLocators:1}),frame:this.getFrameDetails(),statistics:{time:`${performance.measure("command-received","command-send").duration.toFixed(2)} ms`}},l={id:n.getAttribute("data-blinq-id"),contextId:this.contextElement?.getAttribute("data-blinq-context-id"),doc:this.snapshotCapturer.createSnapshot({excludeSelectors:["x-bvt-toolbar","script","style","link[rel=stylesheet]"]})};u.snapshotDetails=l,nt.recordCommand(u)}setPopupHandlers(t){this.popupHandlers=t}setDisableHighlight(t){this.disableHighlight=t}setImproviseLocators(t){this.improviseLocators=t}deselectAriaElements(){for(let t of this.interestedElements.keys())t.style.background=t.__originalBackground,delete t.__originalBackground;this.interestedElements.clear()}processAriaSnapshot(t){let n=this.snapshotUtils.findMatchingElements(t,this.snapshotElements);for(let r of n.values()){let o=r;o&&(o.__originalOutline=o.style.outline,o.style.outline="2px solid blue",setTimeout(()=>{o.style.outline=o.__originalOutline,delete o.__originalOutline},2e3))}}setTestAttributes(t){this.locatorGenerator.options.customAttributes=t}};window.__bvt_Recorder=new Cs(window.__bvt_Recorder_config);var Is=class extends HTMLElement{#t=!1;tooltipText=null;#e=null;#n=!1;constructor(t,n){super()}connectedCallback(){this.#n||(this.init(),this.addEventListener("mouseenter",this.showTooltip),this.addEventListener("mouseleave",this.hideTooltip),this.#n=!0)}init(){this.setAttribute("role","button"),this.style.cssText=`
165
165
  display: inline-flex;
166
166
  align-items: center;
167
167
  justify-content: center;
@@ -144,7 +144,7 @@ class BVTRecorder {
144
144
  getAction: (e) => {
145
145
  this.eventUtils.consumeEvent(e);
146
146
  },
147
- getInterestedElement: () => {},
147
+ getInterestedElement: () => { },
148
148
  hoverOutlineStyle: "",
149
149
  });
150
150
 
@@ -159,7 +159,7 @@ class BVTRecorder {
159
159
  };
160
160
  },
161
161
  getAction: () => null,
162
- getInterestedElement: () => {},
162
+ getInterestedElement: () => { },
163
163
  hoverOutlineStyle: "",
164
164
  });
165
165
 
@@ -174,7 +174,7 @@ class BVTRecorder {
174
174
  };
175
175
  },
176
176
  getAction: () => null,
177
- getInterestedElement: () => {},
177
+ getInterestedElement: () => { },
178
178
  hoverOutlineStyle: "",
179
179
  });
180
180
 
@@ -707,7 +707,8 @@ class BVTRecorder {
707
707
 
708
708
  lastInputId = el.dataset.inputId;
709
709
 
710
- // el.__locators = this.getLocatorsObject(el, { maxLocators: 1 });
710
+ el.__locators = this.getLocatorsObject(el, { maxLocators: 1 });
711
+
711
712
  }
712
713
  const role = this.PW.roleUtils.getAriaRole(el);
713
714
  const label =
@@ -820,8 +821,23 @@ class BVTRecorder {
820
821
  return el.matches(closeBtnSelector);
821
822
  });
822
823
  }
823
-
824
+ docHasShadowDOM() {
825
+ for (const el of document.all) {
826
+ if (el.tagName.includes("-")) {
827
+ if (["x-bvt-toolbar", "x-bvt-tool"].includes(el.tagName.toLowerCase())) continue;
828
+ if (el.shadowRoot) {
829
+ return true;
830
+ }
831
+ }
832
+ }
833
+ return false;
834
+ }
824
835
  getLocatorsObject(el, options = {}) {
836
+ if (!this.docHasShadowDOM()) {
837
+ console.log("No custom elements detected, skipping locator generation");
838
+ return;
839
+ }
840
+ console.log("Custom elements detected locator generation");
825
841
  if (this.contextElement) {
826
842
  const result = this.locatorGenerator.toContextLocators(el, this.contextElement, options);
827
843
  return result;
@@ -880,7 +896,7 @@ class BVTRecorder {
880
896
  action: action.details,
881
897
  element: this.getElementDetails(actionElement, eventName),
882
898
  isPopupCloseClick: this.isPopupCloseEvent(e),
883
- // ...(actionElement.__locators ?? this.getLocatorsObject(actionElement, { maxLocators: 1 })),
899
+ ...(actionElement.__locators ?? this.getLocatorsObject(actionElement, { maxLocators: 1 })),
884
900
  frame: this.getFrameDetails(),
885
901
  statistics: {
886
902
  time: `${performance.measure("command-received", "command-send").duration.toFixed(2)} ms`,
@@ -517,7 +517,7 @@ export class BVTRecorder {
517
517
  this.workspaceService = new PublishService(this.TOKEN);
518
518
  this.pageSet = new Set();
519
519
  this.lastKnownUrlPath = "";
520
- this.world = { attach: () => {} };
520
+ this.world = { attach: () => { } };
521
521
  this.shouldTakeScreenshot = true;
522
522
  this.watcher = null;
523
523
  this.networkEventsFolder = path.join(tmpdir(), "blinq_network_events");
@@ -660,7 +660,7 @@ export class BVTRecorder {
660
660
  }
661
661
 
662
662
  // this.stepRunner.setRemoteDebugPort(this.#remoteDebuggerPort);
663
- this.world = { attach: () => {} };
663
+ this.world = { attach: () => { } };
664
664
 
665
665
  const ai_config_file = path.join(this.projectDir, "ai_config.json");
666
666
  let ai_config = {};
@@ -1137,9 +1137,24 @@ export class BVTRecorder {
1137
1137
  if (this.shouldTakeScreenshot) {
1138
1138
  await this.storeScreenshot(event);
1139
1139
  }
1140
- this.sendEvent(this.events.onNewCommand, cmdEvent);
1141
- this._updateUrlPath();
1142
- await this.generateLocators(event);
1140
+ // this.sendEvent(this.events.onNewCommand, cmdEvent);
1141
+ // this._updateUrlPath();
1142
+ if (event.locators) {
1143
+ Object.assign(cmdEvent, {
1144
+ locators: {
1145
+ locators: event.locators,
1146
+ iframe_src: !event.frame.isTop ? event.frame.url : undefined,
1147
+ nestFrmLoc: event.nestFrmLoc?.children,
1148
+ },
1149
+ allStrategyLocators: event.allStrategyLocators,
1150
+ })
1151
+ this.sendEvent(this.events.onNewCommand, cmdEvent);
1152
+ this._updateUrlPath();
1153
+ } else {
1154
+ this.sendEvent(this.events.onNewCommand, cmdEvent);
1155
+ this._updateUrlPath();
1156
+ await this.generateLocators(event);
1157
+ }
1143
1158
  }
1144
1159
  _updateUrlPath() {
1145
1160
  try {
@@ -1155,7 +1170,7 @@ export class BVTRecorder {
1155
1170
  }
1156
1171
  async closeBrowser() {
1157
1172
  delete process.env.TEMP_RUN;
1158
- await this.watcher.close().then(() => {});
1173
+ await this.watcher.close().then(() => { });
1159
1174
  this.watcher = null;
1160
1175
  this.previousIndex = null;
1161
1176
  this.previousHistoryLength = null;
@@ -2217,7 +2232,7 @@ export class BVTRecorder {
2217
2232
  await page
2218
2233
  .context()
2219
2234
  .grantPermissions(["clipboard-read", "clipboard-write"])
2220
- .catch(() => {});
2235
+ .catch(() => { });
2221
2236
  await page.evaluate(async (clipboardPayload) => {
2222
2237
  console.log("Injecting clipboard payload", clipboardPayload);
2223
2238
  const toArrayBuffer = (base64) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1707-dev",
3
+ "version": "1.0.1708-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",