@tscircuit/runframe 0.0.173 → 0.0.175
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
|
@@ -71,6 +71,79 @@ The CircuitJsonPreview component provides:
|
|
|
71
71
|
import evalWebWorkerBlobUrl from "@tscircuit/eval/blob-url"
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
### Standalone Iframe
|
|
75
|
+
|
|
76
|
+
RunFrame can be embedded in an iframe, allowing you to evaluate tscircuit code from a parent application.
|
|
77
|
+
|
|
78
|
+
First, create an HTML file that will host your RunFrame iframe:
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<!DOCTYPE html>
|
|
82
|
+
<html>
|
|
83
|
+
<head>
|
|
84
|
+
<title>RunFrame Host</title>
|
|
85
|
+
</head>
|
|
86
|
+
<body>
|
|
87
|
+
<iframe
|
|
88
|
+
id="runframe"
|
|
89
|
+
src="https://runframe.tscircuit.com/iframe.html"
|
|
90
|
+
style="width: 100%; height: 600px; border: none;"
|
|
91
|
+
></iframe>
|
|
92
|
+
|
|
93
|
+
<script>
|
|
94
|
+
const iframe = document.getElementById("runframe")
|
|
95
|
+
|
|
96
|
+
// Example: Send circuit code to the iframe
|
|
97
|
+
function updateCircuit() {
|
|
98
|
+
iframe.contentWindow.postMessage(
|
|
99
|
+
{
|
|
100
|
+
vfs: {
|
|
101
|
+
"main.tsx": `
|
|
102
|
+
circuit.add(
|
|
103
|
+
<resistor resistance="1k" />
|
|
104
|
+
)
|
|
105
|
+
`,
|
|
106
|
+
},
|
|
107
|
+
entrypoint: "main.tsx",
|
|
108
|
+
},
|
|
109
|
+
"*"
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Listen for messages from the iframe
|
|
114
|
+
window.addEventListener("message", (event) => {
|
|
115
|
+
if (event.data.type === "CIRCUIT_RENDERED") {
|
|
116
|
+
console.log("Circuit rendering complete:", event.data.circuitJson)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
</script>
|
|
120
|
+
</body>
|
|
121
|
+
</html>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Communication Protocol
|
|
125
|
+
|
|
126
|
+
Messages sent to the iframe should follow this format:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
interface IframeMessage {
|
|
130
|
+
vfs?: Record<string, string> // Virtual filesystem map
|
|
131
|
+
entrypoint?: string // Entry point file name
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Example message:
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
{
|
|
139
|
+
vfs: {
|
|
140
|
+
"main.tsx": "circuit.add(<resistor resistance=\"1k\" />)",
|
|
141
|
+
"components.tsx": "export const CustomComponent = () => ..."
|
|
142
|
+
},
|
|
143
|
+
entrypoint: "main.tsx"
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
74
147
|
## Development
|
|
75
148
|
|
|
76
149
|
### File-Server Interaction with Edit Events
|
|
@@ -163,7 +163,7 @@ var ErrorTabContent = ({
|
|
|
163
163
|
alert("Error copied to clipboard!");
|
|
164
164
|
},
|
|
165
165
|
children: [
|
|
166
|
-
/* @__PURE__ */ jsx4(ClipboardIcon, { className: "rf-w-4 rf-h-4
|
|
166
|
+
/* @__PURE__ */ jsx4(ClipboardIcon, { className: "rf-w-4 rf-h-4" }),
|
|
167
167
|
"Copy Error"
|
|
168
168
|
]
|
|
169
169
|
}
|
|
@@ -178,7 +178,7 @@ var ErrorTabContent = ({
|
|
|
178
178
|
);
|
|
179
179
|
},
|
|
180
180
|
children: [
|
|
181
|
-
/* @__PURE__ */ jsx4(GitHubLogoIcon, { className: "rf-w-4 rf-h-4
|
|
181
|
+
/* @__PURE__ */ jsx4(GitHubLogoIcon, { className: "rf-w-4 rf-h-4" }),
|
|
182
182
|
"Report Issue"
|
|
183
183
|
]
|
|
184
184
|
}
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -12990,7 +12990,7 @@ ${l.join(`
|
|
|
12990
12990
|
*
|
|
12991
12991
|
* This source code is licensed under the ISC license.
|
|
12992
12992
|
* See the LICENSE file in the root directory of this source tree.
|
|
12993
|
-
*/const wSt=eS("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),FMe=r=>typeof r=="boolean"?`${r}`:r===0?"0":r,BMe=Ob,TSt=((r,e)=>t=>{var n;if((e==null?void 0:e.variants)==null)return BMe(r,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(c=>{const u=t==null?void 0:t[c],d=a==null?void 0:a[c];if(u===null)return null;const g=FMe(u)||FMe(d);return i[c][g]}),s=t&&Object.entries(t).reduce((c,u)=>{let[d,g]=u;return g===void 0||(c[d]=g),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:g,..._}=u;return Object.entries(_).every(x=>{let[T,M]=x;return Array.isArray(M)?M.includes({...a,...s}[T]):{...a,...s}[T]===M})?[...c,d,g]:c},[]);return BMe(r,o,l,t==null?void 0:t.class,t==null?void 0:t.className)})("rf-inline-flex rf-items-center rf-justify-center rf-gap-2 rf-whitespace-nowrap rf-rounded-md rf-text-sm rf-font-medium rf-transition-colors focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-pointer-events-none disabled:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus-visible:rf-ring-zinc-300",{variants:{variant:{default:"rf-bg-zinc-900 rf-text-zinc-50 rf-shadow hover:rf-bg-zinc-900/90 dark:rf-bg-zinc-50 dark:rf-text-zinc-900 dark:hover:rf-bg-zinc-50/90",destructive:"rf-bg-red-500 rf-text-zinc-50 rf-shadow-sm hover:rf-bg-red-500/90 dark:rf-bg-red-900 dark:rf-text-zinc-50 dark:hover:rf-bg-red-900/90",outline:"rf-border rf-border-zinc-200 rf-bg-white rf-shadow-sm hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",secondary:"rf-bg-zinc-100 rf-text-zinc-900 rf-shadow-sm hover:rf-bg-zinc-100/80 dark:rf-bg-zinc-800 dark:rf-text-zinc-50 dark:hover:rf-bg-zinc-800/80",ghost:"hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",link:"rf-text-zinc-900 rf-underline-offset-4 hover:rf-underline dark:rf-text-zinc-50"},size:{default:"rf-h-9 rf-px-4 rf-py-2",sm:"rf-h-8 rf-rounded-md rf-px-3 rf-text-xs",lg:"rf-h-10 rf-rounded-md rf-px-8",icon:"rf-h-9 rf-w-9"}},defaultVariants:{variant:"default",size:"default"}}),hC=Ct.forwardRef(({className:r,variant:e,size:t,asChild:n=!1,...i},a)=>{const o=n?B8:"button";return _t.jsx(o,{className:Pg(TSt({variant:e,size:t,className:r})),ref:a,...i})});hC.displayName="Button";const MSt=({code:r,isStreaming:e,errorMessage:t})=>t?_t.jsxs(_t.Fragment,{children:[_t.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-max-h-[500px] rf-overflow-y-auto",children:_t.jsxs("div",{className:"rf-p-4",children:[_t.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error"}),_t.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:t})]})}),_t.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[_t.jsxs(hC,{variant:"outline",onClick:()=>{t&&(navigator.clipboard.writeText(t),alert("Error copied to clipboard!"))},children:[_t.jsx(xSt,{className:"rf-w-4 rf-h-4
|
|
12993
|
+
*/const wSt=eS("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),FMe=r=>typeof r=="boolean"?`${r}`:r===0?"0":r,BMe=Ob,TSt=((r,e)=>t=>{var n;if((e==null?void 0:e.variants)==null)return BMe(r,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(c=>{const u=t==null?void 0:t[c],d=a==null?void 0:a[c];if(u===null)return null;const g=FMe(u)||FMe(d);return i[c][g]}),s=t&&Object.entries(t).reduce((c,u)=>{let[d,g]=u;return g===void 0||(c[d]=g),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:g,..._}=u;return Object.entries(_).every(x=>{let[T,M]=x;return Array.isArray(M)?M.includes({...a,...s}[T]):{...a,...s}[T]===M})?[...c,d,g]:c},[]);return BMe(r,o,l,t==null?void 0:t.class,t==null?void 0:t.className)})("rf-inline-flex rf-items-center rf-justify-center rf-gap-2 rf-whitespace-nowrap rf-rounded-md rf-text-sm rf-font-medium rf-transition-colors focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-pointer-events-none disabled:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus-visible:rf-ring-zinc-300",{variants:{variant:{default:"rf-bg-zinc-900 rf-text-zinc-50 rf-shadow hover:rf-bg-zinc-900/90 dark:rf-bg-zinc-50 dark:rf-text-zinc-900 dark:hover:rf-bg-zinc-50/90",destructive:"rf-bg-red-500 rf-text-zinc-50 rf-shadow-sm hover:rf-bg-red-500/90 dark:rf-bg-red-900 dark:rf-text-zinc-50 dark:hover:rf-bg-red-900/90",outline:"rf-border rf-border-zinc-200 rf-bg-white rf-shadow-sm hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",secondary:"rf-bg-zinc-100 rf-text-zinc-900 rf-shadow-sm hover:rf-bg-zinc-100/80 dark:rf-bg-zinc-800 dark:rf-text-zinc-50 dark:hover:rf-bg-zinc-800/80",ghost:"hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",link:"rf-text-zinc-900 rf-underline-offset-4 hover:rf-underline dark:rf-text-zinc-50"},size:{default:"rf-h-9 rf-px-4 rf-py-2",sm:"rf-h-8 rf-rounded-md rf-px-3 rf-text-xs",lg:"rf-h-10 rf-rounded-md rf-px-8",icon:"rf-h-9 rf-w-9"}},defaultVariants:{variant:"default",size:"default"}}),hC=Ct.forwardRef(({className:r,variant:e,size:t,asChild:n=!1,...i},a)=>{const o=n?B8:"button";return _t.jsx(o,{className:Pg(TSt({variant:e,size:t,className:r})),ref:a,...i})});hC.displayName="Button";const MSt=({code:r,isStreaming:e,errorMessage:t})=>t?_t.jsxs(_t.Fragment,{children:[_t.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-max-h-[500px] rf-overflow-y-auto",children:_t.jsxs("div",{className:"rf-p-4",children:[_t.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error"}),_t.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:t})]})}),_t.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[_t.jsxs(hC,{variant:"outline",onClick:()=>{t&&(navigator.clipboard.writeText(t),alert("Error copied to clipboard!"))},children:[_t.jsx(xSt,{className:"rf-w-4 rf-h-4"}),"Copy Error"]}),_t.jsxs(hC,{variant:"outline",onClick:()=>{window.alert("Not supported yet! Please report/upvote an issue on github.com/tscircuit/tscircuit")},children:[_t.jsx(pSt,{className:"rf-w-4 rf-h-4"}),"Report Issue"]})]})]}):_t.jsx("div",{className:"rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200",children:_t.jsxs("div",{className:"rf-p-4",children:[_t.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-green-800 rf-mb-3",children:"No Errors 👌"}),_t.jsx("p",{className:"rf-text-sm rf-text-green-700",children:"Your code is running without any errors."})]})});var zJ,HMe;function CSt(){if(HMe)return zJ;HMe=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(g,_)=>{for(var x in _)r(g,x,{get:_[x],enumerable:!0})},a=(g,_,x,T)=>{if(_&&typeof _=="object"||typeof _=="function")for(let M of t(_))!n.call(g,M)&&M!==x&&r(g,M,{get:()=>_[M],enumerable:!(T=e(_,M))||T.enumerable});return g},o=g=>a(r({},"__esModule",{value:!0}),g),s={};i(s,{default:()=>d,useMouseMatrixTransform:()=>u}),zJ=o(s);var l=L6e,c=Lx(),u=(g={})=>{const _=(0,c.useRef)(null),[x,T]=(0,c.useState)(0),M=g.canvasElm??_.current,[R,L]=(0,c.useState)(g.initialTransform??(0,l.identity)()),[z,j]=(0,c.useState)(0),[Z,ee]=(0,c.useReducer)(_e=>_e+1,0),W=(0,c.useCallback)(_e=>{g.onSetTransform&&g.onSetTransform(_e),g.transform||L(_e)},[g.onSetTransform,L]),se=(0,c.useCallback)(_e=>{W(_e),ee()},[W]),ae=g.transform??R,ue=(0,c.useCallback)(()=>{T(Date.now())},[]);(0,c.useEffect)(()=>{const _e=g.canvasElm??_.current;if(_e&&!M){j(z+1);return}if(!_e){const at=setTimeout(()=>{j(z+1)},100);return()=>clearTimeout(at)}let Se=g.transform??R,Ae={x:0,y:0},ke={x:0,y:0},De=!1;const Oe=at=>({x:at.pageX-_e.getBoundingClientRect().left-window.scrollX,y:at.pageY-_e.getBoundingClientRect().top-window.scrollY});function Ne(at){g.enabled!==!1&&(g.shouldDrag&&!g.shouldDrag(at)||(Ae=Oe(at),!(Date.now()-x<100)&&(De=!0,at.preventDefault())))}function Ue(at){if(!De||g.enabled===!1||g.shouldDrag&&!g.shouldDrag(at))return;ke=Oe(at);const ct=(0,l.compose)((0,l.translate)(ke.x-Ae.x,ke.y-Ae.y),Se);W(ct),Se=ct,De=!1}function je(at){Oe(at),!(!De||g.enabled===!1)&&(g.shouldDrag&&!g.shouldDrag(at)||(ke=Oe(at),W((0,l.compose)((0,l.translate)(ke.x-Ae.x,ke.y-Ae.y),Se))))}function ze(at){if(g.enabled===!1||g.shouldDrag&&!g.shouldDrag(at))return;const ct=Oe(at),dt=(0,l.compose)((0,l.translate)(ct.x,ct.y),(0,l.scale)(1-at.deltaY/1e3,1-at.deltaY/1e3),(0,l.translate)(-ct.x,-ct.y),Se);W(dt),Se=dt,at.preventDefault()}function Ie(at){if(!De||g.shouldDrag&&!g.shouldDrag(at))return;if(_e){const dt=_e.getBoundingClientRect();if(at.clientX>=dt.left+10&&at.clientX<=dt.right-10&&at.clientY>=dt.top+10&&at.clientY<=dt.bottom-10)return}De=!1,ke=Oe(at);const ct=(0,l.compose)((0,l.translate)(ke.x-Ae.x,ke.y-Ae.y),Se);W(ct),Se=ct}return _e.addEventListener("mousedown",Ne),_e.addEventListener("mouseup",Ue),window.addEventListener("mousemove",je),_e.addEventListener("mouseout",Ie),_e.addEventListener("wheel",ze),()=>{_e.removeEventListener("mousedown",Ne),_e.removeEventListener("mouseup",Ue),window.removeEventListener("mousemove",je),_e.removeEventListener("mouseout",Ie),_e.removeEventListener("wheel",ze)}},[M,z,Z,x,g.enabled,g.shouldDrag]);const me=(0,c.useCallback)(_e=>(0,l.applyToPoint)(ae,_e),[ae]);return{ref:_,transform:ae,applyTransformToPoint:me,setTransform:se,cancelDrag:ue}},d=u;return zJ}var VMe=CSt();/*!
|
|
12994
12994
|
* Determine if an object is a Buffer
|
|
12995
12995
|
*
|
|
12996
12996
|
* @author Feross Aboukhadijeh <https://feross.org>
|
package/dist/standalone.min.js
CHANGED
|
@@ -12995,7 +12995,7 @@ ${l.join(`
|
|
|
12995
12995
|
*
|
|
12996
12996
|
* This source code is licensed under the ISC license.
|
|
12997
12997
|
* See the LICENSE file in the root directory of this source tree.
|
|
12998
|
-
*/const aEt=u4("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),o7e=r=>typeof r=="boolean"?`${r}`:r===0?"0":r,s7e=Ob,oEt=((r,e)=>t=>{var n;if((e==null?void 0:e.variants)==null)return s7e(r,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(c=>{const u=t==null?void 0:t[c],d=a==null?void 0:a[c];if(u===null)return null;const g=o7e(u)||o7e(d);return i[c][g]}),s=t&&Object.entries(t).reduce((c,u)=>{let[d,g]=u;return g===void 0||(c[d]=g),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:g,..._}=u;return Object.entries(_).every(x=>{let[T,M]=x;return Array.isArray(M)?M.includes({...a,...s}[T]):{...a,...s}[T]===M})?[...c,d,g]:c},[]);return s7e(r,o,l,t==null?void 0:t.class,t==null?void 0:t.className)})("rf-inline-flex rf-items-center rf-justify-center rf-gap-2 rf-whitespace-nowrap rf-rounded-md rf-text-sm rf-font-medium rf-transition-colors focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-pointer-events-none disabled:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus-visible:rf-ring-zinc-300",{variants:{variant:{default:"rf-bg-zinc-900 rf-text-zinc-50 rf-shadow hover:rf-bg-zinc-900/90 dark:rf-bg-zinc-50 dark:rf-text-zinc-900 dark:hover:rf-bg-zinc-50/90",destructive:"rf-bg-red-500 rf-text-zinc-50 rf-shadow-sm hover:rf-bg-red-500/90 dark:rf-bg-red-900 dark:rf-text-zinc-50 dark:hover:rf-bg-red-900/90",outline:"rf-border rf-border-zinc-200 rf-bg-white rf-shadow-sm hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",secondary:"rf-bg-zinc-100 rf-text-zinc-900 rf-shadow-sm hover:rf-bg-zinc-100/80 dark:rf-bg-zinc-800 dark:rf-text-zinc-50 dark:hover:rf-bg-zinc-800/80",ghost:"hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",link:"rf-text-zinc-900 rf-underline-offset-4 hover:rf-underline dark:rf-text-zinc-50"},size:{default:"rf-h-9 rf-px-4 rf-py-2",sm:"rf-h-8 rf-rounded-md rf-px-3 rf-text-xs",lg:"rf-h-10 rf-rounded-md rf-px-8",icon:"rf-h-9 rf-w-9"}},defaultVariants:{variant:"default",size:"default"}}),P6=Mt.forwardRef(({className:r,variant:e,size:t,asChild:n=!1,...i},a)=>{const o=n?Bw:"button";return yt.jsx(o,{className:Pg(oEt({variant:e,size:t,className:r})),ref:a,...i})});P6.displayName="Button";const sEt=({code:r,isStreaming:e,errorMessage:t})=>t?yt.jsxs(yt.Fragment,{children:[yt.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-max-h-[500px] rf-overflow-y-auto",children:yt.jsxs("div",{className:"rf-p-4",children:[yt.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error"}),yt.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:t})]})}),yt.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[yt.jsxs(P6,{variant:"outline",onClick:()=>{t&&(navigator.clipboard.writeText(t),alert("Error copied to clipboard!"))},children:[yt.jsx(tEt,{className:"rf-w-4 rf-h-4
|
|
12998
|
+
*/const aEt=u4("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),o7e=r=>typeof r=="boolean"?`${r}`:r===0?"0":r,s7e=Ob,oEt=((r,e)=>t=>{var n;if((e==null?void 0:e.variants)==null)return s7e(r,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(c=>{const u=t==null?void 0:t[c],d=a==null?void 0:a[c];if(u===null)return null;const g=o7e(u)||o7e(d);return i[c][g]}),s=t&&Object.entries(t).reduce((c,u)=>{let[d,g]=u;return g===void 0||(c[d]=g),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:g,..._}=u;return Object.entries(_).every(x=>{let[T,M]=x;return Array.isArray(M)?M.includes({...a,...s}[T]):{...a,...s}[T]===M})?[...c,d,g]:c},[]);return s7e(r,o,l,t==null?void 0:t.class,t==null?void 0:t.className)})("rf-inline-flex rf-items-center rf-justify-center rf-gap-2 rf-whitespace-nowrap rf-rounded-md rf-text-sm rf-font-medium rf-transition-colors focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-pointer-events-none disabled:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus-visible:rf-ring-zinc-300",{variants:{variant:{default:"rf-bg-zinc-900 rf-text-zinc-50 rf-shadow hover:rf-bg-zinc-900/90 dark:rf-bg-zinc-50 dark:rf-text-zinc-900 dark:hover:rf-bg-zinc-50/90",destructive:"rf-bg-red-500 rf-text-zinc-50 rf-shadow-sm hover:rf-bg-red-500/90 dark:rf-bg-red-900 dark:rf-text-zinc-50 dark:hover:rf-bg-red-900/90",outline:"rf-border rf-border-zinc-200 rf-bg-white rf-shadow-sm hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",secondary:"rf-bg-zinc-100 rf-text-zinc-900 rf-shadow-sm hover:rf-bg-zinc-100/80 dark:rf-bg-zinc-800 dark:rf-text-zinc-50 dark:hover:rf-bg-zinc-800/80",ghost:"hover:rf-bg-zinc-100 hover:rf-text-zinc-900 dark:hover:rf-bg-zinc-800 dark:hover:rf-text-zinc-50",link:"rf-text-zinc-900 rf-underline-offset-4 hover:rf-underline dark:rf-text-zinc-50"},size:{default:"rf-h-9 rf-px-4 rf-py-2",sm:"rf-h-8 rf-rounded-md rf-px-3 rf-text-xs",lg:"rf-h-10 rf-rounded-md rf-px-8",icon:"rf-h-9 rf-w-9"}},defaultVariants:{variant:"default",size:"default"}}),P6=Mt.forwardRef(({className:r,variant:e,size:t,asChild:n=!1,...i},a)=>{const o=n?Bw:"button";return yt.jsx(o,{className:Pg(oEt({variant:e,size:t,className:r})),ref:a,...i})});P6.displayName="Button";const sEt=({code:r,isStreaming:e,errorMessage:t})=>t?yt.jsxs(yt.Fragment,{children:[yt.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-max-h-[500px] rf-overflow-y-auto",children:yt.jsxs("div",{className:"rf-p-4",children:[yt.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error"}),yt.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:t})]})}),yt.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[yt.jsxs(P6,{variant:"outline",onClick:()=>{t&&(navigator.clipboard.writeText(t),alert("Error copied to clipboard!"))},children:[yt.jsx(tEt,{className:"rf-w-4 rf-h-4"}),"Copy Error"]}),yt.jsxs(P6,{variant:"outline",onClick:()=>{window.alert("Not supported yet! Please report/upvote an issue on github.com/tscircuit/tscircuit")},children:[yt.jsx($St,{className:"rf-w-4 rf-h-4"}),"Report Issue"]})]})]}):yt.jsx("div",{className:"rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200",children:yt.jsxs("div",{className:"rf-p-4",children:[yt.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-green-800 rf-mb-3",children:"No Errors 👌"}),yt.jsx("p",{className:"rf-text-sm rf-text-green-700",children:"Your code is running without any errors."})]})});var YJ,l7e;function lEt(){if(l7e)return YJ;l7e=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(g,_)=>{for(var x in _)r(g,x,{get:_[x],enumerable:!0})},a=(g,_,x,T)=>{if(_&&typeof _=="object"||typeof _=="function")for(let M of t(_))!n.call(g,M)&&M!==x&&r(g,M,{get:()=>_[M],enumerable:!(T=e(_,M))||T.enumerable});return g},o=g=>a(r({},"__esModule",{value:!0}),g),s={};i(s,{default:()=>d,useMouseMatrixTransform:()=>u}),YJ=o(s);var l=eTe,c=Lx(),u=(g={})=>{const _=(0,c.useRef)(null),[x,T]=(0,c.useState)(0),M=g.canvasElm??_.current,[C,L]=(0,c.useState)(g.initialTransform??(0,l.identity)()),[O,V]=(0,c.useState)(0),[Z,ee]=(0,c.useReducer)(_e=>_e+1,0),W=(0,c.useCallback)(_e=>{g.onSetTransform&&g.onSetTransform(_e),g.transform||L(_e)},[g.onSetTransform,L]),se=(0,c.useCallback)(_e=>{W(_e),ee()},[W]),ae=g.transform??C,ue=(0,c.useCallback)(()=>{T(Date.now())},[]);(0,c.useEffect)(()=>{const _e=g.canvasElm??_.current;if(_e&&!M){V(O+1);return}if(!_e){const at=setTimeout(()=>{V(O+1)},100);return()=>clearTimeout(at)}let Se=g.transform??C,Ae={x:0,y:0},ke={x:0,y:0},De=!1;const Oe=at=>({x:at.pageX-_e.getBoundingClientRect().left-window.scrollX,y:at.pageY-_e.getBoundingClientRect().top-window.scrollY});function Ne(at){g.enabled!==!1&&(g.shouldDrag&&!g.shouldDrag(at)||(Ae=Oe(at),!(Date.now()-x<100)&&(De=!0,at.preventDefault())))}function Ue(at){if(!De||g.enabled===!1||g.shouldDrag&&!g.shouldDrag(at))return;ke=Oe(at);const ct=(0,l.compose)((0,l.translate)(ke.x-Ae.x,ke.y-Ae.y),Se);W(ct),Se=ct,De=!1}function je(at){Oe(at),!(!De||g.enabled===!1)&&(g.shouldDrag&&!g.shouldDrag(at)||(ke=Oe(at),W((0,l.compose)((0,l.translate)(ke.x-Ae.x,ke.y-Ae.y),Se))))}function ze(at){if(g.enabled===!1||g.shouldDrag&&!g.shouldDrag(at))return;const ct=Oe(at),dt=(0,l.compose)((0,l.translate)(ct.x,ct.y),(0,l.scale)(1-at.deltaY/1e3,1-at.deltaY/1e3),(0,l.translate)(-ct.x,-ct.y),Se);W(dt),Se=dt,at.preventDefault()}function Ie(at){if(!De||g.shouldDrag&&!g.shouldDrag(at))return;if(_e){const dt=_e.getBoundingClientRect();if(at.clientX>=dt.left+10&&at.clientX<=dt.right-10&&at.clientY>=dt.top+10&&at.clientY<=dt.bottom-10)return}De=!1,ke=Oe(at);const ct=(0,l.compose)((0,l.translate)(ke.x-Ae.x,ke.y-Ae.y),Se);W(ct),Se=ct}return _e.addEventListener("mousedown",Ne),_e.addEventListener("mouseup",Ue),window.addEventListener("mousemove",je),_e.addEventListener("mouseout",Ie),_e.addEventListener("wheel",ze),()=>{_e.removeEventListener("mousedown",Ne),_e.removeEventListener("mouseup",Ue),window.removeEventListener("mousemove",je),_e.removeEventListener("mouseout",Ie),_e.removeEventListener("wheel",ze)}},[M,O,Z,x,g.enabled,g.shouldDrag]);const me=(0,c.useCallback)(_e=>(0,l.applyToPoint)(ae,_e),[ae]);return{ref:_,transform:ae,applyTransformToPoint:me,setTransform:se,cancelDrag:ue}},d=u;return YJ}var c7e=lEt();/*!
|
|
12999
12999
|
* Determine if an object is a Buffer
|
|
13000
13000
|
*
|
|
13001
13001
|
* @author Feross Aboukhadijeh <https://feross.org>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/runframe",
|
|
3
3
|
"main": "dist/preview.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.175",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/preview.js",
|
|
8
8
|
"./preview": "./dist/preview.js",
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"build:lib": "tsup-node lib/preview.ts lib/runner.ts --platform browser --format esm --dts",
|
|
20
20
|
"build:css": "bun run scripts/build-css.ts",
|
|
21
21
|
"build:css:watch": "chokidar 'lib/components/**/*.tsx' -c 'bun run build:css'",
|
|
22
|
-
"build:site": "cosmos-export",
|
|
22
|
+
"build:site": "cosmos-export && bun run build:iframe && cp ./dist/iframe.html ./cosmos-export && cp ./dist/iframe.min.js ./cosmos-export",
|
|
23
23
|
"build:standalone": "STANDALONE=1 vite build",
|
|
24
|
+
"build:iframe": "STANDALONE=iframe vite build && mv ./dist/lib/entrypoints/iframe.html ./dist/iframe.html",
|
|
24
25
|
"build:standalone-preview": "STANDALONE=preview vite build --emptyOutDir false",
|
|
25
26
|
"analyze": "source-map-explorer 'dist/standalone.min.js'",
|
|
26
27
|
"format:check": "biome format .",
|