code-playpad 0.12.0 → 0.13.0
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 +22 -5
- package/dist/cdn.js +2 -2
- package/dist/{cpp-xLJOrOXX.js → cpp-BVqJclgd.js} +1 -1
- package/dist/{element-Dzhksh6_.js → element-BGm-1VOq.js} +22 -16
- package/dist/element.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{java-DFiOVxDN.js → java-BEvn335o.js} +1 -1
- package/dist/{javascript-CLaHCZ8o.js → javascript-j4E_GxwK.js} +1 -1
- package/dist/{pyodide-Cs-Kwccb.js → pyodide-BRw8SuuC.js} +1 -1
- package/dist/{react-DmuIc3qw.js → react-uV_SMJrS.js} +1 -1
- package/dist/react.d.ts +3 -1
- package/dist/react.js +1 -1
- package/dist/standalone.js +21 -15
- package/dist/{worker-runtime-tSXm-pPB.js → worker-runtime-Bk9bsGrP.js} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ experimental C and C++, and multi-file React — entirely in the reader's browse
|
|
|
9
9
|
**[Live demo →](https://code-playpad.swengr.com)**
|
|
10
10
|
|
|
11
11
|
```html
|
|
12
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.
|
|
12
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.13.0/dist/standalone.js"></script>
|
|
13
13
|
|
|
14
14
|
<code-playpad height="auto">
|
|
15
15
|
print("hello from a static page")
|
|
@@ -229,7 +229,10 @@ matches `npm create vite`.
|
|
|
229
229
|
```
|
|
230
230
|
|
|
231
231
|
Add `file-view="tree"` to list the files as a folder tree beside the editor instead
|
|
232
|
-
of as tabs. It works for every language.
|
|
232
|
+
of as tabs. It works for every language. In a React project, the tree (20% of the
|
|
233
|
+
width) and the code share the first row, and the preview and console fill the second.
|
|
234
|
+
Set the tree's starting width with `tree-width`: a percentage such as `tree-width="35%"`,
|
|
235
|
+
or a number of pixels. The default for other languages is 200 pixels.
|
|
233
236
|
|
|
234
237
|
**Writing files in a page.** HTML reads JSX as tags, so `<App />` would vanish.
|
|
235
238
|
Use one of these:
|
|
@@ -258,7 +261,8 @@ script has already run.
|
|
|
258
261
|
|
|
259
262
|
**Attributes and layout.** `preview-height` sets the preview's height (default 320
|
|
260
263
|
pixels). The preview sits beside the editor when the widget is at least 760px wide,
|
|
261
|
-
and under it otherwise; that depends on the widget's width, not the screen's.
|
|
264
|
+
and under it otherwise; that depends on the widget's width, not the screen's. With a
|
|
265
|
+
file tree, it always sits under the tree and the code. It runs
|
|
262
266
|
on Run or Ctrl/⌘+Enter, and when it nears the viewport if you set `autorun`.
|
|
263
267
|
|
|
264
268
|
**Resizing.** Drag the dividers between the file tree, the code, the preview and the
|
|
@@ -388,7 +392,7 @@ actually sent.
|
|
|
388
392
|
### From a CDN — nothing to install
|
|
389
393
|
|
|
390
394
|
```html
|
|
391
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.
|
|
395
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.13.0/dist/standalone.js"></script>
|
|
392
396
|
```
|
|
393
397
|
|
|
394
398
|
This is the `standalone` build: CodeMirror is bundled in, so a static blog post
|
|
@@ -446,6 +450,7 @@ Next.js, Astro and SvelteKit need no dynamic import or `client:only` guard.
|
|
|
446
450
|
| `height` | number (px), any CSS length, or `auto` |
|
|
447
451
|
| `min-height` / `max-height` | bounds for `auto` |
|
|
448
452
|
| `preview-height` | `react` only: the preview's height |
|
|
453
|
+
| `tree-width` | the file tree's width with `file-view="tree"`: `35%` or pixels (default `20%` for `react`, 200 pixels otherwise) |
|
|
449
454
|
| `file-view` | how a widget with several files lists them: `tabs` (default) or `tree` |
|
|
450
455
|
| `open-file` | which file is on screen to begin with, when not the entry |
|
|
451
456
|
| `theme` | `light`, `dark`, or `auto` (default — follows the reader's saved choice, then the page, then the OS) |
|
|
@@ -997,7 +1002,7 @@ export function Exercise() {
|
|
|
997
1002
|
```
|
|
998
1003
|
|
|
999
1004
|
Props: `code`, `files`, `entry`, `openFile`, `language`, `height`, `minHeight`,
|
|
1000
|
-
`maxHeight`, `previewHeight`, `fileView`, `stdin`, `theme`, `themeControls`,
|
|
1005
|
+
`maxHeight`, `previewHeight`, `treeWidth`, `fileView`, `stdin`, `theme`, `themeControls`,
|
|
1001
1006
|
`readOnly`, `autoRun`, `persist`, `practice`, `className`, `style`, and the
|
|
1002
1007
|
callbacks `onReady`, `onRun`, `onOutput`, `onError`.
|
|
1003
1008
|
|
|
@@ -1080,6 +1085,18 @@ checked by SHA-256, so another version fails. A different origin must allow CORS
|
|
|
1080
1085
|
|
|
1081
1086
|
## Version history
|
|
1082
1087
|
|
|
1088
|
+
### 0.13.0
|
|
1089
|
+
|
|
1090
|
+
- **React projects with a file tree now use two rows:** the tree and the code on top,
|
|
1091
|
+
and the preview and console across the full width below, at any widget width. The
|
|
1092
|
+
preview used to sit in a third column. **Pages with `file-view="tree"` on a React
|
|
1093
|
+
project will look different,** and may want a different `height` or `preview-height`.
|
|
1094
|
+
- **New `tree-width` attribute,** with `treeWidth` on the React wrapper: the file tree's
|
|
1095
|
+
starting width, as a percentage such as `35%` or a number of pixels. The default is
|
|
1096
|
+
20% for React and 200 pixels for other languages.
|
|
1097
|
+
- **Fixed:** a long file tree stopped the row above the preview from shrinking when its divider was dragged.
|
|
1098
|
+
- **Fixed:** the divider above the preview did nothing when Open in window stacked the sections.
|
|
1099
|
+
|
|
1083
1100
|
### 0.12.0
|
|
1084
1101
|
|
|
1085
1102
|
- **Theme button and editor themes:** a light and dark toggle and a list of eight
|
package/dist/cdn.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! code-playpad 0.
|
|
2
|
-
export * from "https://cdn.jsdelivr.net/npm/code-playpad@0.
|
|
1
|
+
/*! code-playpad 0.13.0: CDN entry, loads dist/standalone.js of this exact version */
|
|
2
|
+
export * from "https://cdn.jsdelivr.net/npm/code-playpad@0.13.0/dist/standalone.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./config-DB58UVsk.js";import{t}from"./worker-runtime-tSXm-pPB.js";var n=`code-playpad-cpp-20.1.2-emscripten-4.0.6-r1`,r=/* @__PURE__ */ new Map;async function i(e){r.has(e)||r.set(e,(async()=>{try{return await caches.open(e)}catch{return}})()),await r.get(e)}var a='"use strict";(()=>{var it="code-playpad-cpp-20.1.2-emscripten-4.0.6-r1";async function ot(a,e,i,c,E){let t=new URL(a,i).href,r;try{r=await caches.open(c)}catch{}let n;try{n=await r?.match(t)}catch{}let s=async _=>{if(!_.ok)throw new Error(`Toolchain download failed: ${a} (HTTP ${_.status}). Check the asset URL and retry.`);let l=_.body?.getReader();if(!l)return _.arrayBuffer();let u=[],p=0,d=0;for(;;){let S=await l.read();if(S.done)break;if(p+=S.value.length,p>e.bytes)throw await l.cancel(),new Error(`Unexpected toolchain size: ${a}.`);u.push(S.value),performance.now()-d>100&&(E(`${n?"Reading cached":"Downloading"} ${a}: ${(p/1e6).toFixed(1)} / ${(e.bytes/1e6).toFixed(1)} MB (decoded)`),d=performance.now())}let R=new Uint8Array(p),h=0;for(let S of u)R.set(S,h),h+=S.length;return R.buffer},o=async _=>_.byteLength===e.bytes&&[...new Uint8Array(await crypto.subtle.digest("SHA-256",_))].map(l=>l.toString(16).padStart(2,"0")).join("")===e.sha256;if(n){try{let _=await s(n);if(await o(_))return _}catch{}try{await r?.delete(t)}catch{}n=void 0}let f=await s(await fetch(t));if(!await o(f))throw new Error(`Toolchain integrity check failed: ${a}. Use the pinned toolchain assets.`);try{await r?.put(t,new Response(f))}catch{}return f}var C=class a{static read_bytes(e,i){let c=new a;return c.buf=e.getUint32(i,!0),c.buf_len=e.getUint32(i+4,!0),c}static read_bytes_array(e,i,c){let E=[];for(let t=0;t<c;t++)E.push(a.read_bytes(e,i+8*t));return E}},L=class a{static read_bytes(e,i){let c=new a;return c.buf=e.getUint32(i,!0),c.buf_len=e.getUint32(i+4,!0),c}static read_bytes_array(e,i,c){let E=[];for(let t=0;t<c;t++)E.push(a.read_bytes(e,i+8*t));return E}},Q=0,Z=1,V=2;var J=2;var W=4;var q=1;var x=class{write_bytes(e,i){e.setUint8(i,this.fs_filetype),e.setUint16(i+2,this.fs_flags,!0),e.setBigUint64(i+8,this.fs_rights_base,!0),e.setBigUint64(i+16,this.fs_rights_inherited,!0)}constructor(e,i){this.fs_rights_base=0n,this.fs_rights_inherited=0n,this.fs_filetype=e,this.fs_flags=i}};var j=8,A=class{write_bytes(e,i){e.setBigUint64(i,this.dev,!0),e.setBigUint64(i+8,this.ino,!0),e.setUint8(i+16,this.filetype),e.setBigUint64(i+24,this.nlink,!0),e.setBigUint64(i+32,this.size,!0),e.setBigUint64(i+38,this.atim,!0),e.setBigUint64(i+46,this.mtim,!0),e.setBigUint64(i+52,this.ctim,!0)}constructor(e,i,c){this.dev=0n,this.nlink=0n,this.atim=0n,this.mtim=0n,this.ctim=0n,this.ino=e,this.filetype=i,this.size=c}},at=0;var ft=1,k=class a{static read_bytes(e,i){return new a(e.getBigUint64(i,!0),e.getUint8(i+8),e.getUint32(i+16,!0),e.getBigUint64(i+24,!0),e.getUint16(i+36,!0))}constructor(e,i,c,E,t){this.userdata=e,this.eventtype=i,this.clockid=c,this.timeout=E,this.flags=t}},Y=class{write_bytes(e,i){e.setBigUint64(i,this.userdata,!0),e.setUint16(i+8,this.error,!0),e.setUint8(i+10,this.eventtype)}constructor(e,i,c){this.userdata=e,this.error=i,this.eventtype=c}};var wt=class{enable(e){this.log=ht(e===void 0?!0:e,this.prefix)}get enabled(){return this.isEnabled}constructor(e){this.isEnabled=e,this.prefix="wasi:",this.enable(e)}};function ht(a,e){return a?console.log.bind(console,"%c%s","color: #265BA0",e):()=>{}}var y=new wt(!1);var U=class extends Error{constructor(e){super("exit with exit code "+e),this.code=e}},rt=class{start(e){this.inst=e;try{return e.exports._start(),0}catch(i){if(i instanceof U)return i.code;throw i}}initialize(e){this.inst=e,e.exports._initialize&&e.exports._initialize()}constructor(e,i,c,E={}){this.args=[],this.env=[],this.fds=[],y.enable(E.debug),this.args=e,this.env=i,this.fds=c;let t=this;this.wasiImport={args_sizes_get(r,n){let s=new DataView(t.inst.exports.memory.buffer);s.setUint32(r,t.args.length,!0);let o=0;for(let f of t.args)o+=f.length+1;return s.setUint32(n,o,!0),y.log(s.getUint32(r,!0),s.getUint32(n,!0)),0},args_get(r,n){let s=new DataView(t.inst.exports.memory.buffer),o=new Uint8Array(t.inst.exports.memory.buffer),f=n;for(let _=0;_<t.args.length;_++){s.setUint32(r,n,!0),r+=4;let l=new TextEncoder().encode(t.args[_]);o.set(l,n),s.setUint8(n+l.length,0),n+=l.length+1}return y.enabled&&y.log(new TextDecoder("utf-8").decode(o.slice(f,n))),0},environ_sizes_get(r,n){let s=new DataView(t.inst.exports.memory.buffer);s.setUint32(r,t.env.length,!0);let o=0;for(let f of t.env)o+=new TextEncoder().encode(f).length+1;return s.setUint32(n,o,!0),y.log(s.getUint32(r,!0),s.getUint32(n,!0)),0},environ_get(r,n){let s=new DataView(t.inst.exports.memory.buffer),o=new Uint8Array(t.inst.exports.memory.buffer),f=n;for(let _=0;_<t.env.length;_++){s.setUint32(r,n,!0),r+=4;let l=new TextEncoder().encode(t.env[_]);o.set(l,n),s.setUint8(n+l.length,0),n+=l.length+1}return y.enabled&&y.log(new TextDecoder("utf-8").decode(o.slice(f,n))),0},clock_res_get(r,n){let s;switch(r){case 1:{s=5000n;break}case 0:{s=1000000n;break}default:return 52}return new DataView(t.inst.exports.memory.buffer).setBigUint64(n,s,!0),0},clock_time_get(r,n,s){let o=new DataView(t.inst.exports.memory.buffer);if(r===0)o.setBigUint64(s,BigInt(new Date().getTime())*1000000n,!0);else if(r==1){let f;try{f=BigInt(Math.round(performance.now()*1e6))}catch{f=0n}o.setBigUint64(s,f,!0)}else o.setBigUint64(s,0n,!0);return 0},fd_advise(r,n,s,o){return t.fds[r]!=null?0:8},fd_allocate(r,n,s){return t.fds[r]!=null?t.fds[r].fd_allocate(n,s):8},fd_close(r){if(t.fds[r]!=null){let n=t.fds[r].fd_close();return t.fds[r]=void 0,n}else return 8},fd_datasync(r){return t.fds[r]!=null?t.fds[r].fd_sync():8},fd_fdstat_get(r,n){if(t.fds[r]!=null){let{ret:s,fdstat:o}=t.fds[r].fd_fdstat_get();return o?.write_bytes(new DataView(t.inst.exports.memory.buffer),n),s}else return 8},fd_fdstat_set_flags(r,n){return t.fds[r]!=null?t.fds[r].fd_fdstat_set_flags(n):8},fd_fdstat_set_rights(r,n,s){return t.fds[r]!=null?t.fds[r].fd_fdstat_set_rights(n,s):8},fd_filestat_get(r,n){if(t.fds[r]!=null){let{ret:s,filestat:o}=t.fds[r].fd_filestat_get();return o?.write_bytes(new DataView(t.inst.exports.memory.buffer),n),s}else return 8},fd_filestat_set_size(r,n){return t.fds[r]!=null?t.fds[r].fd_filestat_set_size(n):8},fd_filestat_set_times(r,n,s,o){return t.fds[r]!=null?t.fds[r].fd_filestat_set_times(n,s,o):8},fd_pread(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=C.read_bytes_array(_,n,s),p=0;for(let d of u){let{ret:R,data:h}=t.fds[r].fd_pread(d.buf_len,o);if(R!=0)return _.setUint32(f,p,!0),R;if(l.set(h,d.buf),p+=h.length,o+=BigInt(h.length),h.length!=d.buf_len)break}return _.setUint32(f,p,!0),0}else return 8},fd_prestat_get(r,n){let s=new DataView(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let{ret:o,prestat:f}=t.fds[r].fd_prestat_get();return f?.write_bytes(s,n),o}else return 8},fd_prestat_dir_name(r,n,s){if(t.fds[r]!=null){let{ret:o,prestat:f}=t.fds[r].fd_prestat_get();if(f==null)return o;let _=f.inner.pr_name;return new Uint8Array(t.inst.exports.memory.buffer).set(_.slice(0,s),n),_.byteLength>s?37:0}else return 8},fd_pwrite(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=L.read_bytes_array(_,n,s),p=0;for(let d of u){let R=l.slice(d.buf,d.buf+d.buf_len),{ret:h,nwritten:S}=t.fds[r].fd_pwrite(R,o);if(h!=0)return _.setUint32(f,p,!0),h;if(p+=S,o+=BigInt(S),S!=R.byteLength)break}return _.setUint32(f,p,!0),0}else return 8},fd_read(r,n,s,o){let f=new DataView(t.inst.exports.memory.buffer),_=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let l=C.read_bytes_array(f,n,s),u=0;for(let p of l){let{ret:d,data:R}=t.fds[r].fd_read(p.buf_len);if(d!=0)return f.setUint32(o,u,!0),d;if(_.set(R,p.buf),u+=R.length,R.length!=p.buf_len)break}return f.setUint32(o,u,!0),0}else return 8},fd_readdir(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=0;for(;;){let{ret:p,dirent:d}=t.fds[r].fd_readdir_single(o);if(p!=0)return _.setUint32(f,u,!0),p;if(d==null)break;if(s-u<d.head_length()){u=s;break}let R=new ArrayBuffer(d.head_length());if(d.write_head_bytes(new DataView(R),0),l.set(new Uint8Array(R).slice(0,Math.min(R.byteLength,s-u)),n),n+=d.head_length(),u+=d.head_length(),s-u<d.name_length()){u=s;break}d.write_name_bytes(l,n,s-u),n+=d.name_length(),u+=d.name_length(),o=d.d_next}return _.setUint32(f,u,!0),0}else return 8},fd_renumber(r,n){if(t.fds[r]!=null&&t.fds[n]!=null){let s=t.fds[n].fd_close();return s!=0?s:(t.fds[n]=t.fds[r],t.fds[r]=void 0,0)}else return 8},fd_seek(r,n,s,o){let f=new DataView(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let{ret:_,offset:l}=t.fds[r].fd_seek(n,s);return f.setBigInt64(o,l,!0),_}else return 8},fd_sync(r){return t.fds[r]!=null?t.fds[r].fd_sync():8},fd_tell(r,n){let s=new DataView(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let{ret:o,offset:f}=t.fds[r].fd_tell();return s.setBigUint64(n,f,!0),o}else return 8},fd_write(r,n,s,o){let f=new DataView(t.inst.exports.memory.buffer),_=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let l=L.read_bytes_array(f,n,s),u=0;for(let p of l){let d=_.slice(p.buf,p.buf+p.buf_len),{ret:R,nwritten:h}=t.fds[r].fd_write(d);if(R!=0)return f.setUint32(o,u,!0),R;if(u+=h,h!=d.byteLength)break}return f.setUint32(o,u,!0),0}else return 8},path_create_directory(r,n,s){let o=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let f=new TextDecoder("utf-8").decode(o.slice(n,n+s));return t.fds[r].path_create_directory(f)}else return 8},path_filestat_get(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=new TextDecoder("utf-8").decode(l.slice(s,s+o)),{ret:p,filestat:d}=t.fds[r].path_filestat_get(n,u);return d?.write_bytes(_,f),p}else return 8},path_filestat_set_times(r,n,s,o,f,_,l){let u=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let p=new TextDecoder("utf-8").decode(u.slice(s,s+o));return t.fds[r].path_filestat_set_times(n,p,f,_,l)}else return 8},path_link(r,n,s,o,f,_,l){let u=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null&&t.fds[f]!=null){let p=new TextDecoder("utf-8").decode(u.slice(s,s+o)),d=new TextDecoder("utf-8").decode(u.slice(_,_+l)),{ret:R,inode_obj:h}=t.fds[r].path_lookup(p,n);return h==null?R:t.fds[f].path_link(d,h,!1)}else return 8},path_open(r,n,s,o,f,_,l,u,p){let d=new DataView(t.inst.exports.memory.buffer),R=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let h=new TextDecoder("utf-8").decode(R.slice(s,s+o));y.log(h);let{ret:S,fd_obj:X}=t.fds[r].path_open(n,h,f,_,l,u);if(S!=0)return S;t.fds.push(X);let H=t.fds.length-1;return d.setUint32(p,H,!0),0}else return 8},path_readlink(r,n,s,o,f,_){let l=new DataView(t.inst.exports.memory.buffer),u=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let p=new TextDecoder("utf-8").decode(u.slice(n,n+s));y.log(p);let{ret:d,data:R}=t.fds[r].path_readlink(p);if(R!=null){let h=new TextEncoder().encode(R);if(h.length>f)return l.setUint32(_,0,!0),8;u.set(h,o),l.setUint32(_,h.length,!0)}return d}else return 8},path_remove_directory(r,n,s){let o=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let f=new TextDecoder("utf-8").decode(o.slice(n,n+s));return t.fds[r].path_remove_directory(f)}else return 8},path_rename(r,n,s,o,f,_){let l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null&&t.fds[o]!=null){let u=new TextDecoder("utf-8").decode(l.slice(n,n+s)),p=new TextDecoder("utf-8").decode(l.slice(f,f+_)),{ret:d,inode_obj:R}=t.fds[r].path_unlink(u);if(R==null)return d;if(d=t.fds[o].path_link(p,R,!0),d!=0&&t.fds[r].path_link(u,R,!0)!=0)throw"path_link should always return success when relinking an inode back to the original place";return d}else return 8},path_symlink(r,n,s,o,f){let _=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[s]!=null){let l=new TextDecoder("utf-8").decode(_.slice(r,r+n)),u=new TextDecoder("utf-8").decode(_.slice(o,o+f));return 58}else return 8},path_unlink_file(r,n,s){let o=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let f=new TextDecoder("utf-8").decode(o.slice(n,n+s));return t.fds[r].path_unlink_file(f)}else return 8},poll_oneoff(r,n,s){if(s===0)return 28;if(s>1)return y.log("poll_oneoff: only a single subscription is supported"),58;let o=new DataView(t.inst.exports.memory.buffer),f=k.read_bytes(o,r),_=f.eventtype,l=f.clockid,u=f.timeout;if(_!==at)return y.log("poll_oneoff: only clock subscriptions are supported"),58;let p;if(l===1)p=()=>BigInt(Math.round(performance.now()*1e6));else if(l===0)p=()=>BigInt(new Date().getTime())*1000000n;else return 28;let d=(f.flags&ft)!==0?u:p()+u;for(;d>p(););return new Y(f.userdata,0,_).write_bytes(o,n),0},proc_exit(r){throw new U(r)},proc_raise(r){throw"raised signal "+r},sched_yield(){},random_get(r,n){let s=new Uint8Array(t.inst.exports.memory.buffer).subarray(r,r+n);if("crypto"in globalThis&&(typeof SharedArrayBuffer>"u"||!(t.inst.exports.memory.buffer instanceof SharedArrayBuffer)))for(let o=0;o<n;o+=65536)crypto.getRandomValues(s.subarray(o,o+65536));else for(let o=0;o<n;o++)s[o]=Math.random()*256|0},sock_recv(r,n,s){throw"sockets not supported"},sock_send(r,n,s){throw"sockets not supported"},sock_shutdown(r,n){throw"sockets not supported"},sock_accept(r,n){throw"sockets not supported"}}}};var g=class{fd_allocate(e,i){return 58}fd_close(){return 0}fd_fdstat_get(){return{ret:58,fdstat:null}}fd_fdstat_set_flags(e){return 58}fd_fdstat_set_rights(e,i){return 58}fd_filestat_get(){return{ret:58,filestat:null}}fd_filestat_set_size(e){return 58}fd_filestat_set_times(e,i,c){return 58}fd_pread(e,i){return{ret:58,data:new Uint8Array}}fd_prestat_get(){return{ret:58,prestat:null}}fd_pwrite(e,i){return{ret:58,nwritten:0}}fd_read(e){return{ret:58,data:new Uint8Array}}fd_readdir_single(e){return{ret:58,dirent:null}}fd_seek(e,i){return{ret:58,offset:0n}}fd_sync(){return 0}fd_tell(){return{ret:58,offset:0n}}fd_write(e){return{ret:58,nwritten:0}}path_create_directory(e){return 58}path_filestat_get(e,i){return{ret:58,filestat:null}}path_filestat_set_times(e,i,c,E,t){return 58}path_link(e,i,c){return 58}path_unlink(e){return{ret:58,inode_obj:null}}path_lookup(e,i){return{ret:58,inode_obj:null}}path_open(e,i,c,E,t,r){return{ret:54,fd_obj:null}}path_readlink(e){return{ret:58,data:null}}path_remove_directory(e){return 58}path_rename(e,i,c){return 58}path_unlink_file(e){return 58}},m=class a{static issue_ino(){return a.next_ino++}static root_ino(){return 0n}constructor(){this.ino=a.issue_ino()}};m.next_ino=1n;var b=class extends g{fd_allocate(e,i){if(!(this.file.size>e+i)){let c=new Uint8Array(Number(e+i));c.set(this.file.data,0),this.file.data=c}return 0}fd_fdstat_get(){return{ret:0,fdstat:new x(W,0)}}fd_filestat_set_size(e){if(this.file.size>e)this.file.data=new Uint8Array(this.file.data.buffer.slice(0,Number(e)));else{let i=new Uint8Array(Number(e));i.set(this.file.data,0),this.file.data=i}return 0}fd_read(e){let i=this.file.data.slice(Number(this.file_pos),Number(this.file_pos+BigInt(e)));return this.file_pos+=BigInt(i.length),{ret:0,data:i}}fd_pread(e,i){return{ret:0,data:this.file.data.slice(Number(i),Number(i+BigInt(e)))}}fd_seek(e,i){let c;switch(i){case Q:c=e;break;case Z:c=this.file_pos+e;break;case V:c=BigInt(this.file.data.byteLength)+e;break;default:return{ret:28,offset:0n}}return c<0?{ret:28,offset:0n}:(this.file_pos=c,{ret:0,offset:this.file_pos})}fd_tell(){return{ret:0,offset:this.file_pos}}fd_write(e){if(this.file.readonly)return{ret:8,nwritten:0};if(this.file_pos+BigInt(e.byteLength)>this.file.size){let i=this.file.data;this.file.data=new Uint8Array(Number(this.file_pos+BigInt(e.byteLength))),this.file.data.set(i)}return this.file.data.set(e,Number(this.file_pos)),this.file_pos+=BigInt(e.byteLength),{ret:0,nwritten:e.byteLength}}fd_pwrite(e,i){if(this.file.readonly)return{ret:8,nwritten:0};if(i+BigInt(e.byteLength)>this.file.size){let c=this.file.data;this.file.data=new Uint8Array(Number(i+BigInt(e.byteLength))),this.file.data.set(c)}return this.file.data.set(e,Number(i)),{ret:0,nwritten:e.byteLength}}fd_filestat_get(){return{ret:0,filestat:this.file.stat()}}constructor(e){super(),this.file_pos=0n,this.file=e}};var F=class extends m{path_open(e,i,c){if(this.readonly&&(i&BigInt(64))==BigInt(64))return{ret:63,fd_obj:null};if((e&j)==j){if(this.readonly)return{ret:63,fd_obj:null};this.data=new Uint8Array([])}let E=new b(this);return c&q&&E.fd_seek(0n,V),{ret:0,fd_obj:E}}get size(){return BigInt(this.data.byteLength)}stat(){return new A(this.ino,W,this.size)}constructor(e,i){super(),this.data=new Uint8Array(e),this.readonly=!!i?.readonly}};var P=class a extends g{fd_filestat_get(){return{ret:0,filestat:new A(this.ino,J,BigInt(0))}}fd_fdstat_get(){let e=new x(J,0);return e.fs_rights_base=BigInt(64),{ret:0,fdstat:e}}fd_write(e){return this.write(e),{ret:0,nwritten:e.byteLength}}static lineBuffered(e){let i=new TextDecoder("utf-8",{fatal:!1}),c="";return new a(E=>{c+=i.decode(E,{stream:!0});let t=c.split(`\n`);for(let[r,n]of t.entries())r<t.length-1?e(n):c=n})}constructor(e){super(),this.ino=m.issue_ino(),this.write=e}};var ct="code-playpad Clang 20.1.2 / Emscripten 4.0.6 r1",lt={"clang.js":{bytes:74300,sha256:"b437a648812aabd1cc87cba4a7268e2f53ab94a9071a854ba983dd62328dc30c"},"clang.wasm":{bytes:42578038,sha256:"534571fd4f9136c85d3e25a395cc31983ec3cbd41012e3928b45879a518718fa"},"lld.js":{bytes:71711,sha256:"2da4b0a04b6953bdc4869137631abd11ea7eb5a667fbd19c4ff6d68d56f302bb"},"lld.wasm":{bytes:23228304,sha256:"55ffbe1366525c1b55b65140630e0ca00ff47eae7acfdee6a15b46e738800ec7"},"sysroot.tar":{bytes:29009920,sha256:"a0d92a9fc1dccc2c181ae6812b6c169de3dad851ee4d4e796d15940776648ac5"}};function K(a){if(!a||a.startsWith("/")||/[\\\\\\x00-\\x1f:]/.test(a)||a.split("/").some(e=>!e||e==="."||e===".."))throw new Error(`Invalid project path: ${JSON.stringify(a)}. Use relative paths without . or ...`);return a}function ut(a,e,i,c){let E=K(i??(c==="c"?"main.c":"main.cpp")),t=e?{...e}:{[E]:a};if(!Object.hasOwn(t,E))throw new Error(`Entry file ${E} does not exist.`);let r=Object.keys(t).map(K).sort(),n=f=>/\\.c$/.test(f),s=f=>/\\.(cpp|cc|cxx)$/.test(f);if(r.some(c==="c"?s:n))throw new Error("Mixed C/C++ source projects are not supported yet.");let o=r.filter(c==="c"?n:s);if(!o.includes(E))throw new Error(`Entry ${E} must have a ${c==="c"?".c":".cpp, .cc, or .cxx"} extension.`);if(o.length>32||r.length>256)throw new Error("Project limit: 32 source files and 256 files total.");if(Object.values(t).reduce((f,_)=>f+new TextEncoder().encode(_).length,0)>2e6)throw new Error("Project exceeds the 2 MB source limit.");return{files:t,sources:o,entry:E}}var st,v,dt=Promise.resolve(),G=a=>globalThis.postMessage(a),M=(a,e,i)=>G({type:"progress",id:a,phase:e,message:i}),B=(a,e)=>ot(a,lt[a],st,it,i=>M(e,"downloading",i));function St(a){let e=new Uint8Array(a),i=new TextDecoder,c=[],E=(t,r)=>i.decode(e.subarray(t,t+r)).replace(/\\0.*$/,"");for(let t=0;t+512<=e.length;){let r=E(t,100);if(!r)break;let n=E(t+345,155);n&&(r=n+"/"+r);let s=parseInt(E(t+124,12).trim()||"0",8),o=e[t+156];if(!Number.isSafeInteger(s)||s<0||t+512+s>e.length)throw new Error("Invalid sysroot archive.");if(o===48||o===0)c.push({name:"/"+K(r),data:e.subarray(t+512,t+512+s)});else if(o!==53)throw new Error("Unsupported sysroot archive entry.");t+=512+Math.ceil(s/512)*512}return c}async function Rt(a){let e=URL.createObjectURL(new Blob([a],{type:"text/javascript"}));try{return(await import(e)).default}finally{URL.revokeObjectURL(e)}}function yt(a){return st?(v||(v=(async()=>{let e=await Rt(await B("clang.js",a)),i=await Rt(await B("lld.js",a)),c=await WebAssembly.compile(await B("clang.wasm",a)),E=await WebAssembly.compile(await B("lld.wasm",a));M(a,"booting","Preparing C/C++ standard libraries\\u2026");let t=St(await B("sysroot.tar",a));return{clang:e,lld:i,clangModule:c,lldModule:E,sysroot:t}})().catch(e=>{throw v=void 0,e})),v):Promise.reject(new Error("Configure the rebuilt C/C++ assets with configureCpp({ indexURL }) before creating widgets. See docs/CPP-REBUILD.md."))}async function Et(a,e,i,c){let E,t=await a({thisProgram:i,noInitialRun:!0,print:c,printErr:c,instantiateWasm(r,n){let s=new WebAssembly.Instance(e,r);return E=Object.values(s.exports).find(o=>o instanceof WebAssembly.Memory),n(s,e),s.exports}});return t.memory=E,t}function $(a,e,i){a.mkdirTree(e.slice(0,e.lastIndexOf("/"))||"/"),a.writeFile(e,i)}async function mt(a){let e=performance.now(),i=0,c=(E,t)=>{if(i+=t.length,i>1e6)throw new Error("Output limit exceeded (1 MB).");t&&G({type:E,id:a.id,text:t})};try{let E=ut(a.code,a.files,a.entry,a.compilerLanguage),t=await yt(a.id),r=[],n=0;for(let R of E.sources){M(a.id,"compiling",`Compiling ${R}\\u2026`);let h=await Et(t.clang,t.clangModule,"clang",T=>c("stderr",T+`\n`));for(let T of t.sysroot)$(h.FS,T.name,T.data);for(let[T,pt]of Object.entries(E.files))$(h.FS,"/project/"+T,pt);let S=a.compilerLanguage==="cpp",X=["-cc1","-triple","wasm32-unknown-wasi","-emit-obj","-O0","-std="+(S?"c++20":"c17"),"-resource-dir","/lib/clang/20",...S?["-internal-isystem","/include/wasm32-wasi/c++/v1","-internal-isystem","/include/c++/v1"]:[],"-internal-isystem","/lib/clang/20/include","-internal-isystem","/include/wasm32-wasi","-internal-isystem","/include","-I","/project","-ferror-limit","20","-o","/tmp/output.o","-x",S?"c++":"c","/project/"+R],H=h.callMain(X);if(n=Math.max(n,h.memory?.buffer.byteLength??0),H!==0)throw new Error(`Compilation failed (${R}, exit ${H}).`);r.push(h.FS.readFile("/tmp/output.o").slice())}M(a.id,"linking","Linking\\u2026");let s=await Et(t.lld,t.lldModule,"wasm-ld",R=>c("stderr",R+`\n`));for(let R of t.sysroot)R.name.startsWith("/include/")||$(s.FS,R.name,R.data);r.forEach((R,h)=>$(s.FS,"/tmp/"+h+".o",R));let o=s.callMain(["-m","wasm32","-z","stack-size=1048576","--max-memory=268435456","-L/lib/wasm32-wasi","/lib/wasm32-wasi/crt1-command.o",...r.map((R,h)=>"/tmp/"+h+".o"),...a.compilerLanguage==="cpp"?["-lc++","-lc++abi"]:[],"-lc","/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a","-o","/tmp/program.wasm"]);if(n=Math.max(n,s.memory?.buffer.byteLength??0),o!==0)throw new Error(`Linking failed (exit ${o}).`);let f=await WebAssembly.compile(s.FS.readFile("/tmp/program.wasm").slice().buffer);M(a.id,"running","Running\\u2026");let _={stdout:new TextDecoder,stderr:new TextDecoder},l=R=>new P(h=>c(R,_[R].decode(h,{stream:!0}))),u=new rt([E.entry],[],[new b(new F(new TextEncoder().encode(a.stdin??""))),l("stdout"),l("stderr")]),p=await WebAssembly.instantiate(f,{wasi_snapshot_preview1:u.wasiImport}),d=u.start(p);if(c("stdout",_.stdout.decode()),c("stderr",_.stderr.decode()),d!==0)throw new Error(`Program exited with status ${d}.`);G({type:"result",id:a.id,durationMs:performance.now()-e,memory:{compilerBytes:n,programBytes:p.exports.memory.buffer.byteLength}})}catch(E){G({type:"error",id:a.id,message:E instanceof Error?E.message:String(E),durationMs:performance.now()-e})}}globalThis.onmessage=({data:a})=>{a.type==="init"?(st=a.toolchainURL,G({type:"ready",version:ct,interactiveStdin:!1})):a.type==="run"&&(dt=dt.then(()=>mt(a)))};})();\n',o=new class extends t{id=`cpp`;get label(){return`C/C++ (Clang 20, experimental)`}get source(){return a}async load(e){return await i(n),super.load(e)}initPayload(){return{toolchainURL:e().indexURL}}};function s(t){return{id:t,label:t===`c`?`C17 (experimental)`:`C++20 (experimental)`,statusDecidesFailure:!0,get ready(){return o.ready},interactiveStdin:!1,async editorLanguage(){return(await import(`@codemirror/lang-cpp`)).cpp()},load:e=>o.load(e),run:(n,r={})=>o.run(n,{...r,compilerLanguage:t,timeoutMs:r.timeoutMs??e().timeoutMs}),stop:e=>o.stop(e)}}var c=s(`c`),l=s(`cpp`);export{c as cRuntime,l as cppRuntime};
|
|
1
|
+
import{o as e}from"./config-DB58UVsk.js";import{t}from"./worker-runtime-Bk9bsGrP.js";var n=`code-playpad-cpp-20.1.2-emscripten-4.0.6-r1`,r=/* @__PURE__ */ new Map;async function i(e){r.has(e)||r.set(e,(async()=>{try{return await caches.open(e)}catch{return}})()),await r.get(e)}var a='"use strict";(()=>{var it="code-playpad-cpp-20.1.2-emscripten-4.0.6-r1";async function ot(a,e,i,c,E){let t=new URL(a,i).href,r;try{r=await caches.open(c)}catch{}let n;try{n=await r?.match(t)}catch{}let s=async _=>{if(!_.ok)throw new Error(`Toolchain download failed: ${a} (HTTP ${_.status}). Check the asset URL and retry.`);let l=_.body?.getReader();if(!l)return _.arrayBuffer();let u=[],p=0,d=0;for(;;){let S=await l.read();if(S.done)break;if(p+=S.value.length,p>e.bytes)throw await l.cancel(),new Error(`Unexpected toolchain size: ${a}.`);u.push(S.value),performance.now()-d>100&&(E(`${n?"Reading cached":"Downloading"} ${a}: ${(p/1e6).toFixed(1)} / ${(e.bytes/1e6).toFixed(1)} MB (decoded)`),d=performance.now())}let R=new Uint8Array(p),h=0;for(let S of u)R.set(S,h),h+=S.length;return R.buffer},o=async _=>_.byteLength===e.bytes&&[...new Uint8Array(await crypto.subtle.digest("SHA-256",_))].map(l=>l.toString(16).padStart(2,"0")).join("")===e.sha256;if(n){try{let _=await s(n);if(await o(_))return _}catch{}try{await r?.delete(t)}catch{}n=void 0}let f=await s(await fetch(t));if(!await o(f))throw new Error(`Toolchain integrity check failed: ${a}. Use the pinned toolchain assets.`);try{await r?.put(t,new Response(f))}catch{}return f}var C=class a{static read_bytes(e,i){let c=new a;return c.buf=e.getUint32(i,!0),c.buf_len=e.getUint32(i+4,!0),c}static read_bytes_array(e,i,c){let E=[];for(let t=0;t<c;t++)E.push(a.read_bytes(e,i+8*t));return E}},L=class a{static read_bytes(e,i){let c=new a;return c.buf=e.getUint32(i,!0),c.buf_len=e.getUint32(i+4,!0),c}static read_bytes_array(e,i,c){let E=[];for(let t=0;t<c;t++)E.push(a.read_bytes(e,i+8*t));return E}},Q=0,Z=1,V=2;var J=2;var W=4;var q=1;var x=class{write_bytes(e,i){e.setUint8(i,this.fs_filetype),e.setUint16(i+2,this.fs_flags,!0),e.setBigUint64(i+8,this.fs_rights_base,!0),e.setBigUint64(i+16,this.fs_rights_inherited,!0)}constructor(e,i){this.fs_rights_base=0n,this.fs_rights_inherited=0n,this.fs_filetype=e,this.fs_flags=i}};var j=8,A=class{write_bytes(e,i){e.setBigUint64(i,this.dev,!0),e.setBigUint64(i+8,this.ino,!0),e.setUint8(i+16,this.filetype),e.setBigUint64(i+24,this.nlink,!0),e.setBigUint64(i+32,this.size,!0),e.setBigUint64(i+38,this.atim,!0),e.setBigUint64(i+46,this.mtim,!0),e.setBigUint64(i+52,this.ctim,!0)}constructor(e,i,c){this.dev=0n,this.nlink=0n,this.atim=0n,this.mtim=0n,this.ctim=0n,this.ino=e,this.filetype=i,this.size=c}},at=0;var ft=1,k=class a{static read_bytes(e,i){return new a(e.getBigUint64(i,!0),e.getUint8(i+8),e.getUint32(i+16,!0),e.getBigUint64(i+24,!0),e.getUint16(i+36,!0))}constructor(e,i,c,E,t){this.userdata=e,this.eventtype=i,this.clockid=c,this.timeout=E,this.flags=t}},Y=class{write_bytes(e,i){e.setBigUint64(i,this.userdata,!0),e.setUint16(i+8,this.error,!0),e.setUint8(i+10,this.eventtype)}constructor(e,i,c){this.userdata=e,this.error=i,this.eventtype=c}};var wt=class{enable(e){this.log=ht(e===void 0?!0:e,this.prefix)}get enabled(){return this.isEnabled}constructor(e){this.isEnabled=e,this.prefix="wasi:",this.enable(e)}};function ht(a,e){return a?console.log.bind(console,"%c%s","color: #265BA0",e):()=>{}}var y=new wt(!1);var U=class extends Error{constructor(e){super("exit with exit code "+e),this.code=e}},rt=class{start(e){this.inst=e;try{return e.exports._start(),0}catch(i){if(i instanceof U)return i.code;throw i}}initialize(e){this.inst=e,e.exports._initialize&&e.exports._initialize()}constructor(e,i,c,E={}){this.args=[],this.env=[],this.fds=[],y.enable(E.debug),this.args=e,this.env=i,this.fds=c;let t=this;this.wasiImport={args_sizes_get(r,n){let s=new DataView(t.inst.exports.memory.buffer);s.setUint32(r,t.args.length,!0);let o=0;for(let f of t.args)o+=f.length+1;return s.setUint32(n,o,!0),y.log(s.getUint32(r,!0),s.getUint32(n,!0)),0},args_get(r,n){let s=new DataView(t.inst.exports.memory.buffer),o=new Uint8Array(t.inst.exports.memory.buffer),f=n;for(let _=0;_<t.args.length;_++){s.setUint32(r,n,!0),r+=4;let l=new TextEncoder().encode(t.args[_]);o.set(l,n),s.setUint8(n+l.length,0),n+=l.length+1}return y.enabled&&y.log(new TextDecoder("utf-8").decode(o.slice(f,n))),0},environ_sizes_get(r,n){let s=new DataView(t.inst.exports.memory.buffer);s.setUint32(r,t.env.length,!0);let o=0;for(let f of t.env)o+=new TextEncoder().encode(f).length+1;return s.setUint32(n,o,!0),y.log(s.getUint32(r,!0),s.getUint32(n,!0)),0},environ_get(r,n){let s=new DataView(t.inst.exports.memory.buffer),o=new Uint8Array(t.inst.exports.memory.buffer),f=n;for(let _=0;_<t.env.length;_++){s.setUint32(r,n,!0),r+=4;let l=new TextEncoder().encode(t.env[_]);o.set(l,n),s.setUint8(n+l.length,0),n+=l.length+1}return y.enabled&&y.log(new TextDecoder("utf-8").decode(o.slice(f,n))),0},clock_res_get(r,n){let s;switch(r){case 1:{s=5000n;break}case 0:{s=1000000n;break}default:return 52}return new DataView(t.inst.exports.memory.buffer).setBigUint64(n,s,!0),0},clock_time_get(r,n,s){let o=new DataView(t.inst.exports.memory.buffer);if(r===0)o.setBigUint64(s,BigInt(new Date().getTime())*1000000n,!0);else if(r==1){let f;try{f=BigInt(Math.round(performance.now()*1e6))}catch{f=0n}o.setBigUint64(s,f,!0)}else o.setBigUint64(s,0n,!0);return 0},fd_advise(r,n,s,o){return t.fds[r]!=null?0:8},fd_allocate(r,n,s){return t.fds[r]!=null?t.fds[r].fd_allocate(n,s):8},fd_close(r){if(t.fds[r]!=null){let n=t.fds[r].fd_close();return t.fds[r]=void 0,n}else return 8},fd_datasync(r){return t.fds[r]!=null?t.fds[r].fd_sync():8},fd_fdstat_get(r,n){if(t.fds[r]!=null){let{ret:s,fdstat:o}=t.fds[r].fd_fdstat_get();return o?.write_bytes(new DataView(t.inst.exports.memory.buffer),n),s}else return 8},fd_fdstat_set_flags(r,n){return t.fds[r]!=null?t.fds[r].fd_fdstat_set_flags(n):8},fd_fdstat_set_rights(r,n,s){return t.fds[r]!=null?t.fds[r].fd_fdstat_set_rights(n,s):8},fd_filestat_get(r,n){if(t.fds[r]!=null){let{ret:s,filestat:o}=t.fds[r].fd_filestat_get();return o?.write_bytes(new DataView(t.inst.exports.memory.buffer),n),s}else return 8},fd_filestat_set_size(r,n){return t.fds[r]!=null?t.fds[r].fd_filestat_set_size(n):8},fd_filestat_set_times(r,n,s,o){return t.fds[r]!=null?t.fds[r].fd_filestat_set_times(n,s,o):8},fd_pread(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=C.read_bytes_array(_,n,s),p=0;for(let d of u){let{ret:R,data:h}=t.fds[r].fd_pread(d.buf_len,o);if(R!=0)return _.setUint32(f,p,!0),R;if(l.set(h,d.buf),p+=h.length,o+=BigInt(h.length),h.length!=d.buf_len)break}return _.setUint32(f,p,!0),0}else return 8},fd_prestat_get(r,n){let s=new DataView(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let{ret:o,prestat:f}=t.fds[r].fd_prestat_get();return f?.write_bytes(s,n),o}else return 8},fd_prestat_dir_name(r,n,s){if(t.fds[r]!=null){let{ret:o,prestat:f}=t.fds[r].fd_prestat_get();if(f==null)return o;let _=f.inner.pr_name;return new Uint8Array(t.inst.exports.memory.buffer).set(_.slice(0,s),n),_.byteLength>s?37:0}else return 8},fd_pwrite(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=L.read_bytes_array(_,n,s),p=0;for(let d of u){let R=l.slice(d.buf,d.buf+d.buf_len),{ret:h,nwritten:S}=t.fds[r].fd_pwrite(R,o);if(h!=0)return _.setUint32(f,p,!0),h;if(p+=S,o+=BigInt(S),S!=R.byteLength)break}return _.setUint32(f,p,!0),0}else return 8},fd_read(r,n,s,o){let f=new DataView(t.inst.exports.memory.buffer),_=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let l=C.read_bytes_array(f,n,s),u=0;for(let p of l){let{ret:d,data:R}=t.fds[r].fd_read(p.buf_len);if(d!=0)return f.setUint32(o,u,!0),d;if(_.set(R,p.buf),u+=R.length,R.length!=p.buf_len)break}return f.setUint32(o,u,!0),0}else return 8},fd_readdir(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=0;for(;;){let{ret:p,dirent:d}=t.fds[r].fd_readdir_single(o);if(p!=0)return _.setUint32(f,u,!0),p;if(d==null)break;if(s-u<d.head_length()){u=s;break}let R=new ArrayBuffer(d.head_length());if(d.write_head_bytes(new DataView(R),0),l.set(new Uint8Array(R).slice(0,Math.min(R.byteLength,s-u)),n),n+=d.head_length(),u+=d.head_length(),s-u<d.name_length()){u=s;break}d.write_name_bytes(l,n,s-u),n+=d.name_length(),u+=d.name_length(),o=d.d_next}return _.setUint32(f,u,!0),0}else return 8},fd_renumber(r,n){if(t.fds[r]!=null&&t.fds[n]!=null){let s=t.fds[n].fd_close();return s!=0?s:(t.fds[n]=t.fds[r],t.fds[r]=void 0,0)}else return 8},fd_seek(r,n,s,o){let f=new DataView(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let{ret:_,offset:l}=t.fds[r].fd_seek(n,s);return f.setBigInt64(o,l,!0),_}else return 8},fd_sync(r){return t.fds[r]!=null?t.fds[r].fd_sync():8},fd_tell(r,n){let s=new DataView(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let{ret:o,offset:f}=t.fds[r].fd_tell();return s.setBigUint64(n,f,!0),o}else return 8},fd_write(r,n,s,o){let f=new DataView(t.inst.exports.memory.buffer),_=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let l=L.read_bytes_array(f,n,s),u=0;for(let p of l){let d=_.slice(p.buf,p.buf+p.buf_len),{ret:R,nwritten:h}=t.fds[r].fd_write(d);if(R!=0)return f.setUint32(o,u,!0),R;if(u+=h,h!=d.byteLength)break}return f.setUint32(o,u,!0),0}else return 8},path_create_directory(r,n,s){let o=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let f=new TextDecoder("utf-8").decode(o.slice(n,n+s));return t.fds[r].path_create_directory(f)}else return 8},path_filestat_get(r,n,s,o,f){let _=new DataView(t.inst.exports.memory.buffer),l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let u=new TextDecoder("utf-8").decode(l.slice(s,s+o)),{ret:p,filestat:d}=t.fds[r].path_filestat_get(n,u);return d?.write_bytes(_,f),p}else return 8},path_filestat_set_times(r,n,s,o,f,_,l){let u=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let p=new TextDecoder("utf-8").decode(u.slice(s,s+o));return t.fds[r].path_filestat_set_times(n,p,f,_,l)}else return 8},path_link(r,n,s,o,f,_,l){let u=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null&&t.fds[f]!=null){let p=new TextDecoder("utf-8").decode(u.slice(s,s+o)),d=new TextDecoder("utf-8").decode(u.slice(_,_+l)),{ret:R,inode_obj:h}=t.fds[r].path_lookup(p,n);return h==null?R:t.fds[f].path_link(d,h,!1)}else return 8},path_open(r,n,s,o,f,_,l,u,p){let d=new DataView(t.inst.exports.memory.buffer),R=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let h=new TextDecoder("utf-8").decode(R.slice(s,s+o));y.log(h);let{ret:S,fd_obj:X}=t.fds[r].path_open(n,h,f,_,l,u);if(S!=0)return S;t.fds.push(X);let H=t.fds.length-1;return d.setUint32(p,H,!0),0}else return 8},path_readlink(r,n,s,o,f,_){let l=new DataView(t.inst.exports.memory.buffer),u=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let p=new TextDecoder("utf-8").decode(u.slice(n,n+s));y.log(p);let{ret:d,data:R}=t.fds[r].path_readlink(p);if(R!=null){let h=new TextEncoder().encode(R);if(h.length>f)return l.setUint32(_,0,!0),8;u.set(h,o),l.setUint32(_,h.length,!0)}return d}else return 8},path_remove_directory(r,n,s){let o=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let f=new TextDecoder("utf-8").decode(o.slice(n,n+s));return t.fds[r].path_remove_directory(f)}else return 8},path_rename(r,n,s,o,f,_){let l=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null&&t.fds[o]!=null){let u=new TextDecoder("utf-8").decode(l.slice(n,n+s)),p=new TextDecoder("utf-8").decode(l.slice(f,f+_)),{ret:d,inode_obj:R}=t.fds[r].path_unlink(u);if(R==null)return d;if(d=t.fds[o].path_link(p,R,!0),d!=0&&t.fds[r].path_link(u,R,!0)!=0)throw"path_link should always return success when relinking an inode back to the original place";return d}else return 8},path_symlink(r,n,s,o,f){let _=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[s]!=null){let l=new TextDecoder("utf-8").decode(_.slice(r,r+n)),u=new TextDecoder("utf-8").decode(_.slice(o,o+f));return 58}else return 8},path_unlink_file(r,n,s){let o=new Uint8Array(t.inst.exports.memory.buffer);if(t.fds[r]!=null){let f=new TextDecoder("utf-8").decode(o.slice(n,n+s));return t.fds[r].path_unlink_file(f)}else return 8},poll_oneoff(r,n,s){if(s===0)return 28;if(s>1)return y.log("poll_oneoff: only a single subscription is supported"),58;let o=new DataView(t.inst.exports.memory.buffer),f=k.read_bytes(o,r),_=f.eventtype,l=f.clockid,u=f.timeout;if(_!==at)return y.log("poll_oneoff: only clock subscriptions are supported"),58;let p;if(l===1)p=()=>BigInt(Math.round(performance.now()*1e6));else if(l===0)p=()=>BigInt(new Date().getTime())*1000000n;else return 28;let d=(f.flags&ft)!==0?u:p()+u;for(;d>p(););return new Y(f.userdata,0,_).write_bytes(o,n),0},proc_exit(r){throw new U(r)},proc_raise(r){throw"raised signal "+r},sched_yield(){},random_get(r,n){let s=new Uint8Array(t.inst.exports.memory.buffer).subarray(r,r+n);if("crypto"in globalThis&&(typeof SharedArrayBuffer>"u"||!(t.inst.exports.memory.buffer instanceof SharedArrayBuffer)))for(let o=0;o<n;o+=65536)crypto.getRandomValues(s.subarray(o,o+65536));else for(let o=0;o<n;o++)s[o]=Math.random()*256|0},sock_recv(r,n,s){throw"sockets not supported"},sock_send(r,n,s){throw"sockets not supported"},sock_shutdown(r,n){throw"sockets not supported"},sock_accept(r,n){throw"sockets not supported"}}}};var g=class{fd_allocate(e,i){return 58}fd_close(){return 0}fd_fdstat_get(){return{ret:58,fdstat:null}}fd_fdstat_set_flags(e){return 58}fd_fdstat_set_rights(e,i){return 58}fd_filestat_get(){return{ret:58,filestat:null}}fd_filestat_set_size(e){return 58}fd_filestat_set_times(e,i,c){return 58}fd_pread(e,i){return{ret:58,data:new Uint8Array}}fd_prestat_get(){return{ret:58,prestat:null}}fd_pwrite(e,i){return{ret:58,nwritten:0}}fd_read(e){return{ret:58,data:new Uint8Array}}fd_readdir_single(e){return{ret:58,dirent:null}}fd_seek(e,i){return{ret:58,offset:0n}}fd_sync(){return 0}fd_tell(){return{ret:58,offset:0n}}fd_write(e){return{ret:58,nwritten:0}}path_create_directory(e){return 58}path_filestat_get(e,i){return{ret:58,filestat:null}}path_filestat_set_times(e,i,c,E,t){return 58}path_link(e,i,c){return 58}path_unlink(e){return{ret:58,inode_obj:null}}path_lookup(e,i){return{ret:58,inode_obj:null}}path_open(e,i,c,E,t,r){return{ret:54,fd_obj:null}}path_readlink(e){return{ret:58,data:null}}path_remove_directory(e){return 58}path_rename(e,i,c){return 58}path_unlink_file(e){return 58}},m=class a{static issue_ino(){return a.next_ino++}static root_ino(){return 0n}constructor(){this.ino=a.issue_ino()}};m.next_ino=1n;var b=class extends g{fd_allocate(e,i){if(!(this.file.size>e+i)){let c=new Uint8Array(Number(e+i));c.set(this.file.data,0),this.file.data=c}return 0}fd_fdstat_get(){return{ret:0,fdstat:new x(W,0)}}fd_filestat_set_size(e){if(this.file.size>e)this.file.data=new Uint8Array(this.file.data.buffer.slice(0,Number(e)));else{let i=new Uint8Array(Number(e));i.set(this.file.data,0),this.file.data=i}return 0}fd_read(e){let i=this.file.data.slice(Number(this.file_pos),Number(this.file_pos+BigInt(e)));return this.file_pos+=BigInt(i.length),{ret:0,data:i}}fd_pread(e,i){return{ret:0,data:this.file.data.slice(Number(i),Number(i+BigInt(e)))}}fd_seek(e,i){let c;switch(i){case Q:c=e;break;case Z:c=this.file_pos+e;break;case V:c=BigInt(this.file.data.byteLength)+e;break;default:return{ret:28,offset:0n}}return c<0?{ret:28,offset:0n}:(this.file_pos=c,{ret:0,offset:this.file_pos})}fd_tell(){return{ret:0,offset:this.file_pos}}fd_write(e){if(this.file.readonly)return{ret:8,nwritten:0};if(this.file_pos+BigInt(e.byteLength)>this.file.size){let i=this.file.data;this.file.data=new Uint8Array(Number(this.file_pos+BigInt(e.byteLength))),this.file.data.set(i)}return this.file.data.set(e,Number(this.file_pos)),this.file_pos+=BigInt(e.byteLength),{ret:0,nwritten:e.byteLength}}fd_pwrite(e,i){if(this.file.readonly)return{ret:8,nwritten:0};if(i+BigInt(e.byteLength)>this.file.size){let c=this.file.data;this.file.data=new Uint8Array(Number(i+BigInt(e.byteLength))),this.file.data.set(c)}return this.file.data.set(e,Number(i)),{ret:0,nwritten:e.byteLength}}fd_filestat_get(){return{ret:0,filestat:this.file.stat()}}constructor(e){super(),this.file_pos=0n,this.file=e}};var F=class extends m{path_open(e,i,c){if(this.readonly&&(i&BigInt(64))==BigInt(64))return{ret:63,fd_obj:null};if((e&j)==j){if(this.readonly)return{ret:63,fd_obj:null};this.data=new Uint8Array([])}let E=new b(this);return c&q&&E.fd_seek(0n,V),{ret:0,fd_obj:E}}get size(){return BigInt(this.data.byteLength)}stat(){return new A(this.ino,W,this.size)}constructor(e,i){super(),this.data=new Uint8Array(e),this.readonly=!!i?.readonly}};var P=class a extends g{fd_filestat_get(){return{ret:0,filestat:new A(this.ino,J,BigInt(0))}}fd_fdstat_get(){let e=new x(J,0);return e.fs_rights_base=BigInt(64),{ret:0,fdstat:e}}fd_write(e){return this.write(e),{ret:0,nwritten:e.byteLength}}static lineBuffered(e){let i=new TextDecoder("utf-8",{fatal:!1}),c="";return new a(E=>{c+=i.decode(E,{stream:!0});let t=c.split(`\n`);for(let[r,n]of t.entries())r<t.length-1?e(n):c=n})}constructor(e){super(),this.ino=m.issue_ino(),this.write=e}};var ct="code-playpad Clang 20.1.2 / Emscripten 4.0.6 r1",lt={"clang.js":{bytes:74300,sha256:"b437a648812aabd1cc87cba4a7268e2f53ab94a9071a854ba983dd62328dc30c"},"clang.wasm":{bytes:42578038,sha256:"534571fd4f9136c85d3e25a395cc31983ec3cbd41012e3928b45879a518718fa"},"lld.js":{bytes:71711,sha256:"2da4b0a04b6953bdc4869137631abd11ea7eb5a667fbd19c4ff6d68d56f302bb"},"lld.wasm":{bytes:23228304,sha256:"55ffbe1366525c1b55b65140630e0ca00ff47eae7acfdee6a15b46e738800ec7"},"sysroot.tar":{bytes:29009920,sha256:"a0d92a9fc1dccc2c181ae6812b6c169de3dad851ee4d4e796d15940776648ac5"}};function K(a){if(!a||a.startsWith("/")||/[\\\\\\x00-\\x1f:]/.test(a)||a.split("/").some(e=>!e||e==="."||e===".."))throw new Error(`Invalid project path: ${JSON.stringify(a)}. Use relative paths without . or ...`);return a}function ut(a,e,i,c){let E=K(i??(c==="c"?"main.c":"main.cpp")),t=e?{...e}:{[E]:a};if(!Object.hasOwn(t,E))throw new Error(`Entry file ${E} does not exist.`);let r=Object.keys(t).map(K).sort(),n=f=>/\\.c$/.test(f),s=f=>/\\.(cpp|cc|cxx)$/.test(f);if(r.some(c==="c"?s:n))throw new Error("Mixed C/C++ source projects are not supported yet.");let o=r.filter(c==="c"?n:s);if(!o.includes(E))throw new Error(`Entry ${E} must have a ${c==="c"?".c":".cpp, .cc, or .cxx"} extension.`);if(o.length>32||r.length>256)throw new Error("Project limit: 32 source files and 256 files total.");if(Object.values(t).reduce((f,_)=>f+new TextEncoder().encode(_).length,0)>2e6)throw new Error("Project exceeds the 2 MB source limit.");return{files:t,sources:o,entry:E}}var st,v,dt=Promise.resolve(),G=a=>globalThis.postMessage(a),M=(a,e,i)=>G({type:"progress",id:a,phase:e,message:i}),B=(a,e)=>ot(a,lt[a],st,it,i=>M(e,"downloading",i));function St(a){let e=new Uint8Array(a),i=new TextDecoder,c=[],E=(t,r)=>i.decode(e.subarray(t,t+r)).replace(/\\0.*$/,"");for(let t=0;t+512<=e.length;){let r=E(t,100);if(!r)break;let n=E(t+345,155);n&&(r=n+"/"+r);let s=parseInt(E(t+124,12).trim()||"0",8),o=e[t+156];if(!Number.isSafeInteger(s)||s<0||t+512+s>e.length)throw new Error("Invalid sysroot archive.");if(o===48||o===0)c.push({name:"/"+K(r),data:e.subarray(t+512,t+512+s)});else if(o!==53)throw new Error("Unsupported sysroot archive entry.");t+=512+Math.ceil(s/512)*512}return c}async function Rt(a){let e=URL.createObjectURL(new Blob([a],{type:"text/javascript"}));try{return(await import(e)).default}finally{URL.revokeObjectURL(e)}}function yt(a){return st?(v||(v=(async()=>{let e=await Rt(await B("clang.js",a)),i=await Rt(await B("lld.js",a)),c=await WebAssembly.compile(await B("clang.wasm",a)),E=await WebAssembly.compile(await B("lld.wasm",a));M(a,"booting","Preparing C/C++ standard libraries\\u2026");let t=St(await B("sysroot.tar",a));return{clang:e,lld:i,clangModule:c,lldModule:E,sysroot:t}})().catch(e=>{throw v=void 0,e})),v):Promise.reject(new Error("Configure the rebuilt C/C++ assets with configureCpp({ indexURL }) before creating widgets. See docs/CPP-REBUILD.md."))}async function Et(a,e,i,c){let E,t=await a({thisProgram:i,noInitialRun:!0,print:c,printErr:c,instantiateWasm(r,n){let s=new WebAssembly.Instance(e,r);return E=Object.values(s.exports).find(o=>o instanceof WebAssembly.Memory),n(s,e),s.exports}});return t.memory=E,t}function $(a,e,i){a.mkdirTree(e.slice(0,e.lastIndexOf("/"))||"/"),a.writeFile(e,i)}async function mt(a){let e=performance.now(),i=0,c=(E,t)=>{if(i+=t.length,i>1e6)throw new Error("Output limit exceeded (1 MB).");t&&G({type:E,id:a.id,text:t})};try{let E=ut(a.code,a.files,a.entry,a.compilerLanguage),t=await yt(a.id),r=[],n=0;for(let R of E.sources){M(a.id,"compiling",`Compiling ${R}\\u2026`);let h=await Et(t.clang,t.clangModule,"clang",T=>c("stderr",T+`\n`));for(let T of t.sysroot)$(h.FS,T.name,T.data);for(let[T,pt]of Object.entries(E.files))$(h.FS,"/project/"+T,pt);let S=a.compilerLanguage==="cpp",X=["-cc1","-triple","wasm32-unknown-wasi","-emit-obj","-O0","-std="+(S?"c++20":"c17"),"-resource-dir","/lib/clang/20",...S?["-internal-isystem","/include/wasm32-wasi/c++/v1","-internal-isystem","/include/c++/v1"]:[],"-internal-isystem","/lib/clang/20/include","-internal-isystem","/include/wasm32-wasi","-internal-isystem","/include","-I","/project","-ferror-limit","20","-o","/tmp/output.o","-x",S?"c++":"c","/project/"+R],H=h.callMain(X);if(n=Math.max(n,h.memory?.buffer.byteLength??0),H!==0)throw new Error(`Compilation failed (${R}, exit ${H}).`);r.push(h.FS.readFile("/tmp/output.o").slice())}M(a.id,"linking","Linking\\u2026");let s=await Et(t.lld,t.lldModule,"wasm-ld",R=>c("stderr",R+`\n`));for(let R of t.sysroot)R.name.startsWith("/include/")||$(s.FS,R.name,R.data);r.forEach((R,h)=>$(s.FS,"/tmp/"+h+".o",R));let o=s.callMain(["-m","wasm32","-z","stack-size=1048576","--max-memory=268435456","-L/lib/wasm32-wasi","/lib/wasm32-wasi/crt1-command.o",...r.map((R,h)=>"/tmp/"+h+".o"),...a.compilerLanguage==="cpp"?["-lc++","-lc++abi"]:[],"-lc","/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a","-o","/tmp/program.wasm"]);if(n=Math.max(n,s.memory?.buffer.byteLength??0),o!==0)throw new Error(`Linking failed (exit ${o}).`);let f=await WebAssembly.compile(s.FS.readFile("/tmp/program.wasm").slice().buffer);M(a.id,"running","Running\\u2026");let _={stdout:new TextDecoder,stderr:new TextDecoder},l=R=>new P(h=>c(R,_[R].decode(h,{stream:!0}))),u=new rt([E.entry],[],[new b(new F(new TextEncoder().encode(a.stdin??""))),l("stdout"),l("stderr")]),p=await WebAssembly.instantiate(f,{wasi_snapshot_preview1:u.wasiImport}),d=u.start(p);if(c("stdout",_.stdout.decode()),c("stderr",_.stderr.decode()),d!==0)throw new Error(`Program exited with status ${d}.`);G({type:"result",id:a.id,durationMs:performance.now()-e,memory:{compilerBytes:n,programBytes:p.exports.memory.buffer.byteLength}})}catch(E){G({type:"error",id:a.id,message:E instanceof Error?E.message:String(E),durationMs:performance.now()-e})}}globalThis.onmessage=({data:a})=>{a.type==="init"?(st=a.toolchainURL,G({type:"ready",version:ct,interactiveStdin:!1})):a.type==="run"&&(dt=dt.then(()=>mt(a)))};})();\n',o=new class extends t{id=`cpp`;get label(){return`C/C++ (Clang 20, experimental)`}get source(){return a}async load(e){return await i(n),super.load(e)}initPayload(){return{toolchainURL:e().indexURL}}};function s(t){return{id:t,label:t===`c`?`C17 (experimental)`:`C++20 (experimental)`,statusDecidesFailure:!0,get ready(){return o.ready},interactiveStdin:!1,async editorLanguage(){return(await import(`@codemirror/lang-cpp`)).cpp()},load:e=>o.load(e),run:(n,r={})=>o.run(n,{...r,compilerLanguage:t,timeoutMs:r.timeoutMs??e().timeoutMs}),stop:e=>o.stop(e)}}var c=s(`c`),l=s(`cpp`);export{c as cRuntime,l as cppRuntime};
|
|
@@ -10,7 +10,7 @@ var e=[{id:`default-dark`,label:`One Dark`,mode:`dark`},{id:`monokai`,label:`Mon
|
|
|
10
10
|
--cp-ok: ${n.ok};
|
|
11
11
|
color-scheme: ${t};
|
|
12
12
|
}`]:[]).join(`
|
|
13
|
-
`)}async function d(e){try{return await g(e)}catch(t){return console.warn(`[code-playpad] CodeMirror unavailable, using plain textarea:`,t),_(e)}}var f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Set,m=!1;function h(){m||(m=!0,queueMicrotask(()=>{m=!1;for(let e of p){let t=[...e.adoptedStyleSheets];e.adoptedStyleSheets=[],e.adoptedStyleSheets=t}}))}async function g(t){let[n,r,i,a,o,s,c]=await Promise.all([import(`@codemirror/view`),import(`@codemirror/state`),import(`@codemirror/commands`),import(`@codemirror/language`),import(`@codemirror/autocomplete`),import(`@codemirror/theme-one-dark`),import(`@lezer/highlight`)]),{EditorView:l,keymap:u,lineNumbers:d,highlightActiveLine:m,highlightActiveLineGutter:g,highlightSpecialChars:_,drawSelection:v,rectangularSelection:y,crosshairCursor:b}=n,{EditorState:x,Compartment:S}=r,{defaultKeymap:C,history:w,historyKeymap:T,indentWithTab:E}=i,{syntaxHighlighting:D,defaultHighlightStyle:O,HighlightStyle:k,indentOnInput:A,bracketMatching:j,foldGutter:M,foldKeymap:N}=a,{autocompletion:P,closeBrackets:F,closeBracketsKeymap:I,completionKeymap:L}=o,R=new S,z=new S,B=new S,V=f.get(`default-light`)??[l.theme({"&":{color:`#1f2328`,backgroundColor:`#ffffff`},".cm-gutters":{backgroundColor:`#f6f8fa`,color:`#8b949e`,border:`none`},".cm-activeLine":{backgroundColor:`#f6f8fa88`},".cm-activeLineGutter":{backgroundColor:`#eaeef2`},".cm-cursor":{borderLeftColor:`#1f2328`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`#cfe3ff`}}),D(O,{fallback:!0})];f.set(`default-light`,V);let{tags:H}=c,U=(e,t)=>[l.theme({"&":{color:e.fg,backgroundColor:e.bg},".cm-content":{caretColor:e.fg},".cm-gutters":{backgroundColor:e.surface,color:e.muted,border:`none`},".cm-activeLine":{backgroundColor:e.activeLine},".cm-activeLineGutter":{backgroundColor:e.selection},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.fg},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:e.selection},".cm-tooltip":{backgroundColor:e.surface,color:e.fg,border:`1px solid ${e.border}`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:e.selection,color:e.fg}},{dark:t}),D(k.define([{tag:[H.comment,H.meta],color:e.comment,fontStyle:`italic`},{tag:[H.keyword,H.operatorKeyword,H.modifier],color:e.keyword},{tag:[H.string,H.special(H.string),H.regexp],color:e.string},{tag:[H.number,H.bool,H.null,H.atom],color:e.number},{tag:[H.function(H.variableName),H.function(H.propertyName),H.definition(H.function(H.variableName))],color:e.fn},{tag:[H.typeName,H.className,H.namespace,H.tagName],color:e.type},{tag:[H.variableName,H.propertyName,H.attributeName],color:e.variable},{tag:H.invalid,color:e.keyword,textDecoration:`underline`}]))],W=(t,n)=>{let r=e.find(e=>e.id===n);if(!r?.colors)return t?s.oneDark:V;let i=f.get(r.id);return i||(i=U(r.colors,r.mode===`dark`),f.set(r.id,i)),i},G=u.of([{key:`Mod-Enter`,preventDefault:!0,run:()=>(t.onRun?.(),!0)},{key:`Shift-Enter`,preventDefault:!0,run:()=>(t.onRun?.(),!0)}]),K=t.dark,q=t.themeId,J=t.readOnly,Y=t.language??[],X=e=>x.create({doc:e,extensions:[d(),g(),_(),w(),M(),v(),x.allowMultipleSelections.of(!0),A(),j(),F(),P(),y(),b(),m(),G,u.of([...I,...C,...T,...N,...L,E]),l.lineWrapping,B.of(Y),R.of(W(K,q)),z.of(x.readOnly.of(J)),l.updateListener.of(e=>{e.startState.facet(l.styleModule)!==e.state.facet(l.styleModule)&&h(),e.docChanged&&t.onChange?.(e.state.doc.toString())})]}),Z=new l({parent:t.parent,state:X(t.doc)});p.add(Z.root),h();let Q=/* @__PURE__ */ new Map,$=t.name??``;return{fallback:!1,getCode:()=>Z.state.doc.toString(),setCode(e){Z.dispatch({changes:{from:0,to:Z.state.doc.length,insert:e}})},openFile(e,t){if(e===$)return;Q.set($,Z.state);let n=Q.get(e);Z.setState(n??X(t)),$=e,n&&Z.dispatch({effects:[R.reconfigure(W(K,q)),z.reconfigure(x.readOnly.of(J)),B.reconfigure(Y)]}),h()},fileCode(e,t){if(e===$)return Z.state.doc.toString();let n=Q.get(e);return n?n.doc.toString():t},forgetFiles(e){for(let t of[...Q.keys()])e.includes(t)||Q.delete(t)},setTheme(e,t){K=e,q=t,Z.dispatch({effects:R.reconfigure(W(K,q))})},setReadOnly(e){J=e,Z.dispatch({effects:z.reconfigure(x.readOnly.of(J))})},setLanguage(e){Y=e,Z.dispatch({effects:B.reconfigure(Y)})},focus:()=>Z.focus(),destroy(){p.delete(Z.root),Z.destroy()}}}function _(e){let t=document.createElement(`textarea`);t.className=`cp-fallback-editor`,t.spellcheck=!1,t.value=e.doc,t.readOnly=e.readOnly,t.addEventListener(`input`,()=>e.onChange?.(t.value)),t.addEventListener(`keydown`,t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&(t.preventDefault(),e.onRun?.())}),e.parent.appendChild(t);let n=/* @__PURE__ */ new Map,r=e.name??``;return{fallback:!0,getCode:()=>t.value,setCode:e=>{t.value=e},openFile(e,i){e!==r&&(n.set(r,t.value),t.value=n.get(e)??i,r=e)},fileCode(e,i){return e===r?t.value:n.get(e)??i},forgetFiles(e){for(let t of[...n.keys()])e.includes(t)||n.delete(t)},setTheme:()=>{},setReadOnly:e=>{t.readOnly=e},setLanguage:()=>{},focus:()=>t.focus(),destroy:()=>t.remove()}}var v=/* @__PURE__ */ new Map,y=/* @__PURE__ */ new Map;function b(e,t){v.set(e,t)}function x(){return[...v.keys()]}function S(e){let t=y.get(e);if(t)return t;let n=v.get(e);if(!n)return Promise.reject(/* @__PURE__ */ Error(`Unknown runtime "${e}". Registered: ${x().join(`, `)||`none`}`));let r=n().catch(t=>{throw y.delete(e),t});return y.set(e,r),r}b(`python`,()=>import(`./pyodide-
|
|
13
|
+
`)}async function d(e){try{return await g(e)}catch(t){return console.warn(`[code-playpad] CodeMirror unavailable, using plain textarea:`,t),_(e)}}var f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Set,m=!1;function h(){m||(m=!0,queueMicrotask(()=>{m=!1;for(let e of p){let t=[...e.adoptedStyleSheets];e.adoptedStyleSheets=[],e.adoptedStyleSheets=t}}))}async function g(t){let[n,r,i,a,o,s,c]=await Promise.all([import(`@codemirror/view`),import(`@codemirror/state`),import(`@codemirror/commands`),import(`@codemirror/language`),import(`@codemirror/autocomplete`),import(`@codemirror/theme-one-dark`),import(`@lezer/highlight`)]),{EditorView:l,keymap:u,lineNumbers:d,highlightActiveLine:m,highlightActiveLineGutter:g,highlightSpecialChars:_,drawSelection:v,rectangularSelection:y,crosshairCursor:b}=n,{EditorState:x,Compartment:S}=r,{defaultKeymap:C,history:w,historyKeymap:T,indentWithTab:E}=i,{syntaxHighlighting:D,defaultHighlightStyle:O,HighlightStyle:k,indentOnInput:A,bracketMatching:j,foldGutter:M,foldKeymap:N}=a,{autocompletion:P,closeBrackets:F,closeBracketsKeymap:I,completionKeymap:L}=o,R=new S,z=new S,B=new S,V=f.get(`default-light`)??[l.theme({"&":{color:`#1f2328`,backgroundColor:`#ffffff`},".cm-gutters":{backgroundColor:`#f6f8fa`,color:`#8b949e`,border:`none`},".cm-activeLine":{backgroundColor:`#f6f8fa88`},".cm-activeLineGutter":{backgroundColor:`#eaeef2`},".cm-cursor":{borderLeftColor:`#1f2328`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`#cfe3ff`}}),D(O,{fallback:!0})];f.set(`default-light`,V);let{tags:H}=c,U=(e,t)=>[l.theme({"&":{color:e.fg,backgroundColor:e.bg},".cm-content":{caretColor:e.fg},".cm-gutters":{backgroundColor:e.surface,color:e.muted,border:`none`},".cm-activeLine":{backgroundColor:e.activeLine},".cm-activeLineGutter":{backgroundColor:e.selection},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.fg},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:e.selection},".cm-tooltip":{backgroundColor:e.surface,color:e.fg,border:`1px solid ${e.border}`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:e.selection,color:e.fg}},{dark:t}),D(k.define([{tag:[H.comment,H.meta],color:e.comment,fontStyle:`italic`},{tag:[H.keyword,H.operatorKeyword,H.modifier],color:e.keyword},{tag:[H.string,H.special(H.string),H.regexp],color:e.string},{tag:[H.number,H.bool,H.null,H.atom],color:e.number},{tag:[H.function(H.variableName),H.function(H.propertyName),H.definition(H.function(H.variableName))],color:e.fn},{tag:[H.typeName,H.className,H.namespace,H.tagName],color:e.type},{tag:[H.variableName,H.propertyName,H.attributeName],color:e.variable},{tag:H.invalid,color:e.keyword,textDecoration:`underline`}]))],W=(t,n)=>{let r=e.find(e=>e.id===n);if(!r?.colors)return t?s.oneDark:V;let i=f.get(r.id);return i||(i=U(r.colors,r.mode===`dark`),f.set(r.id,i)),i},G=u.of([{key:`Mod-Enter`,preventDefault:!0,run:()=>(t.onRun?.(),!0)},{key:`Shift-Enter`,preventDefault:!0,run:()=>(t.onRun?.(),!0)}]),K=t.dark,q=t.themeId,J=t.readOnly,Y=t.language??[],X=e=>x.create({doc:e,extensions:[d(),g(),_(),w(),M(),v(),x.allowMultipleSelections.of(!0),A(),j(),F(),P(),y(),b(),m(),G,u.of([...I,...C,...T,...N,...L,E]),l.lineWrapping,B.of(Y),R.of(W(K,q)),z.of(x.readOnly.of(J)),l.updateListener.of(e=>{e.startState.facet(l.styleModule)!==e.state.facet(l.styleModule)&&h(),e.docChanged&&t.onChange?.(e.state.doc.toString())})]}),Z=new l({parent:t.parent,state:X(t.doc)});p.add(Z.root),h();let Q=/* @__PURE__ */ new Map,$=t.name??``;return{fallback:!1,getCode:()=>Z.state.doc.toString(),setCode(e){Z.dispatch({changes:{from:0,to:Z.state.doc.length,insert:e}})},openFile(e,t){if(e===$)return;Q.set($,Z.state);let n=Q.get(e);Z.setState(n??X(t)),$=e,n&&Z.dispatch({effects:[R.reconfigure(W(K,q)),z.reconfigure(x.readOnly.of(J)),B.reconfigure(Y)]}),h()},fileCode(e,t){if(e===$)return Z.state.doc.toString();let n=Q.get(e);return n?n.doc.toString():t},forgetFiles(e){for(let t of[...Q.keys()])e.includes(t)||Q.delete(t)},setTheme(e,t){K=e,q=t,Z.dispatch({effects:R.reconfigure(W(K,q))})},setReadOnly(e){J=e,Z.dispatch({effects:z.reconfigure(x.readOnly.of(J))})},setLanguage(e){Y=e,Z.dispatch({effects:B.reconfigure(Y)})},focus:()=>Z.focus(),destroy(){p.delete(Z.root),Z.destroy()}}}function _(e){let t=document.createElement(`textarea`);t.className=`cp-fallback-editor`,t.spellcheck=!1,t.value=e.doc,t.readOnly=e.readOnly,t.addEventListener(`input`,()=>e.onChange?.(t.value)),t.addEventListener(`keydown`,t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&(t.preventDefault(),e.onRun?.())}),e.parent.appendChild(t);let n=/* @__PURE__ */ new Map,r=e.name??``;return{fallback:!0,getCode:()=>t.value,setCode:e=>{t.value=e},openFile(e,i){e!==r&&(n.set(r,t.value),t.value=n.get(e)??i,r=e)},fileCode(e,i){return e===r?t.value:n.get(e)??i},forgetFiles(e){for(let t of[...n.keys()])e.includes(t)||n.delete(t)},setTheme:()=>{},setReadOnly:e=>{t.readOnly=e},setLanguage:()=>{},focus:()=>t.focus(),destroy:()=>t.remove()}}var v=/* @__PURE__ */ new Map,y=/* @__PURE__ */ new Map;function b(e,t){v.set(e,t)}function x(){return[...v.keys()]}function S(e){let t=y.get(e);if(t)return t;let n=v.get(e);if(!n)return Promise.reject(/* @__PURE__ */ Error(`Unknown runtime "${e}". Registered: ${x().join(`, `)||`none`}`));let r=n().catch(t=>{throw y.delete(e),t});return y.set(e,r),r}b(`python`,()=>import(`./pyodide-BRw8SuuC.js`).then(e=>e.pythonRuntime)),b(`javascript`,()=>import(`./javascript-j4E_GxwK.js`).then(e=>e.javascriptRuntime)),b(`typescript`,()=>import(`./javascript-j4E_GxwK.js`).then(e=>e.typescriptRuntime)),b(`java`,()=>import(`./java-BEvn335o.js`).then(e=>e.javaRuntime)),b(`c`,()=>import(`./cpp-BVqJclgd.js`).then(e=>e.cRuntime)),b(`cpp`,()=>import(`./cpp-BVqJclgd.js`).then(e=>e.cppRuntime)),b(`react`,()=>import(`./react-uV_SMJrS.js`).then(e=>e.reactRuntime));var C=class extends Error{constructor(e=`Execution stopped`){super(e),this.name=`RunStopped`}},w=class extends Error{constructor(e=`Web Workers are unavailable in this page`){super(e),this.name=`WorkerUnavailable`}},T=/* @__PURE__ */ new WeakSet,E=String.raw`
|
|
14
14
|
:host {
|
|
15
15
|
--cp-bg: #ffffff;
|
|
16
16
|
--cp-fg: #1f2328;
|
|
@@ -463,14 +463,19 @@ table.cp-table th { background: var(--cp-bg); }
|
|
|
463
463
|
:host([data-window]) .cp-source { flex: 1 1 0; display: flex; flex-direction: column; }
|
|
464
464
|
:host([data-window]) .cp-has-tree .cp-source { display: grid; }
|
|
465
465
|
:host([data-window]) .cp-preview-pane { flex: 1 1 0; }
|
|
466
|
+
:host([data-window]) .cp-editor-sized .cp-source { flex: none; }
|
|
466
467
|
|
|
467
468
|
/* file-view="tree": the files in a column beside the editor. */
|
|
468
469
|
.cp-root.cp-has-tree { container-type: inline-size; }
|
|
469
470
|
.cp-has-tree .cp-source {
|
|
470
471
|
display: grid;
|
|
471
|
-
grid-template-columns: var(--cp-tree-width, 200px) 7px minmax(0, 1fr);
|
|
472
|
+
grid-template-columns: min(var(--cp-tree-width, 200px), calc(100% - 167px)) 7px minmax(0, 1fr);
|
|
472
473
|
grid-template-rows: 1fr auto;
|
|
473
474
|
}
|
|
475
|
+
/* With a preview, the code gets its own row, so the tree shares only that. */
|
|
476
|
+
.cp-has-tree.cp-has-preview .cp-source { grid-template-columns: min(var(--cp-tree-width, 20%), calc(100% - 167px)) 7px minmax(0, 1fr); }
|
|
477
|
+
/* A sized row follows the divider, so a long tree scrolls instead of holding it open. */
|
|
478
|
+
.cp-editor-sized.cp-has-tree .cp-tabs.cp-tree { height: 0; min-height: 100%; }
|
|
474
479
|
.cp-has-tree .cp-source > :not(.cp-tabs, .cp-split-tree) { grid-column: 3; }
|
|
475
480
|
.cp-has-tree .cp-split-tree { display: block; grid-column: 2; grid-row: 1 / span 2; }
|
|
476
481
|
.cp-tabs.cp-tree {
|
|
@@ -514,19 +519,20 @@ table.cp-table th { background: var(--cp-bg); }
|
|
|
514
519
|
.cp-has-tree .cp-source { display: block; }
|
|
515
520
|
.cp-has-tree .cp-split-tree { display: none; }
|
|
516
521
|
.cp-tabs.cp-tree { max-height: 150px; border-bottom: 1px solid var(--cp-border); }
|
|
522
|
+
.cp-editor-sized.cp-has-tree .cp-tabs.cp-tree { height: auto; min-height: 0; }
|
|
517
523
|
}
|
|
518
524
|
|
|
519
|
-
/* Only a preview sits beside the code
|
|
525
|
+
/* Only a preview sits beside the code, and only with no tree: three columns leave
|
|
526
|
+
the preview too little room. A tree makes any widget a container. */
|
|
520
527
|
@container (min-width: 760px) {
|
|
521
|
-
.cp-has-preview .cp-body { display: flex; align-items: stretch; }
|
|
522
|
-
.cp-has-preview .cp-source { flex: 0 0 var(--cp-source-width, calc(50% - 4px)); min-width: 0; }
|
|
523
|
-
.cp-has-preview .cp-
|
|
524
|
-
.cp-has-preview .cp-preview {
|
|
525
|
-
.cp-has-preview
|
|
526
|
-
.cp-has-preview
|
|
527
|
-
.cp-
|
|
528
|
-
:host([data-window]) .cp-
|
|
529
|
-
:host([data-window]) .cp-source { flex: 0 0 var(--cp-source-width, calc(50% - 4px)); }
|
|
528
|
+
.cp-has-preview:not(.cp-has-tree) .cp-body { display: flex; align-items: stretch; }
|
|
529
|
+
.cp-has-preview:not(.cp-has-tree) .cp-source { display: flex; flex-direction: column; flex: 0 0 var(--cp-source-width, calc(50% - 4px)); min-width: 0; }
|
|
530
|
+
.cp-has-preview:not(.cp-has-tree) .cp-source .cp-editor { flex: 1 1 auto; }
|
|
531
|
+
.cp-has-preview:not(.cp-has-tree) .cp-preview-pane { flex: 1 1 0; min-width: 0; }
|
|
532
|
+
.cp-has-preview:not(.cp-has-tree) .cp-preview { border-top: 0; }
|
|
533
|
+
.cp-has-preview:not(.cp-has-tree) .cp-split.cp-split-main { width: 7px; height: auto; cursor: col-resize; border-width: 0 1px; }
|
|
534
|
+
:host([data-window]) .cp-root:not(.cp-has-tree) .cp-body { flex-direction: row; }
|
|
535
|
+
:host([data-window]) .cp-root:not(.cp-has-tree) .cp-source { flex: 0 0 var(--cp-source-width, calc(50% - 4px)); }
|
|
530
536
|
}
|
|
531
537
|
|
|
532
538
|
@keyframes cp-slide {
|
|
@@ -539,11 +545,11 @@ table.cp-table th { background: var(--cp-bg); }
|
|
|
539
545
|
}
|
|
540
546
|
`,D=e=>()=>import(`@codemirror/lang-javascript`).then(t=>t.javascript(e)),O={py:()=>import(`@codemirror/lang-python`).then(e=>e.python()),pyi:()=>import(`@codemirror/lang-python`).then(e=>e.python()),js:D({}),mjs:D({}),cjs:D({}),jsx:D({jsx:!0}),ts:D({typescript:!0}),mts:D({typescript:!0}),cts:D({typescript:!0}),tsx:D({typescript:!0,jsx:!0}),json:()=>import(`@codemirror/lang-json`).then(e=>e.json()),css:()=>import(`@codemirror/lang-css`).then(e=>e.css()),html:()=>import(`@codemirror/lang-html`).then(e=>e.html()),c:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),h:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),cpp:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),cc:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),cxx:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),hpp:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),hxx:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),java:()=>import(`@codemirror/lang-java`).then(e=>e.java())};async function k(e,t){let n=e.includes(`.`)?e.slice(e.lastIndexOf(`.`)+1).toLowerCase():``,r=t===`react`&&n===`js`?O.jsx:O[n];return r?r().catch(()=>null):null}var A=`code-playpad`,j=1,M=`snippets`,N=`progress`,P=null;function F(){return typeof indexedDB>`u`?Promise.reject(/* @__PURE__ */ Error(`IndexedDB unavailable`)):(P||=new Promise((e,t)=>{let n=indexedDB.open(A,j);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(M)||e.createObjectStore(M),e.objectStoreNames.contains(N)||e.createObjectStore(N,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}).catch(e=>{throw P=null,e}),P)}function I(e,t,n){return F().then(r=>new Promise((i,a)=>{let o=n(r.transaction(e,t).objectStore(e));o.onsuccess=()=>i(o.result),o.onerror=()=>a(o.error)}))}function L(e,t){return I(M,`readwrite`,n=>n.put(t,e)).then(()=>void 0)}function R(e){return I(M,`readonly`,t=>t.get(e)).then(e=>e??null)}function z(e){return I(M,`readwrite`,t=>t.delete(e)).then(()=>void 0)}function B(e,t={}){let n={completed:!0,...t,id:e,updatedAt:Date.now()};return I(N,`readwrite`,e=>e.put(n)).then(()=>n)}function V(e){return I(N,`readonly`,t=>t.get(e)).then(e=>e??null)}function H(){return I(N,`readonly`,e=>e.getAll())}var U=`code-playpad`;function W(e){let t=e.replace(/\t/g,` `).split(`
|
|
541
547
|
`);for(;t.length&&t[0].trim()===``;)t.shift();for(;t.length&&t[t.length-1].trim()===``;)t.pop();let n=t.filter(e=>e.trim()!==``).reduce((e,t)=>Math.min(e,t.match(/^ */)[0].length),1/0);return(n===1/0?t:t.map(e=>e.slice(n))).join(`
|
|
542
|
-
`)}var G=2e5,K=`playpad-file`,q={python:`main.py`,javascript:`main.js`,typescript:`main.ts`,java:`Main.java`,c:`main.c`,cpp:`main.cpp`,react:`src/main.jsx`};function J(e){return q[e]??`main.txt`}var Y=e=>e.tagName===`SCRIPT`&&e.getAttribute(`type`)===`text/plain`;function X(e){return[...e.children].filter(e=>e.tagName.toLowerCase()===K&&[...e.children].some(e=>!Y(e))).map(e=>e.getAttribute(`name`)??``)}function Z(e,t){let n={};for(let t of e.children){if(t.tagName.toLowerCase()!==K)continue;let e=t.getAttribute(`name`),r=[...t.children].find(Y);e&&(n[e]=W((r??t).textContent??``))}if(Object.keys(n).length)return n;let r=[...e.childNodes].filter(e=>e.nodeType!==Node.ELEMENT_NODE||e.tagName.toLowerCase()!==K),i=r.some(e=>e.nodeType===Node.ELEMENT_NODE),a=W(r.filter(e=>!(i&&e.nodeType===Node.TEXT_NODE&&!(e.textContent??``).trim())).map(e=>e.textContent??``).join(``));return{[t]:a}}function Q(e,t){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;return Object.keys(e).length?e:null}}catch{}return e?{[t]:e}:null}var $=typeof HTMLElement>`u`?class{}:HTMLElement,ee=class extends ${static get observedAttributes(){return[`language`,`height`,`min-height`,`max-height`,`preview-height`,`file-view`,`open-file`,`theme`,`theme-controls`,`readonly`,`autorun`,`stdin`,`persist`,`entry`,`practice`]}#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=null;#d=null;#f=null;#p=null;#m={};#h={};#g=`main.py`;#_=null;#v;#y=!1;#b=null;#x=!1;#S=!1;#C=null;#w=null;#T=null;#E=()=>this.#fe();#D=null;#O=null;#k=!0;#A=[];#j=null;#M=null;#N=null;#P=0;#F=!1;#I=null;#L;#R;#z=null;#B=[];#V=/* @__PURE__ */ new Set;#H=null;#U=null;#W=null;constructor(){super(),this.#e=this.attachShadow({mode:`open`})}get code(){return this.#u?this.#u.getCode():this.#m[this.#g]??``}set code(e){this.#m[this.#g]=e,this.#Z()}get practice(){if(this.#I)return this.#I;let e=this.getAttribute(`practice`);if(!e)return null;try{return JSON.parse(e)}catch{return null}}set practice(e){this.#I=e}get files(){return this.#re()}set files(e){let t=Object.keys(e);if(!t.length)return;let n=Object.keys(this.#h);n.length===1&&!this.#h[n[0]]&&(this.#h={...e}),this.#m={...e},this.#B=[],t.includes(this.#g)||(this.#g=this.#te()),this.#u?.forgetFiles([]),this.#Z(),this.#ie(),this.#X()}get entry(){return this.#te()}set entry(e){this.setAttribute(`entry`,e)}openFile(e){if(e in this.#m){this.#u&&(this.#m[this.#g]=this.#u.getCode(),this.#u.openFile(e,this.#m[e]??``)),this.#g=e;for(let t=e.indexOf(`/`);t!==-1;t=e.indexOf(`/`,t+1))this.#V.delete(e.slice(0,t));this.#ie(),this.#X()}}get stdin(){return this.#l?this.#l.value:``}set stdin(e){this.#l&&(this.#l.value=e,this.#c.hidden=!1)}get language(){return this.getAttribute(`language`)||`python`}set language(e){this.setAttribute(`language`,e)}getCode(){return this.code}getFiles(){return this.#re()}reset(){this.#m={...this.#h},this.#g=this.#te(),this.#u?.forgetFiles([]),this.#Z(),this.#ie(),this.#he(),this.#s.hidden=!0,this.#se(),this.#z=null,this.#ce(),this.#me(this.#f?.ready?`${this.#f.label} ready`:``,`idle`)}async run(){if(this.#H)return this.#H.widget.run();if(this.#y)return;await this.#d;let e=this.#re(),t=this.getAttribute(`entry`);if(t&&!(t in e))return this.#$(t,e);this.#Q=!1;let n=this.#te(),r=e[n]??``;this.#y=!0,this.#x=!1,this.#n.disabled=!0,this.#r.hidden=!1,this.#he(),this.#s.hidden=!1;let i=this.practice;this.hasAttribute(`practice`)&&!i&&this.#ge(`The practice attribute is not valid JSON.
|
|
548
|
+
`)}var G=2e5,K=`playpad-file`,q={python:`main.py`,javascript:`main.js`,typescript:`main.ts`,java:`Main.java`,c:`main.c`,cpp:`main.cpp`,react:`src/main.jsx`};function J(e){return q[e]??`main.txt`}var Y=e=>e.tagName===`SCRIPT`&&e.getAttribute(`type`)===`text/plain`;function X(e){return[...e.children].filter(e=>e.tagName.toLowerCase()===K&&[...e.children].some(e=>!Y(e))).map(e=>e.getAttribute(`name`)??``)}function Z(e,t){let n={};for(let t of e.children){if(t.tagName.toLowerCase()!==K)continue;let e=t.getAttribute(`name`),r=[...t.children].find(Y);e&&(n[e]=W((r??t).textContent??``))}if(Object.keys(n).length)return n;let r=[...e.childNodes].filter(e=>e.nodeType!==Node.ELEMENT_NODE||e.tagName.toLowerCase()!==K),i=r.some(e=>e.nodeType===Node.ELEMENT_NODE),a=W(r.filter(e=>!(i&&e.nodeType===Node.TEXT_NODE&&!(e.textContent??``).trim())).map(e=>e.textContent??``).join(``));return{[t]:a}}function Q(e,t){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;return Object.keys(e).length?e:null}}catch{}return e?{[t]:e}:null}var $=typeof HTMLElement>`u`?class{}:HTMLElement,ee=class extends ${static get observedAttributes(){return[`language`,`height`,`min-height`,`max-height`,`preview-height`,`tree-width`,`file-view`,`open-file`,`theme`,`theme-controls`,`readonly`,`autorun`,`stdin`,`persist`,`entry`,`practice`]}#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=null;#d=null;#f=null;#p=null;#m={};#h={};#g=`main.py`;#_=null;#v;#y=!1;#b=null;#x=!1;#S=!1;#C=null;#w=null;#T=null;#E=()=>this.#fe();#D=null;#O=null;#k=!0;#A=[];#j=null;#M=null;#N=null;#P=0;#F=!1;#I=null;#L;#R;#z=null;#B=[];#V=/* @__PURE__ */ new Set;#H=null;#U=null;#W=null;constructor(){super(),this.#e=this.attachShadow({mode:`open`})}get code(){return this.#u?this.#u.getCode():this.#m[this.#g]??``}set code(e){this.#m[this.#g]=e,this.#Z()}get practice(){if(this.#I)return this.#I;let e=this.getAttribute(`practice`);if(!e)return null;try{return JSON.parse(e)}catch{return null}}set practice(e){this.#I=e}get files(){return this.#re()}set files(e){let t=Object.keys(e);if(!t.length)return;let n=Object.keys(this.#h);n.length===1&&!this.#h[n[0]]&&(this.#h={...e}),this.#m={...e},this.#B=[],t.includes(this.#g)||(this.#g=this.#te()),this.#u?.forgetFiles([]),this.#Z(),this.#ie(),this.#X()}get entry(){return this.#te()}set entry(e){this.setAttribute(`entry`,e)}openFile(e){if(e in this.#m){this.#u&&(this.#m[this.#g]=this.#u.getCode(),this.#u.openFile(e,this.#m[e]??``)),this.#g=e;for(let t=e.indexOf(`/`);t!==-1;t=e.indexOf(`/`,t+1))this.#V.delete(e.slice(0,t));this.#ie(),this.#X()}}get stdin(){return this.#l?this.#l.value:``}set stdin(e){this.#l&&(this.#l.value=e,this.#c.hidden=!1)}get language(){return this.getAttribute(`language`)||`python`}set language(e){this.setAttribute(`language`,e)}getCode(){return this.code}getFiles(){return this.#re()}reset(){this.#m={...this.#h},this.#g=this.#te(),this.#u?.forgetFiles([]),this.#Z(),this.#ie(),this.#he(),this.#s.hidden=!0,this.#se(),this.#z=null,this.#ce(),this.#me(this.#f?.ready?`${this.#f.label} ready`:``,`idle`)}async run(){if(this.#H)return this.#H.widget.run();if(this.#y)return;await this.#d;let e=this.#re(),t=this.getAttribute(`entry`);if(t&&!(t in e))return this.#$(t,e);this.#Q=!1;let n=this.#te(),r=e[n]??``;this.#y=!0,this.#x=!1,this.#n.disabled=!0,this.#r.hidden=!1,this.#he(),this.#s.hidden=!1;let i=this.practice;this.hasAttribute(`practice`)&&!i&&this.#ge(`The practice attribute is not valid JSON.
|
|
543
549
|
`,`cp-err`),this.#oe()&&(this.#z=e,this.#ce(),this.#B.length&&this.#ge(`${this.#B.join(`, `)}: HTML tags in this file's markup were read as elements, so its code is incomplete. Write < as <, or put the code in <script type="text/plain">. A <script> left unescaped runs on the host page.\n`,`cp-err`)),this.#Se(`py-run`,{code:r,entry:n,files:e,language:this.language,...i?{practice:i}:{}});try{let t=await this.#Y();if(this.#x)throw new C;if(i&&!t.supportsPractice)throw Error(`Practice mode is not available for ${t.label}.`);this.#me(`Queued…`,`busy`),this.#o.hidden=!1;let a=t.run(r,{stdin:this.#l.value,files:e,entry:n,onStart:()=>this.#me(`Running…`,`busy`),onProgress:e=>this.#me(e.message,`busy`),onStdout:e=>this.#ge(e),onStderr:e=>this.#ge(e,`cp-err`),onEcho:e=>this.#ge(e,`cp-in`),onStdinRequest:()=>this.#ve(),...i?{practice:i}:{},...this.#oe()?{preview:{host:this.#L,onStart:()=>this.#me(`Running…`,`busy`),onConsole:(e,t)=>{this.#ge(`${t}\n`,e===`error`?`cp-err`:e===`warn`?`cp-warn`:void 0),this.#Ce(`playpad-console`,{level:e,text:t,language:this.language})},onRender:e=>this.#Ce(`playpad-render`,{rootText:e,language:this.language}),onError:e=>{this.#me(`Error`,`error`),this.#Se(`py-error`,{...e,language:this.language})}}}:{}});this.#b={runtime:t,run:a};let o=await a;if(o.table&&this.#xe(o.table),o.value!==void 0&&this.#ge(`${o.value}\n`,`cp-value`),o.hint&&this.#be(o.hint,T.has(o)),o.failed=t.statusDecidesFailure?o.failed===!0:!!o.stderr,o.failed)this.#me(`Error · ${o.durationMs} ms`,`error`),this.#Se(`py-error`,{message:o.problem?.message??o.stderr??``,hint:o.hint,language:this.language,...o.problem??{}});else if(o.cases){let e=o.cases.filter(e=>e.expected!==void 0).length,t=o.passed===e;this.#me(e?`${o.passed} of ${e} passed · ${o.durationMs} ms`:`Done in ${o.durationMs} ms`,t?`ok`:`error`)}else this.#me(`Done in ${o.durationMs} ms`,`ok`);return this.#Se(`py-output`,{...o,language:this.language}),o}catch(e){if(e instanceof C)this.#ge(`
|
|
544
550
|
[stopped]
|
|
545
551
|
`,`cp-err`),this.#me(`Stopped`,`error`);else{let t=e instanceof Error?e.message:String(e);this.#ge(t+`
|
|
546
|
-
`,`cp-err`),this.#me(`Failed to start`,`error`),this.#Se(`py-error`,{message:t,language:this.language})}return}finally{this.#b=null,this.#ye(null),this.#_e(),this.#y=!1,this.#n.disabled=!1,this.#r.hidden=!(this.#oe()&&this.#f?.hasLivePreview?.(this.#L)),this.#o.hidden=!0}}stop(){this.#H?this.#H.widget.stop():this.#b?this.#b.runtime.stop?.(this.#b.run):this.#y?this.#x=!0:this.#oe()&&this.#f?.hasLivePreview?.(this.#L)&&(this.#se(),this.#r.hidden=!0,this.#me(`Stopped`,`idle`))}openWindow(){if(this.#H)return this.#H.window.focus(),!0;if(this.#U)return!1;let e=window.open(``,`_blank`,`popup,width=1280,height=800`);if(!e)return this.#me(`The browser blocked the new window`,`error`),!1;let t=this.#re(),n=this.#g,r=document.createElement(this.localName);for(let e of[`language`,`entry`,`file-view`,`preview-height`,`theme`,`theme-controls`,`readonly`,`stdin`]){let t=this.getAttribute(e);t!==null&&r.setAttribute(e,t)}r.setAttribute(`data-window`,``),r.#U=this,r.#W={...this.#h},r.#_=t,this.#se(),this.#r.hidden=!0,e.document.title=`Code playground`,e.document.documentElement.style.height=`100%`,e.document.body.style.cssText=`margin:0;height:100%`,e.document.body.append(r);let i=()=>this.closeWindow();return window.addEventListener(`pagehide`,i),this.#H={window:e,widget:r,onLeave:i,timer:setInterval(()=>{e.closed&&this.closeWindow()},300)},this.#e.querySelector(`.cp-root`)?.classList.add(`cp-popped`),r.#d?.then(()=>(r.openFile(n),r.run())),!0}closeWindow(){let e=this.#H;if(!e)return;this.#H=null,clearInterval(e.timer),window.removeEventListener(`pagehide`,e.onLeave);let{widget:t}=e,n=t.#re(),r=t.#g;t.#se(),t.remove(),e.window.closed||e.window.close(),this.#e.querySelector(`.cp-root`)?.classList.remove(`cp-popped`),this.files=n,this.openFile(r),this.#me(``,`idle`)}prewarm(){return this.#Y()}connectedCallback(){this.#F?(this.#fe(),this.#J()):!this.textContent?.trim()&&document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.#G(),{once:!0}):this.#G()}disconnectedCallback(){this.#C?.disconnect(),this.#C=null,this.#w?.removeEventListener(`change`,this.#E),this.#w=null,this.#T?.disconnect(),this.#T=null,this.#D?.(),this.#D=null,this.#O&&clearTimeout(this.#O),this.#ye(null),setTimeout(()=>{this.isConnected||(this.closeWindow(),this.#se(),this.#u&&(this.#_=this.#re(),this.#u.destroy(),this.#u=null,this.#d=null,this.#F=!1))},0)}attributeChangedCallback(e,t,n){if(this.#F)switch(e){case`theme`:case`theme-controls`:this.#fe();break;case`height`:case`min-height`:case`max-height`:case`preview-height`:this.#pe();break;case`readonly`:this.#u?.setReadOnly(n!==null);break;case`stdin`:this.#c.hidden=n===null&&!this.#l.value;break;case`entry`:case`file-view`:this.#ie();break;case`language`:this.#se(),this.#e.querySelector(`.cp-root`)?.classList.toggle(`cp-has-preview`,this.#oe()),this.#f=null,this.#p=null,this.#S=!1,this.#Y().catch(()=>{})}}#G(){this.#F=!0,this.#h=this.#W??Z(this,this.#ee()),this.#B=this.#oe()?X(this):[],this.#m=this.#_??{...this.#h},this.#g=this.#ne(),this.#K(),this.#fe(),this.#pe();let e=this.getAttribute(`persist`);this.#d=(async()=>{if(e&&this.#_==null){let t=await R(e).catch(()=>null),n=t==null?null:Q(t,this.#ee());if(n){let e={},t=Object.keys(this.#h),r=Object.keys(n);for(let r of t)e[r]=n[r]??this.#h[r];t.length===1&&r.length===1&&!(t[0]in n)&&(e[t[0]]=n[r[0]]),this.#m=e,this.#g=this.#ne()}}this.#ie();let t=await S(this.language).catch(()=>null),n=t?await t.editorLanguage().catch(()=>null):null;this.#u=await d({parent:this.#t,doc:this.#m[this.#g]??``,name:this.#g,dark:this.#ue(),themeId:this.#de(),readOnly:this.hasAttribute(`readonly`),language:n,onRun:()=>void this.run(),onChange:e=>this.#le(e)}),this.#_=null,this.#fe(),this.#X()})(),this.#J()}#K(){let t=document.createElement(`style`);t.textContent=E;let n=document.createElement(`div`);n.className=this.#oe()?`cp-root cp-has-preview`:`cp-root`,n.innerHTML=`
|
|
552
|
+
`,`cp-err`),this.#me(`Failed to start`,`error`),this.#Se(`py-error`,{message:t,language:this.language})}return}finally{this.#b=null,this.#ye(null),this.#_e(),this.#y=!1,this.#n.disabled=!1,this.#r.hidden=!(this.#oe()&&this.#f?.hasLivePreview?.(this.#L)),this.#o.hidden=!0}}stop(){this.#H?this.#H.widget.stop():this.#b?this.#b.runtime.stop?.(this.#b.run):this.#y?this.#x=!0:this.#oe()&&this.#f?.hasLivePreview?.(this.#L)&&(this.#se(),this.#r.hidden=!0,this.#me(`Stopped`,`idle`))}openWindow(){if(this.#H)return this.#H.window.focus(),!0;if(this.#U)return!1;let e=window.open(``,`_blank`,`popup,width=1280,height=800`);if(!e)return this.#me(`The browser blocked the new window`,`error`),!1;let t=this.#re(),n=this.#g,r=document.createElement(this.localName);for(let e of[`language`,`entry`,`file-view`,`preview-height`,`tree-width`,`theme`,`theme-controls`,`readonly`,`stdin`]){let t=this.getAttribute(e);t!==null&&r.setAttribute(e,t)}r.setAttribute(`data-window`,``),r.#U=this,r.#W={...this.#h},r.#_=t,this.#se(),this.#r.hidden=!0,e.document.title=`Code playground`,e.document.documentElement.style.height=`100%`,e.document.body.style.cssText=`margin:0;height:100%`,e.document.body.append(r);let i=()=>this.closeWindow();return window.addEventListener(`pagehide`,i),this.#H={window:e,widget:r,onLeave:i,timer:setInterval(()=>{e.closed&&this.closeWindow()},300)},this.#e.querySelector(`.cp-root`)?.classList.add(`cp-popped`),r.#d?.then(()=>(r.openFile(n),r.run())),!0}closeWindow(){let e=this.#H;if(!e)return;this.#H=null,clearInterval(e.timer),window.removeEventListener(`pagehide`,e.onLeave);let{widget:t}=e,n=t.#re(),r=t.#g;t.#se(),t.remove(),e.window.closed||e.window.close(),this.#e.querySelector(`.cp-root`)?.classList.remove(`cp-popped`),this.files=n,this.openFile(r),this.#me(``,`idle`)}prewarm(){return this.#Y()}connectedCallback(){this.#F?(this.#fe(),this.#J()):!this.textContent?.trim()&&document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.#G(),{once:!0}):this.#G()}disconnectedCallback(){this.#C?.disconnect(),this.#C=null,this.#w?.removeEventListener(`change`,this.#E),this.#w=null,this.#T?.disconnect(),this.#T=null,this.#D?.(),this.#D=null,this.#O&&clearTimeout(this.#O),this.#ye(null),setTimeout(()=>{this.isConnected||(this.closeWindow(),this.#se(),this.#u&&(this.#_=this.#re(),this.#u.destroy(),this.#u=null,this.#d=null,this.#F=!1))},0)}attributeChangedCallback(e,t,n){if(this.#F)switch(e){case`theme`:case`theme-controls`:this.#fe();break;case`height`:case`min-height`:case`max-height`:case`preview-height`:case`tree-width`:this.#pe();break;case`readonly`:this.#u?.setReadOnly(n!==null);break;case`stdin`:this.#c.hidden=n===null&&!this.#l.value;break;case`entry`:case`file-view`:this.#ie();break;case`language`:this.#se(),this.#e.querySelector(`.cp-root`)?.classList.toggle(`cp-has-preview`,this.#oe()),this.#f=null,this.#p=null,this.#S=!1,this.#Y().catch(()=>{})}}#G(){this.#F=!0,this.#h=this.#W??Z(this,this.#ee()),this.#B=this.#oe()?X(this):[],this.#m=this.#_??{...this.#h},this.#g=this.#ne(),this.#K(),this.#fe(),this.#pe();let e=this.getAttribute(`persist`);this.#d=(async()=>{if(e&&this.#_==null){let t=await R(e).catch(()=>null),n=t==null?null:Q(t,this.#ee());if(n){let e={},t=Object.keys(this.#h),r=Object.keys(n);for(let r of t)e[r]=n[r]??this.#h[r];t.length===1&&r.length===1&&!(t[0]in n)&&(e[t[0]]=n[r[0]]),this.#m=e,this.#g=this.#ne()}}this.#ie();let t=await S(this.language).catch(()=>null),n=t?await t.editorLanguage().catch(()=>null):null;this.#u=await d({parent:this.#t,doc:this.#m[this.#g]??``,name:this.#g,dark:this.#ue(),themeId:this.#de(),readOnly:this.hasAttribute(`readonly`),language:n,onRun:()=>void this.run(),onChange:e=>this.#le(e)}),this.#_=null,this.#fe(),this.#X()})(),this.#J()}#K(){let t=document.createElement(`style`);t.textContent=E;let n=document.createElement(`div`);n.className=this.#oe()?`cp-root cp-has-preview`:`cp-root`,n.innerHTML=`
|
|
547
553
|
<div class="cp-toolbar">
|
|
548
554
|
<button class="cp-primary" part="run-button" data-action="run">Run</button>
|
|
549
555
|
<button class="cp-danger" part="stop-button" data-action="stop" hidden>Stop</button>
|
|
@@ -587,8 +593,8 @@ table.cp-table th { background: var(--cp-bg); }
|
|
|
587
593
|
<div class="cp-split cp-split-console" role="separator" tabindex="0" aria-orientation="horizontal" aria-label="Resize the preview and the console"></div>
|
|
588
594
|
<pre class="cp-output" part="output" hidden></pre>
|
|
589
595
|
</div>
|
|
590
|
-
</div>`,this.#e.replaceChildren(t,n),this.#n=n.querySelector(`[data-action="run"]`),this.#r=n.querySelector(`[data-action="stop"]`),this.#i=n.querySelector(`[data-action="reset"]`),this.#a=n.querySelector(`.cp-status`),this.#o=n.querySelector(`.cp-progress`),this.#v=n.querySelector(`.cp-tabs`),this.#t=n.querySelector(`.cp-editor`),this.#c=n.querySelector(`.cp-stdin`),this.#l=n.querySelector(`.cp-stdin textarea`),this.#s=n.querySelector(`.cp-output`),this.#L=n.querySelector(`.cp-preview`),this.#R=n.querySelector(`.cp-edited-note`),this.#oe()||n.querySelector(`.cp-source`).after(this.#s),this.#c.hidden=!this.hasAttribute(`stdin`),this.#l.addEventListener(`input`,()=>this.#c.classList.remove(`cp-attention`)),this.#v.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button[data-file]`);n&&this.openFile(n.getAttribute(`data-file`));let r=t.closest(`button[data-folder]`)?.dataset.folder;r!==void 0&&(this.#V.delete(r)||this.#V.add(r),this.#ie())}),this.#n.addEventListener(`click`,()=>void this.run()),this.#r.addEventListener(`click`,()=>this.stop()),this.#i.addEventListener(`click`,()=>this.reset()),n.querySelector(`[data-action="theme"]`).addEventListener(`click`,()=>{c({mode:this.#ue()?`light`:`dark`})}),n.querySelector(`.cp-theme-picker select`).addEventListener(`change`,t=>{let n=t.target.value,r=e.find(e=>e.id===n)?.mode;r&&c({mode:r,[r]:n})}),n.querySelector(`[data-action="window"]`).addEventListener(`click`,()=>this.openWindow()),n.querySelector(`[data-action="show-window"]`).addEventListener(`click`,()=>this.openWindow()),n.querySelector(`[data-action="close-window"]`).addEventListener(`click`,()=>this.closeWindow()),this.#q(n);let r=()=>void this.#Y().catch(()=>{});this.#t.addEventListener(`pointerdown`,r,{once:!0}),this.#t.addEventListener(`focusin`,r,{once:!0})}#q(e){let t=e.querySelector(`.cp-body`),n=e.querySelector(`.cp-source`),r=e.querySelector(`.cp-preview`),i=e.querySelector(`.cp-preview-pane`),a=this.#v,o=(e,t,n)=>Math.round(Math.max(t,Math.min(e,Math.max(t,n)))),s=(t,n)=>e.style.setProperty(t,`${n}px`),c=(t,n,r,i,a)=>{let o=()=>t.setAttribute(`aria-orientation`,n()===`x`?`vertical`:`horizontal`);t.addEventListener(`pointerdown`,a=>{a.preventDefault();let o=n()===`x`,s=o?a.clientX:a.clientY,c=r();t.setPointerCapture(a.pointerId),e.classList.add(`cp-dragging`,o?`cp-dragging-x`:`cp-dragging-y`);let l=e=>i(c+(o?e.clientX:e.clientY)-s),u=()=>{e.classList.remove(`cp-dragging`,`cp-dragging-x`,`cp-dragging-y`),t.removeEventListener(`pointermove`,l),t.removeEventListener(`pointerup`,u),t.removeEventListener(`pointercancel`,u)};t.addEventListener(`pointermove`,l),t.addEventListener(`pointerup`,u),t.addEventListener(`pointercancel`,u)}),t.addEventListener(`keydown`,e=>{let t={ArrowLeft:-24,ArrowUp:-24,ArrowRight:24,ArrowDown:24}[e.key];t&&(e.preventDefault(),i(r()+t))}),t.addEventListener(`dblclick`,a),t.addEventListener(`focus`,o),t.addEventListener(`pointerenter`,o)},l=()=>getComputedStyle(t).flexDirection===`row`&&getComputedStyle(t).display===`flex`;c(e.querySelector(`.cp-split-tree`),()=>`x`,()=>a.getBoundingClientRect().width,e=>s(`--cp-tree-width`,o(e,90,n.getBoundingClientRect().width-160)),()=>e.style.removeProperty(`--cp-tree-width`)),c(e.querySelector(`.cp-split-main`),()=>l()?`x`:`y`,()=>l()?n.getBoundingClientRect().width:this.#t.getBoundingClientRect().height,n=>{l()?s(`--cp-source-width`,o(n,200,t.getBoundingClientRect().width-200)):(s(`--cp-editor-height`,o(n,80,2e3)),e.classList.add(`cp-editor-sized`))},()=>{e.style.removeProperty(`--cp-source-width`),e.style.removeProperty(`--cp-editor-height`),e.classList.remove(`cp-editor-sized`)}),c(e.querySelector(`.cp-split-console`),()=>`y`,()=>r.getBoundingClientRect().height,e=>s(`--cp-preview-height`,o(e,60,l()||this.#U?i.getBoundingClientRect().height-40:2e3)),()=>e.style.removeProperty(`--cp-preview-height`))}#J(){this.#U||this.#C||typeof IntersectionObserver>`u`||(this.#C=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(this.#C?.disconnect(),this.#C=null,this.#Y().then(()=>{this.hasAttribute(`autorun`)&&this.run()}).catch(()=>{}))},{rootMargin:`300px`}),this.#C.observe(this))}#Y(){return this.#p||=(async()=>{let e=await S(this.language);this.#f=e,!e.ready&&!this.#Q&&(this.#o.hidden=!1,this.#me(`Loading ${e.label}…`,`busy`));try{await e.load(e=>{!this.#y&&!this.#Q&&this.#me(e.message,e.phase===`ready`?`ok`:`busy`)})}catch(e){this.#p=null,this.#me(`Runtime unavailable`,`error`);let t=e instanceof Error?e.message:String(e);throw this.#ge(t+`
|
|
591
|
-
`,`cp-err`),this.#s.hidden=!1,e}finally{this.#o.hidden=!0}return this.#X(),this.#S||(this.#S=!0,this.#Q||this.#me(`${e.label} ready`,`ok`),this.#Se(`py-ready`,{language:e.id,label:e.label})),e})(),this.#p}async#X(){if(!this.#u)return;let e=this.#g,t=await k(e,this.language);if(t){this.#g===e&&this.#u?.setLanguage(t);return}let n=e.includes(`.`)?null:await(this.#f??await S(this.language).catch(()=>null))?.editorLanguage().catch(()=>null);this.#g===e&&this.#u?.setLanguage(n??[])}#Z(){this.#u?this.#u.setCode(this.#m[this.#g]??``):this.#d?.then(()=>{this.#u?.setCode(this.#m[this.#g]??``),this.#ie()})}#Q=!1;#$(e,t){let n=Object.keys(t),r=`This widget's entry is "${e}", but it has no file of that name${n.length?` (its files: ${n.join(`, `)})`:``}. Set entry to one of its files.\n`;this.#he(),this.#s.hidden=!1,this.#ge(r,`cp-err`),this.#Q=!0,this.#me(`Error · entry not found`,`error`);let i={stdout:``,stderr:r,durationMs:0,failed:!0};return this.#Se(`py-error`,{message:r,language:this.language}),this.#Se(`py-output`,{...i,language:this.language}),i}#ee(){return this.getAttribute(`entry`)||J(this.language)}#te(){let e=Object.keys(this.#m),t=this.getAttribute(`entry`);if(t&&e.includes(t))return t;let n=this.#oe()&&e.includes(`index.html`)?`index.html`:J(this.language);return e.includes(n)?n:e[0]??n}#ne(){let e=this.getAttribute(`open-file`);return e&&e in this.#m?e:this.#te()}#re(){if(this.#H)return this.#H.widget.#re();let e={...this.#m};if(this.#u)for(let t of Object.keys(e))e[t]=this.#u.fileCode(t,e[t]);return e}#ie(){let e=Object.keys(this.#m);this.#v.hidden=e.length<2;let t=!this.#v.hidden&&this.getAttribute(`file-view`)===`tree`;if(this.#v.classList.toggle(`cp-tree`,t),this.#e.querySelector(`.cp-root`)?.classList.toggle(`cp-has-tree`,t),this.#v.hidden){this.#v.replaceChildren();return}if(t){this.#ae(e),this.#ce();return}let n=this.#te();this.#v.replaceChildren(...e.map(e=>{let t=document.createElement(`button`);t.dataset.file=e;let r=e.lastIndexOf(`/`)+1;if(r){let n=document.createElement(`span`);n.className=`cp-tab-folder`,n.textContent=e.slice(0,r),t.setAttribute(`aria-label`,e),t.append(n)}return t.append(e.slice(r)),t.setAttribute(`aria-pressed`,String(e===this.#g)),e===n&&(t.classList.add(`cp-entry`),t.title=`entry point — this is the file Run executes`),t})),this.#ce()}#ae(e){let t=this.#te(),n=[],r=(i,a)=>{let o=e.filter(e=>e.startsWith(i)).map(e=>e.slice(i.length)),s=[...new Set(o.filter(e=>e.includes(`/`)).map(e=>e.slice(0,e.indexOf(`/`))))].sort();for(let e of s){let t=i+e,o=!this.#V.has(t),s=document.createElement(`button`);s.className=`cp-tree-folder`,s.dataset.folder=t,s.textContent=e,s.setAttribute(`aria-expanded`,String(o)),s.style.setProperty(`--cp-depth`,String(a)),n.push(s),o&&r(`${t}/`,a+1)}for(let e of o.filter(e=>!e.includes(`/`)).sort()){let r=i+e,o=document.createElement(`button`);o.dataset.file=r,o.textContent=e,o.setAttribute(`aria-label`,r),o.setAttribute(`aria-pressed`,String(r===this.#g)),o.style.setProperty(`--cp-depth`,String(a)),r===t&&(o.classList.add(`cp-entry`),o.title=`entry point — this is the file Run executes`),n.push(o)}};r(``,0),this.#v.replaceChildren(...n)}#oe(){return this.language===`react`}#se(){this.#L&&(this.#f?.dispose?.(this.#L),this.#L.replaceChildren())}#ce(){if(!this.#oe())return;let e=this.#re();for(let t of this.#v.querySelectorAll(`button[data-file]`)){let n=t.dataset.file;t.classList.toggle(`cp-edited`,e[n]!==this.#h[n])}let t=this.#z;this.#R.hidden=!t||Object.keys(e).every(n=>e[n]===t[n])}#le(e){this.#m[this.#g]=e,this.#ce();let t=this.getAttribute(`persist`);if(!t)return;this.#O&&clearTimeout(this.#O);let n=JSON.stringify(this.#re());this.#O=setTimeout(()=>void L(t,n).catch(()=>{}),400)}#ue(){let e=this.getAttribute(`theme`)??`auto`;if(e===`dark`)return!0;if(e===`light`)return!1;let t=s().mode;if(t)return t===`dark`;let n=typeof document>`u`?``:getComputedStyle(document.documentElement).colorScheme,r=n.includes(`dark`);return r===n.includes(`light`)?!!this.#w?.matches:r}#de(){return s()[this.#ue()?`dark`:`light`]}#fe(){this.#D??=l(this.#E),!this.#w&&typeof matchMedia==`function`&&(this.#w=matchMedia(`(prefers-color-scheme: dark)`),this.#w.addEventListener(`change`,this.#E)),!this.#T&&typeof MutationObserver==`function`&&typeof document<`u`&&(this.#T=new MutationObserver(this.#E),this.#T.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`,`data-color-scheme`,`color-scheme`]}));let e=this.#ue(),t=this.#de();this.setAttribute(`data-resolved-theme`,e?`dark`:`light`),this.setAttribute(`data-editor-theme`,t),this.#u?.setTheme(e,t);let n=this.getAttribute(`theme`),r=n===`light`||n===`dark`||this.getAttribute(`theme-controls`)===`off`,i=this.#e.querySelector(`[data-action="theme"]`),a=this.#e.querySelector(`.cp-theme-picker`);if(i&&a){let n=e?`Switch to the light theme`:`Switch to the dark theme`;i.hidden=a.hidden=r,i.title=n,i.setAttribute(`aria-label`,n),a.querySelector(`select`).value=t}}#pe(){for(let[e,t]of[[`height`,`--cp-height`],[`min-height`,`--cp-min-height`],[`max-height`,`--cp-max-height`],[`preview-height`,`--cp-preview-height`]]){let n=this.getAttribute(e);n===null||n===``?this.style.removeProperty(t):this.style.setProperty(t,/^\d+$/.test(n)?`${n}px`:n)}}#me(e,t){this.#a.textContent=e,this.#a.dataset.state=t}#he(){this.#N&&clearTimeout(this.#N),this.#N=null,this.#A=[],this.#P=0,this.#s.replaceChildren(),this.#k=!0}#ge(e,t){if(!e)return;let n=t===`cp-err`&&!this.#k?`\n${e}`:e;this.#k=n.endsWith(`
|
|
596
|
+
</div>`,this.#e.replaceChildren(t,n),this.#n=n.querySelector(`[data-action="run"]`),this.#r=n.querySelector(`[data-action="stop"]`),this.#i=n.querySelector(`[data-action="reset"]`),this.#a=n.querySelector(`.cp-status`),this.#o=n.querySelector(`.cp-progress`),this.#v=n.querySelector(`.cp-tabs`),this.#t=n.querySelector(`.cp-editor`),this.#c=n.querySelector(`.cp-stdin`),this.#l=n.querySelector(`.cp-stdin textarea`),this.#s=n.querySelector(`.cp-output`),this.#L=n.querySelector(`.cp-preview`),this.#R=n.querySelector(`.cp-edited-note`),this.#oe()||n.querySelector(`.cp-source`).after(this.#s),this.#c.hidden=!this.hasAttribute(`stdin`),this.#l.addEventListener(`input`,()=>this.#c.classList.remove(`cp-attention`)),this.#v.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button[data-file]`);n&&this.openFile(n.getAttribute(`data-file`));let r=t.closest(`button[data-folder]`)?.dataset.folder;r!==void 0&&(this.#V.delete(r)||this.#V.add(r),this.#ie())}),this.#n.addEventListener(`click`,()=>void this.run()),this.#r.addEventListener(`click`,()=>this.stop()),this.#i.addEventListener(`click`,()=>this.reset()),n.querySelector(`[data-action="theme"]`).addEventListener(`click`,()=>{c({mode:this.#ue()?`light`:`dark`})}),n.querySelector(`.cp-theme-picker select`).addEventListener(`change`,t=>{let n=t.target.value,r=e.find(e=>e.id===n)?.mode;r&&c({mode:r,[r]:n})}),n.querySelector(`[data-action="window"]`).addEventListener(`click`,()=>this.openWindow()),n.querySelector(`[data-action="show-window"]`).addEventListener(`click`,()=>this.openWindow()),n.querySelector(`[data-action="close-window"]`).addEventListener(`click`,()=>this.closeWindow()),this.#q(n);let r=()=>void this.#Y().catch(()=>{});this.#t.addEventListener(`pointerdown`,r,{once:!0}),this.#t.addEventListener(`focusin`,r,{once:!0})}#q(e){let t=e.querySelector(`.cp-body`),n=e.querySelector(`.cp-source`),r=e.querySelector(`.cp-preview`),i=e.querySelector(`.cp-preview-pane`),a=this.#v,o=(e,t,n)=>Math.round(Math.max(t,Math.min(e,Math.max(t,n)))),s=(t,n)=>e.style.setProperty(t,`${n}px`),c=(t,n,r,i,a)=>{let o=()=>t.setAttribute(`aria-orientation`,n()===`x`?`vertical`:`horizontal`);t.addEventListener(`pointerdown`,a=>{a.preventDefault();let o=n()===`x`,s=o?a.clientX:a.clientY,c=r();t.setPointerCapture(a.pointerId),e.classList.add(`cp-dragging`,o?`cp-dragging-x`:`cp-dragging-y`);let l=e=>i(c+(o?e.clientX:e.clientY)-s),u=()=>{e.classList.remove(`cp-dragging`,`cp-dragging-x`,`cp-dragging-y`),t.removeEventListener(`pointermove`,l),t.removeEventListener(`pointerup`,u),t.removeEventListener(`pointercancel`,u)};t.addEventListener(`pointermove`,l),t.addEventListener(`pointerup`,u),t.addEventListener(`pointercancel`,u)}),t.addEventListener(`keydown`,e=>{let t={ArrowLeft:-24,ArrowUp:-24,ArrowRight:24,ArrowDown:24}[e.key];t&&(e.preventDefault(),i(r()+t))}),t.addEventListener(`dblclick`,a),t.addEventListener(`focus`,o),t.addEventListener(`pointerenter`,o)},l=()=>getComputedStyle(t).flexDirection===`row`&&getComputedStyle(t).display===`flex`;c(e.querySelector(`.cp-split-tree`),()=>`x`,()=>a.getBoundingClientRect().width,e=>s(`--cp-tree-width`,o(e,90,n.getBoundingClientRect().width-160)),()=>e.style.removeProperty(`--cp-tree-width`)),c(e.querySelector(`.cp-split-main`),()=>l()?`x`:`y`,()=>l()?n.getBoundingClientRect().width:this.#t.getBoundingClientRect().height,n=>{l()?s(`--cp-source-width`,o(n,200,t.getBoundingClientRect().width-200)):(s(`--cp-editor-height`,o(n,80,this.#U?t.getBoundingClientRect().height-100:2e3)),e.classList.add(`cp-editor-sized`))},()=>{e.style.removeProperty(`--cp-source-width`),e.style.removeProperty(`--cp-editor-height`),e.classList.remove(`cp-editor-sized`)}),c(e.querySelector(`.cp-split-console`),()=>`y`,()=>r.getBoundingClientRect().height,e=>s(`--cp-preview-height`,o(e,60,l()||this.#U?i.getBoundingClientRect().height-40:2e3)),()=>e.style.removeProperty(`--cp-preview-height`))}#J(){this.#U||this.#C||typeof IntersectionObserver>`u`||(this.#C=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(this.#C?.disconnect(),this.#C=null,this.#Y().then(()=>{this.hasAttribute(`autorun`)&&this.run()}).catch(()=>{}))},{rootMargin:`300px`}),this.#C.observe(this))}#Y(){return this.#p||=(async()=>{let e=await S(this.language);this.#f=e,!e.ready&&!this.#Q&&(this.#o.hidden=!1,this.#me(`Loading ${e.label}…`,`busy`));try{await e.load(e=>{!this.#y&&!this.#Q&&this.#me(e.message,e.phase===`ready`?`ok`:`busy`)})}catch(e){this.#p=null,this.#me(`Runtime unavailable`,`error`);let t=e instanceof Error?e.message:String(e);throw this.#ge(t+`
|
|
597
|
+
`,`cp-err`),this.#s.hidden=!1,e}finally{this.#o.hidden=!0}return this.#X(),this.#S||(this.#S=!0,this.#Q||this.#me(`${e.label} ready`,`ok`),this.#Se(`py-ready`,{language:e.id,label:e.label})),e})(),this.#p}async#X(){if(!this.#u)return;let e=this.#g,t=await k(e,this.language);if(t){this.#g===e&&this.#u?.setLanguage(t);return}let n=e.includes(`.`)?null:await(this.#f??await S(this.language).catch(()=>null))?.editorLanguage().catch(()=>null);this.#g===e&&this.#u?.setLanguage(n??[])}#Z(){this.#u?this.#u.setCode(this.#m[this.#g]??``):this.#d?.then(()=>{this.#u?.setCode(this.#m[this.#g]??``),this.#ie()})}#Q=!1;#$(e,t){let n=Object.keys(t),r=`This widget's entry is "${e}", but it has no file of that name${n.length?` (its files: ${n.join(`, `)})`:``}. Set entry to one of its files.\n`;this.#he(),this.#s.hidden=!1,this.#ge(r,`cp-err`),this.#Q=!0,this.#me(`Error · entry not found`,`error`);let i={stdout:``,stderr:r,durationMs:0,failed:!0};return this.#Se(`py-error`,{message:r,language:this.language}),this.#Se(`py-output`,{...i,language:this.language}),i}#ee(){return this.getAttribute(`entry`)||J(this.language)}#te(){let e=Object.keys(this.#m),t=this.getAttribute(`entry`);if(t&&e.includes(t))return t;let n=this.#oe()&&e.includes(`index.html`)?`index.html`:J(this.language);return e.includes(n)?n:e[0]??n}#ne(){let e=this.getAttribute(`open-file`);return e&&e in this.#m?e:this.#te()}#re(){if(this.#H)return this.#H.widget.#re();let e={...this.#m};if(this.#u)for(let t of Object.keys(e))e[t]=this.#u.fileCode(t,e[t]);return e}#ie(){let e=Object.keys(this.#m);this.#v.hidden=e.length<2;let t=!this.#v.hidden&&this.getAttribute(`file-view`)===`tree`;if(this.#v.classList.toggle(`cp-tree`,t),this.#e.querySelector(`.cp-root`)?.classList.toggle(`cp-has-tree`,t),this.#v.hidden){this.#v.replaceChildren();return}if(t){this.#ae(e),this.#ce();return}let n=this.#te();this.#v.replaceChildren(...e.map(e=>{let t=document.createElement(`button`);t.dataset.file=e;let r=e.lastIndexOf(`/`)+1;if(r){let n=document.createElement(`span`);n.className=`cp-tab-folder`,n.textContent=e.slice(0,r),t.setAttribute(`aria-label`,e),t.append(n)}return t.append(e.slice(r)),t.setAttribute(`aria-pressed`,String(e===this.#g)),e===n&&(t.classList.add(`cp-entry`),t.title=`entry point — this is the file Run executes`),t})),this.#ce()}#ae(e){let t=this.#te(),n=[],r=(i,a)=>{let o=e.filter(e=>e.startsWith(i)).map(e=>e.slice(i.length)),s=[...new Set(o.filter(e=>e.includes(`/`)).map(e=>e.slice(0,e.indexOf(`/`))))].sort();for(let e of s){let t=i+e,o=!this.#V.has(t),s=document.createElement(`button`);s.className=`cp-tree-folder`,s.dataset.folder=t,s.textContent=e,s.setAttribute(`aria-expanded`,String(o)),s.style.setProperty(`--cp-depth`,String(a)),n.push(s),o&&r(`${t}/`,a+1)}for(let e of o.filter(e=>!e.includes(`/`)).sort()){let r=i+e,o=document.createElement(`button`);o.dataset.file=r,o.textContent=e,o.setAttribute(`aria-label`,r),o.setAttribute(`aria-pressed`,String(r===this.#g)),o.style.setProperty(`--cp-depth`,String(a)),r===t&&(o.classList.add(`cp-entry`),o.title=`entry point — this is the file Run executes`),n.push(o)}};r(``,0),this.#v.replaceChildren(...n)}#oe(){return this.language===`react`}#se(){this.#L&&(this.#f?.dispose?.(this.#L),this.#L.replaceChildren())}#ce(){if(!this.#oe())return;let e=this.#re();for(let t of this.#v.querySelectorAll(`button[data-file]`)){let n=t.dataset.file;t.classList.toggle(`cp-edited`,e[n]!==this.#h[n])}let t=this.#z;this.#R.hidden=!t||Object.keys(e).every(n=>e[n]===t[n])}#le(e){this.#m[this.#g]=e,this.#ce();let t=this.getAttribute(`persist`);if(!t)return;this.#O&&clearTimeout(this.#O);let n=JSON.stringify(this.#re());this.#O=setTimeout(()=>void L(t,n).catch(()=>{}),400)}#ue(){let e=this.getAttribute(`theme`)??`auto`;if(e===`dark`)return!0;if(e===`light`)return!1;let t=s().mode;if(t)return t===`dark`;let n=typeof document>`u`?``:getComputedStyle(document.documentElement).colorScheme,r=n.includes(`dark`);return r===n.includes(`light`)?!!this.#w?.matches:r}#de(){return s()[this.#ue()?`dark`:`light`]}#fe(){this.#D??=l(this.#E),!this.#w&&typeof matchMedia==`function`&&(this.#w=matchMedia(`(prefers-color-scheme: dark)`),this.#w.addEventListener(`change`,this.#E)),!this.#T&&typeof MutationObserver==`function`&&typeof document<`u`&&(this.#T=new MutationObserver(this.#E),this.#T.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`,`data-color-scheme`,`color-scheme`]}));let e=this.#ue(),t=this.#de();this.setAttribute(`data-resolved-theme`,e?`dark`:`light`),this.setAttribute(`data-editor-theme`,t),this.#u?.setTheme(e,t);let n=this.getAttribute(`theme`),r=n===`light`||n===`dark`||this.getAttribute(`theme-controls`)===`off`,i=this.#e.querySelector(`[data-action="theme"]`),a=this.#e.querySelector(`.cp-theme-picker`);if(i&&a){let n=e?`Switch to the light theme`:`Switch to the dark theme`;i.hidden=a.hidden=r,i.title=n,i.setAttribute(`aria-label`,n),a.querySelector(`select`).value=t}}#pe(){for(let[e,t]of[[`height`,`--cp-height`],[`min-height`,`--cp-min-height`],[`max-height`,`--cp-max-height`],[`preview-height`,`--cp-preview-height`]]){let n=this.getAttribute(e);n===null||n===``?this.style.removeProperty(t):this.style.setProperty(t,/^\d+$/.test(n)?`${n}px`:n)}let e=this.getAttribute(`tree-width`)?.trim();e?/^(\d+(px)?|\d+(\.\d+)?%)$/.test(e)?this.style.setProperty(`--cp-tree-width`,/\d$/.test(e)?`${e}px`:e):(this.style.removeProperty(`--cp-tree-width`),console.warn(`code-playpad: tree-width="${e}" is not a size. Use a percentage like "20%" or pixels like "240".`)):this.style.removeProperty(`--cp-tree-width`)}#me(e,t){this.#a.textContent=e,this.#a.dataset.state=t}#he(){this.#N&&clearTimeout(this.#N),this.#N=null,this.#A=[],this.#P=0,this.#s.replaceChildren(),this.#k=!0}#ge(e,t){if(!e)return;let n=t===`cp-err`&&!this.#k?`\n${e}`:e;this.#k=n.endsWith(`
|
|
592
598
|
`),this.#A.push({text:n,className:t}),this.#N??=setTimeout(()=>this.#_e(),16)}#_e(){if(this.#N&&clearTimeout(this.#N),this.#N=null,!this.#A.length)return;let e=this.#A;this.#A=[];let t=document.createDocumentFragment(),n=``,r,i=()=>{if(!n)return;let e=document.createElement(`span`);r&&(e.className=r),e.textContent=n,t.appendChild(e),n=``};for(let t of e){if(this.#P>=G)break;let e=t.text;this.#P+e.length>G&&(e=e.slice(0,G-this.#P)+`
|
|
593
599
|
… output truncated for display — the full text is in the playpad-output event
|
|
594
600
|
`),this.#P+=t.text.length,r!==t.className&&(i(),r=t.className),n+=e}i(),this.#s.hidden=!1;let a=this.#s.querySelector(`.cp-prompt`);a?this.#s.insertBefore(t,a):this.#s.appendChild(t),this.#s.scrollTop=this.#s.scrollHeight}#ve(){return this.#_e(),this.#ye(null),new Promise(e=>{let t=document.createElement(`form`);t.className=`cp-prompt`;let n=document.createElement(`input`);n.type=`text`,n.setAttribute(`aria-label`,`Program input — press Enter to send`),n.autocapitalize=`off`,n.autocomplete=`off`,n.spellcheck=!1;let r=document.createElement(`button`);r.type=`submit`,r.className=`cp-send`,r.textContent=`⏎`,r.title=`Send this line (Enter)`;let i=document.createElement(`button`);i.type=`button`,i.className=`cp-eof`,i.textContent=`EOF`,i.title=`End of input (Ctrl-D) — makes input() raise EOFError`;let a=n=>{this.#j===e&&(this.#j=null,this.#M=null,t.remove(),n===null?this.#ge(`
|
package/dist/element.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as CodePlayPadElement,n as defineCodePlayPad}from"./element-
|
|
1
|
+
export{t as CodePlayPadElement,n as defineCodePlayPad}from"./element-BGm-1VOq.js";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./element-
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./element-BGm-1VOq.js";import{t as v}from"./react-version.generated-BNNJmf7J.js";import{a as y,i as b,n as x,r as S,t as C,u as w}from"./config-DB58UVsk.js";export{m as CodePlayPadElement,a as EDITOR_THEMES,C as PYODIDE_VERSION,v as REACT_VERSION,h as RunStopped,r as WorkerUnavailable,f as allProgress,s as clearSnippet,x as configureCpp,S as configurePython,b as configureReact,y as configureTypeScript,o as createEditor,l as defineCodePlayPad,t as getProgress,i as getRuntime,e as getThemePreference,d as listRuntimes,u as loadSnippet,g as onThemePreferenceChange,w as pyodideAssetUrls,c as registerRuntime,p as saveSnippet,n as setProgress,_ as setThemePreference};
|