code-playpad 0.14.1 → 0.15.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.
Files changed (43) hide show
  1. package/README.md +67 -6
  2. package/dist/THIRD-PARTY-NOTICES.txt +25 -0
  3. package/dist/{boot-DW1YzgCY.js → boot-BVedZD8N.js} +1 -1
  4. package/dist/cdn.js +2 -2
  5. package/dist/clike-C2M2Cbvf.js +6 -0
  6. package/dist/compiler-cache-XwslsU5H.js +6 -0
  7. package/dist/compiler-license-manifest.json +11 -8
  8. package/dist/config-3Z6xX6Jr.js +6 -0
  9. package/dist/cpp-BxFy0NSM.js +6 -0
  10. package/dist/cpp-CI2vFLOK.js +1 -0
  11. package/dist/csharp-B4M3Us-m.js +1 -0
  12. package/dist/csharp-ByGGaB0V.js +6 -0
  13. package/dist/{element-BuS9dUwa.js → element-UgFuSGoC.js} +3 -3
  14. package/dist/element.js +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/{java-DjuG1fCk.js → java-2z8CcJaR.js} +1 -1
  18. package/dist/{java-DkfYRvpA.js → java-BYlTOHGf.js} +1 -1
  19. package/dist/{javascript-BSjoEAXh.js → javascript-CNLIMOk1.js} +1 -1
  20. package/dist/{javascript-BBiCDtZ3.js → javascript-kqyWH6DS.js} +1 -1
  21. package/dist/{next-9Fyfv6iD.js → next-C9S3EZEz.js} +1 -1
  22. package/dist/{next-CO6N0Gb9.js → next-xTgh8PXL.js} +1 -1
  23. package/dist/{pyodide-QurAOd7j.js → pyodide-C5KhmXre.js} +1 -1
  24. package/dist/{pyodide-ZBchw4qA.js → pyodide-Cr69zEd2.js} +1 -1
  25. package/dist/{react-DgCTfCMl.js → react-BKPRfjtf.js} +1 -1
  26. package/dist/{react-DI6SODv8.js → react-DPG8BrcN.js} +1 -1
  27. package/dist/react.js +1 -1
  28. package/dist/runtime/config.d.ts +12 -0
  29. package/dist/runtime/csharp/cache.d.ts +2 -0
  30. package/dist/runtime/csharp/project.d.ts +5 -0
  31. package/dist/runtime/csharp/worker.d.ts +1 -0
  32. package/dist/runtime/csharp-worker.generated.d.ts +1 -0
  33. package/dist/runtime/csharp.d.ts +2 -0
  34. package/dist/runtime/worker-runtime.d.ts +8 -0
  35. package/dist/standalone.js +10 -10
  36. package/dist/worker-runtime-5Ujf07eB.js +4 -0
  37. package/dist/worker-runtime-Ub9rvLo_.js +9 -0
  38. package/package.json +9 -3
  39. package/dist/config-DB58UVsk.js +0 -6
  40. package/dist/cpp-Bhr_Zgfk.js +0 -6
  41. package/dist/cpp-C8YnpTSR.js +0 -1
  42. package/dist/worker-runtime-Dd2eBtq3.js +0 -4
  43. package/dist/worker-runtime-DvpugeXD.js +0 -9
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * code-playpad — MIT © 2026 Seung Hun Lee
3
+ * Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
4
+ * Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
5
+ */
6
+ import{n as e,t}from"./types-CfcYqU2K.js";import{t as n}from"./hints-DpBIeoeG.js";var r=1,i=class{#e=null;#t=null;#n=`module`;#r=null;#i=null;#a=!1;#o=!1;#s=``;#c=/* @__PURE__ */ new Set;#l=[];#u=null;#d=!1;get recycleAfterRun(){return!1}get startTimeoutMs(){}initPayload(){return{}}loadModule(e){return Promise.reject(/* @__PURE__ */ Error(`no module named ${e}`))}get ready(){return this.#a}get interactiveStdin(){return this.#o}get version(){return this.#s}load(t){t&&this.#c.add(t);let n=()=>{t&&this.#c.delete(t)};if(!this.#r){let t=new Promise((t,n)=>{this.#i={resolve:t,reject:n};let r;try{if(typeof Worker>`u`)throw Error(`Worker constructor missing`);let e=new Blob([this.source],{type:`text/javascript`});this.#t=URL.createObjectURL(e),r=new Worker(this.#t,{type:this.#n})}catch(t){this.#i=null,n(new e(`Could not start a Web Worker: ${t.message}`));return}this.#e=r;let i=this.startTimeoutMs,a=i===void 0?void 0:setTimeout(()=>{this.#e!==r||this.#a||(this.#m(),n(/* @__PURE__ */ Error(`The ${this.label} worker did not start within ${i} ms.`)))},i);r.onmessage=e=>{if(this.#e!==r)return;let i=e.data;i.type===`ready`?(this.#s=i.version,this.#o=i.interactiveStdin===!0,this.#a=!0,this.#i=null,clearTimeout(a),this.#h({phase:`ready`,message:`${this.label} ready`}),t()):i.type===`fatal`&&!this.#a?(clearTimeout(a),this.#p(i.message,t,n)):this.#g(i)},r.onerror=e=>{if(this.#e!==r)return;let i=e.message||`Worker failed to start`;clearTimeout(a),this.#a?this.#u&&this.#y(this.#u,Error(i)):this.#p(i,t,n)},r.postMessage({type:`init`,...this.initPayload()})});this.#r=t,t.catch(()=>{this.#r===t&&(this.#r=null)})}return this.#r.then(n,e=>{throw n(),e})}run(e,t={}){let n,i,a=new Promise((e,t)=>{n=e,i=t}),o,s=new Promise(e=>{o=e}),c={id:r++,code:e,options:t,stdout:``,stderr:``,resolve:n,reject:i,promise:a,started:!1,settled:!1,done:s,markDone:()=>{clearTimeout(c.timer),c.settled=!0,o()}};return this.#l.push(c),this.#b(),a}stop(e){if(e){let n=this.#l.findIndex(t=>t.promise===e);if(n!==-1){this.#y(this.#l.splice(n,1)[0],new t);return}let r=this.#u;if(!r||r.promise!==e||r.settled)return;if(!r.started){this.#y(r,new t),this.recycleAfterRun&&this.#f();return}}this.#f()}#f(){let e=this.#e!==null,n=this.#i;if(this.#m(),this.#u&&this.#y(this.#u,new t),e&&(n||!this.recycleAfterRun)){let e=this.load();n&&e.then(n.resolve,n.reject),e.catch(()=>{})}}#p(e,t,n){this.#m(),this.#n===`module`?(this.#n=`classic`,this.load().then(t,n)):n(Error(e))}#m(){this.#e?.terminate(),this.#e=null,this.#t&&=(URL.revokeObjectURL(this.#t),null),this.#r=null,this.#i=null,this.#a=!1}#h(e){for(let t of this.#c)t(e)}#g(e){if(e.type===`progress`){this.#h({phase:e.phase,message:e.message}),this.#u&&e.id===this.#u.id&&!this.#u.settled&&this.#u.options.onProgress?.({phase:e.phase,message:e.message});return}let t=this.#u;if(t&&`id`in e&&e.id===t.id)switch(e.type){case`stdout`:t.stdout+=e.text,t.options.onStdout?.(e.text);break;case`echo`:t.options.onEcho?.(e.text);break;case`stdin-request`:this.#v(t,e.request);break;case`module-request`:this.#_(t,e.name);break;case`stderr`:t.stderr+=e.text,t.options.onStderr?.(e.text);break;case`result`:t.resolve({stdout:t.stdout,stderr:t.stderr||void 0,value:e.value,durationMs:Math.round(e.durationMs),failed:!1,...e.memory?{memory:e.memory}:{},...e.cases?{cases:e.cases,passed:e.passed,total:e.total}:{}}),t.markDone();break;case`error`:case`fatal`:{let r=(t.stderr&&!t.stderr.endsWith(`
7
+ `)?`
8
+ `:``)+e.message+`
9
+ `;t.stderr+=r,t.options.onStderr?.(r);let i={stdout:t.stdout,stderr:t.stderr,hint:`hint`in e?e.hint:void 0,durationMs:Math.round(`durationMs`in e?e.durationMs:0),failed:!0,...`cases`in e&&e.cases?{cases:e.cases,passed:0,total:e.cases.length}:{}};`hintAbout`in e&&e.hintAbout===`stdin`&&n.add(i),t.resolve(i),t.markDone();break}}}#_(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`module`,name:t,...r})};this.loadModule(t).then(e=>r({code:e}),e=>r({error:e instanceof Error?e.message:String(e)}))}#v(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`stdin-response`,request:t,text:r})},i=e.options.onStdinRequest;i?i().then(r,()=>r(null)):r(null)}#y(e,t){e.reject(t),e.markDone()}async#b(){if(!this.#d){this.#d=!0;try{for(;this.#l.length;){let e=this.#l.shift();this.#u=e;let t=null;try{if(this.recycleAfterRun?await Promise.race([this.load(),e.done]):await this.load(),e.settled)continue;e.started=!0,e.options.onStart?.(),e.options.timeoutMs&&Number.isFinite(e.options.timeoutMs)&&e.options.timeoutMs>0&&(e.timer=setTimeout(()=>{this.#u!==e||e.settled||(this.#g({type:`error`,id:e.id,message:`Run exceeded its wall-clock time limit.`,durationMs:e.options.timeoutMs}),this.#m())},e.options.timeoutMs)),t=this.#e,this.#e.postMessage({type:`run`,id:e.id,code:e.code,stdin:e.options.stdin,files:e.options.files,entry:e.options.entry,...e.options.compilerLanguage?{compilerLanguage:e.options.compilerLanguage}:{},...e.options.practice?{practice:e.options.practice}:{}}),await e.done}catch(t){this.#y(e,t)}finally{this.#u=null,this.recycleAfterRun&&t&&this.#e===t&&this.#m()}}}finally{this.#d=!1}}}};export{i as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-playpad",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "Embeddable browser code playground: a CodeMirror editor that runs Python, JavaScript, TypeScript, a subset of Java, experimental C/C++ and multi-file React in the browser. No backend. One shared worker per page, blocking input(), multi-file projects, lazy per-language loading.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "scripts": {
35
35
  "dev": "vite --config vite.demo.config.ts",
36
36
  "dev:phone": "vite --config vite.demo.config.ts --mode phone",
37
- "build": "node scripts/sync-cpp.mjs --check && vite build && vite build --config vite.standalone.config.ts && tsc -p tsconfig.build.json && node scripts/check-dist.mjs",
37
+ "build": "node scripts/sync-cpp.mjs --check && node scripts/sync-csharp.mjs --check && vite build && vite build --config vite.standalone.config.ts && tsc -p tsconfig.build.json && node scripts/check-dist.mjs",
38
38
  "build:demo": "npm run build && vite build --config vite.demo.config.ts",
39
39
  "preview:demo": "vite preview --config vite.demo.config.ts",
40
40
  "typecheck": "tsc --noEmit",
@@ -43,6 +43,7 @@
43
43
  "sync:sucrase": "node scripts/sync-sucrase.mjs",
44
44
  "test": "node --test --test-reporter=spec \"tests/*.test.mjs\"",
45
45
  "sync:cpp": "node scripts/sync-cpp.mjs",
46
+ "sync:csharp": "node scripts/sync-csharp.mjs",
46
47
  "check:compiler-licenses": "node scripts/check-compiler-licenses.mjs",
47
48
  "sync:react": "node scripts/sync-react.mjs",
48
49
  "sync:next": "node scripts/sync-next.mjs",
@@ -64,7 +65,8 @@
64
65
  "@codemirror/theme-one-dark": "^6",
65
66
  "@codemirror/view": "^6",
66
67
  "@lezer/highlight": "^1",
67
- "react": ">=18"
68
+ "react": ">=18",
69
+ "@codemirror/legacy-modes": "^6"
68
70
  },
69
71
  "peerDependenciesMeta": {
70
72
  "react": {
@@ -90,6 +92,9 @@
90
92
  },
91
93
  "@codemirror/lang-html": {
92
94
  "optional": true
95
+ },
96
+ "@codemirror/legacy-modes": {
97
+ "optional": true
93
98
  }
94
99
  },
95
100
  "devDependencies": {
@@ -104,6 +109,7 @@
104
109
  "@codemirror/lang-json": "^6.0.2",
105
110
  "@codemirror/lang-python": "^6.2.1",
106
111
  "@codemirror/language": "^6.12.4",
112
+ "@codemirror/legacy-modes": "^6.5.5",
107
113
  "@codemirror/state": "^6.7.1",
108
114
  "@codemirror/theme-one-dark": "^6.1.3",
109
115
  "@codemirror/view": "^6.43.9",
@@ -1,6 +0,0 @@
1
- /*!
2
- * code-playpad — MIT © 2026 Seung Hun Lee
3
- * Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
4
- * Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
5
- */
6
- var e=`314.0.5`,t=`https://cdn.jsdelivr.net/pyodide/v${e}/full/`,n=null;function r(e){t=e.indexURL.endsWith(`/`)?e.indexURL:e.indexURL+`/`}function i(e){n=e.sucraseURL}function a(){return t}function o(){return n}function s(){return[{url:t+`pyodide.js`,as:`script`},{url:t+`pyodide.asm.wasm`,as:`fetch`},{url:t+`python_stdlib.zip`,as:`fetch`}]}var c={indexURL:`https://cdn.jsdelivr.net/npm/@code-playpad/cpp-toolchain@1.0.0/dist/`,timeoutMs:12e4};function l(e){let t={...c};if(e.indexURL!==void 0){let n=new URL(e.indexURL);if(![`https:`,`http:`].includes(n.protocol))throw Error(`C/C++ asset URL must use HTTP or HTTPS.`);t.indexURL=n.href.endsWith(`/`)?n.href:n.href+`/`}if(e.timeoutMs!==void 0){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw Error(`timeoutMs must be a positive finite number.`);t.timeoutMs=e.timeoutMs}c=t}function u(){return{...c}}var d=null,f=null;function p(e){if(e.runtimeURL!==void 0){let t=new URL(e.runtimeURL,typeof location>`u`?void 0:location.href);if(![`https:`,`http:`].includes(t.protocol))throw Error(`The React runtime URL must use HTTP or HTTPS.`);if(/[;,\s]/.test(t.href))throw Error(`The React runtime URL cannot contain ";" or ",": it goes in a Content-Security-Policy.`);d=t.href}e.nonce!==void 0&&(f=e.nonce)}function m(){let e=typeof document>`u`?null:document.querySelector(`script[nonce]`)?.nonce||null;return{runtimeURL:d,nonce:f??e}}export{i as a,m as c,p as i,o as l,l as n,u as o,r,a as s,e as t,s as u};
@@ -1,6 +0,0 @@
1
- /*!
2
- * code-playpad — MIT © 2026 Seung Hun Lee
3
- * Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
4
- * Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
5
- */
6
- import{o as e}from"./config-DB58UVsk.js";import{t}from"./worker-runtime-DvpugeXD.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(`./dist-3xj9-ylK.js`)).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 +0,0 @@
1
- import{o as e}from"./config-DB58UVsk.js";import{t}from"./worker-runtime-Dd2eBtq3.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,4 +0,0 @@
1
- import{d as e,l as t,u as n}from"./element-BuS9dUwa.js";var r=1,i=class{#e=null;#t=null;#n=`module`;#r=null;#i=null;#a=!1;#o=!1;#s=``;#c=/* @__PURE__ */ new Set;#l=[];#u=null;#d=!1;initPayload(){return{}}loadModule(e){return Promise.reject(/* @__PURE__ */ Error(`no module named ${e}`))}get ready(){return this.#a}get interactiveStdin(){return this.#o}get version(){return this.#s}load(t){t&&this.#c.add(t);let n=()=>{t&&this.#c.delete(t)};if(!this.#r){let t=new Promise((t,n)=>{this.#i={resolve:t,reject:n};let r;try{if(typeof Worker>`u`)throw Error(`Worker constructor missing`);let e=new Blob([this.source],{type:`text/javascript`});this.#t=URL.createObjectURL(e),r=new Worker(this.#t,{type:this.#n})}catch(t){this.#i=null,n(new e(`Could not start a Web Worker: ${t.message}`));return}this.#e=r,r.onmessage=e=>{let r=e.data;r.type===`ready`?(this.#s=r.version,this.#o=r.interactiveStdin===!0,this.#a=!0,this.#i=null,this.#h({phase:`ready`,message:`${this.label} ready`}),t()):r.type===`fatal`&&!this.#a?this.#p(r.message,t,n):this.#g(r)},r.onerror=e=>{let r=e.message||`Worker failed to start`;this.#a?this.#u&&this.#y(this.#u,Error(r)):this.#p(r,t,n)},r.postMessage({type:`init`,...this.initPayload()})});this.#r=t,t.catch(()=>{this.#r===t&&(this.#r=null)})}return this.#r.then(n,e=>{throw n(),e})}run(e,t={}){let n,i,a=new Promise((e,t)=>{n=e,i=t}),o,s=new Promise(e=>{o=e}),c={id:r++,code:e,options:t,stdout:``,stderr:``,resolve:n,reject:i,promise:a,started:!1,settled:!1,done:s,markDone:()=>{clearTimeout(c.timer),c.settled=!0,o()}};return this.#l.push(c),this.#b(),a}stop(e){if(e){let t=this.#l.findIndex(t=>t.promise===e);if(t!==-1){this.#y(this.#l.splice(t,1)[0],new n);return}let r=this.#u;if(!r||r.promise!==e||r.settled)return;if(!r.started){this.#y(r,new n);return}}this.#f()}#f(){let e=this.#e!==null,t=this.#i;if(this.#m(),this.#u&&this.#y(this.#u,new n),e){let e=this.load();t&&e.then(t.resolve,t.reject),e.catch(()=>{})}}#p(e,t,n){this.#m(),this.#n===`module`?(this.#n=`classic`,this.load().then(t,n)):n(Error(e))}#m(){this.#e?.terminate(),this.#e=null,this.#t&&=(URL.revokeObjectURL(this.#t),null),this.#r=null,this.#i=null,this.#a=!1}#h(e){for(let t of this.#c)t(e)}#g(e){if(e.type===`progress`){this.#h({phase:e.phase,message:e.message}),this.#u&&e.id===this.#u.id&&!this.#u.settled&&this.#u.options.onProgress?.({phase:e.phase,message:e.message});return}let n=this.#u;if(n&&`id`in e&&e.id===n.id)switch(e.type){case`stdout`:n.stdout+=e.text,n.options.onStdout?.(e.text);break;case`echo`:n.options.onEcho?.(e.text);break;case`stdin-request`:this.#v(n,e.request);break;case`module-request`:this.#_(n,e.name);break;case`stderr`:n.stderr+=e.text,n.options.onStderr?.(e.text);break;case`result`:n.resolve({stdout:n.stdout,stderr:n.stderr||void 0,value:e.value,durationMs:Math.round(e.durationMs),failed:!1,...e.memory?{memory:e.memory}:{},...e.cases?{cases:e.cases,passed:e.passed,total:e.total}:{}}),n.markDone();break;case`error`:case`fatal`:{let r=(n.stderr&&!n.stderr.endsWith(`
2
- `)?`
3
- `:``)+e.message+`
4
- `;n.stderr+=r,n.options.onStderr?.(r);let i={stdout:n.stdout,stderr:n.stderr,hint:`hint`in e?e.hint:void 0,durationMs:Math.round(`durationMs`in e?e.durationMs:0),failed:!0,...`cases`in e&&e.cases?{cases:e.cases,passed:0,total:e.cases.length}:{}};`hintAbout`in e&&e.hintAbout===`stdin`&&t.add(i),n.resolve(i),n.markDone();break}}}#_(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`module`,name:t,...r})};this.loadModule(t).then(e=>r({code:e}),e=>r({error:e instanceof Error?e.message:String(e)}))}#v(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`stdin-response`,request:t,text:r})},i=e.options.onStdinRequest;i?i().then(r,()=>r(null)):r(null)}#y(e,t){e.reject(t),e.markDone()}async#b(){if(!this.#d){this.#d=!0;try{for(;this.#l.length;){let e=this.#l.shift();this.#u=e;try{if(await this.load(),e.settled)continue;e.started=!0,e.options.onStart?.(),e.options.timeoutMs&&Number.isFinite(e.options.timeoutMs)&&e.options.timeoutMs>0&&(e.timer=setTimeout(()=>{this.#u!==e||e.settled||(this.#g({type:`error`,id:e.id,message:`Run exceeded its wall-clock time limit.`,durationMs:e.options.timeoutMs}),this.#m())},e.options.timeoutMs)),this.#e.postMessage({type:`run`,id:e.id,code:e.code,stdin:e.options.stdin,files:e.options.files,entry:e.options.entry,...e.options.compilerLanguage?{compilerLanguage:e.options.compilerLanguage}:{},...e.options.practice?{practice:e.options.practice}:{}}),await e.done}catch(t){this.#y(e,t)}finally{this.#u=null}}}finally{this.#d=!1}}}};export{i as t};
@@ -1,9 +0,0 @@
1
- /*!
2
- * code-playpad — MIT © 2026 Seung Hun Lee
3
- * Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
4
- * Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
5
- */
6
- import{n as e,t}from"./types-CfcYqU2K.js";import{t as n}from"./hints-DpBIeoeG.js";var r=1,i=class{#e=null;#t=null;#n=`module`;#r=null;#i=null;#a=!1;#o=!1;#s=``;#c=/* @__PURE__ */ new Set;#l=[];#u=null;#d=!1;initPayload(){return{}}loadModule(e){return Promise.reject(/* @__PURE__ */ Error(`no module named ${e}`))}get ready(){return this.#a}get interactiveStdin(){return this.#o}get version(){return this.#s}load(t){t&&this.#c.add(t);let n=()=>{t&&this.#c.delete(t)};if(!this.#r){let t=new Promise((t,n)=>{this.#i={resolve:t,reject:n};let r;try{if(typeof Worker>`u`)throw Error(`Worker constructor missing`);let e=new Blob([this.source],{type:`text/javascript`});this.#t=URL.createObjectURL(e),r=new Worker(this.#t,{type:this.#n})}catch(t){this.#i=null,n(new e(`Could not start a Web Worker: ${t.message}`));return}this.#e=r,r.onmessage=e=>{let r=e.data;r.type===`ready`?(this.#s=r.version,this.#o=r.interactiveStdin===!0,this.#a=!0,this.#i=null,this.#h({phase:`ready`,message:`${this.label} ready`}),t()):r.type===`fatal`&&!this.#a?this.#p(r.message,t,n):this.#g(r)},r.onerror=e=>{let r=e.message||`Worker failed to start`;this.#a?this.#u&&this.#y(this.#u,Error(r)):this.#p(r,t,n)},r.postMessage({type:`init`,...this.initPayload()})});this.#r=t,t.catch(()=>{this.#r===t&&(this.#r=null)})}return this.#r.then(n,e=>{throw n(),e})}run(e,t={}){let n,i,a=new Promise((e,t)=>{n=e,i=t}),o,s=new Promise(e=>{o=e}),c={id:r++,code:e,options:t,stdout:``,stderr:``,resolve:n,reject:i,promise:a,started:!1,settled:!1,done:s,markDone:()=>{clearTimeout(c.timer),c.settled=!0,o()}};return this.#l.push(c),this.#b(),a}stop(e){if(e){let n=this.#l.findIndex(t=>t.promise===e);if(n!==-1){this.#y(this.#l.splice(n,1)[0],new t);return}let r=this.#u;if(!r||r.promise!==e||r.settled)return;if(!r.started){this.#y(r,new t);return}}this.#f()}#f(){let e=this.#e!==null,n=this.#i;if(this.#m(),this.#u&&this.#y(this.#u,new t),e){let e=this.load();n&&e.then(n.resolve,n.reject),e.catch(()=>{})}}#p(e,t,n){this.#m(),this.#n===`module`?(this.#n=`classic`,this.load().then(t,n)):n(Error(e))}#m(){this.#e?.terminate(),this.#e=null,this.#t&&=(URL.revokeObjectURL(this.#t),null),this.#r=null,this.#i=null,this.#a=!1}#h(e){for(let t of this.#c)t(e)}#g(e){if(e.type===`progress`){this.#h({phase:e.phase,message:e.message}),this.#u&&e.id===this.#u.id&&!this.#u.settled&&this.#u.options.onProgress?.({phase:e.phase,message:e.message});return}let t=this.#u;if(t&&`id`in e&&e.id===t.id)switch(e.type){case`stdout`:t.stdout+=e.text,t.options.onStdout?.(e.text);break;case`echo`:t.options.onEcho?.(e.text);break;case`stdin-request`:this.#v(t,e.request);break;case`module-request`:this.#_(t,e.name);break;case`stderr`:t.stderr+=e.text,t.options.onStderr?.(e.text);break;case`result`:t.resolve({stdout:t.stdout,stderr:t.stderr||void 0,value:e.value,durationMs:Math.round(e.durationMs),failed:!1,...e.memory?{memory:e.memory}:{},...e.cases?{cases:e.cases,passed:e.passed,total:e.total}:{}}),t.markDone();break;case`error`:case`fatal`:{let r=(t.stderr&&!t.stderr.endsWith(`
7
- `)?`
8
- `:``)+e.message+`
9
- `;t.stderr+=r,t.options.onStderr?.(r);let i={stdout:t.stdout,stderr:t.stderr,hint:`hint`in e?e.hint:void 0,durationMs:Math.round(`durationMs`in e?e.durationMs:0),failed:!0,...`cases`in e&&e.cases?{cases:e.cases,passed:0,total:e.cases.length}:{}};`hintAbout`in e&&e.hintAbout===`stdin`&&n.add(i),t.resolve(i),t.markDone();break}}}#_(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`module`,name:t,...r})};this.loadModule(t).then(e=>r({code:e}),e=>r({error:e instanceof Error?e.message:String(e)}))}#v(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`stdin-response`,request:t,text:r})},i=e.options.onStdinRequest;i?i().then(r,()=>r(null)):r(null)}#y(e,t){e.reject(t),e.markDone()}async#b(){if(!this.#d){this.#d=!0;try{for(;this.#l.length;){let e=this.#l.shift();this.#u=e;try{if(await this.load(),e.settled)continue;e.started=!0,e.options.onStart?.(),e.options.timeoutMs&&Number.isFinite(e.options.timeoutMs)&&e.options.timeoutMs>0&&(e.timer=setTimeout(()=>{this.#u!==e||e.settled||(this.#g({type:`error`,id:e.id,message:`Run exceeded its wall-clock time limit.`,durationMs:e.options.timeoutMs}),this.#m())},e.options.timeoutMs)),this.#e.postMessage({type:`run`,id:e.id,code:e.code,stdin:e.options.stdin,files:e.options.files,entry:e.options.entry,...e.options.compilerLanguage?{compilerLanguage:e.options.compilerLanguage}:{},...e.options.practice?{practice:e.options.practice}:{}}),await e.done}catch(t){this.#y(e,t)}finally{this.#u=null}}}finally{this.#d=!1}}}};export{i as t};