UNPKG

@raycast/api

Version:

Build extensions for Raycast with React and Node.js.

6 lines (3 loc) 2.18 kB
"use strict";var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var i in t)l(e,i,{get:t[i],enumerable:!0})},b=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!A.call(e,s)&&s!==i&&l(e,s,{get:()=>t[s],enumerable:!(o=x(t,s))||o.enumerable});return e};var k=e=>b(l({},"__esModule",{value:!0}),e);var R={};T(R,{runEvalsRemotely:()=>I});module.exports=k(R);var f={production:{url:"https://www.raycast.com",clientID:"KqAdcGhNfBKiUpfjD3nU3VNgh1t0iMPoX2hYEkN9d4I"},staging:{url:"https://www.rayca.st",clientID:"KqAdcGhNfBKiUpfjD3nU3VNgh1t0iMPoX2hYEkN9d4I"},development:{url:"http://localhost:3000",clientID:"rOCD_LhnXFObSLu9v7788qOGu25FZDqEzGjet4Q45ZY"}}[process.env.API_ENV||"production"],N="e69bae0ec90f5e838555",r={};function u(e){switch(e){case"raycastApiURL":return process.env.RAY_APIURL||r.APIURL||f.url;case"raycastAccessToken":return process.env.RAY_TOKEN||r.Token||r.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||r.ClientID||f.clientID;case"githubClientId":return process.env.RAY_GithubClientID||r.GithubClientID||N;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||r.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof r.Target>"u"?C("release"):r.Target)}}function C(e){switch(e){case"debug":return"debug";case"internal":return"internal";case"release":return"";case"x":return"x";case"x-internal":return"x-internal";case"x-debug":return"x-debug";case void 0:return u("flavorName")}}async function I(e,{apiEndpoint:t,...i},o){let s=u("raycastAccessToken"),a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({packageJson:e,options:i})});if(!a.ok||a.body===null)throw await a.text();let p=a.body.getReader(),m=new TextDecoder("utf-8"),{done:g,value:d}=await p.read(),n="";for(;!g;){for(n+=m.decode(d,{stream:!0});n.includes(` `);){let c=n.indexOf(` `)+2,y=n.substring(0,c);n=n.substring(c),o(JSON.parse(y))}({done:g,value:d}=await p.read())}n&&(o(JSON.parse(n)),n="")}0&&(module.exports={runEvalsRemotely});