@studioindia/designx 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@ DesignX is a local-first design tool that runs entirely on your machine. It uses
15
15
  npx @studioindia/designx
16
16
  ```
17
17
 
18
- That's it. DesignX starts a local server on port 3000 and opens the UI in your default browser. All your data is stored in `~/.designx/` on your own machine — nothing is sent to any external server.
18
+ That's it. DesignX starts a local server on port 3000 and opens the UI in your default browser. All your data is stored in `~/DesignX/` on your own machine — nothing is sent to any external server.
19
19
 
20
20
  On first launch, click **Connect GitHub Copilot** and follow the Device Flow prompt to authenticate with your GitHub account.
21
21
 
@@ -25,7 +25,7 @@ On first launch, click **Connect GitHub Copilot** and follow the Device Flow pro
25
25
  designx [options]
26
26
 
27
27
  --port <port> Port to listen on (default: 3000)
28
- --data-dir <path> Where to store project data (default: ~/.designx)
28
+ --data-dir <path> Where to store project data (default: ~/DesignX)
29
29
  --no-open Do not open browser automatically
30
30
  --version, -v Print version
31
31
  --help, -h Print help
@@ -50,7 +50,7 @@ npx @studioindia/designx --no-open
50
50
  ## Data directory layout
51
51
 
52
52
  ```
53
- ~/.designx/
53
+ ~/DesignX/
54
54
  ├── data/
55
55
  │ ├── kb-jobs.json
56
56
  │ └── agent-runs.json
@@ -66,7 +66,7 @@ npx @studioindia/designx --no-open
66
66
 
67
67
  ## How authentication works
68
68
 
69
- DesignX uses [GitHub Device Flow](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow) — the same flow used by the GitHub CLI. You are redirected to `github.com/login/device`, enter a short code, and authorize the app with your own GitHub account. No passwords are stored by DesignX. Your access token lives only in your local `~/.designx/` directory.
69
+ DesignX uses [GitHub Device Flow](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow) — the same flow used by the GitHub CLI. You are redirected to `github.com/login/device`, enter a short code, and authorize the app with your own GitHub account. No passwords are stored by DesignX. Your access token lives only in your local `~/DesignX/` directory.
70
70
 
71
71
  ## Updates
72
72
 
package/bin/designx.js CHANGED
@@ -29,7 +29,7 @@ function getArg(flag) {
29
29
  }
30
30
 
31
31
  const PORT = getArg('--port') ?? process.env.DESIGNX_PORT ?? '3000'
32
- const DATA_DIR = getArg('--data-dir') ?? process.env.DESIGNX_DATA_DIR ?? join(homedir(), '.designx')
32
+ const DATA_DIR = getArg('--data-dir') ?? process.env.DESIGNX_DATA_DIR ?? join(homedir(), 'DesignX')
33
33
  const NO_OPEN = args.includes('--no-open')
34
34
 
35
35
  // ── Help / version ────────────────────────────────────────────────────────────
@@ -47,7 +47,7 @@ if (args.includes('--help') || args.includes('-h')) {
47
47
 
48
48
  Options:
49
49
  --port <port> Port to listen on (default: 3000)
50
- --data-dir <path> Where to store all data (default: ~/.designx)
50
+ --data-dir <path> Where to store all data (default: ~/DesignX)
51
51
  --no-open Do not open browser automatically
52
52
  --version, -v Print version
53
53
  --help, -h Print this help
@@ -1,4 +1,4 @@
1
- import{r as s,p as R,a as O,j as o,n as N,b as U,s as Z,c as H}from"./index-CBUxOHiU.js";const k=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M71.68,97.22,34.74,128l36.94,30.78a12,12,0,1,1-15.36,18.44l-48-40a12,12,0,0,1,0-18.44l48-40A12,12,0,0,1,71.68,97.22Zm176,21.56-48-40a12,12,0,1,0-15.36,18.44L221.26,128l-36.94,30.78a12,12,0,1,0,15.36,18.44l48-40a12,12,0,0,0,0-18.44ZM164.1,28.72a12,12,0,0,0-15.38,7.18l-64,176a12,12,0,0,0,7.18,15.37A11.79,11.79,0,0,0,96,228a12,12,0,0,0,11.28-7.9l64-176A12,12,0,0,0,164.1,28.72Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M240,128l-48,40H64L16,128,64,88H192Z",opacity:"0.2"}),s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM92.8,145.6a8,8,0,1,1-9.6,12.8l-32-24a8,8,0,0,1,0-12.8l32-24a8,8,0,0,1,9.6,12.8L69.33,128Zm58.89-71.4-32,112a8,8,0,1,1-15.38-4.4l32-112a8,8,0,0,1,15.38,4.4Zm53.11,60.2-32,24a8,8,0,0,1-9.6-12.8L186.67,128,163.2,110.4a8,8,0,1,1,9.6-12.8l32,24a8,8,0,0,1,0,12.8Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M67.84,92.61,25.37,128l42.47,35.39a6,6,0,1,1-7.68,9.22l-48-40a6,6,0,0,1,0-9.22l48-40a6,6,0,0,1,7.68,9.22Zm176,30.78-48-40a6,6,0,1,0-7.68,9.22L230.63,128l-42.47,35.39a6,6,0,1,0,7.68,9.22l48-40a6,6,0,0,0,0-9.22Zm-81.79-89A6,6,0,0,0,154.36,38l-64,176A6,6,0,0,0,94,221.64a6.15,6.15,0,0,0,2,.36,6,6,0,0,0,5.64-3.95l64-176A6,6,0,0,0,162.05,34.36Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M66.56,91.07,22.25,128l44.31,36.93A4,4,0,0,1,64,172a3.94,3.94,0,0,1-2.56-.93l-48-40a4,4,0,0,1,0-6.14l48-40a4,4,0,0,1,5.12,6.14Zm176,33.86-48-40a4,4,0,1,0-5.12,6.14L233.75,128l-44.31,36.93a4,4,0,1,0,5.12,6.14l48-40a4,4,0,0,0,0-6.14ZM161.37,36.24a4,4,0,0,0-5.13,2.39l-64,176a4,4,0,0,0,2.39,5.13A4.12,4.12,0,0,0,96,220a4,4,0,0,0,3.76-2.63l64-176A4,4,0,0,0,161.37,36.24Z"}))]]),M=s.forwardRef((e,t)=>s.createElement(R,{ref:t,...e,weights:k}));M.displayName="CodeIcon";const z=M,q=500,K=20,V=300,B="https://stackblitz.com",A=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],W=["project","search","ports","settings"],G=["light","dark"],J=["editor","preview"],I={clickToLoad:e=>m("ctl",e),devToolsHeight:e=>$("devtoolsheight",e),forceEmbedLayout:e=>m("embed",e),hideDevTools:e=>m("hidedevtools",e),hideExplorer:e=>m("hideExplorer",e),hideNavigation:e=>m("hideNavigation",e),openFile:e=>g("file",e),showSidebar:e=>X("showSidebar",e),sidebarView:e=>x("sidebarView",e,W),startScript:e=>g("startScript",e),terminalHeight:e=>$("terminalHeight",e),theme:e=>x("theme",e,G),view:e=>x("view",e,J),zenMode:e=>m("zenMode",e),organization:e=>`${g("orgName",e==null?void 0:e.name)}&${g("orgProvider",e==null?void 0:e.provider)}`,crossOriginIsolated:e=>m("corp",e)};function F(e={}){const t=Object.entries(e).map(([n,r])=>r!=null&&I.hasOwnProperty(n)?I[n](r):"").filter(Boolean);return t.length?`?${t.join("&")}`:""}function m(e,t){return t===!0?`${e}=1`:""}function X(e,t){return typeof t=="boolean"?`${e}=${t?"1":"0"}`:""}function $(e,t){if(typeof t=="number"&&!Number.isNaN(t)){const n=Math.min(100,Math.max(0,t));return`${e}=${encodeURIComponent(Math.round(n))}`}return""}function x(e,t="",n=[]){return n.includes(t)?`${e}=${encodeURIComponent(t)}`:""}function g(e,t){return(Array.isArray(t)?t:[t]).filter(r=>typeof r=="string"&&r.trim()!=="").map(r=>`${e}=${encodeURIComponent(r)}`).join("&")}function L(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function w(e,t){return`${D(t)}${e}${F(t)}`}function E(e,t){const n={forceEmbedLayout:!0};return t&&typeof t=="object"&&Object.assign(n,t),`${D(n)}${e}${F(n)}`}function D(e={}){return(typeof e.origin=="string"?e.origin:B).replace(/\/$/,"")}function _(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),Y(t,n),Q(e,t,n),e.replaceWith(t)}function j(e){if(typeof e=="string"){const t=document.getElementById(e);if(!t)throw new Error(`Could not find element with id '${e}'`);return t}else if(e instanceof HTMLElement)return e;throw new Error(`Invalid element: ${e}`)}function v(e){return e&&e.newWindow===!1?"_self":"_blank"}function Y(e,t={}){const n=Object.hasOwnProperty.call(t,"height")?`${t.height}`:`${V}`,r=Object.hasOwnProperty.call(t,"width")?`${t.width}`:void 0;e.setAttribute("height",n),r?e.setAttribute("width",r):e.setAttribute("style","width:100%;")}function Q(e,t,n={}){var i,a;const r=((a=(i=e.allow)==null?void 0:i.split(";"))==null?void 0:a.map(l=>l.trim()))??[];n.crossOriginIsolated&&!r.includes("cross-origin-isolated")&&r.push("cross-origin-isolated"),r.length>0&&(t.allow=r.join("; "))}class ee{constructor(t){this.pending={},this.port=t,this.port.onmessage=this.messageListener.bind(this)}request({type:t,payload:n}){return new Promise((r,i)=>{const a=L();this.pending[a]={resolve:r,reject:i},this.port.postMessage({type:t,payload:{...n,__reqid:a}})})}messageListener(t){var d;if(typeof((d=t.data.payload)==null?void 0:d.__reqid)!="string")return;const{type:n,payload:r}=t.data,{__reqid:i,__success:a,__error:l}=r;this.pending[i]&&(a?this.pending[i].resolve(this.cleanResult(r)):this.pending[i].reject(l?`${n}: ${l}`:n),delete this.pending[i])}cleanResult(t){const n={...t};return delete n.__reqid,delete n.__success,delete n.__error,Object.keys(n).length?n:null}}class te{constructor(t,n){this.editor={openFile:r=>this._rdc.request({type:"SDK_OPEN_FILE",payload:{path:r}}),setCurrentFile:r=>this._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:r}}),setTheme:r=>this._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:r}}),setView:r=>this._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:r}}),showSidebar:(r=!0)=>this._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:r}})},this.preview={origin:"",getUrl:()=>this._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(r=>(r==null?void 0:r.url)??null),setUrl:(r="/")=>{if(typeof r!="string"||!r.startsWith("/"))throw new Error(`Invalid argument: expected a path starting with '/', got '${r}'`);return this._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:r}})}},this._rdc=new ee(t),Object.defineProperty(this.preview,"origin",{value:typeof n.previewOrigin=="string"?n.previewOrigin:null,writable:!1})}applyFsDiff(t){const n=r=>r!==null&&typeof r=="object";if(!n(t)||!n(t.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(t.destroy))throw new Error("Invalid diff object: expected diff.destroy to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:t})}getDependencies(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})}getFsSnapshot(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})}}const y=[];class ne{constructor(t){this.id=L(),this.element=t,this.pending=new Promise((n,r)=>{const i=({data:c,ports:u})=>{(c==null?void 0:c.action)==="SDK_INIT_SUCCESS"&&c.id===this.id&&(this.vm=new te(u[0],c.payload),n(this.vm),l())},a=()=>{var c;(c=this.element.contentWindow)==null||c.postMessage({action:"SDK_INIT",id:this.id},"*")};function l(){window.clearInterval(p),window.removeEventListener("message",i)}window.addEventListener("message",i),a();let d=0;const p=window.setInterval(()=>{if(this.vm){l();return}if(d>=K){l(),r("Timeout: Unable to establish a connection with the StackBlitz VM"),y.forEach((c,u)=>{c.id===this.id&&y.splice(u,1)});return}d++,a()},q)}),y.push(this)}}const re=e=>{const t=e instanceof Element?"element":"id";return y.find(n=>n[t]===e)??null};function ie(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function se(e){return e.replace(/\[/g,"%5B").replace(/\]/g,"%5D")}function C({template:e,title:t,description:n,dependencies:r,files:i,settings:a}){if(!A.includes(e)){const c=A.map(u=>`'${u}'`).join(", ");console.warn(`Unsupported project.template: must be one of ${c}`)}const l=[],d=(c,u,h="")=>{l.push(ie(c,typeof u=="string"?u:h))};d("project[title]",t),typeof n=="string"&&n.length>0&&d("project[description]",n),d("project[template]",e,"javascript"),r&&(e==="node"?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):d("project[dependencies]",JSON.stringify(r))),a&&d("project[settings]",JSON.stringify(a)),Object.entries(i).forEach(([c,u])=>{d(`project[files][${se(c)}]`,u)});const p=document.createElement("form");return p.method="POST",p.setAttribute("style","display:none!important;"),p.append(...l),p}function oe(e,t){const n=C(e);return n.action=E("/run",t),n.id="sb_run",`<!doctype html>
1
+ import{r as s,p as R,a as O,j as o,n as N,b as U,s as Z,c as H}from"./index-B4DsP2aY.js";const k=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M71.68,97.22,34.74,128l36.94,30.78a12,12,0,1,1-15.36,18.44l-48-40a12,12,0,0,1,0-18.44l48-40A12,12,0,0,1,71.68,97.22Zm176,21.56-48-40a12,12,0,1,0-15.36,18.44L221.26,128l-36.94,30.78a12,12,0,1,0,15.36,18.44l48-40a12,12,0,0,0,0-18.44ZM164.1,28.72a12,12,0,0,0-15.38,7.18l-64,176a12,12,0,0,0,7.18,15.37A11.79,11.79,0,0,0,96,228a12,12,0,0,0,11.28-7.9l64-176A12,12,0,0,0,164.1,28.72Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M240,128l-48,40H64L16,128,64,88H192Z",opacity:"0.2"}),s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM92.8,145.6a8,8,0,1,1-9.6,12.8l-32-24a8,8,0,0,1,0-12.8l32-24a8,8,0,0,1,9.6,12.8L69.33,128Zm58.89-71.4-32,112a8,8,0,1,1-15.38-4.4l32-112a8,8,0,0,1,15.38,4.4Zm53.11,60.2-32,24a8,8,0,0,1-9.6-12.8L186.67,128,163.2,110.4a8,8,0,1,1,9.6-12.8l32,24a8,8,0,0,1,0,12.8Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M67.84,92.61,25.37,128l42.47,35.39a6,6,0,1,1-7.68,9.22l-48-40a6,6,0,0,1,0-9.22l48-40a6,6,0,0,1,7.68,9.22Zm176,30.78-48-40a6,6,0,1,0-7.68,9.22L230.63,128l-42.47,35.39a6,6,0,1,0,7.68,9.22l48-40a6,6,0,0,0,0-9.22Zm-81.79-89A6,6,0,0,0,154.36,38l-64,176A6,6,0,0,0,94,221.64a6.15,6.15,0,0,0,2,.36,6,6,0,0,0,5.64-3.95l64-176A6,6,0,0,0,162.05,34.36Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M66.56,91.07,22.25,128l44.31,36.93A4,4,0,0,1,64,172a3.94,3.94,0,0,1-2.56-.93l-48-40a4,4,0,0,1,0-6.14l48-40a4,4,0,0,1,5.12,6.14Zm176,33.86-48-40a4,4,0,1,0-5.12,6.14L233.75,128l-44.31,36.93a4,4,0,1,0,5.12,6.14l48-40a4,4,0,0,0,0-6.14ZM161.37,36.24a4,4,0,0,0-5.13,2.39l-64,176a4,4,0,0,0,2.39,5.13A4.12,4.12,0,0,0,96,220a4,4,0,0,0,3.76-2.63l64-176A4,4,0,0,0,161.37,36.24Z"}))]]),M=s.forwardRef((e,t)=>s.createElement(R,{ref:t,...e,weights:k}));M.displayName="CodeIcon";const z=M,q=500,K=20,V=300,B="https://stackblitz.com",A=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],W=["project","search","ports","settings"],G=["light","dark"],J=["editor","preview"],I={clickToLoad:e=>m("ctl",e),devToolsHeight:e=>$("devtoolsheight",e),forceEmbedLayout:e=>m("embed",e),hideDevTools:e=>m("hidedevtools",e),hideExplorer:e=>m("hideExplorer",e),hideNavigation:e=>m("hideNavigation",e),openFile:e=>g("file",e),showSidebar:e=>X("showSidebar",e),sidebarView:e=>x("sidebarView",e,W),startScript:e=>g("startScript",e),terminalHeight:e=>$("terminalHeight",e),theme:e=>x("theme",e,G),view:e=>x("view",e,J),zenMode:e=>m("zenMode",e),organization:e=>`${g("orgName",e==null?void 0:e.name)}&${g("orgProvider",e==null?void 0:e.provider)}`,crossOriginIsolated:e=>m("corp",e)};function F(e={}){const t=Object.entries(e).map(([n,r])=>r!=null&&I.hasOwnProperty(n)?I[n](r):"").filter(Boolean);return t.length?`?${t.join("&")}`:""}function m(e,t){return t===!0?`${e}=1`:""}function X(e,t){return typeof t=="boolean"?`${e}=${t?"1":"0"}`:""}function $(e,t){if(typeof t=="number"&&!Number.isNaN(t)){const n=Math.min(100,Math.max(0,t));return`${e}=${encodeURIComponent(Math.round(n))}`}return""}function x(e,t="",n=[]){return n.includes(t)?`${e}=${encodeURIComponent(t)}`:""}function g(e,t){return(Array.isArray(t)?t:[t]).filter(r=>typeof r=="string"&&r.trim()!=="").map(r=>`${e}=${encodeURIComponent(r)}`).join("&")}function L(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function w(e,t){return`${D(t)}${e}${F(t)}`}function E(e,t){const n={forceEmbedLayout:!0};return t&&typeof t=="object"&&Object.assign(n,t),`${D(n)}${e}${F(n)}`}function D(e={}){return(typeof e.origin=="string"?e.origin:B).replace(/\/$/,"")}function _(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),Y(t,n),Q(e,t,n),e.replaceWith(t)}function j(e){if(typeof e=="string"){const t=document.getElementById(e);if(!t)throw new Error(`Could not find element with id '${e}'`);return t}else if(e instanceof HTMLElement)return e;throw new Error(`Invalid element: ${e}`)}function v(e){return e&&e.newWindow===!1?"_self":"_blank"}function Y(e,t={}){const n=Object.hasOwnProperty.call(t,"height")?`${t.height}`:`${V}`,r=Object.hasOwnProperty.call(t,"width")?`${t.width}`:void 0;e.setAttribute("height",n),r?e.setAttribute("width",r):e.setAttribute("style","width:100%;")}function Q(e,t,n={}){var i,a;const r=((a=(i=e.allow)==null?void 0:i.split(";"))==null?void 0:a.map(l=>l.trim()))??[];n.crossOriginIsolated&&!r.includes("cross-origin-isolated")&&r.push("cross-origin-isolated"),r.length>0&&(t.allow=r.join("; "))}class ee{constructor(t){this.pending={},this.port=t,this.port.onmessage=this.messageListener.bind(this)}request({type:t,payload:n}){return new Promise((r,i)=>{const a=L();this.pending[a]={resolve:r,reject:i},this.port.postMessage({type:t,payload:{...n,__reqid:a}})})}messageListener(t){var d;if(typeof((d=t.data.payload)==null?void 0:d.__reqid)!="string")return;const{type:n,payload:r}=t.data,{__reqid:i,__success:a,__error:l}=r;this.pending[i]&&(a?this.pending[i].resolve(this.cleanResult(r)):this.pending[i].reject(l?`${n}: ${l}`:n),delete this.pending[i])}cleanResult(t){const n={...t};return delete n.__reqid,delete n.__success,delete n.__error,Object.keys(n).length?n:null}}class te{constructor(t,n){this.editor={openFile:r=>this._rdc.request({type:"SDK_OPEN_FILE",payload:{path:r}}),setCurrentFile:r=>this._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:r}}),setTheme:r=>this._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:r}}),setView:r=>this._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:r}}),showSidebar:(r=!0)=>this._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:r}})},this.preview={origin:"",getUrl:()=>this._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(r=>(r==null?void 0:r.url)??null),setUrl:(r="/")=>{if(typeof r!="string"||!r.startsWith("/"))throw new Error(`Invalid argument: expected a path starting with '/', got '${r}'`);return this._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:r}})}},this._rdc=new ee(t),Object.defineProperty(this.preview,"origin",{value:typeof n.previewOrigin=="string"?n.previewOrigin:null,writable:!1})}applyFsDiff(t){const n=r=>r!==null&&typeof r=="object";if(!n(t)||!n(t.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(t.destroy))throw new Error("Invalid diff object: expected diff.destroy to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:t})}getDependencies(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})}getFsSnapshot(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})}}const y=[];class ne{constructor(t){this.id=L(),this.element=t,this.pending=new Promise((n,r)=>{const i=({data:c,ports:u})=>{(c==null?void 0:c.action)==="SDK_INIT_SUCCESS"&&c.id===this.id&&(this.vm=new te(u[0],c.payload),n(this.vm),l())},a=()=>{var c;(c=this.element.contentWindow)==null||c.postMessage({action:"SDK_INIT",id:this.id},"*")};function l(){window.clearInterval(p),window.removeEventListener("message",i)}window.addEventListener("message",i),a();let d=0;const p=window.setInterval(()=>{if(this.vm){l();return}if(d>=K){l(),r("Timeout: Unable to establish a connection with the StackBlitz VM"),y.forEach((c,u)=>{c.id===this.id&&y.splice(u,1)});return}d++,a()},q)}),y.push(this)}}const re=e=>{const t=e instanceof Element?"element":"id";return y.find(n=>n[t]===e)??null};function ie(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function se(e){return e.replace(/\[/g,"%5B").replace(/\]/g,"%5D")}function C({template:e,title:t,description:n,dependencies:r,files:i,settings:a}){if(!A.includes(e)){const c=A.map(u=>`'${u}'`).join(", ");console.warn(`Unsupported project.template: must be one of ${c}`)}const l=[],d=(c,u,h="")=>{l.push(ie(c,typeof u=="string"?u:h))};d("project[title]",t),typeof n=="string"&&n.length>0&&d("project[description]",n),d("project[template]",e,"javascript"),r&&(e==="node"?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):d("project[dependencies]",JSON.stringify(r))),a&&d("project[settings]",JSON.stringify(a)),Object.entries(i).forEach(([c,u])=>{d(`project[files][${se(c)}]`,u)});const p=document.createElement("form");return p.method="POST",p.setAttribute("style","display:none!important;"),p.append(...l),p}function oe(e,t){const n=C(e);return n.action=E("/run",t),n.id="sb_run",`<!doctype html>
2
2
  <html>
3
3
  <head><title></title></head>
4
4
  <body>