UNPKG

altair-static

Version:

Static package for altair graphql client

12 lines (9 loc) 7.33 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1ff63067-2bad-5a0c-a899-d98f304bd6dd")}catch(e){}}(); import{a as b,b as $}from"./chunk-FW4363Y4.js";var R=b((q,_)=>{"use strict";(function(r,t){"use strict";typeof _=="object"&&typeof _.exports=="object"?_.exports=t():typeof define=="function"&&define.amd?define([],t):r.objectPath=t()})(q,function(){"use strict";var r=Object.prototype.toString;function t(s,u){return s==null?!1:Object.prototype.hasOwnProperty.call(s,u)}function o(s){if(!s||p(s)&&s.length===0)return!0;if(typeof s!="string"){for(var u in s)if(t(s,u))return!1;return!0}return!1}function l(s){return r.call(s)}function f(s){return typeof s=="object"&&l(s)==="[object Object]"}var p=Array.isArray||function(s){return r.call(s)==="[object Array]"};function d(s){return typeof s=="boolean"||l(s)==="[object Boolean]"}function y(s){var u=parseInt(s);return u.toString()===s?u:s}function x(s){s=s||{};var u=function(i){return Object.keys(u).reduce(function(e,n){return n==="create"||typeof u[n]=="function"&&(e[n]=u[n].bind(u,i)),e},{})},g;s.includeInheritedProps?g=function(){return!0}:g=function(i,e){return typeof e=="number"&&Array.isArray(i)||t(i,e)};function T(i,e){if(g(i,e))return i[e]}function h(i,e,n,c){if(typeof e=="number"&&(e=[e]),!e||e.length===0)return i;if(typeof e=="string")return h(i,e.split(".").map(y),n,c);var a=e[0],v=T(i,a);if(s.includeInheritedProps&&(a==="__proto__"||a==="constructor"&&typeof v=="function"))throw new Error("For security reasons, object's magic properties cannot be set");return e.length===1?((v===void 0||!c)&&(i[a]=n),v):(v===void 0&&(typeof e[1]=="number"?i[a]=[]:i[a]={}),h(i[a],e.slice(1),n,c))}return u.has=function(i,e){if(typeof e=="number"?e=[e]:typeof e=="string"&&(e=e.split(".")),!e||e.length===0)return!!i;for(var n=0;n<e.length;n++){var c=y(e[n]);if(typeof c=="number"&&p(i)&&c<i.length||(s.includeInheritedProps?c in Object(i):t(i,c)))i=i[c];else return!1}return!0},u.ensureExists=function(i,e,n){return h(i,e,n,!0)},u.set=function(i,e,n,c){return h(i,e,n,c)},u.insert=function(i,e,n,c){var a=u.get(i,e);c=~~c,p(a)||(a=[],u.set(i,e,a)),a.splice(c,0,n)},u.empty=function(i,e){if(!o(e)&&i!=null){var n,c;if(n=u.get(i,e)){if(typeof n=="string")return u.set(i,e,"");if(d(n))return u.set(i,e,!1);if(typeof n=="number")return u.set(i,e,0);if(p(n))n.length=0;else if(f(n))for(c in n)g(n,c)&&delete n[c];else return u.set(i,e,null)}}},u.push=function(i,e){var n=u.get(i,e);p(n)||(n=[],u.set(i,e,n)),n.push.apply(n,Array.prototype.slice.call(arguments,2))},u.coalesce=function(i,e,n){for(var c,a=0,v=e.length;a<v;a++)if((c=u.get(i,e[a]))!==void 0)return c;return n},u.get=function(i,e,n){if(typeof e=="number"&&(e=[e]),!e||e.length===0)return i;if(i==null)return n;if(typeof e=="string")return u.get(i,e.split("."),n);var c=y(e[0]),a=T(i,c);return a===void 0?n:e.length===1?a:u.get(i[c],e.slice(1),n)},u.del=function(e,n){if(typeof n=="number"&&(n=[n]),e==null||o(n))return e;if(typeof n=="string")return u.del(e,n.split("."));var c=y(n[0]);if(!g(e,c))return e;if(n.length===1)p(e)?e.splice(c,1):delete e[c];else return u.del(e[c],n.slice(1));return e},u}var E=x();return E.create=x,E.withInheritedProps=x({includeInheritedProps:!0}),E})});var U="init_execute";var S;(function(r){r.INTROSPECTION="introspection",r.QUERY="query",r.SUBSCRIPTION="subscription"})(S||(S={}));var I=class{};var m=[];for(let r=0;r<256;++r)m.push((r+256).toString(16).slice(1));function A(r,t=0){return(m[r[t+0]]+m[r[t+1]]+m[r[t+2]]+m[r[t+3]]+"-"+m[r[t+4]]+m[r[t+5]]+"-"+m[r[t+6]]+m[r[t+7]]+"-"+m[r[t+8]]+m[r[t+9]]+"-"+m[r[t+10]]+m[r[t+11]]+m[r[t+12]]+m[r[t+13]]+m[r[t+14]]+m[r[t+15]]).toLowerCase()}var L=new Uint8Array(16);function P(){return crypto.getRandomValues(L)}function N(r,t,o){return!t&&!r&&crypto.randomUUID?crypto.randomUUID():J(r,t,o)}function J(r,t,o){r=r||{};let l=r.random??r.rng?.()??P();if(l.length<16)throw new Error("Random bytes length must be >= 16");if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,t){if(o=o||0,o<0||o+16>t.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let f=0;f<16;++f)t[o+f]=l[f];return t}return A(l)}var k=N;var w=$(R()),B={atob:{async exec(){return(await import("./chunk-CAVWCVAX.js")).atob}},btoa:{async exec(){return(await import("./chunk-CAVWCVAX.js")).btoa}},"crypto-js":{async exec(){return(await import("./chunk-MIKJ46VC.js")).default}}},H=r=>{if(r.response)return{body:r.response.body,requestType:r.requestType??S.QUERY,responseTime:r.response.responseTime,statusCode:r.response.status,headers:r.response.headers}},X=async r=>{let t=B[r];if(!t)throw new Error(`No request script module found matching "${r}"`);return t.exec()},M=(r,t)=>({data:r,helpers:{getEnvironment:o=>(0,w.get)(r.environment,o),setEnvironment:(o,l,f=!1)=>{(0,w.set)(r.environment,o,l),f&&(r.__toSetActiveEnvironment=r.__toSetActiveEnvironment??{},(0,w.set)(r.__toSetActiveEnvironment,o,l))},getCookie:o=>r.__cookieJar?.[o]??"",setCookie:(o,l,f)=>{t.setCookie(o,l,f)},request:async(o,l,f)=>t.request(o,l,f)},storage:{get:o=>t.getStorageItem(o),set:(o,l)=>t.setStorageItem(o,l)},importModule:o=>X(o),response:H(r),log:o=>{r.requestScriptLogs=r.requestScriptLogs??[],r.requestScriptLogs.push({id:crypto.randomUUID(),time:Date.now(),text:JSON.stringify(o,null,2),source:"Request script"})}});var G=["setCookie","request","getStorageItem","setStorageItem"],C=class{constructor(t){this.worker=t}start(){this.worker.onMessage(async t=>{switch(t.type){case U:try{await this.initExecute(t.payload)}catch(o){await this.makeCall("scriptError",o)}break}})}async initExecute(t){let[o,l]=t,f=await new Promise((p,d)=>{this.worker.onError(s=>{d(s)});let y=JSON.parse(JSON.stringify(l)),x=G.reduce((s,u)=>(s[u]=((...g)=>this.makeCall(u,...g)),s),{}),E={altair:M(y,x),alert:s=>this.makeCall("alert",s)};return this.evalWithContext(o,E).then(s=>p(s)).catch(s=>{d(s)})});f.__toSetActiveEnvironment&&this.makeCall("updateActiveEnvironment",f.__toSetActiveEnvironment),this.makeCall("executeComplete",f)}makeCall(t,...o){return new Promise((l,f)=>{let p=k();this.worker.onMessage(d=>{switch(d.type){case`${t}_response`:return d.payload.id!==p?void 0:l(d.payload.response);case`${t}_error`:return d.payload.id!==p?void 0:f(d.payload.error)}}),this.worker.send(t,{id:p,args:o})})}async evalWithContext(t,o){let l=Object.entries(o);return(0,eval)(` async (${l.map(p=>p[0]).join(",")}) => { ${t}; return altair.data; } `)(...l.map(p=>p[1]))}};var D=["chrome-extension://flnheeellpciglgpaodhkhmapeljopja","chrome-extension://aiopipphfnlndegenpkclffgaiillbdd","moz-extension://567d7e27-43b8-994e-ab50-e770fa7eab4b","http://localhost:4200","https://dash.altairgraphql.dev","https://web.altairgraphql.dev","altair://-"];var O=class extends I{onMessage(t){self.addEventListener("message",o=>{o.origin&&!D.includes(o.origin)||t(o.data)})}send(t,o){self.postMessage({type:t,payload:o})}onError(t){self.addEventListener("error",t),self.addEventListener("unhandledrejection",o=>{o.preventDefault(),t(o.reason)})}};new C(new O).start(); //# sourceMappingURL=worker-2ZPX3FTR.js.map //# debugId=1ff63067-2bad-5a0c-a899-d98f304bd6dd