raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.24k stars 2.94k forks source link

[Brave] – The app didn't open a browser tab #1915

Closed aaronjz closed 2 years ago

aaronjz commented 2 years ago

Extension – Brave

Author: @ron-myers

Description

The app didn't open a browser tab when I selected one and pressed enter (I use the Brave browser). It just crashed.

Error:

Error: Command failed with exit code 1: osascript -e 
    set newTabUrl to "https://sunsetcc.churchofficechms.com/members"
    tell application "Brave Browser"
      activate
      set targetWindow to item 1 of windows
      tell targetWindow
        set visible to false
        set visible to true
        set index to 1
      end tell      
      tell front window to make new tab at after (get active tab) with properties {URL:newTabUrl}      
    end tell

148:154: execution error: Brave Browser got an error: Can’t get item 1 of every window. Invalid index. (-1719)

    set newTabUrl to "https://sunsetcc.churchofficechms.com/members"
    tell application "Brave Browser"
      activate
      set targetWindow to item 1 of windows
      tell targetWindow
        set visible to false
        set visible to true
        set index to 1
      end tell      
      tell front window to make new tab at after (get active tab) with properties {URL:newTabUrl}      
    end tell

148:154: execution error: Brave Browser got an error: Can’t get item 1 of every window. Invalid index. (-1719)
du:brave-search-history.js:8:57

---
 5: `:`
 6: `.charCodeAt(),s=typeof t=="string"?"\r":"\r".charCodeAt();return t[t.length-1]===i&&(t=t.slice(0,t.length-1)),t[t.length-1]===s&&(t=t.slice(0,t.length-1)),t}});var Ji=C((Fc,vt)=>{"use strict";var wt=require("path"),Ki=Dn(),Zi=t=>{t=J({cwd:process.cwd(),path:process.env[Ki()],execPath:process.execPath},t);let i,s=wt.resolve(t.cwd),u=[];for(;i!==s;)u.push(wt.join(s,"node_modules/.bin")),i=s,s=wt.resolve(s,"..");let l=wt.resolve(t.cwd,t.execPath,"..");return u.push(l),u.concat(t.path).join(wt.delimiter)};vt.exports=Zi;vt.exports.default=Zi;vt.exports.env=t=>{t=J({env:process.env},t);let i=J({},t.env),s=Ki({env:i});return t.path=i[s],i[s]=vt.exports(t),i}});var to=C((Dc,zn)=>{"use strict";var eo=(t,i)=>{for(let s of Reflect.ownKeys(i))Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(i,s));return t};zn.exports=eo;zn.exports.default=eo});var ro=C((Nc,Qt)=>{"use strict";var za=to(),zt=new WeakMap,no=(t,i={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let s,u=0,l=t.displayName||t.name||"<anonymous>",o=function(...m){if(zt.set(o,++u),u===1)s=t.apply(this,m),t=null;else if(i.throw===!0)throw new Error(`Function \`${l}\` can only be called once`);return s};return za(o,t),zt.set(o,u),o};Qt.exports=no;Qt.exports.default=no;Qt.exports.callCount=t=>{if(!zt.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return zt.get(t)}});var io=C(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.SIGNALS=void 0;var Qa=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];Vt.SIGNALS=Qa});var Qn=C(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.SIGRTMAX=et.getRealtimeSignals=void 0;var Va=function(){let t=so-oo+1;return Array.from({length:t},Xa)};et.getRealtimeSignals=Va;var Xa=function(t,i){return{name:`SIGRT${i+1}`,number:oo+i,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},oo=34,so=64;et.SIGRTMAX=so});var ao=C(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getSignals=void 0;var Ya=require("os"),Ka=io(),Za=Qn(),Ja=function(){let t=(0,Za.getRealtimeSignals)();return[...Ka.SIGNALS,...t].map(eu)};Xt.getSignals=Ja;var eu=function({name:t,number:i,description:s,action:u,forced:l=!1,standard:o}){let{signals:{[t]:m}}=Ya.constants,b=m!==void 0;return{name:t,number:b?m:i,description:s,supported:b,action:u,forced:l,standard:o}}});var co=C(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.signalsByNumber=tt.signalsByName=void 0;var tu=require("os"),uo=ao(),nu=Qn(),ru=function(){return(0,uo.getSignals)().reduce(iu,{})},iu=function(t,{name:i,number:s,description:u,supported:l,action:o,forced:m,standard:b}){return Pe(J({},t),{[i]:{name:i,number:s,description:u,supported:l,action:o,forced:m,standard:b}})},ou=ru();tt.signalsByName=ou;var su=function(){let t=(0,uo.getSignals)(),i=nu.SIGRTMAX+1,s=Array.from({length:i},(u,l)=>au(l,t));return Object.assign({},...s)},au=function(t,i){let s=uu(t,i);if(s===void 0)return{};let{name:u,description:l,supported:o,action:m,forced:b,standard:_}=s;return{[t]:{name:u,number:t,description:l,supported:o,action:m,forced:b,standard:_}}},uu=function(t,i){let s=i.find(({name:u})=>tu.constants.signals[u]===t);return s!==void 0?s:i.find(u=>u.number===t)},cu=su();tt.signalsByNumber=cu});var fo=C((Hc,lo)=>{"use strict";var{signalsByName:lu}=co(),fu=({timedOut:t,timeout:i,errorCode:s,signal:u,signalDescription:l,exitCode:o,isCanceled:m})=>t?`timed out after ${i} milliseconds`:m?"was canceled":s!==void 0?`failed with ${s}`:u!==void 0?`was killed with ${u} (${l})`:o!==void 0?`failed with exit code ${o}`:"failed",du=({stdout:t,stderr:i,all:s,error:u,signal:l,exitCode:o,command:m,escapedCommand:b,timedOut:_,isCanceled:P,killed:q,parsed:{options:{timeout:k}}})=>{o=o===null?void 0:o,l=l===null?void 0:l;let h=l===void 0?void 0:lu[l].description,S=u&&u.code,D=`Command ${fu({timedOut:_,timeout:k,errorCode:S,signal:l,signalDescription:h,exitCode:o,isCanceled:P})}: ${m}`,I=Object.prototype.toString.call(u)==="[object Error]",G=I?`${D}
 7: ${u.message}`:D,V=[G,i,t].filter(Boolean).join(`
 8: `);return I?(u.originalMessage=u.message,u.message=V):u=new Error(V),u.shortMessage=G,u.command=m,u.escapedCommand=b,u.exitCode=o,u.signal=l,u.signalDescription=h,u.stdout=t,u.stderr=i,s!==void 0&&(u.all=s),"bufferedData"in u&&delete u.bufferedData,u.failed=!0,u.timedOut=Boolean(_),u.isCanceled=P,u.killed=q&&!_,u};lo.exports=du});var mo=C((Wc,Vn)=>{"use strict";var Yt=["stdin","stdout","stderr"],pu=t=>Yt.some(i=>t[i]!==void 0),po=t=>{if(!t)return;let{stdio:i}=t;if(i===void 0)return Yt.map(u=>t[u]);if(pu(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Yt.map(u=>`\`${u}\``).join(", ")}`);if(typeof i=="string")return i;if(!Array.isArray(i))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof i}\``);let s=Math.max(i.length,Yt.length);return Array.from({length:s},(u,l)=>i[l])};Vn.exports=po;Vn.exports.node=t=>{let i=po(t);return i==="ipc"?"ipc":i===void 0||typeof i=="string"?[i,i,i,"ipc"]:i.includes("ipc")?i:[...i,"ipc"]}});var ho=C((zc,Kt)=>{Kt.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Kt.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Kt.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var vo=C((Qc,it)=>{var F=global.process;typeof F!="object"||!F?it.exports=function(){}:(yo=require("assert"),nt=ho(),bo=/^win/i.test(F.platform),_t=require("events"),typeof _t!="function"&&(_t=_t.EventEmitter),F.__signal_exit_emitter__?te=F.__signal_exit_emitter__:(te=F.__signal_exit_emitter__=new _t,te.count=0,te.emitted={}),te.infinite||(te.setMaxListeners(1/0),te.infinite=!0),it.exports=function(t,i){if(global.process===F){yo.equal(typeof t,"function","a callback must be provided for exit handler"),rt===!1&&Xn();var s="exit";i&&i.alwaysLast&&(s="afterexit");var u=function(){te.removeListener(s,t),te.listeners("exit").length===0&&te.listeners("afterexit").length===0&&Zt()};return te.on(s,t),u}},Zt=function(){!rt||global.process!==F||(rt=!1,nt.forEach(function(i){try{F.removeListener(i,Jt[i])}catch{}}),F.emit=en,F.reallyExit=Yn,te.count-=1)},it.exports.unload=Zt,Ue=function(i,s,u){te.emitted[i]||(te.emitted[i]=!0,te.emit(i,s,u))},Jt={},nt.forEach(function(t){Jt[t]=function(){if(F===global.process){var s=F.listeners(t);s.length===te.count&&(Zt(),Ue("exit",null,t),Ue("afterexit",null,t),bo&&t==="SIGHUP"&&(t="SIGINT"),F.kill(F.pid,t))}}}),it.exports.signals=function(){return nt},rt=!1,Xn=function(){rt||F!==global.process||(rt=!0,te.count+=1,nt=nt.filter(function(i){try{return F.on(i,Jt[i]),!0}catch{return!1}}),F.emit=wo,F.reallyExit=go)},it.exports.load=Xn,Yn=F.reallyExit,go=function(i){F===global.process&&(F.exitCode=i||0,Ue("exit",F.exitCode,null),Ue("afterexit",F.exitCode,null),Yn.call(F,F.exitCode))},en=F.emit,wo=function(i,s){if(i==="exit"&&F===global.process){s!==void 0&&(F.exitCode=s);var u=en.apply(this,arguments);return Ue("exit",F.exitCode,null),Ue("afterexit",F.exitCode,null),u}else return en.apply(this,arguments)});var yo,nt,bo,_t,te,Zt,Ue,Jt,rt,Xn,Yn,go,en,wo});var So=C((Vc,_o)=>{"use strict";var mu=require("os"),hu=vo(),yu=1e3*5,bu=(t,i="SIGTERM",s={})=>{let u=t(i);return gu(t,i,s,u),u},gu=(t,i,s,u)=>{if(!wu(i,s,u))return;let l=_u(s),o=setTimeout(()=>{t("SIGKILL")},l);o.unref&&o.unref()},wu=(t,{forceKillAfterTimeout:i},s)=>vu(t)&&i!==!1&&s,vu=t=>t===mu.constants.signals.SIGTERM||typeof t=="string"&&t.toUpperCase()==="SIGTERM",_u=({forceKillAfterTimeout:t=!0})=>{if(t===!0)return yu;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},Su=(t,i)=>{t.kill()&&(i.isCanceled=!0)},Eu=(t,i,s)=>{t.kill(i),s(Object.assign(new Error("Timed out"),{timedOut:!0,signal:i}))},xu=(t,{timeout:i,killSignal:s="SIGTERM"},u)=>{if(i===0||i===void 0)return u;let l,o=new Promise((b,_)=>{l=setTimeout(()=>{Eu(t,s,_)},i)}),m=u.finally(()=>{clearTimeout(l)});return Promise.race([o,m])},Au=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},Pu=async(t,{cleanup:i,detached:s},u)=>{if(!i||s)return u;let l=hu(()=>{t.kill()});return u.finally(()=>{l()})};_o.exports={spawnedKill:bu,spawnedCancel:Su,setupTimeout:xu,validateTimeout:Au,setExitHandler:Pu}});var xo=C((Xc,Eo)=>{"use strict";var Ee=t=>t!==null&&typeof t=="object"&&typeof t.pipe=="function";Ee.writable=t=>Ee(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object";Ee.readable=t=>Ee(t)&&t.readable!==!1&&typeof t._read=="function"&&typeof t._readableState=="object";Ee.duplex=t=>Ee.writable(t)&&Ee.readable(t);Ee.transform=t=>Ee.duplex(t)&&typeof t._transform=="function";Eo.exports=Ee});var Po=C((Yc,Ao)=>{"use strict";var{PassThrough:Tu}=require("stream");Ao.exports=t=>{t=J({},t);let{array:i}=t,{encoding:s}=t,u=s==="buffer",l=!1;i?l=!(s||u):s=s||"utf8",u&&(s=null);let o=new Tu({objectMode:l});s&&o.setEncoding(s);let m=0,b=[];return o.on("data",_=>{b.push(_),l?m=b.length:m+=_.length}),o.getBufferedValue=()=>i?b:u?Buffer.concat(b,m):b.join(""),o.getBufferedLength=()=>m,o}});var To=C((Kc,St)=>{"use strict";var{constants:Ru}=require("buffer"),qu=require("stream"),{promisify:Iu}=require("util"),ku=Po(),Ou=Iu(qu.pipeline),Kn=class extends Error{constructor(){super("maxBuffer exceeded");this.name="MaxBufferError"}};async function Zn(t,i){if(!t)throw new Error("Expected a stream");i=J({maxBuffer:1/0},i);let{maxBuffer:s}=i,u=ku(i);return await new Promise((l,o)=>{let m=b=>{b&&u.getBufferedLength()<=Ru.MAX_LENGTH&&(b.bufferedData=u.getBufferedValue()),o(b)};(async()=>{try{await Ou(t,u),l()}catch(b){m(b)}})(),u.on("data",()=>{u.getBufferedLength()>s&&m(new Kn)})}),u.getBufferedValue()}St.exports=Zn;St.exports.buffer=(t,i)=>Zn(t,Pe(J({},i),{encoding:"buffer"}));St.exports.array=(t,i)=>Zn(t,Pe(J({},i),{array:!0}));St.exports.MaxBufferError=Kn});var qo=C((Zc,Ro)=>{"use strict";var{PassThrough:Cu}=require("stream");Ro.exports=function(){var t=[],i=new Cu({objectMode:!0});return i.setMaxListeners(0),i.add=s,i.isEmpty=u,i.on("unpipe",l),Array.prototype.slice.call(arguments).forEach(s),i;function s(o){return Array.isArray(o)?(o.forEach(s),this):(t.push(o),o.once("end",l.bind(null,o)),o.once("error",i.emit.bind(i,"error")),o.pipe(i,{end:!1}),this)}function u(){return t.length==0}function l(o){t=t.filter(function(m){return m!==o}),!t.length&&i.readable&&i.end()}}});var Co=C((Jc,Oo)=>{"use strict";var ko=xo(),Io=To(),Mu=qo(),ju=(t,i)=>{i===void 0||t.stdin===void 0||(ko(i)?i.pipe(t.stdin):t.stdin.end(i))},Lu=(t,{all:i})=>{if(!i||!t.stdout&&!t.stderr)return;let s=Mu();return t.stdout&&s.add(t.stdout),t.stderr&&s.add(t.stderr),s},Jn=async(t,i)=>{if(!!t){t.destroy();try{return await i}catch(s){return s.bufferedData}}},er=(t,{encoding:i,buffer:s,maxBuffer:u})=>{if(!(!t||!s))return i?Io(t,{encoding:i,maxBuffer:u}):Io.buffer(t,{maxBuffer:u})},Fu=async({stdout:t,stderr:i,all:s},{encoding:u,buffer:l,maxBuffer:o},m)=>{let b=er(t,{encoding:u,buffer:l,maxBuffer:o}),_=er(i,{encoding:u,buffer:l,maxBuffer:o}),P=er(s,{encoding:u,buffer:l,maxBuffer:o*2});try{return await Promise.all([m,b,_,P])}catch(q){return Promise.all([{error:q,signal:q.signal,timedOut:q.timedOut},Jn(t,b),Jn(i,_),Jn(s,P)])}},Du=({input:t})=>{if(ko(t))throw new TypeError("The `input` option cannot be a stream in sync mode")};Oo.exports={handleInput:ju,makeAllStream:Lu,getSpawnedResult:Fu,validateInputSync:Du}});var jo=C((el,Mo)=>{"use strict";var Nu=(async()=>{})().constructor.prototype,Gu=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Nu,t)]),$u=(t,i)=>{for(let[s,u]of Gu){let l=typeof i=="function"?(...o)=>Reflect.apply(u.value,i(),o):u.value.bind(i);Reflect.defineProperty(t,s,Pe(J({},u),{value:l}))}return t},Uu=t=>new Promise((i,s)=>{t.on("exit",(u,l)=>{i({exitCode:u,signal:l})}),t.on("error",u=>{s(u)}),t.stdin&&t.stdin.on("error",u=>{s(u)})});Mo.exports={mergePromise:$u,getSpawnedPromise:Uu}});var Do=C((tl,Fo)=>{"use strict";var Lo=(t,i=[])=>Array.isArray(i)?[t,...i]:[t],Bu=/^[\w.-]+$/,Hu=/"/g,Wu=t=>typeof t!="string"||Bu.test(t)?t:`"${t.replace(Hu,'\\"')}"`,zu=(t,i)=>Lo(t,i).join(" "),Qu=(t,i)=>Lo(t,i).map(s=>Wu(s)).join(" "),Vu=/ +/g,Xu=t=>{let i=[];for(let s of t.trim().split(Vu)){let u=i[i.length-1];u&&u.endsWith("\\")?i[i.length-1]=`${u.slice(0,-1)} ${s}`:i.push(s)}return i};Fo.exports={joinCommand:zu,getEscapedCommand:Qu,parseCommand:Xu}});var Wo=C((nl,ot)=>{"use strict";var Yu=require("path"),tr=require("child_process"),Ku=Vi(),Zu=Yi(),Ju=Ji(),ec=ro(),tn=fo(),Go=mo(),{spawnedKill:tc,spawnedCancel:nc,setupTimeout:rc,validateTimeout:ic,setExitHandler:oc}=So(),{handleInput:sc,getSpawnedResult:ac,makeAllStream:uc,validateInputSync:cc}=Co(),{mergePromise:No,getSpawnedPromise:lc}=jo(),{joinCommand:$o,parseCommand:Uo,getEscapedCommand:Bo}=Do(),fc=1e3*1e3*100,dc=({env:t,extendEnv:i,preferLocal:s,localDir:u,execPath:l})=>{let o=i?J(J({},process.env),t):t;return s?Ju.env({env:o,cwd:u,execPath:l}):o},Ho=(t,i,s={})=>{let u=Ku._parse(t,i,s);return t=u.command,i=u.args,s=u.options,s=J({maxBuffer:fc,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:s.cwd||process.cwd(),execPath:process.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0},s),s.env=dc(s),s.stdio=Go(s),process.platform==="win32"&&Yu.basename(t,".exe")==="cmd"&&i.unshift("/q"),{file:t,args:i,options:s,parsed:u}},Et=(t,i,s)=>typeof i!="string"&&!Buffer.isBuffer(i)?s===void 0?void 0:"":t.stripFinalNewline?Zu(i):i,nn=(t,i,s)=>{let u=Ho(t,i,s),l=$o(t,i),o=Bo(t,i);ic(u.options);let m;try{m=tr.spawn(u.file,u.args,u.options)}catch(S){let E=new tr.ChildProcess,D=Promise.reject(tn({error:S,stdout:"",stderr:"",all:"",command:l,escapedCommand:o,parsed:u,timedOut:!1,isCanceled:!1,killed:!1}));return No(E,D)}let b=lc(m),_=rc(m,u.options,b),P=oc(m,u.options,_),q={isCanceled:!1};m.kill=tc.bind(null,m.kill.bind(m)),m.cancel=nc.bind(null,m,q);let h=ec(async()=>{let[{error:S,exitCode:E,signal:D,timedOut:I},G,V,H]=await ac(m,u.options,P),ne=Et(u.options,G),B=Et(u.options,V),ee=Et(u.options,H);if(S||E!==0||D!==null){let oe=tn({error:S,exitCode:E,signal:D,stdout:ne,stderr:B,all:ee,command:l,escapedCommand:o,parsed:u,timedOut:I,isCanceled:q.isCanceled,killed:m.killed});if(!u.options.reject)return oe;throw oe}return{command:l,escapedCommand:o,exitCode:0,stdout:ne,stderr:B,all:ee,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return sc(m,u.options.input),m.all=uc(m,u.options),No(m,h)};ot.exports=nn;ot.exports.sync=(t,i,s)=>{let u=Ho(t,i,s),l=$o(t,i),o=Bo(t,i);cc(u.options);let m;try{m=tr.spawnSync(u.file,u.args,u.options)}catch(P){throw tn({error:P,stdout:"",stderr:"",all:"",command:l,escapedCommand:o,parsed:u,timedOut:!1,isCanceled:!1,killed:!1})}let b=Et(u.options,m.stdout,m.error),_=Et(u.options,m.stderr,m.error);if(m.error||m.status!==0||m.signal!==null){let P=tn({stdout:b,stderr:_,error:m.error,signal:m.signal,exitCode:m.status,command:l,escapedCommand:o,parsed:u,timedOut:m.error&&m.error.code==="ETIMEDOUT",isCanceled:!1,killed:m.signal!==null});if(!u.options.reject)return P;throw P}return{command:l,escapedCommand:o,exitCode:0,stdout:b,stderr:_,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}};ot.exports.command=(t,i)=>{let[s,...u]=Uo(t);return nn(s,u,i)};ot.exports.commandSync=(t,i)=>{let[s,...u]=Uo(t);return nn.sync(s,u,i)};ot.exports.node=(t,i,s={})=>{i&&!Array.isArray(i)&&typeof i=="object"&&(s=i,i=[]);let u=Go.node(s),l=process.execArgv.filter(b=>!b.startsWith("--inspect")),{nodePath:o=process.execPath,nodeOptions:m=l}=s;return nn(o,[...m,t,...Array.isArray(i)?i:[]],Pe(J({},s),{stdin:void 0,stdout:void 0,stderr:void 0,stdio:u,shell:!1}))}});var bc={};Js(bc,{default:()=>es});var he=require("@raycast/api"),Zo=require("react"),Jo=Ge(ei());var Ht=Ge(require("path")),ni=Ge(require("fs")),ri=Ge(require("util")),ii=Ge(ti()),Te=require("react"),oi=require("@raycast/api"),da=ri.default.promisify(ni.default.readFile),pa=()=>{if(!process.env.HOME)throw new Error("$HOME environment variable is not set.");return Ht.default.join(process.env.HOME,"Library","Application Support","BraveSoftware","Brave-Browser")},ma=t=>Ht.default.join(pa(),t,"History"),ha=()=>"Default",ya=async t=>{let i=ma(t),s=await da(i),u=await(0,ii.default)({locateFile:()=>Ht.default.join(oi.environment.assetsPath,"sql-wasm.wasm")});return new u.Database(s)},si=t=>{let i=[];for(let s=0;s<t.length;s++)i.push(`@t_${s}`);return i},ba=t=>si(t).reduce((i,s,u)=>(i[s]=`%${t[u]}%`,i),{}),ga=t=>si(t).map(i=>`urls.title LIKE ${i}`).join(" AND "),wa=async(t,i)=>{let s=i?i.trim().split(" "):[""],u=`SELECT
 9:             id, url, title,
10:             datetime(last_visit_time / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch', 'localtime')
11:           FROM urls
---

brave-search-history.js:8:10218
processTicksAndRejections:task_queues:96:5
async Vo:brave-search-history.js:13:755
async Ko:brave-search-history.js:25:7
async i:brave-search-history.js:25:167

Steps To Reproduce

  1. Open the search browser history
  2. Select an item and try to open.

The current behavior

Closes the Raycast window, and nothing happens with the Browser.

The expected behavior

Open the selected website in a new default browser tab.

Raycast version

Version: 1.35.2

georgesnow commented 2 years ago

this syntax looks off. the script seems to work in script editor. however, this line returns the index not the window itself.

 set targetWindow to item 1 of windows

you may want to try something more like:

 set targetWindow to item 1 of window 1

that being said it seems to infer the correct the window, but other times when I try to just return item 1 of windows I get an error. but it appears to be timing issue. I get the error if I run this script with brave closed and it has to launch brave. Activate in AppleScript will launch the app if isn't running. The error is that the script tries to get "item 1" before item 1 is even available.

ron-myers commented 2 years ago

Thank you for reporting this, @aaronjz - this portion of the extension is based on the Chrome extension, and I have hit this issue myself recently; I'll have a look at it over the next few days and get a patch pushed up. My gut says it has to do with multiple windows open, and the tab is on a minimized or hidden window.

aaronjz commented 2 years ago

You’re welcome! Thanks for looking into it. I appreciate the work!

Aaron On Jun 10, 2022, 8:26 AM -0700, Ron Myers @.***>, wrote:

Thank you for reporting this, @aaronjz - this portion of the extension is based on the Chrome extension, and I have hit this issue myself recently; I'll have a look at it over the next few days and get a patch pushed up. My gut says it has to do with multiple windows open, and the tab is on a minimized or hidden window. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

georgesnow commented 2 years ago

@ron-myers I had encountered this too. after a few attempts I noticed with the second script below. The window ids seem to be the issue. this appears to work modifying the line to be "first window" to be reliable.

modified script:

set newTabUrl to "https://sunsetcc.churchofficechms.com/members"
tell application "Brave Browser"
    activate
    set targetWindow to item 1 of first window whose index is 1
    tell targetWindow
        set visible to false
        set visible to true
        set index to 1
    end tell
    tell front window to make new tab at after (get active tab) with properties {URL:newTabUrl}
end tell

how I figured out the window ids don't start start at integer of 1, which is why item 1 can't be found. This is with just one window open and one active tab notice the id is 43 and tab index is 44:

tell application "Brave Browser"
    --  return id of every window
    return properties of first window

end tell

Result:
{closeable:true, zoomed:false, active tab index:1, class:window, index:1, visible:true, given name:"", name:"New Tab", miniaturizable:true, mode:"normal", active tab:tab id 44 of window id 43 of application "Brave Browser", id:43, miniaturized:false, resizable:true, bounds:{444, 106, 1644, 937}, zoomable:true}

edit: added "whose index is 1" this is equivalent to "frontmost" window.

stale[bot] commented 2 years ago

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.