Socket
Socket
Sign inDemoInstall

@stackblitz/sdk

Package Overview
Dependencies
0
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.0-alpha.2 to 1.7.0-alpha.3

typings/constants.d.ts

2

bundles/sdk.js

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

function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function n(e,t){return""+i(t)+e+o(t)}function r(e,t){var n={forceEmbedLayout:!0};return t&&"object"==typeof t&&Object.assign(n,t),""+i(n)+e+o(n)}function i(e){return void 0===e&&(e={}),"string"==typeof e.origin?e.origin:"https://stackblitz.com"}function o(t){void 0===t&&(t={});var n=[];t.forceEmbedLayout&&n.push("embed=1"),t.clickToLoad&&n.push("ctl=1");for(var r,i=function(t,n){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t))){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(t.openFile)?t.openFile:[t.openFile]);!(r=i()).done;){var o=r.value;"string"==typeof o&&""!==o.trim()&&n.push("file="+encodeURIComponent(o.trim()))}return"preview"!==t.view&&"editor"!==t.view||n.push("view="+t.view),"light"!==t.theme&&"dark"!==t.theme||n.push("theme="+t.theme),t.hideExplorer&&n.push("hideExplorer=1"),t.hideNavigation&&n.push("hideNavigation=1"),t.hideDevTools&&n.push("hideDevTools=1"),"number"==typeof t.devToolsHeight&&t.devToolsHeight>=0&&t.devToolsHeight<=100&&n.push("devToolsHeight="+Math.round(t.devToolsHeight)),n.length?"?"+n.join("&"):""}function a(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),function(e,t){t&&"object"==typeof t&&(Object.hasOwnProperty.call(t,"height")&&(e.height=""+t.height),Object.hasOwnProperty.call(t,"width")&&(e.width=""+t.width)),e.height||(e.height="300"),e.width||e.setAttribute("style","width:100%;")}(t,n),e.parentNode.replaceChild(t,e)}function d(e){if("string"==typeof e){var t=document.getElementById(e);if(!t)throw new Error("Could not find element with id '"+e+"'");return t}if(e instanceof HTMLElement)return e;throw new Error("Invalid element: "+e)}function c(e){return e&&!1===e.newWindow?"_self":"_blank"}var l=/*#__PURE__*/function(){function e(e){var t=this;this.port=void 0,this.pending={},this.port=e,this.port.onmessage=function(e){var n,r=e.data;if(null!=r&&null!=(n=r.payload)&&n.__reqid){var i=r.payload.__reqid,o=r.payload.__success;if(t.pending[i]){if(delete r.payload.__reqid,delete r.payload.__success,o){var a=0===Object.keys(r.payload).length&&r.payload.constructor===Object?null:r.payload;t.pending[i].resolve(a)}else t.pending[i].reject(r.payload.error?r.type+": "+r.payload.error:r.type);delete t.pending[i]}}}}return e.prototype.request=function(e){var n=this,r=t();return new Promise(function(t,i){n.pending[r]={resolve:t,reject:i},e.payload.__reqid=r,n.port.postMessage(e)})},e}(),s=/*#__PURE__*/function(){function e(e,t){var n=this;this._rdc=void 0,this.editor={openFile:function(e){return n._rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})},setTheme:function(e){return n._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:e}})},setView:function(e){return n._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:e}})},showSidebar:function(e){return void 0===e&&(e=!0),n._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:e}})}},this.preview={origin:"",getUrl:function(){return n._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}})},setUrl:function(e){return void 0===e&&(e="/"),n._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:e}})}},this._rdc=new l(e),Object.defineProperty(this.preview,"origin",{value:"string"==typeof t.previewOrigin?t.previewOrigin:null,writable:!1})}var t=e.prototype;return t.applyFsDiff=function(e){var t=function(e){return null!==e&&"object"==typeof e};if(!t(e)||!t(e.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(e.destroy))throw new Error("Invalid diff object: expected diff.create to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},t.getDependencies=function(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})},t.getFsSnapshot=function(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})},e}(),u=[],p=function(e){var n=this;this.element=void 0,this.id=void 0,this.pending=void 0,this.vm=void 0,this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var r=function(t){var r=t.data;"SDK_INIT_SUCCESS"===(null==r?void 0:r.action)&&r.id===n.id&&(n.vm=new s(t.ports[0],r.payload),e(n.vm),o())},i=function(){n.element.contentWindow&&n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",r)}window.addEventListener("message",r),i();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 u.forEach(function(e,t){e.id===n.id&&u.splice(t,1)});a++,i()}},500)}),u.push(this)},h=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"];function f(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function m(e){h.includes(e.template)||console.warn("Unsupported project.template: must be one of "+h.join(", "));var t="node"===e.template,n=document.createElement("form");return n.method="POST",n.setAttribute("style","display:none!important;"),n.appendChild(f("project[title]",e.title)),n.appendChild(f("project[description]",e.description)),n.appendChild(f("project[template]",e.template)),e.dependencies&&(t?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):n.appendChild(f("project[dependencies]",JSON.stringify(e.dependencies)))),e.settings&&n.appendChild(f("project[settings]",JSON.stringify(e.settings))),Object.keys(e.files).forEach(function(t){"string"==typeof e.files[t]&&n.appendChild(f("project[files]["+t+"]",e.files[t]))}),n}function v(e){var t,n,r,i;return null!=e&&e.contentWindow?(null!=(i=(n=e)instanceof Element?"element":"id",t=null!=(r=u.find(function(e){return e[i]===n}))?r:null)?t:new p(e)).pending:Promise.reject("Provided element is not an iframe.")}module.exports={__proto__:null,connect:v,openProject:function(e,t){!function(e,t){var r=m(e);r.action=n("/run",t),r.target=c(t),document.body.appendChild(r),r.submit(),document.body.removeChild(r)}(e,t)},openProjectId:function(e,t){var r=n("/edit/"+e,t),i=c(t);window.open(r,i)},openGithubProject:function(e,t){var r=n("/github/"+e,t),i=c(t);window.open(r,i)},embedProject:function(e,t,n){var i,o=d(e),c=function(e,t){var n=m(e);return n.action=r("/run",t),n.id="sb","<html><head><title></title></head><body>"+n.outerHTML+"<script>document.getElementById('"+n.id+"').submit();<\/script></body></html>"}(t,n),l=document.createElement("iframe");return a(o,l,n),null==(i=l.contentDocument)||i.write(c),v(l)},embedProjectId:function(e,t,n){var i=d(e),o=document.createElement("iframe");return o.src=r("/edit/"+t,n),a(i,o,n),v(o)},embedGithubProject:function(e,t,n){var i=d(e),o=document.createElement("iframe");return o.src=r("/github/"+t,n),a(i,o,n),v(o)}};
var e=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],t={clickToLoad:function(e){return r("ctl",e)},devToolsHeight:function(e){return function(e,t){return"number"==typeof t&&t>=0&&t<=100?"devToolsHeight="+Math.round(t):""}(0,e)},forceEmbedLayout:function(e){return r("embed",e)},hideDevTools:function(e){return r("hideDevTools",e)},hideExplorer:function(e){return r("hideExplorer",e)},hideNavigation:function(e){return r("hideNavigation",e)},showSidebar:function(e){return function(e,t){return"boolean"==typeof t?"showSidebar="+(t?"1":"0"):""}(0,e)},openFile:function(e){return function(e,t){return(Array.isArray(t)?t:[t]).filter(function(e){return"string"==typeof e&&""!==e.trim()}).map(function(e){return"file="+encodeURIComponent(e.trim())})}(0,e).join("&")},theme:function(e){return i("theme",["light","dark"],e)},view:function(e){return i("view",["preview","editor"],e)}};function n(e){void 0===e&&(e={});var n=Object.entries(e).map(function(e){var n=e[0],r=e[1];return null!=r&&t.hasOwnProperty(n)?t[n](r):""}).filter(Boolean);return n.length?"?"+n.join("&"):""}function r(e,t){return!0===t?e+"=1":""}function i(e,t,n){return"string"==typeof n&&t.includes(n)?e+"="+n:""}function o(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function a(e,t){return""+c(t)+e+n(t)}function d(e,t){var r={forceEmbedLayout:!0};return t&&"object"==typeof t&&Object.assign(r,t),""+c(r)+e+n(r)}function c(e){return void 0===e&&(e={}),"string"==typeof e.origin?e.origin:"https://stackblitz.com"}function u(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),function(e,t){t&&"object"==typeof t&&(Object.hasOwnProperty.call(t,"height")&&(e.height=""+t.height),Object.hasOwnProperty.call(t,"width")&&(e.width=""+t.width)),e.height||(e.height="300"),e.width||e.setAttribute("style","width:100%;")}(t,n),e.parentNode.replaceChild(t,e)}function s(e){if("string"==typeof e){var t=document.getElementById(e);if(!t)throw new Error("Could not find element with id '"+e+"'");return t}if(e instanceof HTMLElement)return e;throw new Error("Invalid element: "+e)}function l(e){return e&&!1===e.newWindow?"_self":"_blank"}function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}var f=/*#__PURE__*/function(){function e(e){this.port=void 0,this.pending={},this.port=e,this.port.onmessage=this.messageListener.bind(this)}var t=e.prototype;return t.request=function(e){var t=this,n=e.type,r=e.payload,i=o();return new Promise(function(e,o){t.pending[i]={resolve:e,reject:o},t.port.postMessage({type:n,payload:p({},r,{__reqid:i})})})},t.messageListener=function(e){var t;if("string"==typeof(null==(t=e.data.payload)?void 0:t.__reqid)){var n=e.data,r=n.type,i=n.payload,o=i.__reqid,a=i.__error;this.pending[o]&&(i.__success?this.pending[o].resolve(function(e){var t=p({},e);return delete t.__reqid,delete t.__success,delete t.__error,Object.keys(t).length?t:null}(i)):this.pending[o].reject(a?r+": "+a:r),delete this.pending[o])}},e}(),h=/*#__PURE__*/function(){function e(e,t){var n=this;this._rdc=void 0,this.editor={openFile:function(e){return n._rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})},setCurrentFile:function(e){return n._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:e}})},setTheme:function(e){return n._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:e}})},setView:function(e){return n._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:e}})},showSidebar:function(e){return void 0===e&&(e=!0),n._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:e}})}},this.preview={origin:"",getUrl:function(){return n._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(function(e){var t;return null!=(t=null==e?void 0:e.url)?t:null})},setUrl:function(e){if(void 0===e&&(e="/"),"string"!=typeof e||!e.startsWith("/"))throw new Error("Invalid argument: expected a path starting with '/', got '"+e+"'");return n._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:e}})}},this._rdc=new f(e),Object.defineProperty(this.preview,"origin",{value:"string"==typeof t.previewOrigin?t.previewOrigin:null,writable:!1})}var t=e.prototype;return t.applyFsDiff=function(e){var t=function(e){return null!==e&&"object"==typeof e};if(!t(e)||!t(e.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(e.destroy))throw new Error("Invalid diff object: expected diff.create to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},t.getDependencies=function(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})},t.getFsSnapshot=function(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})},e}(),m=[],v=function(e){var t=this;this.element=void 0,this.id=void 0,this.pending=void 0,this.vm=void 0,this.id=o(),this.element=e,this.pending=new Promise(function(e,n){var r=function(n){var r=n.data;"SDK_INIT_SUCCESS"===(null==r?void 0:r.action)&&r.id===t.id&&(t.vm=new h(n.ports[0],r.payload),e(t.vm),o())},i=function(){var e;null==(e=t.element.contentWindow)||e.postMessage({action:"SDK_INIT",id:t.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",r)}window.addEventListener("message",r),i();var a=0,d=window.setInterval(function(){if(t.vm)o();else{if(a>=20)return o(),n("Timeout: Unable to establish a connection with the StackBlitz VM"),void m.forEach(function(e,n){e.id===t.id&&m.splice(n,1)});a++,i()}},500)}),m.push(this)};function y(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function g(t){if(!e.includes(t.template)){var n=e.map(function(e){return"'"+e+"'"}).join(", ");console.warn("Unsupported project.template: must be one of "+n)}var r="node"===t.template,i=document.createElement("form");return i.method="POST",i.setAttribute("style","display:none!important;"),i.appendChild(y("project[title]",t.title)),i.appendChild(y("project[description]",t.description)),i.appendChild(y("project[template]",t.template)),t.dependencies&&(r?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):i.appendChild(y("project[dependencies]",JSON.stringify(t.dependencies)))),t.settings&&i.appendChild(y("project[settings]",JSON.stringify(t.settings))),Object.keys(t.files).forEach(function(e){"string"==typeof t.files[e]&&i.appendChild(y("project[files]["+e+"]",t.files[e]))}),i}function w(e){var t,n,r,i;return null!=e&&e.contentWindow?(null!=(i=(n=e)instanceof Element?"element":"id",t=null!=(r=m.find(function(e){return e[i]===n}))?r:null)?t:new v(e)).pending:Promise.reject("Provided element is not an iframe.")}module.exports={connect:w,embedGithubProject:function(e,t,n){var r=s(e),i=document.createElement("iframe");return i.src=d("/github/"+t,n),u(r,i,n),w(i)},embedProject:function(e,t,n){var r,i=s(e),o=function(e,t){var n=g(e);return n.action=d("/run",t),n.id="sb","<html><head><title></title></head><body>"+n.outerHTML+"<script>document.getElementById('"+n.id+"').submit();<\/script></body></html>"}(t,n),a=document.createElement("iframe");return u(i,a,n),null==(r=a.contentDocument)||r.write(o),w(a)},embedProjectId:function(e,t,n){var r=s(e),i=document.createElement("iframe");return i.src=d("/edit/"+t,n),u(r,i,n),w(i)},openGithubProject:function(e,t){var n=a("/github/"+e,t),r=l(t);window.open(n,r)},openProject:function(e,t){!function(e,t){var n=g(e);n.action=a("/run",t),n.target=l(t),document.body.appendChild(n),n.submit(),document.body.removeChild(n)}(e,t)},openProjectId:function(e,t){var n=a("/edit/"+e,t),r=l(t);window.open(n,r)}};
//# sourceMappingURL=sdk.js.map

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

function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function n(e,t){return""+i(t)+e+o(t)}function r(e,t){var n={forceEmbedLayout:!0};return t&&"object"==typeof t&&Object.assign(n,t),""+i(n)+e+o(n)}function i(e){return void 0===e&&(e={}),"string"==typeof e.origin?e.origin:"https://stackblitz.com"}function o(t){void 0===t&&(t={});var n=[];t.forceEmbedLayout&&n.push("embed=1"),t.clickToLoad&&n.push("ctl=1");for(var r,i=function(t,n){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t))){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(t.openFile)?t.openFile:[t.openFile]);!(r=i()).done;){var o=r.value;"string"==typeof o&&""!==o.trim()&&n.push("file="+encodeURIComponent(o.trim()))}return"preview"!==t.view&&"editor"!==t.view||n.push("view="+t.view),"light"!==t.theme&&"dark"!==t.theme||n.push("theme="+t.theme),t.hideExplorer&&n.push("hideExplorer=1"),t.hideNavigation&&n.push("hideNavigation=1"),t.hideDevTools&&n.push("hideDevTools=1"),"number"==typeof t.devToolsHeight&&t.devToolsHeight>=0&&t.devToolsHeight<=100&&n.push("devToolsHeight="+Math.round(t.devToolsHeight)),n.length?"?"+n.join("&"):""}function a(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),function(e,t){t&&"object"==typeof t&&(Object.hasOwnProperty.call(t,"height")&&(e.height=""+t.height),Object.hasOwnProperty.call(t,"width")&&(e.width=""+t.width)),e.height||(e.height="300"),e.width||e.setAttribute("style","width:100%;")}(t,n),e.parentNode.replaceChild(t,e)}function d(e){if("string"==typeof e){var t=document.getElementById(e);if(!t)throw new Error("Could not find element with id '"+e+"'");return t}if(e instanceof HTMLElement)return e;throw new Error("Invalid element: "+e)}function c(e){return e&&!1===e.newWindow?"_self":"_blank"}var l=/*#__PURE__*/function(){function e(e){var t=this;this.port=void 0,this.pending={},this.port=e,this.port.onmessage=function(e){var n,r=e.data;if(null!=r&&null!=(n=r.payload)&&n.__reqid){var i=r.payload.__reqid,o=r.payload.__success;if(t.pending[i]){if(delete r.payload.__reqid,delete r.payload.__success,o){var a=0===Object.keys(r.payload).length&&r.payload.constructor===Object?null:r.payload;t.pending[i].resolve(a)}else t.pending[i].reject(r.payload.error?r.type+": "+r.payload.error:r.type);delete t.pending[i]}}}}return e.prototype.request=function(e){var n=this,r=t();return new Promise(function(t,i){n.pending[r]={resolve:t,reject:i},e.payload.__reqid=r,n.port.postMessage(e)})},e}(),s=/*#__PURE__*/function(){function e(e,t){var n=this;this._rdc=void 0,this.editor={openFile:function(e){return n._rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})},setTheme:function(e){return n._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:e}})},setView:function(e){return n._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:e}})},showSidebar:function(e){return void 0===e&&(e=!0),n._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:e}})}},this.preview={origin:"",getUrl:function(){return n._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}})},setUrl:function(e){return void 0===e&&(e="/"),n._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:e}})}},this._rdc=new l(e),Object.defineProperty(this.preview,"origin",{value:"string"==typeof t.previewOrigin?t.previewOrigin:null,writable:!1})}var t=e.prototype;return t.applyFsDiff=function(e){var t=function(e){return null!==e&&"object"==typeof e};if(!t(e)||!t(e.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(e.destroy))throw new Error("Invalid diff object: expected diff.create to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},t.getDependencies=function(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})},t.getFsSnapshot=function(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})},e}(),u=[],p=function(e){var n=this;this.element=void 0,this.id=void 0,this.pending=void 0,this.vm=void 0,this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var r=function(t){var r=t.data;"SDK_INIT_SUCCESS"===(null==r?void 0:r.action)&&r.id===n.id&&(n.vm=new s(t.ports[0],r.payload),e(n.vm),o())},i=function(){n.element.contentWindow&&n.element.contentWindow.postMessage({action:"SDK_INIT",id:n.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",r)}window.addEventListener("message",r),i();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 u.forEach(function(e,t){e.id===n.id&&u.splice(t,1)});a++,i()}},500)}),u.push(this)},h=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"];function f(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function m(e){h.includes(e.template)||console.warn("Unsupported project.template: must be one of "+h.join(", "));var t="node"===e.template,n=document.createElement("form");return n.method="POST",n.setAttribute("style","display:none!important;"),n.appendChild(f("project[title]",e.title)),n.appendChild(f("project[description]",e.description)),n.appendChild(f("project[template]",e.template)),e.dependencies&&(t?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):n.appendChild(f("project[dependencies]",JSON.stringify(e.dependencies)))),e.settings&&n.appendChild(f("project[settings]",JSON.stringify(e.settings))),Object.keys(e.files).forEach(function(t){"string"==typeof e.files[t]&&n.appendChild(f("project[files]["+t+"]",e.files[t]))}),n}function v(e){var t,n,r,i;return null!=e&&e.contentWindow?(null!=(i=(n=e)instanceof Element?"element":"id",t=null!=(r=u.find(function(e){return e[i]===n}))?r:null)?t:new p(e)).pending:Promise.reject("Provided element is not an iframe.")}var y={__proto__:null,connect:v,openProject:function(e,t){!function(e,t){var r=m(e);r.action=n("/run",t),r.target=c(t),document.body.appendChild(r),r.submit(),document.body.removeChild(r)}(e,t)},openProjectId:function(e,t){var r=n("/edit/"+e,t),i=c(t);window.open(r,i)},openGithubProject:function(e,t){var r=n("/github/"+e,t),i=c(t);window.open(r,i)},embedProject:function(e,t,n){var i,o=d(e),c=function(e,t){var n=m(e);return n.action=r("/run",t),n.id="sb","<html><head><title></title></head><body>"+n.outerHTML+"<script>document.getElementById('"+n.id+"').submit();<\/script></body></html>"}(t,n),l=document.createElement("iframe");return a(o,l,n),null==(i=l.contentDocument)||i.write(c),v(l)},embedProjectId:function(e,t,n){var i=d(e),o=document.createElement("iframe");return o.src=r("/edit/"+t,n),a(i,o,n),v(o)},embedGithubProject:function(e,t,n){var i=d(e),o=document.createElement("iframe");return o.src=r("/github/"+t,n),a(i,o,n),v(o)}};export{y as default};
var e=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],t={clickToLoad:function(e){return r("ctl",e)},devToolsHeight:function(e){return function(e,t){return"number"==typeof t&&t>=0&&t<=100?"devToolsHeight="+Math.round(t):""}(0,e)},forceEmbedLayout:function(e){return r("embed",e)},hideDevTools:function(e){return r("hideDevTools",e)},hideExplorer:function(e){return r("hideExplorer",e)},hideNavigation:function(e){return r("hideNavigation",e)},showSidebar:function(e){return function(e,t){return"boolean"==typeof t?"showSidebar="+(t?"1":"0"):""}(0,e)},openFile:function(e){return function(e,t){return(Array.isArray(t)?t:[t]).filter(function(e){return"string"==typeof e&&""!==e.trim()}).map(function(e){return"file="+encodeURIComponent(e.trim())})}(0,e).join("&")},theme:function(e){return i("theme",["light","dark"],e)},view:function(e){return i("view",["preview","editor"],e)}};function n(e){void 0===e&&(e={});var n=Object.entries(e).map(function(e){var n=e[0],r=e[1];return null!=r&&t.hasOwnProperty(n)?t[n](r):""}).filter(Boolean);return n.length?"?"+n.join("&"):""}function r(e,t){return!0===t?e+"=1":""}function i(e,t,n){return"string"==typeof n&&t.includes(n)?e+"="+n:""}function o(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function a(e,t){return""+c(t)+e+n(t)}function d(e,t){var r={forceEmbedLayout:!0};return t&&"object"==typeof t&&Object.assign(r,t),""+c(r)+e+n(r)}function c(e){return void 0===e&&(e={}),"string"==typeof e.origin?e.origin:"https://stackblitz.com"}function u(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),function(e,t){t&&"object"==typeof t&&(Object.hasOwnProperty.call(t,"height")&&(e.height=""+t.height),Object.hasOwnProperty.call(t,"width")&&(e.width=""+t.width)),e.height||(e.height="300"),e.width||e.setAttribute("style","width:100%;")}(t,n),e.parentNode.replaceChild(t,e)}function s(e){if("string"==typeof e){var t=document.getElementById(e);if(!t)throw new Error("Could not find element with id '"+e+"'");return t}if(e instanceof HTMLElement)return e;throw new Error("Invalid element: "+e)}function l(e){return e&&!1===e.newWindow?"_self":"_blank"}function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}var f=/*#__PURE__*/function(){function e(e){this.port=void 0,this.pending={},this.port=e,this.port.onmessage=this.messageListener.bind(this)}var t=e.prototype;return t.request=function(e){var t=this,n=e.type,r=e.payload,i=o();return new Promise(function(e,o){t.pending[i]={resolve:e,reject:o},t.port.postMessage({type:n,payload:p({},r,{__reqid:i})})})},t.messageListener=function(e){var t;if("string"==typeof(null==(t=e.data.payload)?void 0:t.__reqid)){var n=e.data,r=n.type,i=n.payload,o=i.__reqid,a=i.__error;this.pending[o]&&(i.__success?this.pending[o].resolve(function(e){var t=p({},e);return delete t.__reqid,delete t.__success,delete t.__error,Object.keys(t).length?t:null}(i)):this.pending[o].reject(a?r+": "+a:r),delete this.pending[o])}},e}(),h=/*#__PURE__*/function(){function e(e,t){var n=this;this._rdc=void 0,this.editor={openFile:function(e){return n._rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})},setCurrentFile:function(e){return n._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:e}})},setTheme:function(e){return n._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:e}})},setView:function(e){return n._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:e}})},showSidebar:function(e){return void 0===e&&(e=!0),n._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:e}})}},this.preview={origin:"",getUrl:function(){return n._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(function(e){var t;return null!=(t=null==e?void 0:e.url)?t:null})},setUrl:function(e){if(void 0===e&&(e="/"),"string"!=typeof e||!e.startsWith("/"))throw new Error("Invalid argument: expected a path starting with '/', got '"+e+"'");return n._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:e}})}},this._rdc=new f(e),Object.defineProperty(this.preview,"origin",{value:"string"==typeof t.previewOrigin?t.previewOrigin:null,writable:!1})}var t=e.prototype;return t.applyFsDiff=function(e){var t=function(e){return null!==e&&"object"==typeof e};if(!t(e)||!t(e.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(e.destroy))throw new Error("Invalid diff object: expected diff.create to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},t.getDependencies=function(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})},t.getFsSnapshot=function(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})},e}(),m=[],v=function(e){var t=this;this.element=void 0,this.id=void 0,this.pending=void 0,this.vm=void 0,this.id=o(),this.element=e,this.pending=new Promise(function(e,n){var r=function(n){var r=n.data;"SDK_INIT_SUCCESS"===(null==r?void 0:r.action)&&r.id===t.id&&(t.vm=new h(n.ports[0],r.payload),e(t.vm),o())},i=function(){var e;null==(e=t.element.contentWindow)||e.postMessage({action:"SDK_INIT",id:t.id},"*")};function o(){window.clearInterval(d),window.removeEventListener("message",r)}window.addEventListener("message",r),i();var a=0,d=window.setInterval(function(){if(t.vm)o();else{if(a>=20)return o(),n("Timeout: Unable to establish a connection with the StackBlitz VM"),void m.forEach(function(e,n){e.id===t.id&&m.splice(n,1)});a++,i()}},500)}),m.push(this)};function y(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function g(t){if(!e.includes(t.template)){var n=e.map(function(e){return"'"+e+"'"}).join(", ");console.warn("Unsupported project.template: must be one of "+n)}var r="node"===t.template,i=document.createElement("form");return i.method="POST",i.setAttribute("style","display:none!important;"),i.appendChild(y("project[title]",t.title)),i.appendChild(y("project[description]",t.description)),i.appendChild(y("project[template]",t.template)),t.dependencies&&(r?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):i.appendChild(y("project[dependencies]",JSON.stringify(t.dependencies)))),t.settings&&i.appendChild(y("project[settings]",JSON.stringify(t.settings))),Object.keys(t.files).forEach(function(e){"string"==typeof t.files[e]&&i.appendChild(y("project[files]["+e+"]",t.files[e]))}),i}function w(e){var t,n,r,i;return null!=e&&e.contentWindow?(null!=(i=(n=e)instanceof Element?"element":"id",t=null!=(r=m.find(function(e){return e[i]===n}))?r:null)?t:new v(e)).pending:Promise.reject("Provided element is not an iframe.")}var _={connect:w,embedGithubProject:function(e,t,n){var r=s(e),i=document.createElement("iframe");return i.src=d("/github/"+t,n),u(r,i,n),w(i)},embedProject:function(e,t,n){var r,i=s(e),o=function(e,t){var n=g(e);return n.action=d("/run",t),n.id="sb","<html><head><title></title></head><body>"+n.outerHTML+"<script>document.getElementById('"+n.id+"').submit();<\/script></body></html>"}(t,n),a=document.createElement("iframe");return u(i,a,n),null==(r=a.contentDocument)||r.write(o),w(a)},embedProjectId:function(e,t,n){var r=s(e),i=document.createElement("iframe");return i.src=d("/edit/"+t,n),u(r,i,n),w(i)},openGithubProject:function(e,t){var n=a("/github/"+e,t),r=l(t);window.open(n,r)},openProject:function(e,t){!function(e,t){var n=g(e);n.action=a("/run",t),n.target=l(t),document.body.appendChild(n),n.submit(),document.body.removeChild(n)}(e,t)},openProjectId:function(e,t){var n=a("/edit/"+e,t),r=l(t);window.open(n,r)}};export{_ as default};
//# 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||self).StackBlitzSDK=t()}(this,function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function t(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function n(e,t){return""+r(t)+e+o(t)}function i(e,t){var n={forceEmbedLayout:!0};return t&&"object"==typeof t&&Object.assign(n,t),""+r(n)+e+o(n)}function r(e){return void 0===e&&(e={}),"string"==typeof e.origin?e.origin:"https://stackblitz.com"}function o(t){void 0===t&&(t={});var n=[];t.forceEmbedLayout&&n.push("embed=1"),t.clickToLoad&&n.push("ctl=1");for(var i,r=function(t,n){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,n){if(t){if("string"==typeof t)return e(t,n);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t))){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(t.openFile)?t.openFile:[t.openFile]);!(i=r()).done;){var o=i.value;"string"==typeof o&&""!==o.trim()&&n.push("file="+encodeURIComponent(o.trim()))}return"preview"!==t.view&&"editor"!==t.view||n.push("view="+t.view),"light"!==t.theme&&"dark"!==t.theme||n.push("theme="+t.theme),t.hideExplorer&&n.push("hideExplorer=1"),t.hideNavigation&&n.push("hideNavigation=1"),t.hideDevTools&&n.push("hideDevTools=1"),"number"==typeof t.devToolsHeight&&t.devToolsHeight>=0&&t.devToolsHeight<=100&&n.push("devToolsHeight="+Math.round(t.devToolsHeight)),n.length?"?"+n.join("&"):""}function a(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),function(e,t){t&&"object"==typeof t&&(Object.hasOwnProperty.call(t,"height")&&(e.height=""+t.height),Object.hasOwnProperty.call(t,"width")&&(e.width=""+t.width)),e.height||(e.height="300"),e.width||e.setAttribute("style","width:100%;")}(t,n),e.parentNode.replaceChild(t,e)}function d(e){if("string"==typeof e){var t=document.getElementById(e);if(!t)throw new Error("Could not find element with id '"+e+"'");return t}if(e instanceof HTMLElement)return e;throw new Error("Invalid element: "+e)}function c(e){return e&&!1===e.newWindow?"_self":"_blank"}var l=/*#__PURE__*/function(){function e(e){var t=this;this.port=void 0,this.pending={},this.port=e,this.port.onmessage=function(e){var n,i=e.data;if(null!=i&&null!=(n=i.payload)&&n.__reqid){var r=i.payload.__reqid,o=i.payload.__success;if(t.pending[r]){if(delete i.payload.__reqid,delete i.payload.__success,o){var a=0===Object.keys(i.payload).length&&i.payload.constructor===Object?null:i.payload;t.pending[r].resolve(a)}else t.pending[r].reject(i.payload.error?i.type+": "+i.payload.error:i.type);delete t.pending[r]}}}}return e.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)})},e}(),s=/*#__PURE__*/function(){function e(e,t){var n=this;this._rdc=void 0,this.editor={openFile:function(e){return n._rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})},setTheme:function(e){return n._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:e}})},setView:function(e){return n._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:e}})},showSidebar:function(e){return void 0===e&&(e=!0),n._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:e}})}},this.preview={origin:"",getUrl:function(){return n._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}})},setUrl:function(e){return void 0===e&&(e="/"),n._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:e}})}},this._rdc=new l(e),Object.defineProperty(this.preview,"origin",{value:"string"==typeof t.previewOrigin?t.previewOrigin:null,writable:!1})}var t=e.prototype;return t.applyFsDiff=function(e){var t=function(e){return null!==e&&"object"==typeof e};if(!t(e)||!t(e.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(e.destroy))throw new Error("Invalid diff object: expected diff.create to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},t.getDependencies=function(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})},t.getFsSnapshot=function(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})},e}(),u=[],p=function(e){var n=this;this.element=void 0,this.id=void 0,this.pending=void 0,this.vm=void 0,this.id=t(),this.element=e,this.pending=new Promise(function(e,t){var i=function(t){var i=t.data;"SDK_INIT_SUCCESS"===(null==i?void 0:i.action)&&i.id===n.id&&(n.vm=new s(t.ports[0],i.payload),e(n.vm),o())},r=function(){n.element.contentWindow&&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 u.forEach(function(e,t){e.id===n.id&&u.splice(t,1)});a++,r()}},500)}),u.push(this)},f=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"];function h(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function m(e){f.includes(e.template)||console.warn("Unsupported project.template: must be one of "+f.join(", "));var t="node"===e.template,n=document.createElement("form");return n.method="POST",n.setAttribute("style","display:none!important;"),n.appendChild(h("project[title]",e.title)),n.appendChild(h("project[description]",e.description)),n.appendChild(h("project[template]",e.template)),e.dependencies&&(t?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):n.appendChild(h("project[dependencies]",JSON.stringify(e.dependencies)))),e.settings&&n.appendChild(h("project[settings]",JSON.stringify(e.settings))),Object.keys(e.files).forEach(function(t){"string"==typeof e.files[t]&&n.appendChild(h("project[files]["+t+"]",e.files[t]))}),n}function v(e){var t,n,i,r;return null!=e&&e.contentWindow?(null!=(r=(n=e)instanceof Element?"element":"id",t=null!=(i=u.find(function(e){return e[r]===n}))?i:null)?t:new p(e)).pending:Promise.reject("Provided element is not an iframe.")}return{__proto__:null,connect:v,openProject:function(e,t){!function(e,t){var i=m(e);i.action=n("/run",t),i.target=c(t),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}(e,t)},openProjectId:function(e,t){var i=n("/edit/"+e,t),r=c(t);window.open(i,r)},openGithubProject:function(e,t){var i=n("/github/"+e,t),r=c(t);window.open(i,r)},embedProject:function(e,t,n){var r,o=d(e),c=function(e,t){var n=m(e);return n.action=i("/run",t),n.id="sb","<html><head><title></title></head><body>"+n.outerHTML+"<script>document.getElementById('"+n.id+"').submit();<\/script></body></html>"}(t,n),l=document.createElement("iframe");return a(o,l,n),null==(r=l.contentDocument)||r.write(c),v(l)},embedProjectId:function(e,t,n){var r=d(e),o=document.createElement("iframe");return o.src=i("/edit/"+t,n),a(r,o,n),v(o)},embedGithubProject:function(e,t,n){var r=d(e),o=document.createElement("iframe");return o.src=i("/github/"+t,n),a(r,o,n),v(o)}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).StackBlitzSDK=t()}(this,function(){var e=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],t={clickToLoad:function(e){return r("ctl",e)},devToolsHeight:function(e){return function(e,t){return"number"==typeof t&&t>=0&&t<=100?"devToolsHeight="+Math.round(t):""}(0,e)},forceEmbedLayout:function(e){return r("embed",e)},hideDevTools:function(e){return r("hideDevTools",e)},hideExplorer:function(e){return r("hideExplorer",e)},hideNavigation:function(e){return r("hideNavigation",e)},showSidebar:function(e){return function(e,t){return"boolean"==typeof t?"showSidebar="+(t?"1":"0"):""}(0,e)},openFile:function(e){return function(e,t){return(Array.isArray(t)?t:[t]).filter(function(e){return"string"==typeof e&&""!==e.trim()}).map(function(e){return"file="+encodeURIComponent(e.trim())})}(0,e).join("&")},theme:function(e){return i("theme",["light","dark"],e)},view:function(e){return i("view",["preview","editor"],e)}};function n(e){void 0===e&&(e={});var n=Object.entries(e).map(function(e){var n=e[0],r=e[1];return null!=r&&t.hasOwnProperty(n)?t[n](r):""}).filter(Boolean);return n.length?"?"+n.join("&"):""}function r(e,t){return!0===t?e+"=1":""}function i(e,t,n){return"string"==typeof n&&t.includes(n)?e+"="+n:""}function o(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function d(e,t){return""+u(t)+e+n(t)}function a(e,t){var r={forceEmbedLayout:!0};return t&&"object"==typeof t&&Object.assign(r,t),""+u(r)+e+n(r)}function u(e){return void 0===e&&(e={}),"string"==typeof e.origin?e.origin:"https://stackblitz.com"}function c(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),function(e,t){t&&"object"==typeof t&&(Object.hasOwnProperty.call(t,"height")&&(e.height=""+t.height),Object.hasOwnProperty.call(t,"width")&&(e.width=""+t.width)),e.height||(e.height="300"),e.width||e.setAttribute("style","width:100%;")}(t,n),e.parentNode.replaceChild(t,e)}function s(e){if("string"==typeof e){var t=document.getElementById(e);if(!t)throw new Error("Could not find element with id '"+e+"'");return t}if(e instanceof HTMLElement)return e;throw new Error("Invalid element: "+e)}function l(e){return e&&!1===e.newWindow?"_self":"_blank"}function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}var f=/*#__PURE__*/function(){function e(e){this.port=void 0,this.pending={},this.port=e,this.port.onmessage=this.messageListener.bind(this)}var t=e.prototype;return t.request=function(e){var t=this,n=e.type,r=e.payload,i=o();return new Promise(function(e,o){t.pending[i]={resolve:e,reject:o},t.port.postMessage({type:n,payload:p({},r,{__reqid:i})})})},t.messageListener=function(e){var t;if("string"==typeof(null==(t=e.data.payload)?void 0:t.__reqid)){var n=e.data,r=n.type,i=n.payload,o=i.__reqid,d=i.__error;this.pending[o]&&(i.__success?this.pending[o].resolve(function(e){var t=p({},e);return delete t.__reqid,delete t.__success,delete t.__error,Object.keys(t).length?t:null}(i)):this.pending[o].reject(d?r+": "+d:r),delete this.pending[o])}},e}(),h=/*#__PURE__*/function(){function e(e,t){var n=this;this._rdc=void 0,this.editor={openFile:function(e){return n._rdc.request({type:"SDK_OPEN_FILE",payload:{path:e}})},setCurrentFile:function(e){return n._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:e}})},setTheme:function(e){return n._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:e}})},setView:function(e){return n._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:e}})},showSidebar:function(e){return void 0===e&&(e=!0),n._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:e}})}},this.preview={origin:"",getUrl:function(){return n._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(function(e){var t;return null!=(t=null==e?void 0:e.url)?t:null})},setUrl:function(e){if(void 0===e&&(e="/"),"string"!=typeof e||!e.startsWith("/"))throw new Error("Invalid argument: expected a path starting with '/', got '"+e+"'");return n._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:e}})}},this._rdc=new f(e),Object.defineProperty(this.preview,"origin",{value:"string"==typeof t.previewOrigin?t.previewOrigin:null,writable:!1})}var t=e.prototype;return t.applyFsDiff=function(e){var t=function(e){return null!==e&&"object"==typeof e};if(!t(e)||!t(e.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(e.destroy))throw new Error("Invalid diff object: expected diff.create to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:e})},t.getDependencies=function(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})},t.getFsSnapshot=function(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})},e}(),m=[],v=function(e){var t=this;this.element=void 0,this.id=void 0,this.pending=void 0,this.vm=void 0,this.id=o(),this.element=e,this.pending=new Promise(function(e,n){var r=function(n){var r=n.data;"SDK_INIT_SUCCESS"===(null==r?void 0:r.action)&&r.id===t.id&&(t.vm=new h(n.ports[0],r.payload),e(t.vm),o())},i=function(){var e;null==(e=t.element.contentWindow)||e.postMessage({action:"SDK_INIT",id:t.id},"*")};function o(){window.clearInterval(a),window.removeEventListener("message",r)}window.addEventListener("message",r),i();var d=0,a=window.setInterval(function(){if(t.vm)o();else{if(d>=20)return o(),n("Timeout: Unable to establish a connection with the StackBlitz VM"),void m.forEach(function(e,n){e.id===t.id&&m.splice(n,1)});d++,i()}},500)}),m.push(this)};function y(e,t){var n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function g(t){if(!e.includes(t.template)){var n=e.map(function(e){return"'"+e+"'"}).join(", ");console.warn("Unsupported project.template: must be one of "+n)}var r="node"===t.template,i=document.createElement("form");return i.method="POST",i.setAttribute("style","display:none!important;"),i.appendChild(y("project[title]",t.title)),i.appendChild(y("project[description]",t.description)),i.appendChild(y("project[template]",t.template)),t.dependencies&&(r?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):i.appendChild(y("project[dependencies]",JSON.stringify(t.dependencies)))),t.settings&&i.appendChild(y("project[settings]",JSON.stringify(t.settings))),Object.keys(t.files).forEach(function(e){"string"==typeof t.files[e]&&i.appendChild(y("project[files]["+e+"]",t.files[e]))}),i}function w(e){var t,n,r,i;return null!=e&&e.contentWindow?(null!=(i=(n=e)instanceof Element?"element":"id",t=null!=(r=m.find(function(e){return e[i]===n}))?r:null)?t:new v(e)).pending:Promise.reject("Provided element is not an iframe.")}return{connect:w,embedGithubProject:function(e,t,n){var r=s(e),i=document.createElement("iframe");return i.src=a("/github/"+t,n),c(r,i,n),w(i)},embedProject:function(e,t,n){var r,i=s(e),o=function(e,t){var n=g(e);return n.action=a("/run",t),n.id="sb","<html><head><title></title></head><body>"+n.outerHTML+"<script>document.getElementById('"+n.id+"').submit();<\/script></body></html>"}(t,n),d=document.createElement("iframe");return c(i,d,n),null==(r=d.contentDocument)||r.write(o),w(d)},embedProjectId:function(e,t,n){var r=s(e),i=document.createElement("iframe");return i.src=a("/edit/"+t,n),c(r,i,n),w(i)},openGithubProject:function(e,t){var n=d("/github/"+e,t),r=l(t);window.open(n,r)},openProject:function(e,t){!function(e,t){var n=g(e);n.action=d("/run",t),n.target=l(t),document.body.appendChild(n),n.submit(),document.body.removeChild(n)}(e,t)},openProjectId:function(e,t){var n=d("/edit/"+e,t),r=l(t);window.open(n,r)}}});
//# sourceMappingURL=sdk.umd.js.map
{
"name": "@stackblitz/sdk",
"version": "1.7.0-alpha.2",
"version": "1.7.0-alpha.3",
"description": "SDK for generating and embedding StackBlitz projects.",

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

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

import { VM } from './VM';
import { VM } from './vm';
export declare class Connection {

@@ -3,0 +3,0 @@ element: HTMLIFrameElement;

@@ -1,3 +0,3 @@

import { Project, EmbedOptions, OpenOptions } from './interfaces';
import type { Project, EmbedOptions, OpenOptions } from './interfaces';
export declare function createProjectFrameHTML(project: Project, options?: EmbedOptions): string;
export declare function openNewProject(project: Project, options?: OpenOptions): void;

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

import { EmbedOptions, OpenOptions } from './interfaces';
import type { EmbedOptions, OpenOptions } from './interfaces';
/**

@@ -3,0 +3,0 @@ * Pseudo-random id string for internal accounting.

@@ -1,4 +0,13 @@

export type { Project, OpenOptions, EmbedOptions } from './interfaces';
export type { VM } from './VM';
import * as StackBlitzSDK from './lib';
export default StackBlitzSDK;
import { connect, embedGithubProject, embedProject, embedProjectId, openGithubProject, openProject, openProjectId } from './lib';
export type { Project, ProjectOptions, ProjectDependencies, ProjectFiles, ProjectSettings, ProjectTemplate, EmbedOptions, OpenOptions, OpenFileOption, UiThemeOption, UiViewOption, } from './interfaces';
export type { FsDiff, VM } from './vm';
declare const _default: {
connect: typeof connect;
embedGithubProject: typeof embedGithubProject;
embedProject: typeof embedProject;
embedProjectId: typeof embedProjectId;
openGithubProject: typeof openGithubProject;
openProject: typeof openProject;
openProjectId: typeof openProjectId;
};
export default _default;

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

interface ProjectSettings {
compile?: {
trigger?: 'auto' | 'keystroke' | 'save' | string;
action?: 'hmr' | 'refresh' | string;
clearConsole?: boolean;
};
}
export declare type ProjectTemplate = 'angular-cli' | 'create-react-app' | 'html' | 'javascript' | 'node' | 'polymer' | 'typescript' | 'vue';
export declare type ProjectDependencies = {
[name: string]: string;
};
export declare type ProjectFiles = {
[path: string]: string;
};
import type { PROJECT_TEMPLATES } from './constants';
export interface Project {

@@ -47,5 +34,16 @@ title: string;

}
export declare type OpenFilePath = string | string[];
export declare type UiView = 'default' | 'preview' | 'editor';
export declare type UiTheme = 'default' | 'light' | 'dark';
export declare type ProjectTemplate = typeof PROJECT_TEMPLATES[number];
export interface ProjectDependencies {
[name: string]: string;
}
export interface ProjectFiles {
[path: string]: string;
}
export interface ProjectSettings {
compile?: {
trigger?: 'auto' | 'keystroke' | 'save' | string;
action?: 'hmr' | 'refresh' | string;
clearConsole?: boolean;
};
}
export interface ProjectOptions {

@@ -66,3 +64,3 @@ /**

*/
openFile?: OpenFilePath;
openFile?: OpenFileOption;
/**

@@ -73,3 +71,3 @@ * Show only the code editor or only the preview page.

*/
view?: UiView;
view?: UiViewOption;
/**

@@ -80,7 +78,8 @@ * Select the color theme for the editor UI.

*/
theme?: UiTheme;
theme?: UiThemeOption;
/**
* Height of the Console panel below the preview page (as a percentage number, between `0` and `100`).
*
* By default, the Console will appear collapsed, and can be opened by users. This option is ignored in WebContainers-based projects.
* By default, the Console will appear collapsed, and can be opened by users.
* This option is ignored in WebContainers-based projects.
*/

@@ -95,11 +94,13 @@ devToolsHeight?: number;

/**
* Hide the sidebar on page load.
*
* Users will still be able to open the sidebar by clicking one of the sidebar icons.
* Hide the ActivityBar (sidebar icons).
*/
hideExplorer?: boolean;
/**
* Hide the preview URL.
* Show the sidebar as open or closed on page load.
*
* This might be ignored on narrow viewport widths (mobile and/or tablets).
*
* On larger viewports, defaults to `false` for `embedProject*` methods, and `true` for `openProject*` methods.
*/
hideNavigation?: boolean;
showSidebar?: boolean;
/**

@@ -119,2 +120,3 @@ * Use the “embed” layout of the editor.

* Set the origin URL of your StackBlitz EE server.
*
* Defaults to `https://stackblitz.com`.

@@ -140,16 +142,9 @@ */

width?: number | string;
/**
* Hide the preview URL in embeds.
*/
hideNavigation?: boolean;
}
export interface FsDiff {
create: {
[path: string]: string;
};
destroy: string[];
}
export interface RequestData {
type: string;
payload: {
__reqid?: string;
[key: string]: any;
};
}
export {};
export declare type OpenFileOption = string | string[];
export declare type UiViewOption = 'default' | 'preview' | 'editor';
export declare type UiThemeOption = 'default' | 'light' | 'dark';
import type { Project, OpenOptions, EmbedOptions } from './interfaces';
import type { VM } from './VM';
import type { VM } from './vm';
/**

@@ -4,0 +4,0 @@ * Get a VM instance for an existing StackBlitz project iframe.

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc