turbowrap-issue-widget 1.0.2 → 1.0.3

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.
@@ -1,4 +1,4 @@
1
- var IssueWidget=function(aA){"use strict";var zc=Object.defineProperty;var jc=(aA,oA,CA)=>oA in aA?zc(aA,oA,{enumerable:!0,configurable:!0,writable:!0,value:CA}):aA[oA]=CA;var fA=(aA,oA,CA)=>jc(aA,typeof oA!="symbol"?oA+"":oA,CA);class oA{constructor(A){fA(this,"baseUrl");fA(this,"apiKey");fA(this,"teamId");this.baseUrl=A.apiUrl.replace(/\/$/,""),this.apiKey=A.apiKey,this.teamId=A.teamId}async analyzeIssue(A,t,r,s){const n=new FormData;n.append("title",A.title),n.append("description",A.description),A.screenshots.forEach((i,B)=>{n.append("screenshots",i,`screenshot-${B}-${Date.now()}.png`)}),A.figmaLink&&n.append("figma_link",A.figmaLink),A.websiteLink&&n.append("website_link",A.websiteLink),A.selectedElement&&n.append("selected_element",JSON.stringify(A.selectedElement));try{const i=await fetch(`${this.baseUrl}/linear/create/analyze`,{method:"POST",headers:{"X-Widget-Key":this.apiKey},body:n});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);await this.parseSSEStream(i,t,B=>{B.questions&&B.gemini_insights!==void 0&&r({questions:B.questions,geminiInsights:B.gemini_insights,tempSessionId:B.temp_session_id})},s)}catch(i){s(i instanceof Error?i.message:"Unknown error")}}async finalizeIssue(A,t,r,s){try{const n=await fetch(`${this.baseUrl}/linear/create/finalize`,{method:"POST",headers:{"Content-Type":"application/json","X-Widget-Key":this.apiKey},body:JSON.stringify({title:A.title,description:A.description,user_answers:A.userAnswers,gemini_insights:A.geminiInsights,team_id:A.teamId||this.teamId,figma_link:A.figmaLink,website_link:A.websiteLink,selected_element:A.selectedElement})});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);await this.parseSSEStream(n,t,i=>{i.identifier&&i.url&&i.id&&r({id:i.id,identifier:i.identifier,url:i.url})},s)}catch(n){s(n instanceof Error?n.message:"Unknown error")}}async parseSSEStream(A,t,r,s){var a;const n=(a=A.body)==null?void 0:a.getReader();if(!n){s("Response body is not readable");return}const i=new TextDecoder;let B="";try{for(;;){const{done:o,value:c}=await n.read();if(o)break;B+=i.decode(c,{stream:!0});const w=B.split(`
1
+ var IssueWidget=function(aA){"use strict";var zc=Object.defineProperty;var jc=(aA,oA,CA)=>oA in aA?zc(aA,oA,{enumerable:!0,configurable:!0,writable:!0,value:CA}):aA[oA]=CA;var fA=(aA,oA,CA)=>jc(aA,typeof oA!="symbol"?oA+"":oA,CA);class oA{constructor(A){fA(this,"baseUrl");fA(this,"apiKey");fA(this,"teamId");this.baseUrl=A.apiUrl.replace(/\/$/,""),this.apiKey=A.apiKey,this.teamId=A.teamId}async analyzeIssue(A,t,r,s){const n=new FormData;n.append("title",A.title),n.append("description",A.description),A.screenshots.forEach((i,B)=>{n.append("screenshots",i,`screenshot-${B}-${Date.now()}.png`)}),A.figmaLink&&n.append("figma_link",A.figmaLink),A.websiteLink&&n.append("website_link",A.websiteLink),A.selectedElement&&n.append("selected_element",JSON.stringify(A.selectedElement));try{const i=await fetch(`${this.baseUrl}/api/linear/create/analyze`,{method:"POST",headers:{"X-Widget-Key":this.apiKey},body:n});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);await this.parseSSEStream(i,t,B=>{B.questions&&B.gemini_insights!==void 0&&r({questions:B.questions,geminiInsights:B.gemini_insights,tempSessionId:B.temp_session_id})},s)}catch(i){s(i instanceof Error?i.message:"Unknown error")}}async finalizeIssue(A,t,r,s){try{const n=await fetch(`${this.baseUrl}/api/linear/create/finalize`,{method:"POST",headers:{"Content-Type":"application/json","X-Widget-Key":this.apiKey},body:JSON.stringify({title:A.title,description:A.description,user_answers:A.userAnswers,gemini_insights:A.geminiInsights,team_id:A.teamId||this.teamId,figma_link:A.figmaLink,website_link:A.websiteLink,selected_element:A.selectedElement})});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);await this.parseSSEStream(n,t,i=>{i.identifier&&i.url&&i.id&&r({id:i.id,identifier:i.identifier,url:i.url})},s)}catch(n){s(n instanceof Error?n.message:"Unknown error")}}async parseSSEStream(A,t,r,s){var a;const n=(a=A.body)==null?void 0:a.getReader();if(!n){s("Response body is not readable");return}const i=new TextDecoder;let B="";try{for(;;){const{done:o,value:c}=await n.read();if(o)break;B+=i.decode(c,{stream:!0});const w=B.split(`
2
2
  `);B=w.pop()||"";let l="";for(const u of w)if(u.startsWith("event: "))l=u.slice(7).trim();else if(u.startsWith("data: ")){const g=u.slice(6);try{const Q=JSON.parse(g);if(l==="error"||Q.error){s(String(Q.error||Q.message||"Unknown error"));return}Q.message&&(l==="progress"||l==="log")&&t(String(Q.message)),(l==="complete"||Q.questions||Q.identifier)&&r(Q)}catch{}}}}finally{n.releaseLock()}}}/*!
3
3
  * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
4
4
  * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>