Skip to main content
Glama
508.2f016d122fc2981d.jsβ€’13.2 kB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[508],{133:(e,t,n)=>{"use strict";n.d(t,{S:()=>o});var i=n(8497),o=function(){function e(e,t,n){void 0===n&&(n={}),this.status="idle",this.options=n,this.sandboxSetup=t,this.iframeSelector=e}return e.prototype.updateOptions=function(e){(0,i.j)(this.options,e)||(this.options=e,this.updateSandbox())},e.prototype.updateSandbox=function(e,t){throw void 0===e&&(e=this.sandboxSetup),Error("Method not implemented")},e.prototype.destroy=function(){throw Error("Method not implemented")},e.prototype.dispatch=function(e){throw Error("Method not implemented")},e.prototype.listen=function(e){throw Error("Method not implemented")},e}()},5508:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SandpackRuntime:()=>w});var i=n(7192),o=n(8497),r=n(133),s=n(6919);n(4272);for(var a=function(){function e(e,t,n){var o=this;this.type=e,this.handleMessage=t,this.protocol=n,this._disposeMessageListener=this.protocol.channelListen(function(e){return(0,i._)(o,void 0,void 0,function(){var t,n,o,r;return(0,i.a)(this,function(i){switch(i.label){case 0:if(!(e.type===this.getTypeId()&&e.method))return[3,4];t=e,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.handleMessage(t)];case 2:return n=i.sent(),o={type:this.getTypeId(),msgId:t.msgId,result:n},this.protocol.dispatch(o),[3,4];case 3:return r=i.sent(),o={type:this.getTypeId(),msgId:t.msgId,error:{message:r.message}},this.protocol.dispatch(o),[3,4];case 4:return[2]}})})})}return e.prototype.getTypeId=function(){return"protocol-".concat(this.type)},e.prototype.dispose=function(){this._disposeMessageListener()},e}(),c=function(){function e(e,t){this.globalListeners={},this.globalListenersCount=0,this.channelListeners={},this.channelListenersCount=0,this.channelId=Math.floor(1e6*Math.random()),this.frameWindow=e.contentWindow,this.origin=t,this.globalListeners=[],this.channelListeners=[],this.eventListener=this.eventListener.bind(this),"undefined"!=typeof window&&window.addEventListener("message",this.eventListener)}return e.prototype.cleanup=function(){window.removeEventListener("message",this.eventListener),this.globalListeners={},this.channelListeners={},this.globalListenersCount=0,this.channelListenersCount=0},e.prototype.register=function(){this.frameWindow&&this.frameWindow.postMessage({type:"register-frame",origin:document.location.origin,id:this.channelId},this.origin)},e.prototype.dispatch=function(e){this.frameWindow&&this.frameWindow.postMessage((0,i.h)({$id:this.channelId,codesandbox:!0},e),this.origin)},e.prototype.globalListen=function(e){var t=this;if("function"!=typeof e)return function(){};var n=this.globalListenersCount;return this.globalListeners[n]=e,this.globalListenersCount++,function(){delete t.globalListeners[n]}},e.prototype.channelListen=function(e){var t=this;if("function"!=typeof e)return function(){};var n=this.channelListenersCount;return this.channelListeners[n]=e,this.channelListenersCount++,function(){delete t.channelListeners[n]}},e.prototype.eventListener=function(e){if(e.source===this.frameWindow){var t=e.data;t.codesandbox&&(Object.values(this.globalListeners).forEach(function(e){return e(t)}),t.$id===this.channelId&&Object.values(this.channelListeners).forEach(function(e){return e(t)}))}},e}(),d=new Map,l=Object.entries(s),p=0;p<l.length;p++){var u=l[p],h=u[0],f=u[1];if(f.extensions){var m=f.extensions;if(m.length)for(var b=0;b<m.length;b++){var v=m[b];d.set(v,h)}}}var x="$CSB_RELAY",g="-{{suffix}}",y="https://".concat("2.19.8".replace(/\./g,"-")).concat(g,"-sandpack.codesandbox.io/"),w=function(e){function t(t,n,o){void 0===o&&(o={});var r=e.call(this,t,n,o)||this;if(r.getTranspilerContext=function(){return new Promise(function(e){var t=r.listen(function(n){"transpiler-context"===n.type&&(e(n.data),t())});r.dispatch({type:"get-transpiler-context"})})},r.getTranspiledFiles=function(){return new Promise(function(e){var t=r.listen(function(n){"all-modules"===n.type&&(e(n.data),t())});r.dispatch({type:"get-modules"})})},r.bundlerURL=r.createBundlerURL(),r.bundlerState=void 0,r.errors=[],r.status="initializing","string"==typeof t){r.selector=t;var s=document.querySelector(t);(0,i.n)(s,"The element '".concat(t,"' was not found")),r.element=s,r.iframe=document.createElement("iframe"),r.initializeElement()}else r.element=t,r.iframe=t;return r.iframe.getAttribute("sandbox")||(r.iframe.setAttribute("sandbox","allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"),r.iframe.setAttribute("allow","accelerometer; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; clipboard-read; clipboard-write; xr-spatial-tracking;")),r.setLocationURLIntoIFrame(),r.iframeProtocol=new c(r.iframe,r.bundlerURL),r.unsubscribeGlobalListener=r.iframeProtocol.globalListen(function(e){"initialized"===e.type&&r.iframe.contentWindow&&(r.iframeProtocol.register(),r.options.fileResolver&&(r.fileResolverProtocol=new a("fs",function(e){return(0,i._)(r,void 0,void 0,function(){return(0,i.a)(this,function(t){if("isFile"===e.method)return[2,this.options.fileResolver.isFile(e.params[0])];if("readFile"===e.method)return[2,this.options.fileResolver.readFile(e.params[0])];throw Error("Method not supported")})})},r.iframeProtocol)),r.updateSandbox(r.sandboxSetup,!0))}),r.unsubscribeChannelListener=r.iframeProtocol.channelListen(function(e){switch(e.type){case"start":r.errors=[];break;case"status":r.status=e.status;break;case"action":"show-error"===e.action&&(r.errors=(0,i.i)((0,i.i)([],r.errors,!0),[(0,i.e)(e)],!1));break;case"done":r.status="done";break;case"state":r.bundlerState=e.state}}),o.experimental_enableServiceWorker&&r.serviceWorkerHandshake(),r}return(0,i.g)(t,e),t.prototype.createBundlerURL=function(){var e,t=this.options.bundlerURL||y;if(this.options.bundlerURL)return t;if(this.options.teamId&&(t=t.replace("https://","https://"+this.options.teamId+"-")+"?cache=".concat(Date.now())),this.options.experimental_enableServiceWorker){var n=[];n.push(Math.random().toString(36).slice(4)),t=t.replace(g,"-".concat(null!=(e=this.options.experimental_stableServiceWorkerId)?e:n.join("-")))}else t=t.replace(g,"");return t},t.prototype.serviceWorkerHandshake=function(){var e=this,t=new MessageChannel,n=this.iframe.contentWindow;if(!n)throw Error("Could not get iframe contentWindow");var i=t.port1;i.onmessage=function(t){if("object"==typeof t.data&&t.data.$channel===x)switch(t.data.$type){case"preview/ready":break;case"preview/request":e.handleWorkerRequest(t.data,i)}};var o=function(){n.postMessage({$channel:x,$type:"preview/init"},"*",[t.port2]),e.iframe.removeEventListener("load",o)};this.iframe.addEventListener("load",o)},t.prototype.handleWorkerRequest=function(e,t){return(0,i._)(this,void 0,void 0,function(){var n,o,r,s,a,c,l,p;return(0,i.a)(this,function(i){switch(i.label){case 0:n=function(){var n={$channel:x,$type:"preview/response",id:e.id,headers:{"Content-Type":"text/html; charset=utf-8"},status:404,body:"File not found"};t.postMessage(n)},i.label=1;case 1:if(i.trys.push([1,4,,5]),o=new URL(e.url,this.bundlerURL).pathname,r={},s=this.getFiles()[o])return[3,3];return[4,this.getTranspiledFiles()];case 2:if(!(s=i.sent().find(function(e){return e.path.endsWith(o)})))return n(),[2];i.label=3;case 3:if(a=s.code,!r["Content-Type"]){var u;c=(u=o.split(".")).length<=1?"":u[u.length-1],(l=d.get(c))&&(r["Content-Type"]=l)}return p={$channel:x,$type:"preview/response",id:e.id,headers:r,status:200,body:a},t.postMessage(p),[3,5];case 4:return console.error(i.sent()),n(),[3,5];case 5:return[2]}})})},t.prototype.setLocationURLIntoIFrame=function(){var e,t=this.options.startRoute?new URL(this.options.startRoute,this.bundlerURL).toString():this.bundlerURL;null==(e=this.iframe.contentWindow)||e.location.replace(t),this.iframe.src=t},t.prototype.destroy=function(){this.unsubscribeChannelListener(),this.unsubscribeGlobalListener(),this.iframeProtocol.cleanup()},t.prototype.updateOptions=function(e){(0,o.j)(this.options,e)||(this.options=e,this.updateSandbox())},t.prototype.updateSandbox=function(e,t){void 0===e&&(e=this.sandboxSetup),this.sandboxSetup=(0,i.h)((0,i.h)({},this.sandboxSetup),e);var n,o,r,s,a=this.getFiles(),c=Object.keys(a).reduce(function(e,t){var n;return(0,i.h)((0,i.h)({},e),((n={})[t]={code:a[t].code,path:t},n))},{}),d=JSON.parse((0,i.b)(this.sandboxSetup.dependencies,this.sandboxSetup.devDependencies,this.sandboxSetup.entry));try{d=JSON.parse(a["/package.json"].code)}catch(e){console.error((0,i.c)("could not parse package.json file: "+e.message))}var l=Object.keys(a).reduce(function(e,t){var n;return(0,i.h)((0,i.h)({},e),((n={})[t]={content:a[t].code,path:t},n))},{});this.dispatch((0,i.h)((0,i.h)({},this.options),{type:"compile",codesandbox:!0,version:3,isInitializationCompile:t,modules:c,reactDevTools:this.options.reactDevTools,externalResources:this.options.externalResources||[],hasFileResolver:!!this.options.fileResolver,disableDependencyPreprocessing:this.sandboxSetup.disableDependencyPreprocessing,experimental_enableServiceWorker:this.options.experimental_enableServiceWorker,template:this.sandboxSetup.template||function(e,t){if(!e)return"static";var n=e.dependencies,o=void 0===n?{}:n,r=e.devDependencies,s=(0,i.i)((0,i.i)([],Object.keys(o),!0),Object.keys(void 0===r?{}:r),!0),a=Object.keys(t),c=["@adonisjs/framework","@adonisjs/core"];if(s.some(function(e){return c.indexOf(e)>-1}))return"adonis";var d=["nuxt","nuxt-edge","nuxt-ts","nuxt-ts-edge","nuxt3"];if(s.some(function(e){return d.indexOf(e)>-1}))return"nuxt";if(s.indexOf("next")>-1)return"next";var l=["apollo-server","apollo-server-express","apollo-server-hapi","apollo-server-koa","apollo-server-lambda","apollo-server-micro"];if(s.some(function(e){return l.indexOf(e)>-1}))return"apollo";if(s.indexOf("mdx-deck")>-1)return"mdx-deck";if(s.indexOf("gridsome")>-1)return"gridsome";if(s.indexOf("vuepress")>-1)return"vuepress";if(s.indexOf("ember-cli")>-1)return"ember";if(s.indexOf("sapper")>-1)return"sapper";if(s.indexOf("gatsby")>-1)return"gatsby";if(s.indexOf("quasar")>-1)return"quasar";if(s.indexOf("@docusaurus/core")>-1)return"docusaurus";if(s.indexOf("remix")>-1)return"remix";if(s.indexOf("astro")>-1)return"node";if(a.some(function(e){return e.endsWith(".re")}))return"reason";var p=["parcel-bundler","parcel"];if(s.some(function(e){return p.indexOf(e)>-1}))return"parcel";var u=["@dojo/core","@dojo/framework"];if(s.some(function(e){return u.indexOf(e)>-1}))return"@dojo/cli-create-app";if(s.indexOf("@nestjs/core")>-1||s.indexOf("@nestjs/common")>-1)return"nest";if(s.indexOf("react-styleguidist")>-1)return"styleguidist";if(s.indexOf("react-scripts")>-1)return"create-react-app";if(s.indexOf("react-scripts-ts")>-1)return"create-react-app-typescript";if(s.indexOf("@angular/core")>-1)return"angular-cli";if(s.indexOf("preact-cli")>-1)return"preact-cli";if(s.indexOf("@sveltech/routify")>-1||s.indexOf("@roxi/routify")>-1||s.indexOf("vite")>-1||s.indexOf("@frontity/core")>-1)return"node";if(s.indexOf("svelte")>-1)return"svelte";if(s.indexOf("vue")>-1)return"vue-cli";if(s.indexOf("cx")>-1)return"cxjs";var h=["express","koa","nodemon","ts-node","@tensorflow/tfjs-node","webpack-dev-server","snowpack"];if(s.some(function(e){return h.indexOf(e)>-1})||Object.keys(o).length>=50)return"node"}(d,l),showOpenInCodeSandbox:null==(n=this.options.showOpenInCodeSandbox)||n,showErrorScreen:null==(o=this.options.showErrorScreen)||o,showLoadingScreen:null!=(r=this.options.showLoadingScreen)&&r,skipEval:this.options.skipEval||!1,clearConsoleDisabled:!this.options.clearConsoleOnFirstCompile,logLevel:null!=(s=this.options.logLevel)?s:i.S.Info,customNpmRegistries:this.options.customNpmRegistries,teamId:this.options.teamId,sandboxId:this.options.sandboxId}))},t.prototype.dispatch=function(e){"refresh"===e.type&&(this.setLocationURLIntoIFrame(),this.options.experimental_enableServiceWorker&&this.serviceWorkerHandshake()),this.iframeProtocol.dispatch(e)},t.prototype.listen=function(e){return this.iframeProtocol.channelListen(e)},t.prototype.getCodeSandboxURL=function(){var e=this.getFiles();return fetch("https://codesandbox.io/api/v1/sandboxes/define?json=1",{method:"POST",body:JSON.stringify({files:Object.keys(e).reduce(function(t,n){var o;return(0,i.h)((0,i.h)({},t),((o={})[n.replace("/","")]={content:e[n].code,isBinary:!1},o))},{})}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){return{sandboxId:e.sandbox_id,editorUrl:"https://codesandbox.io/s/".concat(e.sandbox_id),embedUrl:"https://codesandbox.io/embed/".concat(e.sandbox_id)}})},t.prototype.getFiles=function(){var e=this.sandboxSetup;return void 0===e.files["/package.json"]?(0,i.d)(e.files,e.dependencies,e.devDependencies,e.entry):this.sandboxSetup.files},t.prototype.initializeElement=function(){this.iframe.style.border="0",this.iframe.style.width=this.options.width||"100%",this.iframe.style.height=this.options.height||"100%",this.iframe.style.overflow="hidden",(0,i.n)(this.element.parentNode,"The given iframe does not have a parent."),this.element.parentNode.replaceChild(this.iframe,this.element)},t}(r.S)},6919:(e,t,n)=>{e.exports=n(2904)}}]);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HelloGGX/shadcn-vue-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server