Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stackblitz/sdk

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackblitz/sdk - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

2

bundles/sdk.js

@@ -1,2 +0,2 @@

var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.ctl&&(t+="ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),(e.view&&"preview"===e.view||"editor"===e.view)&&(t+=(t.length?"&":"")+"view="+e.view),t.length?"?"+t:t):t}function i(e,t,n){if(null===e.parentNode)throw"Invalid Element";t.id=e.id,a(t,n),e.parentNode.replaceChild(t,e)}function r(e){if("string"==typeof e){var t=document.getElementById(e);if(null!==t)return t}else if(e instanceof HTMLElement)return e;throw"Invalid Element"}function o(e){return e&&!1===e.newWindow?"_self":"_blank"}function a(t,n){n&&(n.hasOwnProperty("height")&&(t.height=""+n.height),n.hasOwnProperty("width")&&(t.width=""+n.width)),t.height||(t.height=e),t.width||t.setAttribute("style","width:100%;")}var d=function(e){var t=this;this.pending={},this.port=e,this.port.onmessage=function(e){if(e.data.payload.__reqid){var n=e.data.payload.__reqid,i=e.data.payload.__success;if(t.pending[n]){if(delete e.data.payload.__reqid,delete e.data.payload.__success,i){var r=0===Object.keys(e.data.payload).length&&e.data.payload.constructor===Object?null:e.data.payload;t.pending[n].resolve(r)}else{var o=e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type;t.pending[n].reject(o)}delete t.pending[n]}}}};d.prototype.request=function(e){var n=this,i=t();return new Promise(function(t,r){n.pending[i]={resolve:t,reject:r},e.payload.__reqid=i,n.port.postMessage(e)})};var c=function(e,t){var n=this;this.rdc=new d(e),this.preview={},Object.defineProperty(this.preview,"origin",{value:t.previewOrigin,writable:!1}),this.editor={openFile:function(e){return n.rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})}}};c.prototype.applyFsDiff=function(e){return this.rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},c.prototype.getFsSnapshot=function(){return this.rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})};var s=[],p=function(e){var n=this;this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){t.data.action&&"SDK_INIT_SUCCESS"===t.data.action&&t.data.id===n.id&&(n.vm=new c(t.ports[0],t.data.payload),e(n.vm),o())},r=function(){n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",i)}window.addEventListener("message",i),r();var a=0,d=window.setInterval(function(){if(n.vm)o();else{if(a>=20)return o(),t("Timeout: Unable to establish a connection with the StackBlitz VM"),void s.forEach(function(e,t){e.id===n.id&&s.splice(t,1)});a++,r()}},500)}),s.push(this)},l=function(e){var t=e instanceof Element?"element":"id",n=s.find(function(n){return n[t]===e});return n||null};function u(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function h(e){var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(u("project[title]",e.title)),t.appendChild(u("project[description]",e.description)),t.appendChild(u("project[template]",e.template)),e.tags&&e.tags.forEach(function(e,n){t.appendChild(u("project[tags]["+n+"]",e))}),e.dependencies&&t.appendChild(u("project[dependencies]",JSON.stringify(e.dependencies))),Object.keys(e.files).forEach(function(n){t.appendChild(u("project[files]["+n+"]",e.files[n]))}),t}function f(e,t){var i=document.createElement("iframe"),r=h(e);return r.id="sb",r.action="https://stackblitz.com/run"+n(t),i.src="data:text/html;charset=utf-8,<html><head><title></title></head><body>"+encodeURI(r.outerHTML)+"<script>document.getElementById('sb').submit();<\/script></body></html>",i}function m(e,t){document.createElement("iframe");var i=h(e);i.action="https://stackblitz.com/run"+n(t),i.target=o(t),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}var v={connect:function(e){if(!e||!e.contentWindow)return Promise.reject("Provided element is not an iframe.");var t=l(e);return t?t.pending:new p(e).pending},openGithubProject:function(e,t){window.open("https://stackblitz.com/github/"+e+n(t),o(t))},openProject:function(e,t){m(e,t)},openProjectId:function(e,t){window.open("https://stackblitz.com/edit/"+e+n(t),o(t))},embedGithubProject:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/github/"+t+n(o),i(a,d,o),v.connect(d)},embedProject:function(e,t,n){var o=r(e),a=f(t,n);return i(o,a,n),v.connect(a)},embedProjectId:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/edit/"+t+n(o),i(a,d,o),v.connect(d)}};module.exports=v;
var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.ctl&&(t+="ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),(e.view&&"preview"===e.view||"editor"===e.view)&&(t+=(t.length?"&":"")+"view="+e.view),t.length?"?"+t:t):t}function i(e,t,n){if(null===e.parentNode)throw new Error("Invalid Element");t.id=e.id,a(t,n),e.parentNode.replaceChild(t,e)}function r(e){if("string"==typeof e){var t=document.getElementById(e);if(null!==t)return t}else if(e instanceof HTMLElement)return e;throw new Error("Invalid Element")}function o(e){return e&&!1===e.newWindow?"_self":"_blank"}function a(t,n){n&&(n.hasOwnProperty("height")&&(t.height=""+n.height),n.hasOwnProperty("width")&&(t.width=""+n.width)),t.height||(t.height=e),t.width||t.setAttribute("style","width:100%;")}var d=function(e){var t=this;this.pending={},this.port=e,this.port.onmessage=function(e){if(e.data.payload.__reqid){var n=e.data.payload.__reqid,i=e.data.payload.__success;if(t.pending[n]){if(delete e.data.payload.__reqid,delete e.data.payload.__success,i){var r=0===Object.keys(e.data.payload).length&&e.data.payload.constructor===Object?null:e.data.payload;t.pending[n].resolve(r)}else{var o=e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type;t.pending[n].reject(o)}delete t.pending[n]}}}};d.prototype.request=function(e){var n=this,i=t();return new Promise(function(t,r){n.pending[i]={resolve:t,reject:r},e.payload.__reqid=i,n.port.postMessage(e)})};var c=function(e,t){var n=this;this.rdc=new d(e),this.preview={},Object.defineProperty(this.preview,"origin",{value:t.previewOrigin,writable:!1}),this.editor={openFile:function(e){return n.rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})}}};c.prototype.applyFsDiff=function(e){return this.rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},c.prototype.getFsSnapshot=function(){return this.rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})};var p=[],s=function(e){var n=this;this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){t.data.action&&"SDK_INIT_SUCCESS"===t.data.action&&t.data.id===n.id&&(n.vm=new c(t.ports[0],t.data.payload),e(n.vm),o())},r=function(){n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",i)}window.addEventListener("message",i),r();var a=0,d=window.setInterval(function(){if(n.vm)o();else{if(a>=20)return o(),t("Timeout: Unable to establish a connection with the StackBlitz VM"),void p.forEach(function(e,t){e.id===n.id&&p.splice(t,1)});a++,r()}},500)}),p.push(this)},l=function(e){var t=e instanceof Element?"element":"id",n=p.find(function(n){return n[t]===e});return n||null},u=["typescript","create-react-app","angular-cli"];function h(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function f(e){if(-1===u.indexOf(e.template))throw new Error("Unsupported project template, must be one of: "+u.join(", "));var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(h("project[title]",e.title)),t.appendChild(h("project[description]",e.description)),t.appendChild(h("project[template]",e.template)),e.tags&&e.tags.forEach(function(e,n){t.appendChild(h("project[tags]["+n+"]",e))}),e.dependencies&&t.appendChild(h("project[dependencies]",JSON.stringify(e.dependencies))),Object.keys(e.files).forEach(function(n){t.appendChild(h("project[files]["+n+"]",e.files[n]))}),t}function m(e,t){var i=f(e);i.action="https://stackblitz.com/run"+n(t),i.id="sb";var r=document.createElement("iframe");return r.src="data:text/html;charset=utf-8,<html><head><title></title></head><body>"+encodeURI(i.outerHTML)+"<script>document.getElementById('sb').submit();<\/script></body></html>",r}function v(e,t){var i=f(e);i.action="https://stackblitz.com/run"+n(t),i.target=o(t),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}var w={connect:function(e){if(!e||!e.contentWindow)return Promise.reject("Provided element is not an iframe.");var t=l(e);return t?t.pending:new s(e).pending},openGithubProject:function(e,t){window.open("https://stackblitz.com/github/"+e+n(t),o(t))},openProject:function(e,t){v(e,t)},openProjectId:function(e,t){window.open("https://stackblitz.com/edit/"+e+n(t),o(t))},embedGithubProject:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/github/"+t+n(o),i(a,d,o),w.connect(d)},embedProject:function(e,t,n){var o=r(e),a=m(t,n);return i(o,a,n),w.connect(a)},embedProjectId:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/edit/"+t+n(o),i(a,d,o),w.connect(d)}};module.exports=w;
//# sourceMappingURL=sdk.js.map

@@ -1,2 +0,2 @@

var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.ctl&&(t+="ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),(e.view&&"preview"===e.view||"editor"===e.view)&&(t+=(t.length?"&":"")+"view="+e.view),t.length?"?"+t:t):t}function i(e,t,n){if(null===e.parentNode)throw"Invalid Element";t.id=e.id,a(t,n),e.parentNode.replaceChild(t,e)}function r(e){if("string"==typeof e){var t=document.getElementById(e);if(null!==t)return t}else if(e instanceof HTMLElement)return e;throw"Invalid Element"}function o(e){return e&&!1===e.newWindow?"_self":"_blank"}function a(t,n){n&&(n.hasOwnProperty("height")&&(t.height=""+n.height),n.hasOwnProperty("width")&&(t.width=""+n.width)),t.height||(t.height=e),t.width||t.setAttribute("style","width:100%;")}var d=function(e){var t=this;this.pending={},this.port=e,this.port.onmessage=function(e){if(e.data.payload.__reqid){var n=e.data.payload.__reqid,i=e.data.payload.__success;if(t.pending[n]){if(delete e.data.payload.__reqid,delete e.data.payload.__success,i){var r=0===Object.keys(e.data.payload).length&&e.data.payload.constructor===Object?null:e.data.payload;t.pending[n].resolve(r)}else{var o=e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type;t.pending[n].reject(o)}delete t.pending[n]}}}};d.prototype.request=function(e){var n=this,i=t();return new Promise(function(t,r){n.pending[i]={resolve:t,reject:r},e.payload.__reqid=i,n.port.postMessage(e)})};var c=function(e,t){var n=this;this.rdc=new d(e),this.preview={},Object.defineProperty(this.preview,"origin",{value:t.previewOrigin,writable:!1}),this.editor={openFile:function(e){return n.rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})}}};c.prototype.applyFsDiff=function(e){return this.rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},c.prototype.getFsSnapshot=function(){return this.rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})};var s=[],p=function(e){var n=this;this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){t.data.action&&"SDK_INIT_SUCCESS"===t.data.action&&t.data.id===n.id&&(n.vm=new c(t.ports[0],t.data.payload),e(n.vm),o())},r=function(){n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",i)}window.addEventListener("message",i),r();var a=0,d=window.setInterval(function(){if(n.vm)o();else{if(a>=20)return o(),t("Timeout: Unable to establish a connection with the StackBlitz VM"),void s.forEach(function(e,t){e.id===n.id&&s.splice(t,1)});a++,r()}},500)}),s.push(this)},l=function(e){var t=e instanceof Element?"element":"id",n=s.find(function(n){return n[t]===e});return n||null};function u(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function h(e){var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(u("project[title]",e.title)),t.appendChild(u("project[description]",e.description)),t.appendChild(u("project[template]",e.template)),e.tags&&e.tags.forEach(function(e,n){t.appendChild(u("project[tags]["+n+"]",e))}),e.dependencies&&t.appendChild(u("project[dependencies]",JSON.stringify(e.dependencies))),Object.keys(e.files).forEach(function(n){t.appendChild(u("project[files]["+n+"]",e.files[n]))}),t}function f(e,t){var i=document.createElement("iframe"),r=h(e);return r.id="sb",r.action="https://stackblitz.com/run"+n(t),i.src="data:text/html;charset=utf-8,<html><head><title></title></head><body>"+encodeURI(r.outerHTML)+"<script>document.getElementById('sb').submit();<\/script></body></html>",i}function m(e,t){document.createElement("iframe");var i=h(e);i.action="https://stackblitz.com/run"+n(t),i.target=o(t),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}var v={connect:function(e){if(!e||!e.contentWindow)return Promise.reject("Provided element is not an iframe.");var t=l(e);return t?t.pending:new p(e).pending},openGithubProject:function(e,t){window.open("https://stackblitz.com/github/"+e+n(t),o(t))},openProject:function(e,t){m(e,t)},openProjectId:function(e,t){window.open("https://stackblitz.com/edit/"+e+n(t),o(t))},embedGithubProject:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/github/"+t+n(o),i(a,d,o),v.connect(d)},embedProject:function(e,t,n){var o=r(e),a=f(t,n);return i(o,a,n),v.connect(a)},embedProjectId:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/edit/"+t+n(o),i(a,d,o),v.connect(d)}};export default v;
var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.ctl&&(t+="ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),(e.view&&"preview"===e.view||"editor"===e.view)&&(t+=(t.length?"&":"")+"view="+e.view),t.length?"?"+t:t):t}function i(e,t,n){if(null===e.parentNode)throw new Error("Invalid Element");t.id=e.id,a(t,n),e.parentNode.replaceChild(t,e)}function r(e){if("string"==typeof e){var t=document.getElementById(e);if(null!==t)return t}else if(e instanceof HTMLElement)return e;throw new Error("Invalid Element")}function o(e){return e&&!1===e.newWindow?"_self":"_blank"}function a(t,n){n&&(n.hasOwnProperty("height")&&(t.height=""+n.height),n.hasOwnProperty("width")&&(t.width=""+n.width)),t.height||(t.height=e),t.width||t.setAttribute("style","width:100%;")}var d=function(e){var t=this;this.pending={},this.port=e,this.port.onmessage=function(e){if(e.data.payload.__reqid){var n=e.data.payload.__reqid,i=e.data.payload.__success;if(t.pending[n]){if(delete e.data.payload.__reqid,delete e.data.payload.__success,i){var r=0===Object.keys(e.data.payload).length&&e.data.payload.constructor===Object?null:e.data.payload;t.pending[n].resolve(r)}else{var o=e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type;t.pending[n].reject(o)}delete t.pending[n]}}}};d.prototype.request=function(e){var n=this,i=t();return new Promise(function(t,r){n.pending[i]={resolve:t,reject:r},e.payload.__reqid=i,n.port.postMessage(e)})};var c=function(e,t){var n=this;this.rdc=new d(e),this.preview={},Object.defineProperty(this.preview,"origin",{value:t.previewOrigin,writable:!1}),this.editor={openFile:function(e){return n.rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})}}};c.prototype.applyFsDiff=function(e){return this.rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},c.prototype.getFsSnapshot=function(){return this.rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})};var p=[],s=function(e){var n=this;this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){t.data.action&&"SDK_INIT_SUCCESS"===t.data.action&&t.data.id===n.id&&(n.vm=new c(t.ports[0],t.data.payload),e(n.vm),o())},r=function(){n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",i)}window.addEventListener("message",i),r();var a=0,d=window.setInterval(function(){if(n.vm)o();else{if(a>=20)return o(),t("Timeout: Unable to establish a connection with the StackBlitz VM"),void p.forEach(function(e,t){e.id===n.id&&p.splice(t,1)});a++,r()}},500)}),p.push(this)},l=function(e){var t=e instanceof Element?"element":"id",n=p.find(function(n){return n[t]===e});return n||null},u=["typescript","create-react-app","angular-cli"];function h(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function f(e){if(-1===u.indexOf(e.template))throw new Error("Unsupported project template, must be one of: "+u.join(", "));var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(h("project[title]",e.title)),t.appendChild(h("project[description]",e.description)),t.appendChild(h("project[template]",e.template)),e.tags&&e.tags.forEach(function(e,n){t.appendChild(h("project[tags]["+n+"]",e))}),e.dependencies&&t.appendChild(h("project[dependencies]",JSON.stringify(e.dependencies))),Object.keys(e.files).forEach(function(n){t.appendChild(h("project[files]["+n+"]",e.files[n]))}),t}function m(e,t){var i=f(e);i.action="https://stackblitz.com/run"+n(t),i.id="sb";var r=document.createElement("iframe");return r.src="data:text/html;charset=utf-8,<html><head><title></title></head><body>"+encodeURI(i.outerHTML)+"<script>document.getElementById('sb').submit();<\/script></body></html>",r}function v(e,t){var i=f(e);i.action="https://stackblitz.com/run"+n(t),i.target=o(t),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}var w={connect:function(e){if(!e||!e.contentWindow)return Promise.reject("Provided element is not an iframe.");var t=l(e);return t?t.pending:new s(e).pending},openGithubProject:function(e,t){window.open("https://stackblitz.com/github/"+e+n(t),o(t))},openProject:function(e,t){v(e,t)},openProjectId:function(e,t){window.open("https://stackblitz.com/edit/"+e+n(t),o(t))},embedGithubProject:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/github/"+t+n(o),i(a,d,o),w.connect(d)},embedProject:function(e,t,n){var o=r(e),a=m(t,n);return i(o,a,n),w.connect(a)},embedProjectId:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/edit/"+t+n(o),i(a,d,o),w.connect(d)}};export default w;
//# sourceMappingURL=sdk.m.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.StackBlitzSDK=t()}(this,function(){var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.ctl&&(t+="ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),(e.view&&"preview"===e.view||"editor"===e.view)&&(t+=(t.length?"&":"")+"view="+e.view),t.length?"?"+t:t):t}function i(t,n,i){if(null===t.parentNode)throw"Invalid Element";n.id=t.id,function(t,n){n&&(n.hasOwnProperty("height")&&(t.height=""+n.height),n.hasOwnProperty("width")&&(t.width=""+n.width));t.height||(t.height=e);t.width||t.setAttribute("style","width:100%;")}(n,i),t.parentNode.replaceChild(n,t)}function o(e){if("string"==typeof e){var t=document.getElementById(e);if(null!==t)return t}else if(e instanceof HTMLElement)return e;throw"Invalid Element"}function r(e){return e&&!1===e.newWindow?"_self":"_blank"}var a=function(e){var t=this;this.pending={},this.port=e,this.port.onmessage=function(e){if(e.data.payload.__reqid){var n=e.data.payload.__reqid,i=e.data.payload.__success;if(t.pending[n]){if(delete e.data.payload.__reqid,delete e.data.payload.__success,i){var o=0===Object.keys(e.data.payload).length&&e.data.payload.constructor===Object?null:e.data.payload;t.pending[n].resolve(o)}else{var r=e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type;t.pending[n].reject(r)}delete t.pending[n]}}}};a.prototype.request=function(e){var n=this,i=t();return new Promise(function(t,o){n.pending[i]={resolve:t,reject:o},e.payload.__reqid=i,n.port.postMessage(e)})};var d=function(e,t){var n=this;this.rdc=new a(e),this.preview={},Object.defineProperty(this.preview,"origin",{value:t.previewOrigin,writable:!1}),this.editor={openFile:function(e){return n.rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})}}};d.prototype.applyFsDiff=function(e){return this.rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},d.prototype.getFsSnapshot=function(){return this.rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})};var c=[];function s(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function p(e){var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(s("project[title]",e.title)),t.appendChild(s("project[description]",e.description)),t.appendChild(s("project[template]",e.template)),e.tags&&e.tags.forEach(function(e,n){t.appendChild(s("project[tags]["+n+"]",e))}),e.dependencies&&t.appendChild(s("project[dependencies]",JSON.stringify(e.dependencies))),Object.keys(e.files).forEach(function(n){t.appendChild(s("project[files]["+n+"]",e.files[n]))}),t}var l={connect:function(e){if(!e||!e.contentWindow)return Promise.reject("Provided element is not an iframe.");var n,i,o=(i=(n=e)instanceof Element?"element":"id",c.find(function(e){return e[i]===n})||null);return o?o.pending:new function(e){var n=this;this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){t.data.action&&"SDK_INIT_SUCCESS"===t.data.action&&t.data.id===n.id&&(n.vm=new d(t.ports[0],t.data.payload),e(n.vm),r())},o=function(){n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function r(){window.clearInterval(s),window.removeEventListener("message",i)}window.addEventListener("message",i),o();var a=0,s=window.setInterval(function(){if(n.vm)r();else{if(a>=20)return r(),t("Timeout: Unable to establish a connection with the StackBlitz VM"),void c.forEach(function(e,t){e.id===n.id&&c.splice(t,1)});a++,o()}},500)}),c.push(this)}(e).pending},openGithubProject:function(e,t){window.open("https://stackblitz.com/github/"+e+n(t),r(t))},openProject:function(e,t){!function(e,t){document.createElement("iframe");var i=p(e);i.action="https://stackblitz.com/run"+n(t),i.target=r(t),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}(e,t)},openProjectId:function(e,t){window.open("https://stackblitz.com/edit/"+e+n(t),r(t))},embedGithubProject:function(e,t,r){var a=o(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/github/"+t+n(r),i(a,d,r),l.connect(d)},embedProject:function(e,t,r){var a,d,c,s,u=o(e),h=(a=t,d=r,c=document.createElement("iframe"),(s=p(a)).id="sb",s.action="https://stackblitz.com/run"+n(d),c.src="data:text/html;charset=utf-8,<html><head><title></title></head><body>"+encodeURI(s.outerHTML)+"<script>document.getElementById('sb').submit();<\/script></body></html>",c);return i(u,h,r),l.connect(h)},embedProjectId:function(e,t,r){var a=o(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/edit/"+t+n(r),i(a,d,r),l.connect(d)}};return l});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.StackBlitzSDK=t()}(this,function(){var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.ctl&&(t+="ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),(e.view&&"preview"===e.view||"editor"===e.view)&&(t+=(t.length?"&":"")+"view="+e.view),t.length?"?"+t:t):t}function i(t,n,i){if(null===t.parentNode)throw new Error("Invalid Element");n.id=t.id,function(t,n){n&&(n.hasOwnProperty("height")&&(t.height=""+n.height),n.hasOwnProperty("width")&&(t.width=""+n.width));t.height||(t.height=e);t.width||t.setAttribute("style","width:100%;")}(n,i),t.parentNode.replaceChild(n,t)}function r(e){if("string"==typeof e){var t=document.getElementById(e);if(null!==t)return t}else if(e instanceof HTMLElement)return e;throw new Error("Invalid Element")}function o(e){return e&&!1===e.newWindow?"_self":"_blank"}var a=function(e){var t=this;this.pending={},this.port=e,this.port.onmessage=function(e){if(e.data.payload.__reqid){var n=e.data.payload.__reqid,i=e.data.payload.__success;if(t.pending[n]){if(delete e.data.payload.__reqid,delete e.data.payload.__success,i){var r=0===Object.keys(e.data.payload).length&&e.data.payload.constructor===Object?null:e.data.payload;t.pending[n].resolve(r)}else{var o=e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type;t.pending[n].reject(o)}delete t.pending[n]}}}};a.prototype.request=function(e){var n=this,i=t();return new Promise(function(t,r){n.pending[i]={resolve:t,reject:r},e.payload.__reqid=i,n.port.postMessage(e)})};var d=function(e,t){var n=this;this.rdc=new a(e),this.preview={},Object.defineProperty(this.preview,"origin",{value:t.previewOrigin,writable:!1}),this.editor={openFile:function(e){return n.rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})}}};d.prototype.applyFsDiff=function(e){return this.rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},d.prototype.getFsSnapshot=function(){return this.rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})};var c=[],p=["typescript","create-react-app","angular-cli"];function s(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function l(e){if(-1===p.indexOf(e.template))throw new Error("Unsupported project template, must be one of: "+p.join(", "));var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(s("project[title]",e.title)),t.appendChild(s("project[description]",e.description)),t.appendChild(s("project[template]",e.template)),e.tags&&e.tags.forEach(function(e,n){t.appendChild(s("project[tags]["+n+"]",e))}),e.dependencies&&t.appendChild(s("project[dependencies]",JSON.stringify(e.dependencies))),Object.keys(e.files).forEach(function(n){t.appendChild(s("project[files]["+n+"]",e.files[n]))}),t}var u={connect:function(e){if(!e||!e.contentWindow)return Promise.reject("Provided element is not an iframe.");var n,i,r=(i=(n=e)instanceof Element?"element":"id",c.find(function(e){return e[i]===n})||null);return r?r.pending:new function(e){var n=this;this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){t.data.action&&"SDK_INIT_SUCCESS"===t.data.action&&t.data.id===n.id&&(n.vm=new d(t.ports[0],t.data.payload),e(n.vm),o())},r=function(){n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(p),window.removeEventListener("message",i)}window.addEventListener("message",i),r();var a=0,p=window.setInterval(function(){if(n.vm)o();else{if(a>=20)return o(),t("Timeout: Unable to establish a connection with the StackBlitz VM"),void c.forEach(function(e,t){e.id===n.id&&c.splice(t,1)});a++,r()}},500)}),c.push(this)}(e).pending},openGithubProject:function(e,t){window.open("https://stackblitz.com/github/"+e+n(t),o(t))},openProject:function(e,t){var i,r;i=t,(r=l(e)).action="https://stackblitz.com/run"+n(i),r.target=o(i),document.body.appendChild(r),r.submit(),document.body.removeChild(r)},openProjectId:function(e,t){window.open("https://stackblitz.com/edit/"+e+n(t),o(t))},embedGithubProject:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/github/"+t+n(o),i(a,d,o),u.connect(d)},embedProject:function(e,t,o){var a=r(e),d=function(e,t){var i=l(e);i.action="https://stackblitz.com/run"+n(t),i.id="sb";var r=document.createElement("iframe");return r.src="data:text/html;charset=utf-8,<html><head><title></title></head><body>"+encodeURI(i.outerHTML)+"<script>document.getElementById('sb').submit();<\/script></body></html>",r}(t,o);return i(a,d,o),u.connect(d)},embedProjectId:function(e,t,o){var a=r(e),d=document.createElement("iframe");return d.src="https://stackblitz.com/edit/"+t+n(o),i(a,d,o),u.connect(d)}};return u});
//# sourceMappingURL=sdk.umd.js.map
{
"name": "@stackblitz/sdk",
"version": "0.3.2",
"version": "0.3.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "./bundles/sdk.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc