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 1.1.1 to 1.2.0

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.forceEmbedLayout&&(t+="embed=1"),e.clickToLoad&&(t+=(t.length?"&":"")+"ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),!e.view||"preview"!==e.view&&"editor"!==e.view||(t+=(t.length?"&":"")+"view="+e.view),e.hideExplorer&&(t+=(t.length?"&":"")+"hideExplorer=1"),e.hideNavigation&&(t+=(t.length?"&":"")+"hideNavigation=1;"),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:{}})},c.prototype.getDependencies=function(){return this.rdc.request({type:"SDK_GET_DEPS_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","javascript"];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);return i.action="https://stackblitz.com/run"+n(t),i.id="sb","<html><head><title></title></head><body>"+i.outerHTML+"<script>document.getElementById('sb').submit();<\/script></body></html>"}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),d=document.createElement("iframe");return i(o,d,n),d.contentDocument.write(a),w.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),w.connect(d)}};module.exports=w;
var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.forceEmbedLayout&&(t+="embed=1"),e.clickToLoad&&(t+=(t.length?"&":"")+"ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),!e.view||"preview"!==e.view&&"editor"!==e.view||(t+=(t.length?"&":"")+"view="+e.view),e.hideExplorer&&(t+=(t.length?"&":"")+"hideExplorer=1"),e.hideNavigation&&(t+=(t.length?"&":"")+"hideNavigation=1;"),e.hideDevTools&&(t+=(t.length?"&":"")+"hidedevtools=1"),"number"==typeof e.devToolsHeight&&e.devToolsHeight>0&&e.devToolsHeight<100&&(t+=(t.length?"&":"")+"devtoolsheight="+e.devToolsHeight),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 o(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 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{t.pending[n].reject(e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type)}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:{}})},d.prototype.getDependencies=function(){return this.rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})};var c=[],s=["typescript","create-react-app","angular-cli","javascript"],p="https://stackblitz.com/run";function l(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function u(e){if(-1===s.indexOf(e.template))throw new Error("Unsupported project template, must be one of: "+s.join(", "));var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(l("project[title]",e.title)),t.appendChild(l("project[description]",e.description)),t.appendChild(l("project[template]",e.template)),e.tags&&e.tags.forEach(function(e){t.appendChild(l("project[tags][]",e))}),e.dependencies&&t.appendChild(l("project[dependencies]",JSON.stringify(e.dependencies))),e.settings&&t.appendChild(l("project[settings]",JSON.stringify(e.settings))),Object.keys(e.files).forEach(function(n){t.appendChild(l("project[files]["+n+"]",e.files[n]))}),t}var h={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&&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){var i=u(e);i.action=p+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),h.connect(d)},embedProject:function(e,t,r){var a=o(e),d=function(e,t){var i=u(e);return i.action=p+n(t),i.id="sb","<html><head><title></title></head><body>"+i.outerHTML+"<script>document.getElementById('sb').submit();<\/script></body></html>"}(t,r),c=document.createElement("iframe");return i(a,c,r),c.contentDocument&&c.contentDocument.write(d),h.connect(c)},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),h.connect(d)}};module.exports=h;
//# 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.forceEmbedLayout&&(t+="embed=1"),e.clickToLoad&&(t+=(t.length?"&":"")+"ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),!e.view||"preview"!==e.view&&"editor"!==e.view||(t+=(t.length?"&":"")+"view="+e.view),e.hideExplorer&&(t+=(t.length?"&":"")+"hideExplorer=1"),e.hideNavigation&&(t+=(t.length?"&":"")+"hideNavigation=1;"),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:{}})},c.prototype.getDependencies=function(){return this.rdc.request({type:"SDK_GET_DEPS_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","javascript"];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);return i.action="https://stackblitz.com/run"+n(t),i.id="sb","<html><head><title></title></head><body>"+i.outerHTML+"<script>document.getElementById('sb').submit();<\/script></body></html>"}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),d=document.createElement("iframe");return i(o,d,n),d.contentDocument.write(a),w.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),w.connect(d)}};export default w;
var e="300";function t(){return Math.random().toString(36).substring(7)}function n(e){var t="";return e?(e.forceEmbedLayout&&(t+="embed=1"),e.clickToLoad&&(t+=(t.length?"&":"")+"ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),!e.view||"preview"!==e.view&&"editor"!==e.view||(t+=(t.length?"&":"")+"view="+e.view),e.hideExplorer&&(t+=(t.length?"&":"")+"hideExplorer=1"),e.hideNavigation&&(t+=(t.length?"&":"")+"hideNavigation=1;"),e.hideDevTools&&(t+=(t.length?"&":"")+"hidedevtools=1"),"number"==typeof e.devToolsHeight&&e.devToolsHeight>0&&e.devToolsHeight<100&&(t+=(t.length?"&":"")+"devtoolsheight="+e.devToolsHeight),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 o(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 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{t.pending[n].reject(e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type)}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:{}})},d.prototype.getDependencies=function(){return this.rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})};var c=[],s=["typescript","create-react-app","angular-cli","javascript"],p="https://stackblitz.com/run";function l(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function u(e){if(-1===s.indexOf(e.template))throw new Error("Unsupported project template, must be one of: "+s.join(", "));var t=document.createElement("form");return t.method="POST",t.setAttribute("style","display:none;"),t.appendChild(l("project[title]",e.title)),t.appendChild(l("project[description]",e.description)),t.appendChild(l("project[template]",e.template)),e.tags&&e.tags.forEach(function(e){t.appendChild(l("project[tags][]",e))}),e.dependencies&&t.appendChild(l("project[dependencies]",JSON.stringify(e.dependencies))),e.settings&&t.appendChild(l("project[settings]",JSON.stringify(e.settings))),Object.keys(e.files).forEach(function(n){t.appendChild(l("project[files]["+n+"]",e.files[n]))}),t}var h={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&&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){var i=u(e);i.action=p+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),h.connect(d)},embedProject:function(e,t,r){var a=o(e),d=function(e,t){var i=u(e);return i.action=p+n(t),i.id="sb","<html><head><title></title></head><body>"+i.outerHTML+"<script>document.getElementById('sb').submit();<\/script></body></html>"}(t,r),c=document.createElement("iframe");return i(a,c,r),c.contentDocument&&c.contentDocument.write(d),h.connect(c)},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),h.connect(d)}};export default h;
//# 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.forceEmbedLayout&&(t+="embed=1"),e.clickToLoad&&(t+=(t.length?"&":"")+"ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),!e.view||"preview"!==e.view&&"editor"!==e.view||(t+=(t.length?"&":"")+"view="+e.view),e.hideExplorer&&(t+=(t.length?"&":"")+"hideExplorer=1"),e.hideNavigation&&(t+=(t.length?"&":"")+"hideNavigation=1;"),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 o(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 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:{}})},d.prototype.getDependencies=function(){return this.rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})};var c=[],p=["typescript","create-react-app","angular-cli","javascript"];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,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(p),window.removeEventListener("message",i)}window.addEventListener("message",i),o();var a=0,p=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){var i,o;i=t,(o=l(e)).action="https://stackblitz.com/run"+n(i),o.target=r(i),document.body.appendChild(o),o.submit(),document.body.removeChild(o)},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),u.connect(d)},embedProject:function(e,t,r){var a,d,c=o(e),p=(a=r,(d=l(t)).action="https://stackblitz.com/run"+n(a),d.id="sb","<html><head><title></title></head><body>"+d.outerHTML+"<script>document.getElementById('sb').submit();<\/script></body></html>"),s=document.createElement("iframe");return i(c,s,r),s.contentDocument.write(p),u.connect(s)},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),u.connect(d)}};return u});
!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.forceEmbedLayout&&(t+="embed=1"),e.clickToLoad&&(t+=(t.length?"&":"")+"ctl=1"),e.openFile&&(t+=(t.length?"&":"")+"file="+e.openFile),!e.view||"preview"!==e.view&&"editor"!==e.view||(t+=(t.length?"&":"")+"view="+e.view),e.hideExplorer&&(t+=(t.length?"&":"")+"hideExplorer=1"),e.hideNavigation&&(t+=(t.length?"&":"")+"hideNavigation=1;"),e.hideDevTools&&(t+=(t.length?"&":"")+"hidedevtools=1"),"number"==typeof e.devToolsHeight&&e.devToolsHeight>0&&e.devToolsHeight<100&&(t+=(t.length?"&":"")+"devtoolsheight="+e.devToolsHeight),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 o(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 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{t.pending[n].reject(e.data.payload.error?e.data.type+": "+e.data.payload.error:e.data.type)}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:{}})},d.prototype.getDependencies=function(){return this.rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})};var c=[],p=["typescript","create-react-app","angular-cli","javascript"],s="https://stackblitz.com/run";function l(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function u(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(l("project[title]",e.title)),t.appendChild(l("project[description]",e.description)),t.appendChild(l("project[template]",e.template)),e.tags&&e.tags.forEach(function(e){t.appendChild(l("project[tags][]",e))}),e.dependencies&&t.appendChild(l("project[dependencies]",JSON.stringify(e.dependencies))),e.settings&&t.appendChild(l("project[settings]",JSON.stringify(e.settings))),Object.keys(e.files).forEach(function(n){t.appendChild(l("project[files]["+n+"]",e.files[n]))}),t}var h={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&&n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function r(){window.clearInterval(p),window.removeEventListener("message",i)}window.addEventListener("message",i),o();var a=0,p=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){var i=u(e);i.action=s+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),h.connect(d)},embedProject:function(e,t,r){var a=o(e),d=function(e,t){var i=u(e);return i.action=s+n(t),i.id="sb","<html><head><title></title></head><body>"+i.outerHTML+"<script>document.getElementById('sb').submit();<\/script></body></html>"}(t,r),c=document.createElement("iframe");return i(a,c,r),c.contentDocument&&c.contentDocument.write(d),h.connect(c)},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),h.connect(d)}};return h});
//# sourceMappingURL=sdk.umd.js.map
{
"name": "@stackblitz/sdk",
"version": "1.1.1",
"version": "1.2.0",
"description": "",

@@ -13,3 +13,3 @@ "main": "./bundles/sdk.js",

"compile": "tsc --p tsconfig.json",
"bundle": "microbundle --i dist/index.js --name StackBlitzSDK --target=browser",
"bundle": "npx microbundle --i dist/index.js --name StackBlitzSDK --target=browser",
"docs": "typedoc --out docs/ src/index.ts"

@@ -16,0 +16,0 @@ },

@@ -19,5 +19,14 @@ export interface RequestData {

};
settings?: {
compile?: {
trigger?: 'auto' | 'keystroke' | 'save' | string;
action?: 'hmr' | 'refresh' | string;
clearConsole?: boolean;
};
};
}
export interface ProjectOptions {
openFile?: string;
hideDevTools?: boolean;
devToolsHeight?: number;
}

@@ -24,0 +33,0 @@ export interface OpenOptions extends ProjectOptions {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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