@elixir-playground/runtime 1.0.0 → 1.1.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/NOTICE.md +0 -1
- package/chunks/{git-remote-DnEba0y9.js → git-remote-Bb9EZlDN.js} +1 -1
- package/chunks/wasi-BuobPCe8.js +1 -0
- package/exec.html +1 -1
- package/frames/{browser-C6dmTjO4.js → browser-C1G3It0R.js} +1 -1
- package/frames/{exec-DcNLuXnX.js → exec-C4uIgAUX.js} +1 -1
- package/frames/{host-gpGAUuqR.js → host-f4apmOAk.js} +4 -14
- package/git.js +1 -1
- package/licenses/index.json +0 -9
- package/nodejs.js +1 -1
- package/package.json +9 -3
- package/worker.js +1 -1
- package/chunks/wasi-M0pSoirQ.js +0 -1
- package/claude.html +0 -10
- package/frames/browser-CpIeD-9w.js +0 -682
- package/frames/claude-BdzjrDKT.js +0 -1
- package/frames/worker-PmIsqqyU.js +0 -16
- package/licenses/fzstd-0.1.1/LICENSE +0 -21
package/NOTICE.md
CHANGED
|
@@ -23,7 +23,6 @@ their texts, and `licenses/index.json` lists them.
|
|
|
23
23
|
| [esbuild-wasm](https://github.com/evanw/esbuild) | 0.25.4 | MIT | |
|
|
24
24
|
| [events](git://github.com/Gozala/events) | 3.3.0 | MIT | |
|
|
25
25
|
| [fflate](https://101arrowz.github.io/fflate) | 0.8.2 | MIT | |
|
|
26
|
-
| [fzstd](https://github.com/101arrowz/fzstd) | 0.1.1 | MIT | |
|
|
27
26
|
| [get-east-asian-width](sindresorhus/get-east-asian-width) | 1.7.0 | MIT | |
|
|
28
27
|
| [ieee754](git://github.com/feross/ieee754) | 1.2.1 | BSD-3-Clause | |
|
|
29
28
|
| [is-fullwidth-code-point](sindresorhus/is-fullwidth-code-point) | 5.1.0 | MIT | |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,i as t,o as n,r,s as i,t as a,v as o}from"./fs-GnBaZCKr.js";import{i as s,n as c,r as l,t as u}from"./wasi-
|
|
1
|
+
import{_ as e,i as t,o as n,r,s as i,t as a,v as o}from"./fs-GnBaZCKr.js";import{i as s,n as c,r as l,t as u}from"./wasi-BuobPCe8.js";var d=`4.3.3`;function f(e,{args:t}){if(t[0]===`--version`)return e.write(`0.25.4
|
|
2
2
|
`),e.exit(0);e.write(`esbuild: not yet available in the playground
|
|
3
3
|
`),e.exit(1)}function p(e,{args:t}){if(t[0]===`--help`)return e.write(`\u2248 tailwindcss v${d}\n`),e.exit(0);e.write(`tailwind: not yet available in the playground
|
|
4
4
|
`),e.exit(1)}var m=(e,t)=>(n,{args:r,cwd:a,env:o})=>{if(r.length&&r.every(e=>e===`clean`))return n.exit(0);let s=e.readText(`${a}/hex_metadata.config`)??``,c=e=>s.match(RegExp(`\\{<<"${e}">>,\\s*<<"([^"]*)">>\\}`))?.[1],[l,u]=[c(`name`),c(`version`)],d=o.MIX_APP_PATH,f=e=>n.write(`make: ${e}\n`),p=l&&u&&d?t(l,u,f):null;if(!(p instanceof Uint8Array)){let e=l?`${l} ${u}`:a;return f(typeof p==`string`?p:`there is no WebAssembly build of ${e}'s native code in the playground`),n.exit(2)}for(let t of i(p)){let n=`${d}/${t.name.replace(/\/$/,``)}`;t.type===`5`?e.mkdir(n):t.type===`0`&&(e.mkdir(n.slice(0,n.lastIndexOf(`/`))),e.write(n,t.body))}n.write(`make: ${l} ${u}'s native code, built to WebAssembly for the playground\n`),n.exit(0)},h=1,g=2,_=1,v=2,y=3,b=12,ee=(e,{memory:t})=>{let n=new TextEncoder,r=t=>e.write(new Uint8Array([t.length,...t])),i=e=>r(n.encode(e.toString(16))),a=4*1024**3,o=()=>t?.buffer.byteLength??0,s=new Uint8Array;e.oninput=t=>{for(s=new Uint8Array([...s,...t]);s.length&&s.length>=1+s[0];){let t=s[1];if(s=s.subarray(1+s[0]),t===h)i(o()),i(a);else if(t===g){for(let[e,t]of[[_,a],[v,a],[y,a-o()],[b,a-o()]])r(new Uint8Array([e])),i(t);r(new Uint8Array([0]))}else return e.exit(0)}},e.onclose=()=>e.exit(0)};function x(e){let t=[],n=null,r=null;for(let i of e)r?i===r?r=null:n+=i:i===`"`||i===`'`?(r=i,n??=``):/\s/.test(i)?(n!==null&&t.push(n),n=null):n=(n??``)+i;return n!==null&&t.push(n),t}function te(e){let t=e.trim();for(;;){let e=t.replace(/\s*<\s*\/dev\/null\s*$/,``).replace(/^\(([\s\S]*)\)$/,`$1`).trim();if(e===t)break;t=e}let n=[[]];for(let e of x(t))e===`&&`?n.push([]):n[n.length-1].push(e);return n}var S=new Map;function C(e){S.clear();for(let[t,n]of e)S.set(t,n)}var w=e=>S.get(e)?.multicall===!0,T=e=>S.get(e)?.multicall===!1,ne=e=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e);function E(e,t){let n=S.get(t);if(n)return(r,{args:i,cwd:a,env:o,root:s})=>{let l=n.multicall?e.module():e.load?.(t)??null;if(!l)return r.write(`${t}: not in this site (${n.url.pathname.split(`/`).pop()})\n`),r.exit(127);let u=e.terminal?.()??null,d=r.input.splice(0),f=!e.read,p=new c({args:[t,...i],env:{...t===`git`?{GIT_PAGER:`cat`}:{},...o,PWD:a,...u?{COLUMNS:String(u[0])}:{}},root:s,stdin:t=>{let n=d[0];if(!n){let n=f?new Uint8Array:e.read(t);return f||=!n.length,n}return n.length<=t?d.shift():(d[0]=n.subarray(t),n.subarray(0,t))},stdout:e=>r.write(e.slice()),stderr:t=>(e.stderr??r.write.bind(r))(t.slice()),sleep:ne,tty:!!u,fetch:e.fetch,shared:e.shared}),m=new WebAssembly.Instance(l,p.imports);r.exit(p.start(m))}}function re(e,t){return(n,r)=>{if(t)return t(n,r);let[i,a=``]=r.args,o=i===`-c`?te(a):[];if(!o.some(e=>w(e[0])))return n.write(`sh: only sh -c runs here
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e,d as t,f as n,i as r,l as i,m as a,n as o,r as s,t as c,v as l,x as u,y as d}from"./fs-GnBaZCKr.js";var f=class{constructor(e){this.inbox=[],this.eof=!1,this.peer=e,this.status=1}connected(e){this.status===0&&(this.status=e,this.notify?.())}receive(e){this.inbox.push(e),this.notify?.()}finish(){this.eof=!0,this.notify?.()}take(e){let t=new Uint8Array(Math.min(e,this.inbox.reduce((e,t)=>e+t.length,0))),n=0;for(;n<t.length;){let e=this.inbox[0],r=e.subarray(0,t.length-n);t.set(r,n),n+=r.length,r.length===e.length?this.inbox.shift():this.inbox[0]=e.subarray(r.length)}return t}},p=49152+Math.floor(Math.random()*16384);function m(){let e=p;return p=p>=65535?49152:p+1,e}function h(e){if(!e.includes(`:`))return e.startsWith(`127.`)||e===`0.0.0.0`;let t=e.split(`:`).map(e=>parseInt(e,16)||0);return t.length===8&&t.slice(0,7).every(e=>e===0)?t[7]<=1:t.length===8&&t.slice(0,5).every(e=>e===0)&&t[5]===65535&&t[6]>>8==127}var g=-40,_=class{constructor(e={ports:[],open(){},send(){},end(){},close(){}}){this.remote=e,this.listeners=new Map,this.waiting=new Map,this.endpoints=new Map,this.next=2,this.peers=new Set,this.udp=new Map}listen(e){let t=e===0,n=e=>this.listeners.has(e)||this.peers.has(e);if(t)do e=m();while(n(e));if(n(e))return null;let r=[];return this.listeners.set(e,r),this.remote.listening?.(e,!0,t),{queue:r,port:e}}accepted(e,t){let n=this.listeners.get(t);if(!n)return!1;let r=this.remote,i=new f({send:t=>r.send(e,t),end:()=>r.end(e),close:()=>{this.endpoints.delete(e),r.close(e)}});return this.endpoints.set(e,i),this.waiting.set(e,i),n.push({id:e,ip:`127.0.0.1`,port:m()}),this.onqueue?.get(t)?.(),!0}connect(e){let t=this.listeners.get(e);if(t){let n=this.next+=2,r,i=new f({send:e=>r.receive(e),end:()=>r.finish(),close:()=>r.finish()});return r=new f({send:e=>i.receive(e),end:()=>i.finish(),close:()=>i.finish()}),this.waiting.set(n,i),t.push({id:n,ip:`127.0.0.1`,port:m()}),this.onqueue?.get(e)?.(),r}if(!this.remote.ports.includes(e)&&!this.peers.has(e))return null;let n=this.next+=2,r=this.remote,i=new f({send:e=>r.send(n,e),end:()=>r.end(n),close:()=>{this.endpoints.delete(n),r.close(n)}});return this.endpoints.set(n,i),r.open(n,e),i}https(e,t){if(!this.remote.https)return null;let n=this.next+=2,r=this.remote,i=new f({send:e=>r.send(n,e),end:()=>r.end(n),close:()=>{this.endpoints.delete(n),r.close(n)}});return this.endpoints.set(n,i),r.open(n,t,e),i}dial(e,t){let n=this.next+=2,r=this.remote,i=new f({send:e=>r.send(n,e),end:()=>r.end(n),close:()=>{this.endpoints.delete(n),r.close(n)}});return i.status=0,this.endpoints.set(n,i),r.dial?r.dial(n,e,t):i.connected(g),i}connected(e,t,n){let r=this.endpoints.get(e);r&&(t!==1&&this.endpoints.delete(e),r.local=n,r.connected(t))}udpBind(e){if(e===0)do e=m();while(this.udp.has(e));if(this.udp.has(e))return null;let t={port:e,queue:[]};return this.udp.set(e,t),this.remote.bound?.(e),t}udpUnbind(e){this.udp.delete(e)&&this.remote.unbound?.(e)}udpSend(e,t,n,r){let i=h(t)?this.udp.get(n):null;i?(i.queue.push({address:`127.0.0.1`,port:e,bytes:r}),i.notify?.()):this.remote.datagram?.(e,t,n,r)}datagram(e,t,n,r){let i=this.udp.get(e);i&&(i.queue.push({address:t,port:n,bytes:r}),i.notify?.())}data(e,t){this.endpoints.get(e)?.receive(t)}ended(e){this.endpoints.get(e)?.finish()}unlisten(e){this.listeners.delete(e)&&this.remote.listening?.(e,!1)}},v=1024,y=1,b=1025,x=2049,S=()=>new SharedArrayBuffer(12292);function C(e,t){let n=new Int32Array(e);for(let e=2;e<v;e++)if(Atomics.compareExchange(n,y+e,0,t)===0)return e;throw Error(`a process has at most 1022 worker threads`)}function w(e,t,n){for(let r=t;r>1;r=Atomics.load(e,y+r))if(r===n)return!0;return n===1}function T(e,t){Atomics.store(new Int32Array(e),b+t,1)}function E(e,t){let n=new Int32Array(e),r=[];for(let e=2;e<v;e++)Atomics.load(n,y+e)&&w(n,e,t)&&r.push(e);for(let e of r)Atomics.store(n,b+e,0),Atomics.store(n,x+e,0),Atomics.store(n,y+e,0)}function D(e,t){let n=new Int32Array(e);for(let e=1;e<v;e++)if(Atomics.load(n,x+e)&&w(n,e,t))return!0;let r=Atomics.load(n,0);return r!==0&&w(n,r,t)}function O(e,t,n,r=1){let i=k(e,t);if(!n)return i;let a=new Int32Array(n),o=()=>{for(let e=r;e>1;e=Atomics.load(a,y+e))if(Atomics.load(a,b+e))return b+e;return-1},s=e=>Atomics.store(a,x+r,e);return(e,t)=>{s(1);for(let e;;){let t=o();if(t>=0)for(s(0);;)Atomics.wait(a,t,1);if((e=Atomics.compareExchange(a,0,0,r))===0)break;Atomics.wait(a,0,e,10)}try{return i(e,t)}finally{Atomics.store(a,0,0),Atomics.notify(a,0,1),s(0)}}}function k(e,t){let n=new Int32Array(e),r=new Int32Array(t,0,2),i=new Uint8Array(t,8),a=new DataView(t,8),o=new TextEncoder,s=new TextDecoder;return(e,t=new Uint8Array)=>{let c=o.encode(JSON.stringify(e));for(a.setUint32(0,c.length,!0),i.set(c,4),i.set(t,4+c.length),Atomics.store(r,1,4+c.length+t.length),Atomics.store(r,0,1),Atomics.add(n,0,1),Atomics.notify(n,0);Atomics.load(r,0)===1;)Atomics.wait(r,0,1,1e3);let l=a.getUint32(0,!0),u=Atomics.load(r,1),d=JSON.parse(s.decode(i.slice(4,4+l))),f=i.slice(4+l,u);return Atomics.store(r,0,0),{answer:d,bytes:f}}}var A=524288;function j(t){return t===`dir`?e.DIR:t===`link`?e.SYMLINK:e.REG}function M(e,t){return e.shared.prefixes.some(e=>t===e||t.startsWith(`${e}/`))}function N(e,t,{type:n,size:r,ino:i,mtime:a}){let o=e.view();o.setBigUint64(t,2n,!0),o.setBigUint64(t+8,BigInt(i),!0),o.setUint8(t+16,j(n)),o.setBigUint64(t+24,1n,!0),o.setBigUint64(t+32,BigInt(r),!0),o.setBigUint64(t+40,BigInt(a),!0),o.setBigUint64(t+48,BigInt(a),!0),o.setBigUint64(t+56,BigInt(a),!0)}function P(t,n){let r=(e,n)=>t.shared.call(e,n),i=(e,t)=>r(e,t).answer,a=(e,n,r)=>t.absolute(e,t.string(n,r)),o=e=>t.fds.get(e)?.remote,s=(e,r)=>(o,s,c)=>{let u=a(o,s,c);return M(t,u)?i({op:e,path:u}).error??l.SUCCESS:n[r](o,s,c)};return{path_open(e,r,o,s,c,u,f,p,m){let h=a(e,o,s);if(!M(t,h))return n.path_open(e,r,o,s,c,u,f,p,m);let g=i({op:`open`,path:h,oflags:c,follow:!!(r&1)});if(g.error)return g.error;let _=t.next++;return t.fds.set(_,{path:h,remote:{handle:g.handle,position:0,append:!!(p&d.APPEND),dir:g.type===`dir`,listing:null}}),t.view().setUint32(m,_,!0),l.SUCCESS},path_filestat_get(e,r,o,s,c){let u=a(e,o,s);if(!M(t,u))return n.path_filestat_get(e,r,o,s,c);let d=i({op:`stat`,path:u,follow:!!(r&1)});return d.error?d.error:(N(t,c,d),l.SUCCESS)},path_symlink(e,r,o,s,c){let u=a(o,s,c);return M(t,u)?i({op:`symlink`,path:u,target:t.string(e,r)}).error??l.SUCCESS:n.path_symlink(e,r,o,s,c)},path_readlink(e,r,o,s,c,u){let d=a(e,r,o);if(!M(t,d))return n.path_readlink(e,r,o,s,c,u);let f=i({op:`readlink`,path:d});if(f.error)return f.error;let p=new TextEncoder().encode(f.target).subarray(0,c);return t.bytes(s,p.length).set(p),t.view().setUint32(u,p.length,!0),l.SUCCESS},path_create_directory:s(`mkdir`,`path_create_directory`),path_remove_directory:s(`rmdir`,`path_remove_directory`),path_unlink_file:s(`unlink`,`path_unlink_file`),path_rename(e,r,o,s,c,u){let d=a(e,r,o),f=a(s,c,u);return!M(t,d)&&!M(t,f)?n.path_rename(e,r,o,s,c,u):M(t,d)===M(t,f)?i({op:`rename`,path:d,to:f}).error??l.SUCCESS:75},path_link(e,r,o,s,c,u,d){let f=a(e,o,s),p=a(c,u,d);return!M(t,f)&&!M(t,p)?n.path_link(e,r,o,s,c,u,d):M(t,f)===M(t,p)?i({op:`link`,path:f,to:p,follow:!!(r&1)}).error??l.SUCCESS:75},fd_read(e,i,a,s){let c=o(e);if(!c)return n.fd_read(e,i,a,s);if(c.dir)return l.ISDIR;let u=0;for(let[e,n]of t.iovecs(i,a)){let i=0;for(;i<n;){let a=Math.min(n-i,A),{answer:o,bytes:s}=r({op:`read`,handle:c.handle,offset:c.position,length:a});if(o.error)return o.error;if(t.bytes(e+i,s.length).set(s),i+=s.length,c.position+=s.length,s.length<a)break}if(u+=i,i<n)break}return t.view().setUint32(s,u,!0),l.SUCCESS},fd_write(e,r,a,s){let c=o(e);if(!c)return n.fd_write(e,r,a,s);let u=0;for(let[e,n]of t.iovecs(r,a)){for(let r=0;r<n;r+=A){let a=t.bytes(e+r,Math.min(A,n-r)).slice(),o=i({op:`write`,handle:c.handle,offset:c.position,append:c.append},a);if(o.error)return o.error;c.position=o.position}u+=n}return t.view().setUint32(s,u,!0),l.SUCCESS},fd_seek(e,r,a,s){let c=o(e);if(!c)return n.fd_seek(e,r,a,s);let u=a===2?i({op:`fstat`,handle:c.handle}).size:0,d=[0,c.position,u][a];if(d===void 0)return l.INVAL;let f=d+Number(r);return f<0?l.INVAL:(c.position=f,t.view().setBigUint64(s,BigInt(f),!0),l.SUCCESS)},fd_filestat_get(e,r){let a=o(e);if(!a)return n.fd_filestat_get(e,r);let s=i({op:`fstat`,handle:a.handle});return s.error?s.error:(N(t,r,s),l.SUCCESS)},fd_filestat_set_size(e,t){let r=o(e);return r?i({op:`truncate`,handle:r.handle,size:Number(t)}).error??l.SUCCESS:n.fd_filestat_set_size(e,t)},fd_allocate(e,t,r){let a=o(e);if(!a)return n.fd_allocate(e,t,r);let s=i({op:`fstat`,handle:a.handle});if(s.error)return s.error;let c=Number(t+r);return c<=s.size?l.SUCCESS:i({op:`truncate`,handle:a.handle,size:c}).error??l.SUCCESS},fd_fdstat_get(r,i){let a=o(r);if(!a)return n.fd_fdstat_get(r,i);let s=t.view();return s.setUint8(i,a.dir?e.DIR:e.REG),s.setUint16(i+2,a.append?d.APPEND:0,!0),s.setBigUint64(i+8,18446744073709551615n,!0),s.setBigUint64(i+16,18446744073709551615n,!0),l.SUCCESS},fd_readdir(e,r,a,s,c){let u=o(e);if(!u)return n.fd_readdir(e,r,a,s,c);if(!u.dir)return l.NOTDIR;if(!u.listing||s===0n){let e=i({op:`readdir`,handle:u.handle});if(e.error)return e.error;u.listing=e.entries}let d=0;for(let e=Number(s);e<u.listing.length&&d<a;e++){let[n,i,o]=u.listing[e],s=new TextEncoder().encode(n),c=new Uint8Array(24+s.length),l=new DataView(c.buffer);l.setBigUint64(0,BigInt(e+1),!0),l.setBigUint64(8,BigInt(o),!0),l.setUint32(16,s.length,!0),l.setUint8(20,j(i)),c.set(s,24);let f=Math.min(c.length,a-d);t.bytes(r+d,f).set(c.subarray(0,f)),d+=f}return t.view().setUint32(c,d,!0),l.SUCCESS},fd_close(e){let r=o(e);return r?(t.fds.delete(e),i({op:`close`,handle:r.handle}).error??l.SUCCESS):n.fd_close(e)}}}var F={name:`@elixir-playground/runtime`,version:`1.1.0`,provides:{manifest:[2],fs:[3],wasi:[1],processes:[1],crossterm:[1],beam:[1],tls:[1],tailscale:[1],nif:[1],claude:[1]}}.provides.nif;function I(e){let t=new TextEncoder().encode(e),n=new Uint8Array(15+t.length);return n.set([131,104,2,119,5,...new TextEncoder().encode(`error`),109]),new DataView(n.buffer).setUint32(11,t.length),n.set(t,15),n}var L=52;function R(e,t){let n=WebAssembly.Module.imports(e).filter(({module:e,kind:n,name:r})=>e===`wasi_snapshot_preview1`&&n===`function`&&!(r in t)).map(({name:e})=>[e,()=>L]);return n.length?{...t,...Object.fromEntries(n)}:t}var z=class{constructor(e){this.wasi=e,this.instances=new Map,this.next=1}within(e,t){let n=this.wasi.memory;this.wasi.memory=e.exports.memory;try{return t()}finally{this.wasi.memory=n}}create(e){try{let t=new WebAssembly.Module(e),n=WebAssembly.Module.exports(t).some(({name:e})=>e===`beamos_nif_abi`),r=new WebAssembly.Instance(t,{wasi_snapshot_preview1:R(t,this.wasi.imports.wasi_snapshot_preview1)}),i=r.exports,a=n?i.beamos_nif_abi():null;if(a===null||!F.includes(a))throw Error(`built for ${a===null?`an unnumbered erl_nif layer`:`erl_nif layer ${a}`}, not ${F.join(` or `)}: build it again`);this.within(r,()=>i._initialize?.());let o=this.next++;return this.instances.set(o,r),new TextEncoder().encode(String(o))}catch(e){return new TextEncoder().encode(`error ${e.message}`)}}call(e,t){let n=this.instances.get(e);if(!n)return I(`no such NIF library`);try{return this.within(n,()=>{let{memory:e,beamos_nif_input:r,beamos_nif_run:i,beamos_nif_output:a}=n.exports;new Uint8Array(e.buffer,r(t.length)>>>0,t.length).set(t);let o=i(t.length);return new Uint8Array(e.buffer,a()>>>0,o>>>0).slice()})}catch(t){if(this.instances.delete(e),t instanceof q)return I(`the NIF library exited (${t.code})`);if(t instanceof WebAssembly.RuntimeError)return I(`the NIF library crashed: ${t.message}`);throw t}}answer(e,t){return e===`new`?this.create(t):this.call(Number(e),t)}},B=class{constructor(){this.output=[],this.errors=null,this.ended=!1,this.status=null,this.input=[],this.closed=!1,this.taken=0}write(e){this.output.push(typeof e==`string`?new TextEncoder().encode(e):e),this.notify?.()}writeError(e){if(!this.errors)return this.write(e);this.errors.push(typeof e==`string`?new TextEncoder().encode(e):e),this.notify?.()}exit(e){this.ended=!0,this.status=e,this.notify?.()}};function V(e,t,n){let r=new TextDecoder().decode(n.slice()).split(`\0`),[i,a]=r,o=Number(r[2]),s=r.slice(3,3+o),c=Number(r[3+o]),u=Object.fromEntries(r.slice(4+o,4+o+c).map(e=>{let t=e.indexOf(`=`);return[e.slice(0,t),e.slice(t+1)]})),d=i.split(`/`).pop(),f=e.programs[d]??e.programs[d.split(`-`)[0]]??e.programs[`*`]?.(d);if(!f)return l.NOENT;let p=new B;t.process=p;try{f(p,{args:s,cwd:a||u.PWD||`/`,env:u,root:e.root})}catch(e){p.write(`${i}: ${e.message}\n`),p.exit(1)}return null}function H(n){let f=l.SUCCESS;return{fd_prestat_get(e,t){let r=n.fds.get(e);if(!r||!r.preopen)return l.BADF;let i=n.view();return i.setUint8(t,0),i.setUint32(t+4,new TextEncoder().encode(r.preopen).length,!0),f},fd_prestat_dir_name(e,t,r){let i=n.fds.get(e);return!i||!i.preopen?l.BADF:(n.bytes(t,r).set(new TextEncoder().encode(i.preopen).subarray(0,r)),f)},fd_fdstat_get(t,r){let i=n.fds.get(t);if(!i)return l.BADF;let a=n.view(),s=i.stream?e.CHAR:i.node instanceof o?e.DIR:e.REG;a.setUint8(r,i.pipe?e.CHAR:s),a.setUint16(r+2,i.append?d.APPEND:0,!0);let c=i.stream&&(i.tty??n.tty)?18446744073709551579n:18446744073709551615n;return a.setBigUint64(r+8,c,!0),a.setBigUint64(r+16,c,!0),f},fd_fdstat_set_flags:()=>f,fd_close(e){if(!n.fds.has(e)||e<3)return e<3?f:l.BADF;let t=n.fds.get(e);return t.endpoint&&t.endpoint.peer.close(),t.listener&&(n.network.listeners.delete(t.port),n.network.remote.listening?.(t.port,!1)),t.changed&&n.onchange(t.path),t.process&&(t.process.closed=!0,t.process.onclose?.()),n.fds.delete(e),f},fd_sync:()=>f,fd_datasync:()=>f,fd_advise:()=>f,fd_fdstat_set_rights:()=>f,fd_filestat_get(e,t){let r=n.fds.get(e);if(!r)return l.BADF;if(r.spawn){let e=r.process?.status;return n.filestat(t,{ino:0n,size:e==null?0:e+1,mtime:a()}),f}return r.listener?(n.filestat(t,{ino:0n,size:r.port,mtime:a()}),f):(n.filestat(t,r.stream||r.pipe?null:r.node),f)},fd_filestat_set_size(e,t){let r=n.fds.get(e);return r?.endpoint?(r.endpoint.peer.end(),f):r?.process?(r.process.closed=!0,f):!r||!(r.node instanceof s)?l.BADF:(r.node.truncate(Number(t)),r.changed=!0,f)},fd_allocate(e,t,r){let i=n.fds.get(e);if(!i||!(i.node instanceof s))return i?l.SPIPE:l.BADF;let a=Number(t+r);return a>i.node.size&&(i.node.truncate(a),i.changed=!0),f},fd_filestat_set_times:()=>f,path_filestat_set_times:()=>f,fd_read(e,t,r,i){let a=n.fds.get(e);if(!a)return l.BADF;n.pump();let o=0,u=a.endpoint||a.listener;if(a.pipe){if(!a.reads)return l.BADF;let e=n.iovecs(t,r).reduce((e,[,t])=>e+t,0),i=a.pipe.read(e);if(!i)return n.block(a.pipe.changed());for(let[e,a]of n.iovecs(t,r)){let t=i.subarray(o,o+a);n.bytes(e,t.length).set(t),o+=t.length}}else if(a.nif){if(!a.answer){let e=new Uint8Array(a.request.reduce((e,t)=>e+t.length,0)),t=0;for(let n of a.request)e.set(n,t),t+=n.length;a.answer=n.nifs.answer(a.nif,e)}for(let[e,i]of n.iovecs(t,r)){let t=a.answer.subarray(a.position,a.position+i);if(n.bytes(e,t.length).set(t),a.position+=t.length,o+=t.length,t.length<i)break}}else if(a.spawn){let e=a.process;if(!e)return l.BADF;let[i,s]=n.iovecs(t,r)[0]||[0,0];if(e.output.length){let t=e.output[0],r=t.subarray(0,s);n.bytes(i,r.length).set(r),r.length===t.length?e.output.shift():e.output[0]=t.subarray(r.length),o=r.length}else if(!e.ended)return l.AGAIN}else if(u){let[e,i]=n.iovecs(t,r)[0]||[0,0],s;if(a.listener){let e=a.listener.shift();if(!e)return l.AGAIN;s=new TextEncoder().encode(`${e.id} ${e.ip} ${e.port}`)}else if(a.endpoint.inbox.length)s=a.endpoint.take(i);else if(a.endpoint.eof)s=new Uint8Array;else return l.AGAIN;n.bytes(e,s.length).set(s.subarray(0,i)),o=Math.min(i,s.length)}else if(a.node instanceof c)for(let[e,i]of n.iovecs(t,r)){let t=a.node.read(i);if(n.bytes(e,t.length).set(t),o+=t.length,t.length<i)break}else if(a.stream&&(a.source||e===0)){let e=n.iovecs(t,r).reduce((e,[,t])=>e+t,0),i=(a.source??n.stdin)(e);if(i===null)return a.ready?n.block(a.ready()):l.AGAIN;let s=0;for(let[e,a]of n.iovecs(t,r)){let t=i.subarray(s,s+a);n.bytes(e,t.length).set(t),s+=t.length}o=s}else{let e=a.node;if(!(e instanceof s))return l.ISDIR;for(let[i,s]of n.iovecs(t,r)){let t=e.bytes.subarray(a.position,a.position+s);if(n.bytes(i,t.length).set(t),a.position+=t.length,o+=t.length,t.length<s)break}}return n.view().setUint32(i,o,!0),f},fd_write(e,t,r,i){let o=n.fds.get(e);if(!o)return l.BADF;let u=0;if(o.pipe){if(o.reads)return l.BADF;for(let[e,i]of n.iovecs(t,r)){let t=o.pipe.write(n.bytes(e,i),n.suspending&&n.bounded);if(t===-1&&!u)return l.PIPE;if(t===null&&!u)return n.block(o.pipe.changed());if(t===null||t===-1||(u+=t,t<i))break}return n.view().setUint32(i,u,!0),f}for(let[i,d]of n.iovecs(t,r)){let t=n.bytes(i,d);if(o.nif)o.request.push(t.slice());else if(o.terminal)n.terminal.mode(new TextDecoder().decode(t.slice()).trim());else if(o.spawn&&!o.process){let e=V(n,o,t);if(e)return e}else if(o.spawn)o.process.input.push(t.slice());else if(o.endpoint)o.endpoint.peer.send(t.slice());else if(o.stream){let r=o.sink??n.out[e];r&&r(t.slice())}else if(!(o.node instanceof c)){let e=o.node;if(!(e instanceof s))return l.ISDIR;o.append&&(o.position=e.size);let n=o.position+d;e.reserve(n),e.data.set(t,o.position),n>e.size&&(e.size=n),e.mtime=a(),e.written=!0,o.changed=!0,o.position=n}u+=d}return n.view().setUint32(i,u,!0),f},fd_seek(e,t,r,i){let a=n.fds.get(e);if(!a)return l.BADF;if(a.stream||a.pipe)return l.SPIPE;let o=a.node instanceof s?a.node.size:0,c=[0,a.position,o][r];if(c===void 0)return l.INVAL;let u=c+Number(t);return u<0?l.INVAL:(a.position=u,n.view().setBigUint64(i,BigInt(u),!0),f)},fd_readdir(e,t,r,a,s){let c=n.fds.get(e);if(!c||!(c.node instanceof o))return l.NOTDIR;let u=n.view(),d=[...c.node.entries.entries()],p=0;for(let e=Number(a);e<d.length&&p<r;e++){let[a,o]=d[e],s=new TextEncoder().encode(a),c=new Uint8Array(24),l=new DataView(c.buffer);l.setBigUint64(0,BigInt(e+1),!0),l.setBigUint64(8,o.ino,!0),l.setUint32(16,s.length,!0),l.setUint8(20,i(o));let u=new Uint8Array(24+s.length);u.set(c),u.set(s,24);let f=Math.min(u.length,r-p);n.bytes(t+p,f).set(u.subarray(0,f)),p+=f}return u.setUint32(s,p,!0),f},path_open(e,i,c,p,m,h,g,_,v){let y=n.string(c,p).replace(/^\/+/,``);if(y===`.proc/spawn`){let e=n.next++;return n.fds.set(e,{spawn:!0,process:null}),n.view().setUint32(v,e,!0),f}if(y.startsWith(`.tty/`)){let e;if(!n.terminal)return l.NOENT;if(y===`.tty/mode`)e={terminal:!0,node:new s};else if(y===`.tty/size`)e={node:new s(new TextEncoder().encode(n.terminal.size().join(` `))),position:0};else return l.NOENT;let t=n.next++;return n.fds.set(t,e),n.view().setUint32(v,t,!0),f}if(y.startsWith(`.nif/`)){let e=n.next++;return n.fds.set(e,{nif:y.slice(5),request:[],answer:null,position:0}),n.view().setUint32(v,e,!0),f}if(y.startsWith(`.net/`)){let[,e,t,r]=y.split(`/`),i=n.network,a;if(e===`listen`){let e=i.listen(Number(r));if(!e)return l.ADDRINUSE;a={listener:e.queue,port:e.port}}else if(e===`conn`){let e=i.waiting.get(Number(t));if(!e)return l.NOENT;i.waiting.delete(Number(t)),a={endpoint:e}}else if(e===`connect`){let e=i.connect(Number(r));if(!e)return l.CONNREFUSED;a={endpoint:e}}else if(e===`https`){let e=i.https(t,Number(r));if(!e)return l.NOENT;a={endpoint:e}}else return l.NOENT;let o=n.next++;return n.fds.set(o,a),n.view().setUint32(v,o,!0),f}let b=n.resolve(e,n.string(c,p),!!(i&1)),x=b.node,S=!1;if(x&&m&u.CREAT&&m&u.EXCL)return l.EXIST;if(x instanceof r)return l.LOOP;if(!x){if(!(m&u.CREAT)||!b.parent)return b.error;x=new s,x.written=!0,S=!0,b.parent.entries.set(b.name,x),b.parent.mtime=a()}if(m&u.DIRECTORY&&!(x instanceof o))return l.NOTDIR;try{t(x,n.fetch)}catch{return l.IO}x instanceof s&&m&u.TRUNC&&(x.truncate(0),x.written=!0,S=!0);let C=n.next++;return n.fds.set(C,{node:x,position:0,append:!!(_&d.APPEND),path:n.absolute(e,n.string(c,p)),changed:S}),n.view().setUint32(v,C,!0),f},path_filestat_get(e,t,r,i,a){let o=n.resolve(e,n.string(r,i),!!(t&1));return o.node?(n.filestat(a,o.node),f):o.error},path_create_directory(e,t,r){let i=n.resolve(e,n.string(t,r));if(i.node)return l.EXIST;if(!i.parent)return i.error;let a=new o;return a.parent=i.parent,i.parent.entries.set(i.name,a),n.onchange(n.absolute(e,n.string(t,r))),f},path_remove_directory(e,t,r){let i=n.resolve(e,n.string(t,r));return i.node?i.node instanceof o?i.node.entries.size?l.NOTEMPTY:(i.parent.entries.delete(i.name),n.onchange(n.absolute(e,n.string(t,r))),f):l.NOTDIR:i.error},path_unlink_file(e,t,r){let i=n.resolve(e,n.string(t,r));return i.node?i.node instanceof o?l.ISDIR:(i.parent.entries.delete(i.name),n.onchange(n.absolute(e,n.string(t,r))),f):i.error},path_rename(e,t,r,i,a,s){let c=n.resolve(e,n.string(t,r));if(!c.node)return c.error;let u=n.resolve(i,n.string(a,s));return u.parent?u.node instanceof o&&u.node.entries.size?l.NOTEMPTY:(c.parent.entries.delete(c.name),u.parent.entries.set(u.name,c.node),c.node instanceof o&&(c.node.parent=u.parent),n.onchange(n.absolute(e,n.string(t,r))),n.onchange(n.absolute(i,n.string(a,s))),f):u.error},path_link(e,t,r,i,a,s,c){let u=n.resolve(e,n.string(r,i),!!(t&1));if(!u.node)return u.error;if(u.node instanceof o)return l.PERM;let d=n.resolve(a,n.string(s,c));return d.node?l.EXIST:d.parent?(d.parent.entries.set(d.name,u.node),n.onchange(n.absolute(a,n.string(s,c))),f):d.error},path_symlink(e,t,i,o,s){let c=n.resolve(i,n.string(o,s));return c.node?l.EXIST:c.parent?(c.parent.entries.set(c.name,new r(n.string(e,t))),c.parent.mtime=a(),n.onchange(n.absolute(i,n.string(o,s))),f):c.error},path_readlink(e,t,i,a,o,s){let c=n.resolve(e,n.string(t,i));if(!c.node)return c.error;if(!(c.node instanceof r))return l.INVAL;let u=new TextEncoder().encode(c.node.target).subarray(0,o);return n.bytes(a,u.length).set(u),n.view().setUint32(s,u.length,!0),f},sock_accept:()=>l.NOSYS,sock_shutdown:()=>l.NOSYS}}var U=65536,W=class{constructor(){this.chunks=[],this.size=0,this.readers=0,this.writers=0,this.waiting=[]}read(e){if(!this.size)return this.writers?null:new Uint8Array;let t=new Uint8Array(Math.min(e,this.size)),n=0;for(;n<t.length;){let e=this.chunks[0],r=e.subarray(0,t.length-n);t.set(r,n),n+=r.length,r.length===e.length?this.chunks.shift():this.chunks[0]=e.subarray(r.length)}return this.size-=t.length,this.wake(),t}write(e,t=!0){if(!this.readers)return-1;if(!e.length)return 0;let n=t?U-this.size:e.length;if(n<=0)return null;let r=e.slice(0,n);return this.chunks.push(r),this.size+=r.length,this.wake(),r.length}changed(){return new Promise(e=>this.waiting.push(e))}open(e){e?this.readers++:this.writers++}close(e){e?this.readers--:this.writers--,this.wake()}wake(){let e=this.waiting.splice(0);for(let t of e)t()}};function G(e,t){let n=t=>{let n=e.fds.get(t);if(!n)return l.BADF;let r=n.remote??(n.node instanceof s?n:null);return r&&!n.nif?r:l.SPIPE},r=(e,t,r)=>{let i=n(e);if(typeof i==`number`)return i;let[a,o]=[i.position,i.append];Object.assign(i,{position:Number(t),append:!1});try{return r()}finally{Object.assign(i,{position:a,append:o})}};return{fd_pread:(e,n,i,a,o)=>r(e,a,()=>t.fd_read(e,n,i,o)),fd_pwrite:(e,n,i,a,o)=>r(e,a,()=>t.fd_write(e,n,i,o)),fd_tell(t,r){let i=n(t);return typeof i==`number`?i:(e.view().setBigUint64(r,BigInt(i.position),!0),l.SUCCESS)}}}var K=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>t(...e.map(e=>typeof e==`number`?e>>>0:e))])),q=class extends Error{constructor(e){super(`exit ${e}`),this.code=e}},J=class{constructor({args:e,env:t,root:n,stdin:r,stdout:i,stderr:a,sleep:o,tty:s=!1,terminal:c=null,network:l=new _,pump:u=()=>{},fetch:d,programs:f={},onchange:p=()=>{},shared:m=null,suspending:h=!1,bounded:g=!0}){this.suspending=h,this.bounded=g,this.blocked=null,this.interrupt=null,this.stack=null,this.strand=0,this.exports=null,this.shared=m,this.terminal=c,this.onchange=p,this.fetch=d,this.programs=f,this.tty=s,this.network=l,this.pump=u,this.args=e,this.env=Object.entries(t).map(([e,t])=>`${e}=${t}`),this.root=n,this.stdin=r,this.out={1:i,2:a},this.sleep=o,this.fds=new Map([[0,{stream:!0}],[1,{stream:!0}],[2,{stream:!0}],[3,{node:n,preopen:`/`,path:``}]]),this.next=4,this.memory=null,this.nifs=new z(this);let v=this.functions(),y=m?{...v,...P(this,v)}:v;this.io=y;let b=K({...y,...G(this,y),fd_close:e=>this.close(e),fd_renumber:(e,t)=>this.renumber(e,t)});this.imports={wasi_snapshot_preview1:h?this.suspend(b):b}}block(e){return this.suspending&&(this.blocked=e),l.AGAIN}async suspended(e){let t=this.stack?.value,n=this.strand;try{return await e}finally{this.stack&&(this.stack.value=t),this.strand=n}}suspend(e){let t={...e},n=async(e,t)=>{let n=l.AGAIN;for(;this.blocked;){let r=this.blocked;this.blocked=null,await this.suspended(this.interrupt?Promise.race([r,this.interrupt]):r),this.pump(),n=e(...t)}return n};for(let r of[`fd_read`,`fd_write`]){let i=e[r];t[r]=new WebAssembly.Suspending((...e)=>{let t=i(...e);return this.blocked?n(i,e):t})}return t.poll_oneoff=new WebAssembly.Suspending((...e)=>this.poll(...e.map(e=>e>>>0))),t}async poll(e,t,n,r){let i=[];for(let t=0;t<n;t++){let n=this.view(),r=e+48*t,o=n.getUint8(r+8),s=n.getBigUint64(r,!0);if(o===0){let e=n.getBigUint64(r+24,!0),t=n.getUint16(r+40,!0)&1;i.push({tag:o,userdata:s,fd:-1,at:t?e:a()+e})}else i.push({tag:o,userdata:s,fd:n.getUint32(r+16,!0),at:0n})}for(;;){this.pump();let e=a(),n=i.filter(({tag:t,fd:n,at:r})=>{if(t===0)return e>=r;let i=this.fds.get(n)?.pipe;return i?t===1?i.size>0||!i.writers:i.size<65536||!i.readers:!0});if(n.length){let e=this.view();return n.forEach(({tag:n,userdata:r,fd:i},a)=>{let o=t+32*a;e.setBigUint64(o,r,!0),e.setUint16(o+8,n&&!this.fds.has(i)?l.BADF:0,!0),e.setUint8(o+10,n);let s=this.fds.get(i)?.pipe;e.setBigUint64(o+16,BigInt(s?n===1?s.size:U-s.size:0),!0);let c=s&&(n===1?!s.writers:!s.readers);e.setUint16(o+24,+!!c,!0)}),e.setUint32(r,n.length,!0),l.SUCCESS}let o=i.map(({fd:e})=>this.fds.get(e)?.pipe?.changed()).filter(e=>e!==void 0),s=i.reduce((e,{tag:t,at:n})=>t===0&&(e===null||n<e)?n:e,null);s!==null&&o.push(new Promise(t=>setTimeout(t,Number(s-e)/1e6))),this.interrupt&&o.push(this.interrupt),await this.suspended(Promise.race(o))}}close(e){let t=this.fds.get(e);return t?t.shares?(t.shares--,this.fds.delete(e),l.SUCCESS):t.pipe?(t.pipe.close(!!t.reads),this.fds.delete(e),l.SUCCESS):this.io.fd_close(e):l.BADF}release(){for(let e of[...this.fds.keys()])this.close(e),this.fds.delete(e)}dup(e){let t=this.fds.get(e);if(!t)return null;t.shares=(t.shares??0)+1;let n=this.next++;return this.fds.set(n,t),n}renumber(e,t){let n=this.fds.get(e);return n?(e===t||(this.fds.has(t)&&this.close(t),this.fds.set(t,n),this.fds.delete(e)),l.SUCCESS):l.BADF}start(e){this.memory=e.exports.memory;try{return e.exports._start(),0}catch(e){if(e instanceof q)return e.code;throw e}}view(){return new DataView(this.memory.buffer)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}string(e,t){return new TextDecoder().decode(this.bytes(e,t).slice())}absolute(e,t){let n=t.startsWith(`/`)?``:this.fds.get(e)?.path??``,r=[];for(let e of`${n}/${t}`.split(`/`))e===`..`?r.pop():e&&e!==`.`&&r.push(e);return`/`+r.join(`/`)}resolve(e,t,r=!1){let i=this.fds.get(e);return!i||!(i.node instanceof o)?{error:l.BADF}:n(this.root,i.node,t,r)}filestat(t,n){let r=this.view(),s=n instanceof o;r.setBigUint64(t,1n,!0),r.setBigUint64(t+8,n?n.ino:0n,!0),r.setUint8(t+16,n?i(n):e.CHAR),r.setBigUint64(t+24,1n,!0),r.setBigUint64(t+32,BigInt(n&&!s?n.size:0),!0);let c=n?n.mtime:a();r.setBigUint64(t+40,c,!0),r.setBigUint64(t+48,c,!0),r.setBigUint64(t+56,c,!0)}iovecs(e,t){let n=this.view(),r=[];for(let i=0;i<t;i++)r.push([n.getUint32(e+8*i,!0),n.getUint32(e+8*i+4,!0)]);return r}functions(){let e=this,t=l.SUCCESS,n=n=>({sizes(r,i){let a=e.view();return a.setUint32(r,n.length,!0),a.setUint32(i,n.reduce((e,t)=>e+new TextEncoder().encode(t).length+1,0),!0),t},get(r,i){let a=e.view(),o=i;return n.forEach((t,n)=>{let i=new TextEncoder().encode(t);a.setUint32(r+4*n,o,!0),e.bytes(o,i.length).set(i),a.setUint8(o+i.length,0),o+=i.length+1}),t}}),r=n(this.args),i=n(this.env);return{args_sizes_get:(e,t)=>r.sizes(e,t),args_get:(e,t)=>r.get(e,t),environ_sizes_get:(e,t)=>i.sizes(e,t),environ_get:(e,t)=>i.get(e,t),clock_res_get(n,r){return e.view().setBigUint64(r,1000n,!0),t},clock_time_get(n,r,i){e.pump();let o=n===0?a():BigInt(Math.round(performance.now()*1e6));return e.view().setBigUint64(i,o,!0),t},random_get(n,r){for(let t=0;t<r;t+=65536){let i=new Uint8Array(Math.min(65536,r-t));crypto.getRandomValues(i),e.bytes(n+t,i.length).set(i)}return t},proc_exit(e){throw new q(e)},proc_raise(e){throw new q(128+e)},sched_yield:()=>t,poll_oneoff(n,r,i,o){let s=e.view(),c=1/0,l=0;for(let e=0;e<i;e++){let t=n+48*e,i=s.getUint8(t+8),o=r+32*l;if(i===0){let e=s.getBigUint64(t+24,!0),n=s.getUint16(t+40,!0)&1,r=Number(n?e-a():e)/1e6;c=Math.min(c,Math.max(0,r))}s.setBigUint64(o,s.getBigUint64(t,!0),!0),s.setUint16(o+8,0,!0),s.setUint8(o+10,i),l++}return c!==1/0&&c>0&&e.sleep(c),e.pump(),s.setUint32(o,l,!0),t},...H(this)}}};export{z as a,T as c,O as d,_ as f,B as i,C as l,J as n,D as o,W as r,E as s,q as t,S as u};
|
package/exec.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./host-
|
|
1
|
+
import{t as e}from"./host-f4apmOAk.js";var t=/* @__PURE__ */ e(((e,t)=>{(e=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},o=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},s=e=>o(t({},`__esModule`,{value:!0}),e),c=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),l={};a(l,{analyzeMetafile:()=>ve,analyzeMetafileSync:()=>Se,build:()=>me,buildSync:()=>ye,context:()=>he,default:()=>De,formatMessages:()=>_e,formatMessagesSync:()=>xe,initialize:()=>Te,stop:()=>Ce,transform:()=>ge,transformSync:()=>be,version:()=>pe}),e.exports=s(l);function u(e){let t=e=>{if(e===null)n.write8(0);else if(typeof e==`boolean`)n.write8(1),n.write8(+e);else if(typeof e==`number`)n.write8(2),n.write32(e|0);else if(typeof e==`string`)n.write8(3),n.write(p(e));else if(e instanceof Uint8Array)n.write8(4),n.write(e);else if(e instanceof Array){n.write8(5),n.write32(e.length);for(let n of e)t(n)}else{let r=Object.keys(e);n.write8(6),n.write32(r.length);for(let i of r)n.write(p(i)),t(e[i])}},n=new f;return n.write32(0),n.write32(e.id<<1|!e.isRequest),t(e.value),_(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function d(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return m(n.read());case 4:return n.read();case 5:{let e=n.read32(),r=[];for(let n=0;n<e;n++)r.push(t());return r}case 6:{let e=n.read32(),r={};for(let i=0;i<e;i++)r[m(n.read())]=t();return r}default:throw Error(`Invalid packet`)}},n=new f(e),r=n.read32(),i=!(r&1);r>>>=1;let a=t();if(n.ptr!==e.length)throw Error(`Invalid packet`);return{id:r,isRequest:i,value:a}}var f=class{constructor(e=/* @__PURE__ */ new Uint8Array(1024)){this.buf=e,this.len=0,this.ptr=0}_write(e){if(this.len+e>this.buf.length){let t=new Uint8Array((this.len+e)*2);t.set(this.buf),this.buf=t}return this.len+=e,this.len-e}write8(e){let t=this._write(1);this.buf[t]=e}write32(e){let t=this._write(4);_(this.buf,e,t)}write(e){let t=this._write(4+e.length);_(this.buf,e.length,t),this.buf.set(e,t+4)}_read(e){if(this.ptr+e>this.buf.length)throw Error(`Invalid packet`);return this.ptr+=e,this.ptr-e}read8(){return this.buf[this._read(1)]}read32(){return g(this.buf,this._read(4))}read(){let e=this.read32(),t=new Uint8Array(e),n=this._read(t.length);return t.set(this.buf.subarray(n,n+e)),t}},p,m,h;if(typeof TextEncoder<`u`&&typeof TextDecoder<`u`){let e=new TextEncoder,t=new TextDecoder;p=t=>e.encode(t),m=e=>t.decode(e),h=`new TextEncoder().encode("")`}else if(typeof Buffer<`u`)p=e=>Buffer.from(e),m=e=>{let{buffer:t,byteOffset:n,byteLength:r}=e;return Buffer.from(t,n,r).toString()},h=`Buffer.from("")`;else throw Error(`No UTF-8 codec found`);if(!(p(``)instanceof Uint8Array))throw Error(`Invariant violation: "${h} instanceof Uint8Array" is incorrectly false
|
|
2
2
|
|
|
3
3
|
This indicates that your JavaScript environment is broken. You cannot use
|
|
4
4
|
esbuild in this environment because esbuild relies on this invariant. This
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./site-Bq_qZN66.js";await t();var n=new Set(e()),r=!1;addEventListener(`message`,e=>{e.source!==window.parent||r||e.data?.kind===`playground-exec`&&e.ports[0]&&(n.has(e.origin)?(r=!0,new Worker(new URL(new URL(`host-
|
|
1
|
+
import{n as e,t}from"./site-Bq_qZN66.js";await t();var n=new Set(e()),r=!1;addEventListener(`message`,e=>{e.source!==window.parent||r||e.data?.kind===`playground-exec`&&e.ports[0]&&(n.has(e.origin)?(r=!0,new Worker(new URL(new URL(`host-f4apmOAk.js`,import.meta.url).href,``+import.meta.url),{type:`module`,name:`playground-exec`}).postMessage({kind:`playground-exec`},[e.ports[0]]),window.parent.postMessage({kind:`playground-exec-started`},e.origin)):window.parent.postMessage({kind:`playground-exec-refused`},e.origin))}),window.parent.postMessage({kind:`playground-exec-loaded`,isolated:crossOriginIsolated},`*`);
|
|
@@ -9,8 +9,8 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
9
9
|
`),o=i<0?/* @__PURE__ */ new Uint8Array:e.slice(i+4),[,s,c]=a[0].match(/^HTTP\/1\.[01] (\d+) ?(.*)$/)||[null,`502`,`Bad Gateway`],l=[];for(let e of a.slice(1)){let r=e.indexOf(`:`);if(r<0)continue;let i=e.slice(0,r).trim().toLowerCase(),a=e.slice(r+1).trim();if(i===`set-cookie`&&this.remember(a,n),i===`location`){let e=a.match(/^http:\/\/(?:localhost|127\.0\.0\.1)(?::(\d+))?(\/.*)?$/);if(e){let n=Number(e[1]??80),r=e[2]??`/`;l.push([i,n===t?r:this.elsewhere(n,r)]);continue}}this.origins&&i===`x-frame-options`&&/^sameorigin$/i.test(a)||(this.origins&&i===`content-security-policy`?l.push([i,a.replace(/frame-ancestors([^;]*)/i,(e,t)=>/'none'/.test(t)?e:`${e} ${this.ide}`)]):l.push([i,a]))}l.some(([e,t])=>e===`transfer-encoding`&&/chunked/i.test(t))&&(o=y(o));let u=l.findIndex(([e,t])=>e===`content-encoding`&&t===`gzip`);if(u>=0){let e=new Blob([o]).stream().pipeThrough(new DecompressionStream(`gzip`));o=new Uint8Array(await new Response(e).arrayBuffer()),l.splice(u,1)}let d=l.find(([e])=>e===`content-type`)?.[1]??``;if(r&&d.startsWith(`text/html`)){let e=new TextDecoder().decode(o),n=e.search(/<head[^>]*>/i),r=_(t,this.origins,this.ide),i=n<0?r+e:e.replace(/<head[^>]*>/i,e=>e+r);o=new TextEncoder().encode(i)}return{status:Number(s),reason:c,headers:l,body:o,cookies:n}}elsewhere(e,t){return this.origins?this.origins.replace(`{port}`,String(e))+t:`/__playground/port/${e}${t}`}remember(e,t){let[n,...r]=e.split(`;`),i=n.indexOf(`=`),a=n.slice(0,i).trim(),o=n.slice(i+1).trim(),s=r.map(e=>e.trim().split(`=`)[0].toLowerCase()),c=r.some(e=>{let[t,n]=e.trim().split(`=`);return t.toLowerCase()===`max-age`&&Number(n)<=0||t.toLowerCase()===`expires`&&Date.parse(n)<Date.now()});if(s.includes(`httponly`)||typeof document>`u`&&!t){c?this.cookies.delete(a):this.cookies.set(a,o);let e=r.map(e=>e.trim()).find(e=>/^path=/i.test(e))??`path=/`;t?t.push(`${a}=; ${e}; max-age=0`):typeof document<`u`&&x(a)&&(document.cookie=`${a}=; ${e}; max-age=0`);return}this.cookies.delete(a);let l=r.map(e=>e.trim()).filter(e=>!/^(secure|samesite|domain)/i.test(e)),u=[`${a}=${o}`,...l,...c?[`max-age=0`]:[]].join(`; `);t?t.push(u):document.cookie=u}};function x(e){return document.cookie.split(`;`).some(t=>t.split(`=`)[0].trim()===e)}var S=/* @__PURE__ */ o(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||
|
|
10
10
|
/* istanbul ignore next */9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),C=/* @__PURE__ */ o(((e,t)=>{t.exports=typeof process==`object`&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),ee=/* @__PURE__ */ o(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=S(),a=C();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),te=/* @__PURE__ */ o(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),ne=/* @__PURE__ */ o(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),w=/* @__PURE__ */ o(((e,t)=>{let n=C(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=S(),{safeRe:a,t:o}=ee(),s=te(),{compareIdentifiers:c}=ne();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);this.prerelease=l[4]?l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),re=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),ie=/* @__PURE__ */ o(((e,t)=>{let n=re();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),ae=/* @__PURE__ */ o(((e,t)=>{let n=re();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),oe=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),se=/* @__PURE__ */ o(((e,t)=>{let n=re();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),ce=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t)=>new n(e,t).major})),le=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t)=>new n(e,t).minor})),ue=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t)=>new n(e,t).patch})),de=/* @__PURE__ */ o(((e,t)=>{let n=re();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),fe=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),pe=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(t,e,r)})),me=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t)=>n(e,t,!0)})),he=/* @__PURE__ */ o(((e,t)=>{let n=w();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),ge=/* @__PURE__ */ o(((e,t)=>{let n=he();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),_e=/* @__PURE__ */ o(((e,t)=>{let n=he();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),ve=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(e,t,r)>0})),ye=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(e,t,r)<0})),be=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(e,t,r)===0})),xe=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(e,t,r)!==0})),Se=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(e,t,r)>=0})),Ce=/* @__PURE__ */ o(((e,t)=>{let n=fe();t.exports=(e,t,r)=>n(e,t,r)<=0})),we=/* @__PURE__ */ o(((e,t)=>{let n=be(),r=xe(),i=ve(),a=Se(),o=ye(),s=Ce();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Te=/* @__PURE__ */ o(((e,t)=>{let n=w(),r=re(),{safeRe:i,t:a}=ee();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2],c=o[3]||`0`,l=o[4]||`0`,u=t.includePrerelease&&o[5]?`-${o[5]}`:``,d=t.includePrerelease&&o[6]?`+${o[6]}`:``;return r(`${s}.${c}.${l}${u}${d}`,t)}})),Ee=/* @__PURE__ */ o(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=/* @__PURE__ */ new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),De=/* @__PURE__ */ o(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,ce(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>se(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=/* @__PURE__ */ new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(le(this.set[t],e,this.options))return!0;return!1}};let r=new(Ee()),i=te(),a=Oe(),o=C(),s=w(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=ee(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=S(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=ne(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=ie(e,t),o(`xrange`,e),e=oe(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},ne=(e,t)=>e.trim().split(/\s+/).map(e=>re(e,t)).join(` `),re=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},ie=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>ae(e,t)).join(` `)),ae=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},oe=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),se=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),ce=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),le=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Oe=/* @__PURE__ */ o(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.value=this.semver===n?``:this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),this.semver=r[2]?new c(r[2],this.options.loose):n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``||new l(t.value,n).test(this.value):t.operator===``?t.value===``||new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=te(),{safeRe:i,t:a}=ee(),o=we(),s=C(),c=w(),l=De()})),ke=/* @__PURE__ */ o(((e,t)=>{let n=De();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Ae=/* @__PURE__ */ o(((e,t)=>{let n=De();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),je=/* @__PURE__ */ o(((e,t)=>{let n=w(),r=De();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Me=/* @__PURE__ */ o(((e,t)=>{let n=w(),r=De();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Ne=/* @__PURE__ */ o(((e,t)=>{let n=w(),r=De(),i=ve();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;
|
|
11
11
|
/* istanbul ignore next */
|
|
12
|
-
default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),Pe=/* @__PURE__ */ o(((e,t)=>{let n=De();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Fe=/* @__PURE__ */ o(((e,t)=>{let n=w(),r=Oe(),{ANY:i}=r,a=De(),o=ke(),s=ve(),c=ye(),l=Ce(),u=Se();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),Ie=/* @__PURE__ */ o(((e,t)=>{let n=Fe();t.exports=(e,t,r)=>n(e,t,`>`,r)})),Le=/* @__PURE__ */ o(((e,t)=>{let n=Fe();t.exports=(e,t,r)=>n(e,t,`<`,r)})),Re=/* @__PURE__ */ o(((e,t)=>{let n=De();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),ze=/* @__PURE__ */ o(((e,t)=>{let n=ke(),r=fe();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),Be=/* @__PURE__ */ o(((e,t)=>{let n=De(),r=Oe(),{ANY:i}=r,a=ke(),o=fe(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=/* @__PURE__ */ new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),T=(/* @__PURE__ */ o(((e,t)=>{let n=ee(),r=S(),i=w(),a=ne();t.exports={parse:re(),valid:ie(),clean:ae(),inc:oe(),diff:se(),major:ce(),minor:le(),patch:ue(),prerelease:de(),compare:fe(),rcompare:pe(),compareLoose:me(),compareBuild:he(),sort:ge(),rsort:_e(),gt:ve(),lt:ye(),eq:be(),neq:xe(),gte:Se(),lte:Ce(),cmp:we(),coerce:Te(),Comparator:Oe(),Range:De(),satisfies:ke(),toComparators:Ae(),maxSatisfying:je(),minSatisfying:Me(),minVersion:Ne(),validRange:Pe(),outside:Fe(),gtr:Ie(),ltr:Le(),intersects:Re(),simplifyRange:ze(),subset:Be(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}})))(),Ve={name:`@elixir-playground/runtime`,version:`1.
|
|
13
|
-
`))}tls(){let e=this.find(`tls`);return e?{module:this.file(e.name,e.value.module).href,roots:this.file(e.name,e.value.roots).href}:null}tailscale(){let e=this.find(`tailscale`);if(!e)return null;let{module:t,glue:n}=e.value;return{module:this.file(e.name,t),glue:this.file(e.name,n)}}versions(){let e=this.find(`otp`)?.value,t=this.find(`elixir`)?.value;return e&&t?{otp:e,elixir:t}:null}template(e){for(let t of Object.values(this.manifest.packages)){let n=t.playground.template,r=t.playground.fs?.root;if(n?.kind===e&&r)return{id:n.id,label:n.label,root:r}}return null}};const Ue=(e,t)=>`${e.replace(/^\/+/,``)}/${t}`,We=(e,t)=>t===`.`||t===``?e:`${e.replace(/\/+$/,``)}/${t}`;async function Ge(e){let t=await fetch(e);if(!t.ok)throw Error(`${e}: ${t.status}`);return await t.json()}function Ke(e){let t=14695981039346656037n;for(let n of new TextEncoder().encode(e))t=BigInt.asUintN(64,(t^BigInt(n))*1099511628211n);return t.toString(16).padStart(16,`0`)}const qe=Ve,Je=e=>(0,T.coerce)(e)?.version??e,Ye=(e,t)=>(0,T.validRange)(t)!==null&&(0,T.satisfies)(Je(e),t);function Xe(e,t=qe){let n=[];if(!t.provides.manifest?.includes(e.manifest))return[`site.json is manifest ${e.manifest}; this runtime reads ${t.provides.manifest}`];let r=n=>n===t.name?t.version:e.packages[n]?.version,i=Object.entries(e.packages);for(let[e,a]of i){let i=`${e}@${a.version}`;for(let[e,t]of Object.entries(a.peerDependencies??{})){let a=r(e);a===void 0?n.push(`${i} needs ${e} ${t}, which is missing`):Ye(a,t)||n.push(`${i} needs ${e} ${t}, not ${a}`)}for(let[e,r]of Object.entries(a.playground.abi??{})){let a=t.provides[e]??[];a.includes(r)||n.push(`${i} uses the ${e} ABI ${r}; ${t.name}@${t.version} `+(a.length?`speaks ${a.join(`, `)}`:`has none`))}}let a=e=>{let t=i.filter(([,t])=>t.playground[e]!==void 0);return t.length>1&&n.push(`more than one ${e} package: ${t.map(([e])=>e).join(`, `)}`),t[0]?.[1]??null},o=a(`otp`),s=a(`elixir`),c=s?.playground.requires?.otp;o&&c&&!Ye(o.playground.otp,c)&&n.push(`Elixir ${s.playground.elixir} needs OTP ${c}, not ${o.playground.otp}`);for(let[e,t]of i){let r=t.playground.template;r&&(o&&r.otp!==o.playground.otp&&n.push(`${e} was compiled with OTP ${r.otp}, not ${o.playground.otp}`),s&&r.elixir!==s.playground.elixir&&n.push(`${e} was compiled with Elixir ${r.elixir}, not ${s.playground.elixir}`))}for(let[e,r]of i){let i=r.playground.fs;i&&(t.provides.fs?.includes(i.format)||n.push(`${e}@${r.version}'s files are fs format ${i.format}; this runtime reads ${t.provides.fs}`),(!/^\/[^/]/.test(i.root)||/\/$|\/\.\.?(\/|$)/.test(i.root))&&n.push(`${e}@${r.version}'s files have no absolute root: ${i.root}`))}for(let[t,i]of Object.entries(e.boot?.packages??{}))r(t)!==i&&n.push(`the boot images were recorded with ${t}@${i}, not ${r(t)??`none`}`);let l=o?.playground.nifAbi;if(l){let e=Number(l.split(`-`)[0]);t.provides.nif?.includes(e)||n.push(`OTP's NIF ABI is ${l}; ${t.name}@${t.version} loads layer ${t.provides.nif?.join(`, `)||`none`}`)}return n}function Ze(e,t=qe){let n=Xe(e,t);if(n.length)throw Object.assign(/* @__PURE__ */ Error(`this site's packages do not fit @elixir-playground/runtime@${t.version}: ${n.join(`; `)}`),{code:`ERUNTIME`})}function Qe(e,t){let n=new TextEncoder;e.onmessage=({data:e,ports:r})=>{let i=t();if(e?.kind===`http`){if(!i){let e=n.encode(`The project is not running.`);r[0].postMessage({status:503,reason:`Service Unavailable`,headers:[[`content-type`,`text/plain`]],body:e},[e.buffer]);return}i.request(e).then(e=>r[0].postMessage(e,[e.body.buffer]))}else e?.kind===`websocket`&&(i?i.websocket(e,r[0]):r[0].postMessage({close:{code:1006,reason:``,clean:!1}}))}}const $e=4369;var et=class{nodes=/* @__PURE__ */ new Map;creation=Math.floor(Math.random()*2147483647)+1};function tt(e,t,n){let r=/* @__PURE__ */ new Uint8Array,i=null,a=new TextDecoder,o=new TextEncoder,s=r=>{let s=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r[0]===120&&i===null){let o=s.getUint16(9),c=a.decode(r.subarray(11,11+o)),l=s.getUint16(11+o),u=/* @__PURE__ */ new Uint8Array(6);u[0]=118,e.nodes.has(c)?u[1]=1:(i=c,e.nodes.set(c,{port:s.getUint16(1),type:r[3],protocol:r[4],highest:s.getUint16(5),lowest:s.getUint16(7),extra:r.slice(13+o,13+o+l)}),e.creation=e.creation%4294967295+1,new DataView(u.buffer).setUint32(2,e.creation)),t(u),u[1]&&n()}else if(r[0]===122){let i=a.decode(r.subarray(1)),s=e.nodes.get(i);if(!s)t(new Uint8Array([119,1]));else{let e=o.encode(i),n=new Uint8Array(14+e.length+s.extra.length),r=new DataView(n.buffer);n[0]=119,r.setUint16(2,s.port),n[4]=s.type,n[5]=s.protocol,r.setUint16(6,s.highest),r.setUint16(8,s.lowest),r.setUint16(10,e.length),n.set(e,12),r.setUint16(12+e.length,s.extra.length),n.set(s.extra,14+e.length),t(n)}n()}else if(r[0]===110){let r=[...e.nodes].map(([e,t])=>`name ${e} at port ${t.port}\n`),i=o.encode(r.join(``)),a=new Uint8Array(4+i.length);new DataView(a.buffer).setUint32(0,$e),a.set(i,4),t(a),n()}else n()};return{data(e){let t=new Uint8Array(r.length+e.length);for(t.set(r),t.set(e,r.length),r=t;r.length>=2;){let e=r[0]<<8|r[1];if(r.length<2+e)break;let t=r.slice(2,2+e);r=r.subarray(2+e),s(t)}},closed(){i!==null&&e.nodes.delete(i),i=null}}}function nt(e){return t=>{let n=tt(e,e=>t.write(e),()=>{n.closed(),t.close()});t.ondata=e=>n.data(e),t.onend=()=>{n.closed(),t.close()},t.onclose=()=>n.closed()}}function rt(e,t){let n=new URL(e,new URL(t,location.href)).href,r=new Blob([`import ${JSON.stringify(n)};`],{type:`text/javascript`});return new Worker(URL.createObjectURL(r),{type:`module`})}var it=class{doorbell;requests;next;worker;ready;boot=null;archived=[];constructor({base:e=`./`,site:t=null,boots:n=[`boot`],template:r=[],archive:i=null,store:a=null,storePort:o=null,sharedPort:s=null,onchange:c=e=>{},onkept:l=e=>{},onwarning:u=e=>{}}={}){this.doorbell=new SharedArrayBuffer(4),this.requests=/* @__PURE__ */ new Map,this.next=0,this.worker=rt(`files.js`,e),this.ready=new Promise((e,t)=>{this.worker.onmessage=({data:n})=>{if(n.kind===`ready`)this.boot=n.boot,this.archived=n.archived??[],e();else if(n.kind===`failed`)t(Error(n.message));else if(n.kind===`changed`)c(n.paths);else if(n.kind===`warning`)u(n.message);else if(n.kind===`kept`)l(n.records);else if(n.kind===`reply`){let e=this.requests.get(n.id);this.requests.delete(n.id),n.error?e?.reject(Object.assign(Error(n.error),{code:n.code})):e?.resolve(n)}}}),this.worker.postMessage({kind:`start`,site:t,doorbell:this.doorbell,boots:n,template:r,archive:i,store:a,storePort:o,sharedPort:s},[o,s].filter(e=>e!==null))}hideShared(e){return this.ask({op:`hide-shared`,hide:e}).then(()=>{})}apply(e){let t=e.flatMap(e=>e.kind===`file`?[e.data.buffer]:[]);this.worker.postMessage({kind:`apply`,records:e},t)}connect(){let e=new SharedArrayBuffer(1048584);return this.worker.postMessage({kind:`connect`,channel:e}),{doorbell:this.doorbell,channel:e}}disconnect({channel:e}){this.worker.postMessage({kind:`disconnect`,channel:e})}ask(e){return new Promise((t,n)=>{let r=++this.next;this.requests.set(r,{resolve:t,reject:n}),this.worker.postMessage({kind:`request`,id:r,...e})})}list(e,t=[]){return this.ask({op:`list`,path:e,skip:t}).then(e=>e.entries)}stat(e){return this.ask({op:`stat`,path:e}).then(e=>e.type)}lstat(e){return this.ask({op:`lstat`,path:e})}readdir(e){return this.ask({op:`readdir`,path:e}).then(e=>e.names)}unlink(e){return this.ask({op:`unlink`,path:e}).then(()=>{})}rmdir(e){return this.ask({op:`rmdir`,path:e}).then(()=>{})}read(e){return this.ask({op:`read`,path:e}).then(e=>e.data)}write(e,t){return this.ask({op:`write`,path:e,data:typeof t==`string`?new TextEncoder().encode(t):t}).then(()=>{})}mkdir(e){return this.ask({op:`mkdir`,path:e}).then(()=>{})}remove(e){return this.ask({op:`remove`,path:e}).then(()=>{})}rename(e,t){return this.ask({op:`rename`,path:e,to:t}).then(()=>{})}symlink(e,t){return this.ask({op:`symlink`,path:t,target:e}).then(()=>{})}changes(e=[]){return this.ask({op:`changes`,skip:e}).then(({changed:e,removed:t})=>({changed:e,removed:t}))}search(e,t,n=[],r=1e3){return this.ask({op:`search`,path:e,query:t,skip:n,limit:r}).then(({hits:e,truncated:t,error:n})=>({hits:e,truncated:t,error:n}))}flush(){return this.ask({op:`flush`}).then(()=>{})}};const at=new TextEncoder;var ot=class{worker;files;channel;pending=/* @__PURE__ */ new Map;next=0;ready;constructor({base:e,site:t,files:n}){this.files=n,this.channel=n.connect(),this.worker=rt(`git.js`,e),this.worker.onmessage=({data:e})=>{this.pending.get(e.id)?.(e),this.pending.delete(e.id)};let{channel:r,worker:i}=this;this.ready=(async()=>{let e=new He(t).programs().get(`git`);if(!e)return!1;let n=await fetch(e.url),a=new Uint8Array(await n.arrayBuffer());return!n.ok||a[0]!==0||a[1]!==97?!1:(i.postMessage({kind:`start`,files:r,git:await WebAssembly.compile(a)}),!0)})().catch(()=>!1)}async run(e,{cwd:t=`/work`,env:n={},stdin:r}={}){if(!await this.ready)return{code:127,stdout:/* @__PURE__ */ new Uint8Array,stderr:at.encode(`git: not found
|
|
12
|
+
default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),Pe=/* @__PURE__ */ o(((e,t)=>{let n=De();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Fe=/* @__PURE__ */ o(((e,t)=>{let n=w(),r=Oe(),{ANY:i}=r,a=De(),o=ke(),s=ve(),c=ye(),l=Ce(),u=Se();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),Ie=/* @__PURE__ */ o(((e,t)=>{let n=Fe();t.exports=(e,t,r)=>n(e,t,`>`,r)})),Le=/* @__PURE__ */ o(((e,t)=>{let n=Fe();t.exports=(e,t,r)=>n(e,t,`<`,r)})),Re=/* @__PURE__ */ o(((e,t)=>{let n=De();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),ze=/* @__PURE__ */ o(((e,t)=>{let n=ke(),r=fe();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),Be=/* @__PURE__ */ o(((e,t)=>{let n=De(),r=Oe(),{ANY:i}=r,a=ke(),o=fe(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=/* @__PURE__ */ new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),T=(/* @__PURE__ */ o(((e,t)=>{let n=ee(),r=S(),i=w(),a=ne();t.exports={parse:re(),valid:ie(),clean:ae(),inc:oe(),diff:se(),major:ce(),minor:le(),patch:ue(),prerelease:de(),compare:fe(),rcompare:pe(),compareLoose:me(),compareBuild:he(),sort:ge(),rsort:_e(),gt:ve(),lt:ye(),eq:be(),neq:xe(),gte:Se(),lte:Ce(),cmp:we(),coerce:Te(),Comparator:Oe(),Range:De(),satisfies:ke(),toComparators:Ae(),maxSatisfying:je(),minSatisfying:Me(),minVersion:Ne(),validRange:Pe(),outside:Fe(),gtr:Ie(),ltr:Le(),intersects:Re(),simplifyRange:ze(),subset:Be(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}})))(),Ve={name:`@elixir-playground/runtime`,version:`1.1.0`,provides:{manifest:[2],fs:[3],wasi:[1],processes:[1],crossterm:[1],beam:[1],tls:[1],tailscale:[1],nif:[1],claude:[1]}},He=class{manifest;url;constructor(e){this.manifest=e.manifest,this.url=new URL(e.url)}find(e){for(let[t,n]of Object.entries(this.manifest.packages)){let r=n.playground[e];if(r!=null)return{name:t,entry:n,value:r}}return null}file(e,t){let n=this.manifest.packages[e];if(!n)throw Error(`${e}: not on this site`);return new URL(t,new URL(n.base,this.url))}beam(){let e=this.find(`beam`);if(!e)return null;let{loader:t,wasm:n}=e.value;return{loader:this.file(e.name,t),wasm:this.file(e.name,n)}}shell(){let e=this.find(`shell`);return e?this.file(e.name,e.value):null}programs(){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(this.manifest.packages))for(let[r,{module:i,multicall:a=!1}]of Object.entries(n.playground.programs??{}))e.has(r)||e.set(r,{url:this.file(t,i),multicall:a});return e}multicall(){for(let{url:e,multicall:t}of this.programs().values())if(t)return e;return null}layers(){let e=[],t=0;for(let[n,r]of Object.entries(this.manifest.packages)){let i=r.playground.fs;i&&(e.push({name:n,layer:i,first:t}),t+=i.count)}return e}async tree(e=Ge){return(await Promise.all(this.layers().map(async({name:t,layer:n,first:r})=>(await e(this.file(t,n.manifest))).map(([e,t,i,a])=>a===void 0?[Ue(n.root,e),t,i]:[Ue(n.root,e),t,i,r+a])))).flat()}otp(){let e=this.find(`otp`),t=e?.entry.playground.fs?.root;return e&&t?{version:e.value,root:t}:null}elixir(){let e=this.find(`elixir`),t=e?.entry.playground.fs?.root;return e&&t?{version:e.value,root:t}:null}bin(){let e=/* @__PURE__ */ new Map;for(let t of Object.values(this.manifest.packages)){let n=t.playground.fs?.root;if(n)for(let[r,i]of Object.entries(t.playground.bin??{}))e.has(r)||e.set(r,We(n,i))}return e}environment(){let e={};for(let t of Object.values(this.manifest.packages)){let n=t.playground.fs?.root;if(n)for(let[r,i]of Object.entries(t.playground.env??{}))e[r]??=We(n,i)}return e}bundle(e){for(let{name:t,layer:n,first:r}of this.layers())if(e>=r&&e<r+n.count)return this.file(t,`${n.bundles}${e-r}.tar`);throw Error(`no bundle ${e} on this site`)}boot(e){let t=this.manifest.boot;if(!t?.images.includes(e))throw Error(`this site has no boot image ${e}`);return new URL(`${e}.tar.gz`,new URL(t.base,this.url))}boots(e){let t=this.manifest.boot?.images??[];return e?e.filter(e=>t.includes(e)):t}fsVersion(){return Ke(this.layers().map(({name:e,layer:t})=>`${e}@${t.version}`).sort().join(`
|
|
13
|
+
`))}tls(){let e=this.find(`tls`);return e?{module:this.file(e.name,e.value.module).href,roots:this.file(e.name,e.value.roots).href}:null}tailscale(){let e=this.find(`tailscale`);if(!e)return null;let{module:t,glue:n}=e.value;return{module:this.file(e.name,t),glue:this.file(e.name,n)}}versions(){let e=this.find(`otp`)?.value,t=this.find(`elixir`)?.value;return e&&t?{otp:e,elixir:t}:null}template(e){for(let t of Object.values(this.manifest.packages)){let n=t.playground.template,r=t.playground.fs?.root;if(n?.kind===e&&r)return{id:n.id,label:n.label,root:r}}return null}};const Ue=(e,t)=>`${e.replace(/^\/+/,``)}/${t}`,We=(e,t)=>t===`.`||t===``?e:`${e.replace(/\/+$/,``)}/${t}`;async function Ge(e){let t=await fetch(e);if(!t.ok)throw Error(`${e}: ${t.status}`);return await t.json()}function Ke(e){let t=14695981039346656037n;for(let n of new TextEncoder().encode(e))t=BigInt.asUintN(64,(t^BigInt(n))*1099511628211n);return t.toString(16).padStart(16,`0`)}const qe=Ve,Je=e=>(0,T.coerce)(e)?.version??e,Ye=(e,t)=>(0,T.validRange)(t)!==null&&(0,T.satisfies)(Je(e),t);function Xe(e,t=qe){let n=[];if(!t.provides.manifest?.includes(e.manifest))return[`site.json is manifest ${e.manifest}; this runtime reads ${t.provides.manifest}`];let r=n=>n===t.name?t.version:e.packages[n]?.version,i=Object.entries(e.packages);for(let[e,a]of i){let i=`${e}@${a.version}`;for(let[e,t]of Object.entries(a.peerDependencies??{})){let a=r(e);a===void 0?n.push(`${i} needs ${e} ${t}, which is missing`):Ye(a,t)||n.push(`${i} needs ${e} ${t}, not ${a}`)}for(let[e,r]of Object.entries(a.playground.abi??{})){let a=t.provides[e]??[];a.includes(r)||n.push(`${i} uses the ${e} ABI ${r}; ${t.name}@${t.version} `+(a.length?`speaks ${a.join(`, `)}`:`has none`))}}let a=e=>{let t=i.filter(([,t])=>t.playground[e]!==void 0);return t.length>1&&n.push(`more than one ${e} package: ${t.map(([e])=>e).join(`, `)}`),t[0]?.[1]??null},o=a(`otp`),s=a(`elixir`),c=s?.playground.requires?.otp;o&&c&&!Ye(o.playground.otp,c)&&n.push(`Elixir ${s.playground.elixir} needs OTP ${c}, not ${o.playground.otp}`);for(let[e,t]of i){let r=t.playground.template;r&&(o&&r.otp!==o.playground.otp&&n.push(`${e} was compiled with OTP ${r.otp}, not ${o.playground.otp}`),s&&r.elixir!==s.playground.elixir&&n.push(`${e} was compiled with Elixir ${r.elixir}, not ${s.playground.elixir}`))}for(let[e,r]of i){let i=r.playground.fs;i&&(t.provides.fs?.includes(i.format)||n.push(`${e}@${r.version}'s files are fs format ${i.format}; this runtime reads ${t.provides.fs}`),(!/^\/[^/]/.test(i.root)||/\/$|\/\.\.?(\/|$)/.test(i.root))&&n.push(`${e}@${r.version}'s files have no absolute root: ${i.root}`))}for(let[t,i]of Object.entries(e.boot?.packages??{}))r(t)!==i&&n.push(`the boot images were recorded with ${t}@${i}, not ${r(t)??`none`}`);for(let[t,r]of Object.entries(e.boot?.layers??{})){let i=e.packages[t]?.playground.fs;i&&i.version!==r&&n.push(`the boot images were recorded with ${t}'s files ${r}, not ${i.version}`)}let l=o?.playground.nifAbi;if(l){let e=Number(l.split(`-`)[0]);t.provides.nif?.includes(e)||n.push(`OTP's NIF ABI is ${l}; ${t.name}@${t.version} loads layer ${t.provides.nif?.join(`, `)||`none`}`)}return n}function Ze(e,t=qe){let n=Xe(e,t);if(n.length)throw Object.assign(/* @__PURE__ */ Error(`this site's packages do not fit @elixir-playground/runtime@${t.version}: ${n.join(`; `)}`),{code:`ERUNTIME`})}function Qe(e,t){let n=new TextEncoder;e.onmessage=({data:e,ports:r})=>{let i=t();if(e?.kind===`http`){if(!i){let e=n.encode(`The project is not running.`);r[0].postMessage({status:503,reason:`Service Unavailable`,headers:[[`content-type`,`text/plain`]],body:e},[e.buffer]);return}i.request(e).then(e=>r[0].postMessage(e,[e.body.buffer]))}else e?.kind===`websocket`&&(i?i.websocket(e,r[0]):r[0].postMessage({close:{code:1006,reason:``,clean:!1}}))}}const $e=4369;var et=class{nodes=/* @__PURE__ */ new Map;creation=Math.floor(Math.random()*2147483647)+1};function tt(e,t,n){let r=/* @__PURE__ */ new Uint8Array,i=null,a=new TextDecoder,o=new TextEncoder,s=r=>{let s=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r[0]===120&&i===null){let o=s.getUint16(9),c=a.decode(r.subarray(11,11+o)),l=s.getUint16(11+o),u=/* @__PURE__ */ new Uint8Array(6);u[0]=118,e.nodes.has(c)?u[1]=1:(i=c,e.nodes.set(c,{port:s.getUint16(1),type:r[3],protocol:r[4],highest:s.getUint16(5),lowest:s.getUint16(7),extra:r.slice(13+o,13+o+l)}),e.creation=e.creation%4294967295+1,new DataView(u.buffer).setUint32(2,e.creation)),t(u),u[1]&&n()}else if(r[0]===122){let i=a.decode(r.subarray(1)),s=e.nodes.get(i);if(!s)t(new Uint8Array([119,1]));else{let e=o.encode(i),n=new Uint8Array(14+e.length+s.extra.length),r=new DataView(n.buffer);n[0]=119,r.setUint16(2,s.port),n[4]=s.type,n[5]=s.protocol,r.setUint16(6,s.highest),r.setUint16(8,s.lowest),r.setUint16(10,e.length),n.set(e,12),r.setUint16(12+e.length,s.extra.length),n.set(s.extra,14+e.length),t(n)}n()}else if(r[0]===110){let r=[...e.nodes].map(([e,t])=>`name ${e} at port ${t.port}\n`),i=o.encode(r.join(``)),a=new Uint8Array(4+i.length);new DataView(a.buffer).setUint32(0,$e),a.set(i,4),t(a),n()}else n()};return{data(e){let t=new Uint8Array(r.length+e.length);for(t.set(r),t.set(e,r.length),r=t;r.length>=2;){let e=r[0]<<8|r[1];if(r.length<2+e)break;let t=r.slice(2,2+e);r=r.subarray(2+e),s(t)}},closed(){i!==null&&e.nodes.delete(i),i=null}}}function nt(e){return t=>{let n=tt(e,e=>t.write(e),()=>{n.closed(),t.close()});t.ondata=e=>n.data(e),t.onend=()=>{n.closed(),t.close()},t.onclose=()=>n.closed()}}function rt(e,t){let n=new URL(e,new URL(t,location.href)).href,r=new Blob([`import ${JSON.stringify(n)};`],{type:`text/javascript`});return new Worker(URL.createObjectURL(r),{type:`module`})}var it=class{doorbell;requests;next;worker;ready;boot=null;archived=[];constructor({base:e=`./`,site:t=null,boots:n=[`boot`],template:r=[],archive:i=null,store:a=null,storePort:o=null,sharedPort:s=null,onchange:c=e=>{},onkept:l=e=>{},onwarning:u=e=>{}}={}){this.doorbell=new SharedArrayBuffer(4),this.requests=/* @__PURE__ */ new Map,this.next=0,this.worker=rt(`files.js`,e),this.ready=new Promise((e,t)=>{this.worker.onmessage=({data:n})=>{if(n.kind===`ready`)this.boot=n.boot,this.archived=n.archived??[],e();else if(n.kind===`failed`)t(Error(n.message));else if(n.kind===`changed`)c(n.paths);else if(n.kind===`warning`)u(n.message);else if(n.kind===`kept`)l(n.records);else if(n.kind===`reply`){let e=this.requests.get(n.id);this.requests.delete(n.id),n.error?e?.reject(Object.assign(Error(n.error),{code:n.code})):e?.resolve(n)}}}),this.worker.postMessage({kind:`start`,site:t,doorbell:this.doorbell,boots:n,template:r,archive:i,store:a,storePort:o,sharedPort:s},[o,s].filter(e=>e!==null))}hideShared(e){return this.ask({op:`hide-shared`,hide:e}).then(()=>{})}apply(e){let t=e.flatMap(e=>e.kind===`file`?[e.data.buffer]:[]);this.worker.postMessage({kind:`apply`,records:e},t)}connect(){let e=new SharedArrayBuffer(1048584);return this.worker.postMessage({kind:`connect`,channel:e}),{doorbell:this.doorbell,channel:e}}disconnect({channel:e}){this.worker.postMessage({kind:`disconnect`,channel:e})}ask(e){return new Promise((t,n)=>{let r=++this.next;this.requests.set(r,{resolve:t,reject:n}),this.worker.postMessage({kind:`request`,id:r,...e})})}list(e,t=[]){return this.ask({op:`list`,path:e,skip:t}).then(e=>e.entries)}stat(e){return this.ask({op:`stat`,path:e}).then(e=>e.type)}lstat(e){return this.ask({op:`lstat`,path:e})}readdir(e){return this.ask({op:`readdir`,path:e}).then(e=>e.names)}unlink(e){return this.ask({op:`unlink`,path:e}).then(()=>{})}rmdir(e){return this.ask({op:`rmdir`,path:e}).then(()=>{})}read(e){return this.ask({op:`read`,path:e}).then(e=>e.data)}write(e,t){return this.ask({op:`write`,path:e,data:typeof t==`string`?new TextEncoder().encode(t):t}).then(()=>{})}mkdir(e){return this.ask({op:`mkdir`,path:e}).then(()=>{})}remove(e){return this.ask({op:`remove`,path:e}).then(()=>{})}rename(e,t){return this.ask({op:`rename`,path:e,to:t}).then(()=>{})}symlink(e,t){return this.ask({op:`symlink`,path:t,target:e}).then(()=>{})}changes(e=[]){return this.ask({op:`changes`,skip:e}).then(({changed:e,removed:t})=>({changed:e,removed:t}))}search(e,t,n=[],r=1e3){return this.ask({op:`search`,path:e,query:t,skip:n,limit:r}).then(({hits:e,truncated:t,error:n})=>({hits:e,truncated:t,error:n}))}flush(){return this.ask({op:`flush`}).then(()=>{})}};const at=new TextEncoder;var ot=class{worker;files;channel;pending=/* @__PURE__ */ new Map;next=0;ready;constructor({base:e,site:t,files:n}){this.files=n,this.channel=n.connect(),this.worker=rt(`git.js`,e),this.worker.onmessage=({data:e})=>{this.pending.get(e.id)?.(e),this.pending.delete(e.id)};let{channel:r,worker:i}=this;this.ready=(async()=>{let e=new He(t).programs().get(`git`);if(!e)return!1;let n=await fetch(e.url),a=new Uint8Array(await n.arrayBuffer());return!n.ok||a[0]!==0||a[1]!==97?!1:(i.postMessage({kind:`start`,files:r,git:await WebAssembly.compile(a)}),!0)})().catch(()=>!1)}async run(e,{cwd:t=`/work`,env:n={},stdin:r}={}){if(!await this.ready)return{code:127,stdout:/* @__PURE__ */ new Uint8Array,stderr:at.encode(`git: not found
|
|
14
14
|
`)};let i=++this.next,a=typeof r==`string`?at.encode(r):r??null;return new Promise(r=>{this.pending.set(i,({code:e,stdout:t,stderr:n})=>r({code:e,stdout:t,stderr:n})),this.worker.postMessage({kind:`run`,id:i,args:e,cwd:t,env:n,stdin:a})})}stop(){this.worker.terminate(),this.files.disconnect(this.channel);let e=at.encode(`git: stopped
|
|
15
15
|
`);for(let t of this.pending.values())t({id:0,code:1,stdout:/* @__PURE__ */ new Uint8Array,stderr:e});this.pending.clear()}};function*st(e){let t=(t,n)=>{let r=t;for(;r<t+n&&e[r]!==0;)r++;return new TextDecoder().decode(e.subarray(t,r))},n=null,r=null;for(let i=0;i+512<=e.length&&e[i]!==0;){let a=t(i,100),o=t(i+345,155);o&&(a=`${o}/${a}`),n!==null&&(a=n,n=null);let s=parseInt(t(i+124,12).trim()||`0`,8),c=BigInt(parseInt(t(i+136,12).trim()||`0`,8))*1000000000n,l=String.fromCharCode(e[i+156]||48),u=t(i+157,100);r!==null&&l!==`K`&&l!==`L`&&l!==`x`&&(u=r,r=null);let d=i+512;if(l===`L`)n=t(d,s);else if(l===`K`)r=t(d,s);else if(l===`x`){let t=e.subarray(d,d+s);n=ct(t,`path`),r=ct(t,`linkpath`)}else l!==`g`&&(yield{name:a,type:l,body:e.slice(d,d+s),mtime:c,link:u});i=d+Math.ceil(s/512)*512}}function ct(e,t){let n=new TextDecoder;for(let r=0;r<e.length;){let i=e.indexOf(32,r);if(i<0)break;let a=parseInt(n.decode(e.subarray(r,i)),10);if(!(a>0))break;let o=n.decode(e.subarray(i+1,r+a-1));if(o.startsWith(`${t}=`))return o.slice(t.length+1);r+=a}return null}async function lt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}Ve.provides.nif,49152+Math.floor(Math.random()*16384);function ut(e){if(!e.includes(`:`))return e.startsWith(`127.`)||e===`0.0.0.0`;let t=e.split(`:`).map(e=>parseInt(e,16)||0);return t.length===8&&t.slice(0,7).every(e=>e===0)?t[7]<=1:t.length===8&&t.slice(0,5).every(e=>e===0)&&t[5]===65535&&t[6]>>8==127}const dt=e=>/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`;new TextEncoder;const ft={HOME:`/home/user`,LANG:`C.UTF-8`,TERM:`xterm-256color`,PATH:`/usr/bin:/home/user/.mix/escripts`,MIX_HOME:`/home/user/.mix`,TARGET_ARCH:`wasm32`,TARGET_OS:`unknown`,TARGET_ABI:`wasi`},pt=e=>({...ft,...e.environment()}),mt={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGKILL:9,SIGTERM:15},ht=Object.fromEntries(Object.entries(mt).map(([e,t])=>[t,e])),gt=/^\x1b\[\d+;\d+R$/;function _t(e,t,n=[]){let r=``,i=0,a=n.filter(e=>e.trim()),o=a.length,s=!1,c=!0,l=(t,n=t.length)=>{let a=0;for(;a<r.length&&a<t.length&&r[a]===t[a];)a++;let o=i>a?`\b`.repeat(i-a):r.slice(i,a),s=t.slice(a)+` `.repeat(Math.max(0,r.length-t.length));e(o+s+`\b`.repeat(a+s.length-n)),r=t,i=n},u=e=>{e.trim()&&a.push(e),o=a.length,t.input(e+`
|
|
16
16
|
`)};return{keys:n=>{if(s)n===``&&c?(e(`^C`),t.interrupt()):t.input(n);else if(n===`\r`)e(`\r
|
|
@@ -29,7 +29,7 @@ default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(
|
|
|
29
29
|
`),[n,r]=t[0].split(` `),i=[];for(let e of t.slice(1)){let t=e.indexOf(`:`);t>0&&i.push([e.slice(0,t).trim().toLowerCase(),e.slice(t+1).trim()])}let o=e=>i.find(([t])=>t===e)?.[1],s=a.subarray(e+4),c,l;if(o(`transfer-encoding`)?.toLowerCase().includes(`chunked`)){let t=It(s);if(!t)return null;c=t.body,l=e+4+t.used}else{let t=o(`content-length`)??`0`;if(!/^\d+$/.test(t))throw Error(`a malformed Content-Length`);let n=Number(t);if(s.length<n)return null;c=s.slice(0,n),l=e+4+n}return{method:n,target:r,headers:i,header:o,body:c,used:l}},u=async()=>{if(o||c)return;let d;try{d=l()}catch(e){return c=!0,zt(n,400,`Bad Request`,`playground: ${e.message}\n`)}if(!d){s&&(c=!0,n.end());return}o=!0,a=a.slice(d.used);let{method:f,target:p,headers:m,header:h,body:g}=d,_=h(`connection`)?.toLowerCase()===`close`,v=p.replace(/^https?:\/\/[^/]+/,``),y=`https://${r}${i===443?``:`:${i}`}${v}`;e(f,y);for(let[e,t]of At[r.toLowerCase()]??[])h(e)||m.push([e,t]);let b;try{b=await fetch(y,{method:f,headers:m.filter(([e])=>!jt.has(e)),body:[`GET`,`HEAD`].includes(f)?void 0:g,credentials:`omit`,redirect:`follow`})}catch(e){return t(y),c=!0,zt(n,502,`Bad Gateway`,`playground: ${f} ${y} failed in the browser (${e.message}); the site may not allow cross-origin requests
|
|
30
30
|
`)}let x=f===`HEAD`||[204,304].includes(b.status),S=[];b.headers.forEach((e,t)=>{(!Mt.has(t)||x&&t===`content-length`)&&S.push([t,e])});let C=x||!b.body;if(Lt(n,b.status,b.statusText||Nt[b.status]||`unknown`,S,!C,_),!C){try{let e=b.body.getReader();for(;;){let{done:t,value:r}=await e.read();if(t)break;Rt(n,r)}}catch{return c=!0,n.end()}n.write(Ot.encode(`0\r
|
|
31
31
|
\r
|
|
32
|
-
`))}if(o=!1,_)return c=!0,n.end();u()};n.ondata=e=>{c||(a=Ft(a,e),u())},n.onend=()=>{s=!0,u()}}}var Ut={comment:"The TCP relay's hosts (docs/relay.md): the backend's /relay connects only to these, on port 443, for a TLS client that names the same host. The page reads it too: `fetch` lists the hosts it reaches by its own fetch() (they send CORS headers), not by the relay. A host goes one way for all its paths (the TLS is the page's own, so the relay never sees them): api.anthropic.com's Messages API sends CORS headers, but Claude Code's /api/claude_code/settings there does not, nor the Messages API for a subscription's OAuth token.",port:443,hosts:[`github.com`,`*.github.com`,`*.githubusercontent.com`,`gitlab.com`,`codeberg.org`,`pushin.eu`,`api.anthropic.com`,`platform.claude.com`],fetch:[`api.github.com`,`raw.githubusercontent.com`]};const Wt=65536,Gt=new TextEncoder,Kt=new TextDecoder,qt=(e,t)=>(e=e.toLowerCase().replace(/\.$/,``),t.some(t=>t.startsWith(`*.`)?e.endsWith(t.slice(1)):e===t)),Jt=(e,t)=>t===Ut.port&&qt(e,Ut.hosts)&&!qt(e,Ut.fetch);function Yt(e){return e===`econnrefused`?`econnrefused`:/timeout|etimedout|idle/.test(e)?`etimedout`:e===`not_allowed`?`enetunreach`:`ehostunreach`}function Xt(e=()=>new WebSocket(Zt())){let t=null,n=null,r=null,i=1,a=/* @__PURE__ */ new Map,o=(e,n,r=/* @__PURE__ */ new Uint8Array)=>{let i=new Uint8Array(5+r.length);i[0]=e,new DataView(i.buffer).setUint32(1,n),i.set(r,5),t?.send(i)},s=(e,t)=>{let n=/* @__PURE__ */ new Uint8Array(4);new DataView(n.buffer).setUint32(0,t),o(7,e,n)};function c(e){a.delete(e),!(a.size||r)&&(r=setTimeout(()=>{r=null,!a.size&&(t?.close(),t=null,n=null)},3e4))}function l(e,t){for(;t.queue.length&&t.inflight+t.queue[0].length<=262144;){let n=t.queue.shift();t.inflight+=n.length,o(4,e,n)}t.ending&&!t.queue.length&&(t.ending=!1,o(5,e))}function u(e){let t=new Uint8Array(e);if(t.length<5)return;let n=t[0],r=new DataView(e).getUint32(1),i=t.subarray(5),o=a.get(r);if(o){if(n===2)o.opened=!0,o.open.resolve(o.tunnel);else if(n===4)o.tunnel.ondata(i.slice()),s(r,i.length);else if(n===7&&i.length===4)o.inflight-=new DataView(e).getUint32(5),l(r,o);else if(n===5)c(r),o.tunnel.onend(null);else if(n===3){c(r);let e=Kt.decode(i);o.opened?o.tunnel.onend(e):o.open.reject(Object.assign(Error(e),{code:Yt(e)}))}}}function d(){return n||=new Promise(r=>{let i=e();i.binaryType=`arraybuffer`,i.onopen=()=>{t=i,r(i)},i.onmessage=({data:e})=>{e instanceof ArrayBuffer&&u(e)},i.onerror=()=>{},i.onclose=()=>{r(null),t===i&&(t=null),n=null;for(let[e,t]of a)a.delete(e),t.opened?t.tunnel.onend(`closed`):t.open.resolve(null)}})}return async function(e,t){if(r&&clearTimeout(r),r=null,!await d())return null;let n=i++;return new Promise((r,i)=>{let s={opened:!1,open:{resolve:r,reject:i},inflight:0,queue:[],ending:!1,tunnel:{ondata:()=>{},onend:()=>{},write:e=>{if(a.has(n)){for(let t=0;t<e.length;t+=Wt)s.queue.push(e.slice(t,t+Wt));l(n,s)}},end:()=>{a.has(n)&&(s.ending=!0,l(n,s))},close:()=>{a.has(n)&&(o(6,n),c(n))}}};a.set(n,s);let u=Gt.encode(e),d=new Uint8Array(2+u.length);new DataView(d.buffer).setUint16(0,t),d.set(u,2),o(1,n,d)})}}const Zt=()=>`${self.location.origin.replace(/^http/,`ws`)}/relay`;function Qt(e){if(e.length<12||!(e[4]<<8|e[5]))return Math.min(e.length,12);let t=12;for(;t<e.length&&e[t]!==0;)t+=e[t]+1;return Math.min(e.length,t+5)}function $t(e,t){if(e.length<12)return/* @__PURE__ */ new Uint8Array;let n=Qt(e),r=e.slice(0,n);return r[2]=128|e[2]&121,r[3]=128|t,r.set([0,+(n>12),0,0,0,0,0,0],4),r}const en=(e,t)=>e(t).catch(()=>$t(t,2));function tn(e){return({address:t,bytes:n},r)=>{en(e,n).then(e=>r(t,53,e))}}function nn(e){return t=>{let n=/* @__PURE__ */ new Uint8Array,r=0,i=!1;t.ondata=a=>{let o=new Uint8Array(n.length+a.length);for(o.set(n),o.set(a,n.length),n=o;n.length>=2&&n.length>=2+(n[0]<<8|n[1]);){let a=n[0]<<8|n[1],o=n.slice(2,2+a);n=n.slice(2+a),r++,en(e,o).then(e=>{let n=new Uint8Array(2+e.length);n.set([e.length>>8,e.length&255]),n.set(e,2),t.write(n),--r===0&&i&&t.end()})}},t.onend=()=>{i=!0,r===0&&t.end()}}}function rn(e,t){let n=!1,r=()=>{n||(n=!0,t.close())};e.ondata=e=>{let n=e.slice();t.postMessage({data:n},[n.buffer])},e.onend=()=>t.postMessage({end:!0}),e.onclose=()=>{n||t.postMessage({close:!0}),r()},t.onmessage=({data:t})=>{`data`in t?e.write(t.data):`end`in t?e.end():(r(),e.close())}}function an(e){return/refused/i.test(e)?-14:/timeout|deadline|timed out/i.test(e)?-73:/not connected|not running|not allowed/i.test(e)?-40:-23}const on={[-14]:`econnrefused`,[-23]:`ehostunreach`,[-40]:`enetunreach`,[-73]:`etimedout`},sn=(e,t)=>e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`,cn=12e4;function ln(e){let t=t=>e.emit(`blocked`,t);async function n(t,n,r){let i=new MessageChannel,a=i.port1;return await e.call(`tailnetDial`,[t,n,r,i.port2],[i.port2])?new Promise((e,t)=>{let n={ondata:()=>{},onend:()=>{},write:e=>{let t=e.slice();a.postMessage({kind:`data`,bytes:t},[t.buffer])},end:()=>a.postMessage({kind:`end`}),close:()=>{a.postMessage({kind:`close`}),a.close()}};a.onmessage=({data:r})=>{r.kind===`open`?(n.local=r.local,e(n)):r.kind===`error`?(a.close(),t(Error(r.message))):r.kind===`data`?n.ondata(r.bytes):r.kind===`end`&&n.onend(r.error??null)}}):(a.close(),null)}let r=(e,t)=>n(e,t,`tcp`).catch(e=>{throw Object.assign(e,{code:on[an(e.message)]})}),i=(e,{address:r,port:i})=>{let a=!1;e.onclose=()=>a=!0,n(r,i,`tcp`).then(n=>{if(!n)t(sn(r,i)),a||e.refuse(-40);else{if(a)return n.close();e.dialed(n.local),un(e,n)}},t=>{a||e.refuse(an(t.message))})};function a(){let e=/* @__PURE__ */ new Map,r=t=>{let n=e.get(t);n&&(e.delete(t),clearTimeout(n.timer),n.tunnel.then(e=>e?.close()))},i=t=>{let n=e.get(t);n&&(clearTimeout(n.timer),n.timer=setTimeout(()=>r(t),cn))},a=(a,{from:o,address:s,port:c},l)=>{let u=n(s,c,`udp`).then(n=>n?(n.ondata=e=>{i(a),l(s,c,e)},n.onend=()=>r(a),n):(t(sn(s,c)),e.delete(a),null),()=>(e.delete(a),null));e.set(a,{from:o,tunnel:u,timer:setTimeout(()=>r(a),cn)})};return{send:(t,n)=>{let{from:r,address:o,port:s,bytes:c}=t,l=`${r} ${o} ${s}`;e.has(l)||a(l,t,n),i(l),e.get(l)?.tunnel.then(e=>e?.write(c))},unbound:t=>{for(let[n,i]of e)i.from===t&&r(n)}}}return{tunnel:r,outbound:i,udp:a,resolve:t=>e.call(`tailnetResolve`,[t]).catch(()=>$t(t,3)),blocked:t}}function un(e,t){e.ondata=e=>t.write(e),e.onend=()=>t.end(),e.onclose=()=>t.close(),t.ondata=t=>e.write(t),t.onend=()=>e.end()}var dn=new URL(`esbuild-DJd0QPVm.wasm`,import.meta.url).href;const D={sep:`/`,normalize(e){let t=e.startsWith(`/`),n=[];for(let r of e.split(`/`))r===`..`?n.length&&n[n.length-1]!==`..`?n.pop():t||n.push(`..`):r&&r!==`.`&&n.push(r);return(t?`/`:``)+n.join(`/`)||(t?`/`:`.`)},join:(...e)=>D.normalize(e.filter(Boolean).join(`/`)),resolve:(...e)=>{let t=``;for(let n of e)t=n.startsWith(`/`)?n:`${t}/${n}`;return D.normalize(t.startsWith(`/`)?t:`/${t}`)},dirname:e=>{let t=e.replace(/\/+$/,``).lastIndexOf(`/`);return t<=0?e.startsWith(`/`)?`/`:`.`:e.slice(0,t)},basename:(e,t)=>{let n=e.replace(/\/+$/,``).split(`/`).pop()??``;return t&&n.endsWith(t)?n.slice(0,-t.length):n},extname:e=>{let t=D.basename(e),n=t.lastIndexOf(`.`);return n>0?t.slice(n):``},isAbsolute:e=>e.startsWith(`/`),relative:(e,t)=>{let n=D.resolve(e).split(`/`).filter(Boolean),r=D.resolve(t).split(`/`).filter(Boolean),i=0;for(;i<n.length&&n[i]===r[i];)i++;return[...n.slice(i).map(()=>`..`),...r.slice(i)].join(`/`)}};var fn=class extends Error{dir;constructor(e){super(`not fetched yet: ${e}`),this.dir=e}};const pn=new TextDecoder;var mn=class{node;dirs=/* @__PURE__ */ new Map;files=/* @__PURE__ */ new Map;constructor(e){this.node=e}async fetch(e){let t=(await this.node.list(e).catch(()=>[])).filter(t=>D.dirname(t.path)===e);this.dirs.set(e,t.map(e=>D.basename(e.path))),await Promise.all(t.filter(e=>!e.dir).map(async e=>this.files.set(e.path,await this.node.read(e.path))));for(let e of t.filter(e=>e.dir))this.dirs.has(e.path)||this.dirs.set(e.path,[])}forget(){this.dirs.clear(),this.files.clear()}readdir(e){let t=this.dirs.get(D.normalize(e));if(!t)throw new fn(D.normalize(e));return t}read(e){let t=D.normalize(e),n=this.files.get(t);if(n)return n;let r=D.dirname(t);if(this.dirs.has(r)){let e=/* @__PURE__ */ Error(`ENOENT: no such file, open '${t}'`);throw e.code=`ENOENT`,e}throw new fn(r)}exists(e){let t=D.normalize(e);if(this.files.has(t)||this.dirs.has(t))return!0;if(this.dirs.has(D.dirname(t)))return!1;throw new fn(D.dirname(t))}get fs(){let e=e=>Object.assign(e,{toString:()=>pn.decode(e)});return{readdirSync:e=>this.readdir(e),readFileSync:(t,n)=>{let r=this.read(t);return(typeof n==`string`?n:n?.encoding)?pn.decode(r):e(r)},existsSync:e=>this.exists(e),statSync:e=>{let t=D.normalize(e);if(!this.exists(t))throw Error(`ENOENT: ${t}`);let n=this.dirs.has(t);return{isDirectory:()=>n,isFile:()=>!n}}}}};async function hn(e,t){await e.stat(t)!==`dir`&&(await hn(e,D.dirname(t)),await e.mkdir(t))}async function gn(e,t){for(let n=0;;n++)try{return await t()}catch(t){let r=t instanceof fn?t:t?.cause;if(!(r instanceof fn)||n>200)throw t;await e.fetch(r.dir)}}function _n(e,t,n,r){let i=/* @__PURE__ */ new Map,a=(e,t)=>{let o={exports:{}};return i.set(t,o),Function(`module`,`exports`,`require`,`__filename`,`__dirname`,e)(o,o.exports,e=>{if(e in n)return n[e];if(e.startsWith(`node:`)&&e.slice(5)in n)return n[e.slice(5)];let o=D.join(D.dirname(t),e);for(let e of[o,`${o}.js`,`${o}.cjs`,`${o}/index.js`]){let t=i.get(e);if(t)return t.exports;let n=null;try{n=r.read(e)}catch(e){if(e instanceof fn)throw e}if(n)return a(pn.decode(n),e)}throw Error(`Cannot find module '${e}' from ${t}`)},t,D.dirname(t)),o.exports};return a(e,t)}const vn=/* @__PURE__ */ new Set;function yn(e){for(let t of vn)t(e)}let bn=null;function xn(){return bn??=import(`./browser-C6dmTjO4.js`).then(e=>/* @__PURE__ */ c(e.default,1)).then(async e=>(await e.initialize({wasmURL:dn,worker:!0}),e)),bn}const Sn={".js":`js`,".mjs":`js`,".cjs":`js`,".jsx":`jsx`,".ts":`ts`,".mts":`ts`,".cts":`ts`,".tsx":`tsx`,".json":`json`,".css":`css`,".txt":`text`},Cn=[`.tsx`,`.ts`,`.jsx`,`.js`,`.mjs`,`.cjs`,`.css`,`.json`],wn=[`browser`,`import`,`module`,`default`];function Tn(e,t){let n={entryPoints:[],external:[],loader:{},define:{}},r=[],i=[],a=!1,o=e=>e.split(`,`).filter(Boolean);for(let s of e){if(!s.startsWith(`--`)){n.entryPoints.push(D.resolve(t,s));continue}let e=s.match(/^--([a-z-]+):([^=]*)(?:=(.*))?$/);if(e){let[,t,a,o=``]=e;t===`external`?n.external.push(a):t===`alias`?r.push([a,o]):t===`loader`?n.loader[a]=o:t===`define`?n.define[a]=o:i.push(s);continue}let[,c,l]=s.match(/^--([a-z-]+)(?:=(.*))?$/)??[];switch(c){case`bundle`:case`minify`:case`splitting`:n[c]=!0;break;case`sourcemap`:n.sourcemap=l||!0;break;case`target`:n.target=o(l??``);break;case`outdir`:case`outfile`:case`outbase`:n[c]=D.resolve(t,l??``);break;case`format`:case`platform`:case`jsx`:n[c]=l;break;case`public-path`:n.publicPath=l;break;case`entry-names`:n.entryNames=l;break;case`chunk-names`:n.chunkNames=l;break;case`asset-names`:n.assetNames=l;break;case`main-fields`:n.mainFields=o(l??``);break;case`resolve-extensions`:n.resolveExtensions=o(l??``);break;case`watch`:a=!0;break;case`log-level`:case`color`:break;default:i.push(s)}}return{options:n,aliases:r,watch:a,ignored:i}}function En(e,t){let n=e.indexOf(`*`);return n<0?t===e||t.startsWith(`${e}/`):t.length>=e.length-1&&t.startsWith(e.slice(0,n))&&t.endsWith(e.slice(n+1))}function Dn(e,t){let n=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=n(t);if(e)return e}return null}if(e&&typeof e==`object`){for(let t of wn)if(t in e){let r=n(e[t]);if(r)return r}}return null};if(typeof e==`string`||Array.isArray(e))return t===`.`?n(e):null;if(!e||typeof e!=`object`)return null;let r=Object.keys(e);if(!r.some(e=>e.startsWith(`.`)))return t===`.`?n(e):null;let i=e;if(t in i)return n(i[t]);for(let e of r){let r=e.indexOf(`*`);if(r<0)continue;let[a,o]=[e.slice(0,r),e.slice(r+1)];if(t.startsWith(a)&&t.endsWith(o)){let r=n(i[e]),s=t.slice(a.length,t.length-o.length);return r?.replace(`*`,s)??null}}return null}const On=new TextDecoder,kn=/* @__PURE__ */ new Set([`js`,`jsx`,`ts`,`tsx`]);function An(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function jn(e,{args:t,cwd:n,env:r,fs:i}){if(t.includes(`--version`)){e.write(`0.25.4
|
|
32
|
+
`))}if(o=!1,_)return c=!0,n.end();u()};n.ondata=e=>{c||(a=Ft(a,e),u())},n.onend=()=>{s=!0,u()}}}var Ut={comment:"The TCP relay's hosts (docs/relay.md): the backend's /relay connects only to these, on port 443, for a TLS client that names the same host. The page reads it too: `fetch` lists the hosts it reaches by its own fetch() (they send CORS headers), not by the relay. A host goes one way for all its paths (the TLS is the page's own, so the relay never sees them): api.anthropic.com's Messages API sends CORS headers, but Claude Code's /api/claude_code/settings there does not, nor the Messages API for a subscription's OAuth token.",port:443,hosts:[`github.com`,`*.github.com`,`*.githubusercontent.com`,`gitlab.com`,`codeberg.org`,`pushin.eu`,`api.anthropic.com`,`platform.claude.com`],fetch:[`api.github.com`,`raw.githubusercontent.com`]};const Wt=65536,Gt=new TextEncoder,Kt=new TextDecoder,qt=(e,t)=>(e=e.toLowerCase().replace(/\.$/,``),t.some(t=>t.startsWith(`*.`)?e.endsWith(t.slice(1)):e===t)),Jt=(e,t)=>t===Ut.port&&qt(e,Ut.hosts)&&!qt(e,Ut.fetch);function Yt(e){return e===`econnrefused`?`econnrefused`:/timeout|etimedout|idle/.test(e)?`etimedout`:e===`not_allowed`?`enetunreach`:`ehostunreach`}function Xt(e=()=>new WebSocket(Zt())){let t=null,n=null,r=null,i=1,a=/* @__PURE__ */ new Map,o=(e,n,r=/* @__PURE__ */ new Uint8Array)=>{let i=new Uint8Array(5+r.length);i[0]=e,new DataView(i.buffer).setUint32(1,n),i.set(r,5),t?.send(i)},s=(e,t)=>{let n=/* @__PURE__ */ new Uint8Array(4);new DataView(n.buffer).setUint32(0,t),o(7,e,n)};function c(e){a.delete(e),!(a.size||r)&&(r=setTimeout(()=>{r=null,!a.size&&(t?.close(),t=null,n=null)},3e4))}function l(e,t){for(;t.queue.length&&t.inflight+t.queue[0].length<=262144;){let n=t.queue.shift();t.inflight+=n.length,o(4,e,n)}t.ending&&!t.queue.length&&(t.ending=!1,o(5,e))}function u(e){let t=new Uint8Array(e);if(t.length<5)return;let n=t[0],r=new DataView(e).getUint32(1),i=t.subarray(5),o=a.get(r);if(o){if(n===2)o.opened=!0,o.open.resolve(o.tunnel);else if(n===4)o.tunnel.ondata(i.slice()),s(r,i.length);else if(n===7&&i.length===4)o.inflight-=new DataView(e).getUint32(5),l(r,o);else if(n===5)c(r),o.tunnel.onend(null);else if(n===3){c(r);let e=Kt.decode(i);o.opened?o.tunnel.onend(e):o.open.reject(Object.assign(Error(e),{code:Yt(e)}))}}}function d(){return n||=new Promise(r=>{let i=e();i.binaryType=`arraybuffer`,i.onopen=()=>{t=i,r(i)},i.onmessage=({data:e})=>{e instanceof ArrayBuffer&&u(e)},i.onerror=()=>{},i.onclose=()=>{r(null),t===i&&(t=null),n=null;for(let[e,t]of a)a.delete(e),t.opened?t.tunnel.onend(`closed`):t.open.resolve(null)}})}return async function(e,t){if(r&&clearTimeout(r),r=null,!await d())return null;let n=i++;return new Promise((r,i)=>{let s={opened:!1,open:{resolve:r,reject:i},inflight:0,queue:[],ending:!1,tunnel:{ondata:()=>{},onend:()=>{},write:e=>{if(a.has(n)){for(let t=0;t<e.length;t+=Wt)s.queue.push(e.slice(t,t+Wt));l(n,s)}},end:()=>{a.has(n)&&(s.ending=!0,l(n,s))},close:()=>{a.has(n)&&(o(6,n),c(n))}}};a.set(n,s);let u=Gt.encode(e),d=new Uint8Array(2+u.length);new DataView(d.buffer).setUint16(0,t),d.set(u,2),o(1,n,d)})}}const Zt=()=>`${self.location.origin.replace(/^http/,`ws`)}/relay`;function Qt(e){if(e.length<12||!(e[4]<<8|e[5]))return Math.min(e.length,12);let t=12;for(;t<e.length&&e[t]!==0;)t+=e[t]+1;return Math.min(e.length,t+5)}function $t(e,t){if(e.length<12)return/* @__PURE__ */ new Uint8Array;let n=Qt(e),r=e.slice(0,n);return r[2]=128|e[2]&121,r[3]=128|t,r.set([0,+(n>12),0,0,0,0,0,0],4),r}const en=(e,t)=>e(t).catch(()=>$t(t,2));function tn(e){return({address:t,bytes:n},r)=>{en(e,n).then(e=>r(t,53,e))}}function nn(e){return t=>{let n=/* @__PURE__ */ new Uint8Array,r=0,i=!1;t.ondata=a=>{let o=new Uint8Array(n.length+a.length);for(o.set(n),o.set(a,n.length),n=o;n.length>=2&&n.length>=2+(n[0]<<8|n[1]);){let a=n[0]<<8|n[1],o=n.slice(2,2+a);n=n.slice(2+a),r++,en(e,o).then(e=>{let n=new Uint8Array(2+e.length);n.set([e.length>>8,e.length&255]),n.set(e,2),t.write(n),--r===0&&i&&t.end()})}},t.onend=()=>{i=!0,r===0&&t.end()}}}function rn(e,t){let n=!1,r=()=>{n||(n=!0,t.close())};e.ondata=e=>{let n=e.slice();t.postMessage({data:n},[n.buffer])},e.onend=()=>t.postMessage({end:!0}),e.onclose=()=>{n||t.postMessage({close:!0}),r()},t.onmessage=({data:t})=>{`data`in t?e.write(t.data):`end`in t?e.end():(r(),e.close())}}function an(e){return/refused/i.test(e)?-14:/timeout|deadline|timed out/i.test(e)?-73:/not connected|not running|not allowed/i.test(e)?-40:-23}const on={[-14]:`econnrefused`,[-23]:`ehostunreach`,[-40]:`enetunreach`,[-73]:`etimedout`},sn=(e,t)=>e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`,cn=12e4;function ln(e){let t=t=>e.emit(`blocked`,t);async function n(t,n,r){let i=new MessageChannel,a=i.port1;return await e.call(`tailnetDial`,[t,n,r,i.port2],[i.port2])?new Promise((e,t)=>{let n={ondata:()=>{},onend:()=>{},write:e=>{let t=e.slice();a.postMessage({kind:`data`,bytes:t},[t.buffer])},end:()=>a.postMessage({kind:`end`}),close:()=>{a.postMessage({kind:`close`}),a.close()}};a.onmessage=({data:r})=>{r.kind===`open`?(n.local=r.local,e(n)):r.kind===`error`?(a.close(),t(Error(r.message))):r.kind===`data`?n.ondata(r.bytes):r.kind===`end`&&n.onend(r.error??null)}}):(a.close(),null)}let r=(e,t)=>n(e,t,`tcp`).catch(e=>{throw Object.assign(e,{code:on[an(e.message)]})}),i=(e,{address:r,port:i})=>{let a=!1;e.onclose=()=>a=!0,n(r,i,`tcp`).then(n=>{if(!n)t(sn(r,i)),a||e.refuse(-40);else{if(a)return n.close();e.dialed(n.local),un(e,n)}},t=>{a||e.refuse(an(t.message))})};function a(){let e=/* @__PURE__ */ new Map,r=t=>{let n=e.get(t);n&&(e.delete(t),clearTimeout(n.timer),n.tunnel.then(e=>e?.close()))},i=t=>{let n=e.get(t);n&&(clearTimeout(n.timer),n.timer=setTimeout(()=>r(t),cn))},a=(a,{from:o,address:s,port:c},l)=>{let u=n(s,c,`udp`).then(n=>n?(n.ondata=e=>{i(a),l(s,c,e)},n.onend=()=>r(a),n):(t(sn(s,c)),e.delete(a),null),()=>(e.delete(a),null));e.set(a,{from:o,tunnel:u,timer:setTimeout(()=>r(a),cn)})};return{send:(t,n)=>{let{from:r,address:o,port:s,bytes:c}=t,l=`${r} ${o} ${s}`;e.has(l)||a(l,t,n),i(l),e.get(l)?.tunnel.then(e=>e?.write(c))},unbound:t=>{for(let[n,i]of e)i.from===t&&r(n)}}}return{tunnel:r,outbound:i,udp:a,resolve:t=>e.call(`tailnetResolve`,[t]).catch(()=>$t(t,3)),blocked:t}}function un(e,t){e.ondata=e=>t.write(e),e.onend=()=>t.end(),e.onclose=()=>t.close(),t.ondata=t=>e.write(t),t.onend=()=>e.end()}var dn=new URL(`esbuild-DJd0QPVm.wasm`,import.meta.url).href;const D={sep:`/`,normalize(e){let t=e.startsWith(`/`),n=[];for(let r of e.split(`/`))r===`..`?n.length&&n[n.length-1]!==`..`?n.pop():t||n.push(`..`):r&&r!==`.`&&n.push(r);return(t?`/`:``)+n.join(`/`)||(t?`/`:`.`)},join:(...e)=>D.normalize(e.filter(Boolean).join(`/`)),resolve:(...e)=>{let t=``;for(let n of e)t=n.startsWith(`/`)?n:`${t}/${n}`;return D.normalize(t.startsWith(`/`)?t:`/${t}`)},dirname:e=>{let t=e.replace(/\/+$/,``).lastIndexOf(`/`);return t<=0?e.startsWith(`/`)?`/`:`.`:e.slice(0,t)},basename:(e,t)=>{let n=e.replace(/\/+$/,``).split(`/`).pop()??``;return t&&n.endsWith(t)?n.slice(0,-t.length):n},extname:e=>{let t=D.basename(e),n=t.lastIndexOf(`.`);return n>0?t.slice(n):``},isAbsolute:e=>e.startsWith(`/`),relative:(e,t)=>{let n=D.resolve(e).split(`/`).filter(Boolean),r=D.resolve(t).split(`/`).filter(Boolean),i=0;for(;i<n.length&&n[i]===r[i];)i++;return[...n.slice(i).map(()=>`..`),...r.slice(i)].join(`/`)}};var fn=class extends Error{dir;constructor(e){super(`not fetched yet: ${e}`),this.dir=e}};const pn=new TextDecoder;var mn=class{node;dirs=/* @__PURE__ */ new Map;files=/* @__PURE__ */ new Map;constructor(e){this.node=e}async fetch(e){let t=(await this.node.list(e).catch(()=>[])).filter(t=>D.dirname(t.path)===e);this.dirs.set(e,t.map(e=>D.basename(e.path))),await Promise.all(t.filter(e=>!e.dir).map(async e=>this.files.set(e.path,await this.node.read(e.path))));for(let e of t.filter(e=>e.dir))this.dirs.has(e.path)||this.dirs.set(e.path,[])}forget(){this.dirs.clear(),this.files.clear()}readdir(e){let t=this.dirs.get(D.normalize(e));if(!t)throw new fn(D.normalize(e));return t}read(e){let t=D.normalize(e),n=this.files.get(t);if(n)return n;let r=D.dirname(t);if(this.dirs.has(r)){let e=/* @__PURE__ */ Error(`ENOENT: no such file, open '${t}'`);throw e.code=`ENOENT`,e}throw new fn(r)}exists(e){let t=D.normalize(e);if(this.files.has(t)||this.dirs.has(t))return!0;if(this.dirs.has(D.dirname(t)))return!1;throw new fn(D.dirname(t))}get fs(){let e=e=>Object.assign(e,{toString:()=>pn.decode(e)});return{readdirSync:e=>this.readdir(e),readFileSync:(t,n)=>{let r=this.read(t);return(typeof n==`string`?n:n?.encoding)?pn.decode(r):e(r)},existsSync:e=>this.exists(e),statSync:e=>{let t=D.normalize(e);if(!this.exists(t))throw Error(`ENOENT: ${t}`);let n=this.dirs.has(t);return{isDirectory:()=>n,isFile:()=>!n}}}}};async function hn(e,t){await e.stat(t)!==`dir`&&(await hn(e,D.dirname(t)),await e.mkdir(t))}async function gn(e,t){for(let n=0;;n++)try{return await t()}catch(t){let r=t instanceof fn?t:t?.cause;if(!(r instanceof fn)||n>200)throw t;await e.fetch(r.dir)}}function _n(e,t,n,r){let i=/* @__PURE__ */ new Map,a=(e,t)=>{let o={exports:{}};return i.set(t,o),Function(`module`,`exports`,`require`,`__filename`,`__dirname`,e)(o,o.exports,e=>{if(e in n)return n[e];if(e.startsWith(`node:`)&&e.slice(5)in n)return n[e.slice(5)];let o=D.join(D.dirname(t),e);for(let e of[o,`${o}.js`,`${o}.cjs`,`${o}/index.js`]){let t=i.get(e);if(t)return t.exports;let n=null;try{n=r.read(e)}catch(e){if(e instanceof fn)throw e}if(n)return a(pn.decode(n),e)}throw Error(`Cannot find module '${e}' from ${t}`)},t,D.dirname(t)),o.exports};return a(e,t)}const vn=/* @__PURE__ */ new Set;function yn(e){for(let t of vn)t(e)}let bn=null;function xn(){return bn??=import(`./browser-C1G3It0R.js`).then(e=>/* @__PURE__ */ c(e.default,1)).then(async e=>(await e.initialize({wasmURL:dn,worker:!0}),e)),bn}const Sn={".js":`js`,".mjs":`js`,".cjs":`js`,".jsx":`jsx`,".ts":`ts`,".mts":`ts`,".cts":`ts`,".tsx":`tsx`,".json":`json`,".css":`css`,".txt":`text`},Cn=[`.tsx`,`.ts`,`.jsx`,`.js`,`.mjs`,`.cjs`,`.css`,`.json`],wn=[`browser`,`import`,`module`,`default`];function Tn(e,t){let n={entryPoints:[],external:[],loader:{},define:{}},r=[],i=[],a=!1,o=e=>e.split(`,`).filter(Boolean);for(let s of e){if(!s.startsWith(`--`)){n.entryPoints.push(D.resolve(t,s));continue}let e=s.match(/^--([a-z-]+):([^=]*)(?:=(.*))?$/);if(e){let[,t,a,o=``]=e;t===`external`?n.external.push(a):t===`alias`?r.push([a,o]):t===`loader`?n.loader[a]=o:t===`define`?n.define[a]=o:i.push(s);continue}let[,c,l]=s.match(/^--([a-z-]+)(?:=(.*))?$/)??[];switch(c){case`bundle`:case`minify`:case`splitting`:n[c]=!0;break;case`sourcemap`:n.sourcemap=l||!0;break;case`target`:n.target=o(l??``);break;case`outdir`:case`outfile`:case`outbase`:n[c]=D.resolve(t,l??``);break;case`format`:case`platform`:case`jsx`:n[c]=l;break;case`public-path`:n.publicPath=l;break;case`entry-names`:n.entryNames=l;break;case`chunk-names`:n.chunkNames=l;break;case`asset-names`:n.assetNames=l;break;case`main-fields`:n.mainFields=o(l??``);break;case`resolve-extensions`:n.resolveExtensions=o(l??``);break;case`watch`:a=!0;break;case`log-level`:case`color`:break;default:i.push(s)}}return{options:n,aliases:r,watch:a,ignored:i}}function En(e,t){let n=e.indexOf(`*`);return n<0?t===e||t.startsWith(`${e}/`):t.length>=e.length-1&&t.startsWith(e.slice(0,n))&&t.endsWith(e.slice(n+1))}function Dn(e,t){let n=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=n(t);if(e)return e}return null}if(e&&typeof e==`object`){for(let t of wn)if(t in e){let r=n(e[t]);if(r)return r}}return null};if(typeof e==`string`||Array.isArray(e))return t===`.`?n(e):null;if(!e||typeof e!=`object`)return null;let r=Object.keys(e);if(!r.some(e=>e.startsWith(`.`)))return t===`.`?n(e):null;let i=e;if(t in i)return n(i[t]);for(let e of r){let r=e.indexOf(`*`);if(r<0)continue;let[a,o]=[e.slice(0,r),e.slice(r+1)];if(t.startsWith(a)&&t.endsWith(o)){let r=n(i[e]),s=t.slice(a.length,t.length-o.length);return r?.replace(`*`,s)??null}}return null}const On=new TextDecoder,kn=/* @__PURE__ */ new Set([`js`,`jsx`,`ts`,`tsx`]);function An(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function jn(e,{args:t,cwd:n,env:r,fs:i}){if(t.includes(`--version`)){e.write(`0.25.4
|
|
33
33
|
`),e.exit(0);return}let a=Tn(t,n);a.ignored.length&&e.write(`esbuild (playground): ignoring ${a.ignored.join(` `)}\n`);let o=(r.NODE_PATH??``).split(`:`).filter(Boolean),s=/* @__PURE__ */ new Map,c=async e=>(s.has(e)||s.set(e,await i.stat(e)),s.get(e)??null),l=async e=>{if(await c(e)!==`file`)return null;try{return JSON.parse(On.decode(await i.read(e)))}catch{return null}},u=async e=>{if(await c(e)===`file`)return e;for(let t of Cn)if(await c(e+t)===`file`)return e+t;if(await c(e)===`dir`){let t=await l(`${e}/package.json`);for(let n of[`browser`,`module`,`main`]){let r=t?.[n];if(typeof r==`string`){let t=await u(D.resolve(e,r));if(t)return t}}for(let t of Cn)if(await c(`${e}/index${t}`)===`file`)return`${e}/index${t}`}return null},d=async(e,t)=>{let n=e.split(`/`),r=e.startsWith(`@`)?2:1,i=n.slice(0,r).join(`/`),a=n.length>r?`./${n.slice(r).join(`/`)}`:`.`,s=[];for(let e=t;s.push(`${e}/node_modules`),e!==`/`;e=D.dirname(e));s.push(...o);for(let e of s){let t=D.resolve(e,i);if(await c(t)!==`dir`)continue;let n=await l(`${t}/package.json`);if(n?.exports!==void 0){let e=Dn(n.exports,a);if(e)return u(D.resolve(t,e))}let r=await u(a===`.`?t:D.resolve(t,a));if(r)return r}return null},f=async(e,t)=>{let n=On.decode(t),r=n.match(/\/\/# sourceMappingURL=(?!data:)(\S+)\s*$/);if(!r)return t;let a=await i.read(D.resolve(D.dirname(e),r[1])).catch(()=>null),o=a?`data:application/json;base64,${An(a)}`:``;return n.slice(0,r.index)+(o?`//# sourceMappingURL=${o}\n`:``)},p=/* @__PURE__ */ new Set,m=a.options.external??[],h={name:`playground-files`,setup(e){e.onResolve({filter:/.*/},async({path:e,resolveDir:t,kind:r})=>{if(r===`entry-point`)return{path:e};if(e.startsWith(`data:`))return;if(/^(https?:)?\/\//.test(e)||m.some(t=>En(t,e)))return{path:e,external:!0};let i=e,o=t||n;for(let[t,r]of a.aliases)if(e===t||e.startsWith(`${t}/`)){i=r+e.slice(t.length),o=n;break}let s=i.startsWith(`.`)||i.startsWith(`/`)?await u(D.resolve(o,i)):await d(i,o);return s?{path:s}:{errors:[{text:`Could not resolve "${e}"`}]}}),e.onLoad({filter:/.*/},async({path:e})=>{p.add(e);let t=await i.read(e),n=a.options.loader?.[D.extname(e)]??Sn[D.extname(e)];return{contents:kn.has(n)?await f(e,t):t,loader:n??`file`,resolveDir:D.dirname(e)}})}},g=null,_=!0,v=[],y=e=>e.some(e=>p.has(e)),b=async t=>{_=!0,await te(),_=!1,t&&e.write(`[watch] build finished, watching for changes...
|
|
34
34
|
`);let n=y(v);v=[],n&&x()},x=()=>{g&&clearTimeout(g),g=setTimeout(()=>{g=null,e.write(`[watch] build started (change detected)
|
|
35
35
|
`),b(!1)},50)},S=e=>{_?v.push(...e):y(e)&&x()};a.watch&&vn.add(S),e.onkill=()=>{vn.delete(S),g&&clearTimeout(g)};let C=await xn(),ee=async(t,n)=>{if(!t.length)return;let r=await C.formatMessages(t,{kind:n,color:!1});e.write(r.join(``))},te=async()=>{let t=performance.now();p=/* @__PURE__ */ new Set,s.clear();try{let r=await C.build({...a.options,absWorkingDir:n,write:!1,logLevel:`silent`,plugins:[h]});await ee(r.warnings,`warning`);let o=[];for(let e of r.outputFiles??[]){await hn(i,D.dirname(e.path)),await i.write(e.path,e.contents);let t=D.relative(n,e.path),r=(e.contents.length/1024).toFixed(1);o.push(` ${t} ${r}kb`)}return e.write(`\n${o.join(`
|
|
@@ -1935,17 +1935,7 @@ input:where([type='button'], [type='reset'], [type='submit']),
|
|
|
1935
1935
|
`;const ql=`4.3.3`,Jl=`/__tailwindcss`,Yl={[`${Jl}/index.css`]:Ul,[`${Jl}/preflight.css`]:Wl,[`${Jl}/theme.css`]:Gl,[`${Jl}/utilities.css`]:Kl},Xl=/\.(png|jpe?g|gif|webp|ico|woff2?|ttf|otf|eot|mp4|webm|zip|gz|beam|wasm)$/i;function Zl(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(i.startsWith(`${t}=`))return i.slice(t.length+1);if(i===t||i===n)return e[r+1]}}const Ql=new TextDecoder;async function $l(e,{args:t,cwd:n,env:r,fs:i}){if(t.includes(`--help`)||t.includes(`-h`)||t.includes(`--version`)){e.write(`≈ tailwindcss v${ql}\n`),e.exit(0);return}let a=Zl(t,`--input`,`-i`),o=Zl(t,`--output`,`-o`),s=t.some(e=>e===`--watch`||e.startsWith(`--watch=`));if(!a||!o){e.write(`tailwindcss: the playground needs --input and --output
|
|
1936
1936
|
`),e.exit(1);return}let c=D.resolve(n,a),l=D.resolve(n,o),u=(r.NODE_PATH??``).split(`:`).filter(Boolean),d=new mn(i),f=async e=>Ql.decode(await i.read(e)),p=async(e,t,n)=>{let r=e.startsWith(`.`)||e.startsWith(`/`)?[t]:[t,...u];for(let t of r)for(let r of n){let n=D.resolve(t,e+r);try{return{path:n,content:await f(n)}}catch{}}throw Error(`Can't resolve '${e}' from ${t}`)},m=[],h=[],g=async()=>{let t=performance.now(),n=await f(c);h=[c];let r=await gn(d,()=>Bl(n,{base:D.dirname(c),from:c,async loadStylesheet(e,t){if(e===`tailwindcss`||e.startsWith(`tailwindcss/`)){let t=e===`tailwindcss`?`${Jl}/index.css`:`${Jl}/${e.slice(12)}`,n=t.endsWith(`.css`)?t:`${t}.css`;return{path:n,base:Jl,content:Yl[n]??``}}if(t===Jl){let t=D.join(Jl,e);return{path:t,base:Jl,content:Yl[t]??``}}let n=await p(e,t,[``,`.css`,`/index.css`]);return h.push(n.path),{path:n.path,base:D.dirname(n.path),content:n.content}},async loadModule(e,t){let n=await p(e,t,[``,`.js`,`.cjs`,`/index.js`]);h.push(n.path);let r=_n(n.content,n.path,{"tailwindcss/plugin":Hl,fs:d.fs,path:D},d),i=r?.default??r;return{path:n.path,base:D.dirname(n.path),module:i}}}));m=r.sources.filter(e=>!e.negated).map(e=>{let t=D.resolve(e.base,e.pattern).split(`/`),n=t.findIndex(e=>/[*{?[]/.test(e));return n<0?t.join(`/`):t.slice(0,n).join(`/`)}),r.root&&r.root!==`none`&&m.push(D.resolve(r.root.base,r.root.pattern));let a=/* @__PURE__ */ new Set;for(let e of m){let t=await i.list(e).catch(()=>[{path:e,dir:!1}]),n=await Promise.all(t.filter(e=>!e.dir&&!Xl.test(e.path)&&e.path!==l).map(e=>f(e.path).catch(()=>``)));for(let e of n)for(let t of e.split(/[\s"'`<>={};]+/)){let e=t.replace(/^[,.:]+|[,.:]+$/g,``);e&&e.length<200&&a.add(e)}}let o=await gn(d,()=>r.build([...a]));await hn(i,D.dirname(l)),await i.write(l,o),e.write(`\nDone in ${Math.round(performance.now()-t)}ms.\n`)};e.write(`≈ tailwindcss v${ql}\n`);try{await g()}catch(t){if(e.write(`Error: ${t.message}\n`),!s){e.exit(1);return}}if(!s){e.exit(0);return}let _=null,v=t=>{t.some(e=>e!==l&&(h.includes(e)||m.some(t=>e===t||e.startsWith(`${t}/`))))&&(_&&clearTimeout(_),_=setTimeout(()=>{_=null,g().catch(t=>e.write(`Error: ${t.message}\n`))},50))};vn.add(v),e.onkill=()=>{vn.delete(v),_&&clearTimeout(_)}}var eu=class{thread;id;forget;node;ondata=()=>{};onend=()=>{};onclose=()=>{};closed=!1;constructor(e,t,n,r){this.thread=e,this.id=t,this.forget=n,this.node=r}write(e){this.closed||this.thread.postMessage({kind:`net`,op:`data`,id:this.id,bytes:e})}end(){this.closed||this.thread.postMessage({kind:`net`,op:`end`,id:this.id})}close(){this.closed||(this.closed=!0,this.forget(this.id),this.thread.postMessage({kind:`net`,op:`close`,id:this.id}))}reset(){this.closed||(this.closed=!0,this.forget(this.id),this.thread.postMessage({kind:`net`,op:`reset`,id:this.id}))}closedBy(e){this.closed||(this.closed=!0,this.forget(this.id),this.onclose(e))}};const tu=(e,t,n,r=null,i=()=>({}))=>(a,o)=>{let s=t();if(!s)return a.write(`node: no files
|
|
1937
1937
|
`),a.exit(1);let c=s.connect(),l=new Worker(new URL(`nodejs.js`,new URL(e,location.href)),{type:`module`}),u=/* @__PURE__ */ new Map,d=e=>u.delete(e),f=1,p={connect(e){let t=new eu(l,f+=2,d,p);return u.set(t.id,t),l.postMessage({kind:`net`,op:`open`,id:t.id,port:e}),t}},m=/* @__PURE__ */ new Set,h=null,g=e=>{if(e.op===`udp-bind`){h??=n?.udp()??null;let t=h?.bind(e.port,(e,n,r)=>l.postMessage({kind:`net`,op:`udp`,to:t,address:e,port:n,bytes:r}))??null;l.postMessage({kind:`net`,op:`udp-bound`,ref:e.ref,port:t})}else if(e.op===`udp-send`)h?.send(e);else if(e.op===`udp-close`)h?.unbind(e.port);else if(e.op===`listen`){let t=n?.listen(e.port,p)??null;t!==null&&m.add(t),l.postMessage({kind:`net`,op:`listening`,ref:e.ref,port:t})}else if(e.op===`unlisten`)m.delete(e.port),n?.unlisten(e.port,p);else if(e.op===`dns`){let t=t=>l.postMessage({kind:`net`,op:`dns`,ref:e.ref,answer:t});if(!n)return t(/* @__PURE__ */ new Uint8Array);n.resolve(e.query).then(t,()=>t(/* @__PURE__ */ new Uint8Array))}else if(e.op===`connect`&&e.via===`tcp`&&e.host){let t=new eu(l,e.id,d,p);u.set(e.id,t);let r=t=>{d(e.id),l.postMessage({kind:`net`,op:`refused`,id:e.id,code:t})};if(!n)return r(`ENETUNREACH`);n.dial(t,e.host,e.port).then(t=>l.postMessage({kind:`net`,op:`connected`,id:e.id,local:t}),e=>r(e.code??`EHOSTUNREACH`))}else if(e.op===`connect`){let t=n?.route(e.port,e.host)??null;if(l.postMessage({kind:`net`,op:t?`connected`:`refused`,id:e.id}),!t)return;let r=new eu(l,e.id,d,p);u.set(e.id,r),t(r)}else{let t=u.get(e.id);if(!t)return;e.op===`data`?t.ondata(e.bytes):e.op===`end`?t.onend():t.closedBy(`close`)}},_=e=>l.postMessage({kind:`changed`,paths:e});vn.add(_);let v=!1,y=/* @__PURE__ */ new Map,b=[],x=/* @__PURE__ */ new Set,S=[!1,!0],C=e=>{let{id:t,shared:n}=e,r={stdin:!!e.terminal?.[0]&&!!o.tty?.stdin,stdout:!!e.terminal?.[1]&&!!o.tty?.stdout},c=!1,u=n?new Int32Array(n,0,4):null,d=n?(n.byteLength-16)/2:0,f=n?[new Uint8Array(n,16,d),new Uint8Array(n,16+d,d)]:null,p=[0,0],m=!1,h=e=>typeof e==`string`?new TextEncoder().encode(e):e,g=(n,r)=>{if(e.inherit)n&&a.writeError?a.writeError(r):a.write(r);else if(f){let e=f[n],t=p[n];t<0||t+r.length>e.length?p[n]=-1:(e.set(r,t),p[n]+=r.length)}else l.postMessage({kind:`child`,op:n?`err`:`out`,id:t,bytes:r})},_={write:e=>g(0,h(e)),writeError:e=>g(1,h(e)),exit:(e=0)=>{if(m)return;m=!0,y.delete(t),x.delete(_);let n=b.indexOf(_);n>=0&&b.splice(n,1),c&&a.raw?.(...S),u?(Atomics.store(u,1,e),Atomics.store(u,2,p[0]),Atomics.store(u,3,p[1]),Atomics.store(u,0,1),Atomics.notify(u,0)):l.postMessage({kind:`child`,op:`exit`,id:t,code:e})},onkill:null,onowner:null};(r.stdin||r.stdout)&&(_.size=()=>a.size?.()??[80,24],x.add(_)),r.stdin&&(_.raw=(e,t)=>{c=!0,a.raw?.(e,t)},b.push(_)),y.set(t,_);let v=i().sh;if(!v)return _.writeError(`sh: not in this playground
|
|
1938
|
-
`),_.exit(127);Promise.resolve(v(_,{args:[`-c`,e.line],cwd:e.cwd,env:e.env,fs:s,tty:r})).catch(e=>{_.writeError(`${e.message}\n`),_.exit(1)}),e.input&&(e.input.length&&_.oninput?.(e.input),_.oninput?.(null))},ee=e=>{let t=y.get(e);t&&(t.onowner?.(),t.exit(143))},te=e=>{if(!v){v=!0;for(let e of[...y.values()])e.onowner?.();vn.delete(_),l.terminate(),s.disconnect(c);for(let e of m)n?.unlisten(e,p);h?.close();for(let e of[...u.values()])e.closedBy(`close`);a.exit(e)}};l.onmessage=({data:e})=>{e.kind===`out`?(e.fd===2&&a.writeError?a.writeError:a.write)(e.bytes):e.kind===`net`?g(e):e.kind===`tty`?(S=[e.raw,!e.raw],a.raw?.(...S)):e.kind===`child`&&e.op===`spawn`?C(e):e.kind===`child`&&e.op===`kill`?ee(e.id):e.kind===`child`&&e.op===`stdin`?y.get(e.id)?.oninput?.(e.end?null:e.bytes):e.kind===`exit`&&te(e.code)},l.onerror=e=>{e.preventDefault(),(a.writeError??a.write)(`node: ${e.message||`the worker failed to start`}\n`),te(1)},a.onkill=()=>te(130),a.onowner=()=>te(130),l.postMessage({kind:`start`,args:o.args,cwd:o.cwd,env:o.env,doorbell:c.doorbell,channel:c.channel,tls:r,tty:o.tty?.stdout??!1,stdinTty:o.tty?.stdin??!1,bun:o.bun??!1,columns:a.size?.()[0]??80,rows:a.size?.()[1]??24}),a.oninput=e=>{let t=b.at(-1);if(t)return t.oninput?.(e);l.postMessage(e===null?{kind:`stdin`,end:!0}:{kind:`stdin`,bytes:e})},a.onresize=(e,t)=>{l.postMessage({kind:`resize`,columns:e,rows:t});for(let n of x)n.onresize?.(e,t)}};var nu=class{value;transfer;constructor(e,t){this.value=e,this.transfer=t}};const ru=(e,t)=>new nu(e,t);var iu=class{port;next=1;waiting=/* @__PURE__ */ new Map;handlers={};listeners=/* @__PURE__ */ new Map;constructor(e){this.port=e,e.onmessage=({data:e})=>void this.receive(e)}handle(e){return Object.assign(this.handlers,e),this}call(e,t=[],n=[]){let r=this.next++;return new Promise((i,a)=>{this.waiting.set(r,{resolve:i,reject:a}),this.port.postMessage({call:r,method:e,args:t},n)})}emit(e,t,n=[]){this.port.postMessage({event:e,data:t},n)}on(e,t){let n=this.listeners.get(e);return n||this.listeners.set(e,n=/* @__PURE__ */ new Set),n.add(t),()=>n.delete(t)}close(){for(let{reject:e}of this.waiting.values())e(/* @__PURE__ */ Error(`closed`));this.waiting.clear(),this.port.close()}async receive(e){if(`reply`in e){let t=this.waiting.get(e.reply);this.waiting.delete(e.reply),e.error===void 0?t?.resolve(e.value):t?.reject(Object.assign(Error(e.error),{code:e.code}))}else if(`call`in e)try{let t=this.handlers[e.method];if(!t)throw Error(`no such call: ${e.method}`);let n=await t(...e.args),[r,i]=n instanceof nu?[n.value,n.transfer]:[n,[]];this.port.postMessage({reply:e.call,value:r},i)}catch(t){let n=t?.code;this.port.postMessage({reply:e.call,error:t instanceof Error?t.message:String(t),...typeof n==`string`?{code:n}:{}})}else for(let t of this.listeners.get(e.event)??[])t(e.data)}};new
|
|
1939
|
-
---- Bun! ----
|
|
1940
|
-
`),new TextEncoder().encode(`class WebSocket { constructor() { throw new Error('ws: not in the playground'); } }
|
|
1941
|
-
module.exports = WebSocket;
|
|
1942
|
-
module.exports.WebSocket = WebSocket;
|
|
1943
|
-
module.exports.WebSocketServer = WebSocket;
|
|
1944
|
-
`),new TextEncoder().encode(`{"type":"commonjs"}
|
|
1945
|
-
`),new TextEncoder().encode(`module.exports = (...args) => fetch(...args);
|
|
1946
|
-
module.exports.default = module.exports;
|
|
1947
|
-
Object.assign(module.exports, { Headers, Request, Response });
|
|
1948
|
-
`);async function au(e,t,n,r){if(r.throwIfAborted(),await e.stat(`${t}/cli.js`))return;r.throwIfAborted();let i=/* @__PURE__ */ new Set([t]);for(let{name:e}of n)for(let n=e.indexOf(`/`);n>=0;n=e.indexOf(`/`,n+1))i.add(`${t}/${e.slice(0,n)}`);for(let t of[...i].sort())r.throwIfAborted(),await e.mkdir(t);r.throwIfAborted();let a=n.find(e=>e.name===`cli.js`);await Promise.all(n.filter(e=>e!==a).map(n=>e.write(`${t}/${n.name}`,n.data))),r.throwIfAborted(),a&&await e.write(`${t}/cli.js`,a.data)}async function ou(e,t,n){let r=await e();n.aborted&&(r.close(),n.throwIfAborted());let i=new iu(r),a=()=>i.close();n.addEventListener(`abort`,a,{once:!0}),i.on(`progress`,t);try{return await i.call(`files`)}finally{n.removeEventListener(`abort`,a),i.close()}}const su=(e,t)=>async(n,r)=>{let i=e().node,a=e=>(n.writeError??n.write)(e);if(!i)return a(`claude: node is not in this playground
|
|
1938
|
+
`),_.exit(127);Promise.resolve(v(_,{args:[`-c`,e.line],cwd:e.cwd,env:e.env,fs:s,tty:r})).catch(e=>{_.writeError(`${e.message}\n`),_.exit(1)}),e.input&&(e.input.length&&_.oninput?.(e.input),_.oninput?.(null))},ee=e=>{let t=y.get(e);t&&(t.onowner?.(),t.exit(143))},te=e=>{if(!v){v=!0;for(let e of[...y.values()])e.onowner?.();vn.delete(_),l.terminate(),s.disconnect(c);for(let e of m)n?.unlisten(e,p);h?.close();for(let e of[...u.values()])e.closedBy(`close`);a.exit(e)}};l.onmessage=({data:e})=>{e.kind===`out`?(e.fd===2&&a.writeError?a.writeError:a.write)(e.bytes):e.kind===`net`?g(e):e.kind===`tty`?(S=[e.raw,!e.raw],a.raw?.(...S)):e.kind===`child`&&e.op===`spawn`?C(e):e.kind===`child`&&e.op===`kill`?ee(e.id):e.kind===`child`&&e.op===`stdin`?y.get(e.id)?.oninput?.(e.end?null:e.bytes):e.kind===`exit`&&te(e.code)},l.onerror=e=>{e.preventDefault(),(a.writeError??a.write)(`node: ${e.message||`the worker failed to start`}\n`),te(1)},a.onkill=()=>te(130),a.onowner=()=>te(130),l.postMessage({kind:`start`,args:o.args,cwd:o.cwd,env:o.env,doorbell:c.doorbell,channel:c.channel,tls:r,tty:o.tty?.stdout??!1,stdinTty:o.tty?.stdin??!1,bun:o.bun??!1,columns:a.size?.()[0]??80,rows:a.size?.()[1]??24}),a.oninput=e=>{let t=b.at(-1);if(t)return t.oninput?.(e);l.postMessage(e===null?{kind:`stdin`,end:!0}:{kind:`stdin`,bytes:e})},a.onresize=(e,t)=>{l.postMessage({kind:`resize`,columns:e,rows:t});for(let n of x)n.onresize?.(e,t)}};var nu=class{value;transfer;constructor(e,t){this.value=e,this.transfer=t}};const ru=(e,t)=>new nu(e,t);var iu=class{port;next=1;waiting=/* @__PURE__ */ new Map;handlers={};listeners=/* @__PURE__ */ new Map;constructor(e){this.port=e,e.onmessage=({data:e})=>void this.receive(e)}handle(e){return Object.assign(this.handlers,e),this}call(e,t=[],n=[]){let r=this.next++;return new Promise((i,a)=>{this.waiting.set(r,{resolve:i,reject:a}),this.port.postMessage({call:r,method:e,args:t},n)})}emit(e,t,n=[]){this.port.postMessage({event:e,data:t},n)}on(e,t){let n=this.listeners.get(e);return n||this.listeners.set(e,n=/* @__PURE__ */ new Set),n.add(t),()=>n.delete(t)}close(){for(let{reject:e}of this.waiting.values())e(/* @__PURE__ */ Error(`closed`));this.waiting.clear(),this.port.close()}async receive(e){if(`reply`in e){let t=this.waiting.get(e.reply);this.waiting.delete(e.reply),e.error===void 0?t?.resolve(e.value):t?.reject(Object.assign(Error(e.error),{code:e.code}))}else if(`call`in e)try{let t=this.handlers[e.method];if(!t)throw Error(`no such call: ${e.method}`);let n=await t(...e.args),[r,i]=n instanceof nu?[n.value,n.transfer]:[n,[]];this.port.postMessage({reply:e.call,value:r},i)}catch(t){let n=t?.code;this.port.postMessage({reply:e.call,error:t instanceof Error?t.message:String(t),...typeof n==`string`?{code:n}:{}})}else for(let t of this.listeners.get(e.event)??[])t(e.data)}};async function au(e,t,n,r){if(r.throwIfAborted(),await e.stat(`${t}/cli.js`))return;r.throwIfAborted();let i=/* @__PURE__ */ new Set([t]);for(let{name:e}of n)for(let n=e.indexOf(`/`);n>=0;n=e.indexOf(`/`,n+1))i.add(`${t}/${e.slice(0,n)}`);for(let t of[...i].sort())r.throwIfAborted(),await e.mkdir(t);r.throwIfAborted();let a=n.find(e=>e.name===`cli.js`);await Promise.all(n.filter(e=>e!==a).map(n=>e.write(`${t}/${n.name}`,n.data))),r.throwIfAborted(),a&&await e.write(`${t}/cli.js`,a.data)}async function ou(e,t,n){let r=await e();n.aborted&&(r.close(),n.throwIfAborted());let i=new iu(r),a=()=>i.close();n.addEventListener(`abort`,a,{once:!0}),i.on(`progress`,t);try{return await i.call(`files`)}finally{n.removeEventListener(`abort`,a),i.close()}}const su=(e,t)=>async(n,r)=>{let i=e().node,a=e=>(n.writeError??n.write)(e);if(!i)return a(`claude: node is not in this playground
|
|
1949
1939
|
`),n.exit(1);let o=new AbortController,{signal:s}=o,c=[];n.oninput=e=>c.push(e?.slice()??null);let l=()=>{o.abort(),c.length=0,n.exit(130)};n.onkill=l,n.onowner=l;let u;try{let{version:e,files:n}=await ou(t,a,s);u=`/opt/claude-code/${e}`,await au(r.fs,u,n,s),s.throwIfAborted()}catch(e){return s.aborted?void 0:(a(`claude: ${e.message}\n`),n.exit(1))}let d=i(n,{...r,args:[`${u}/cli.js`,`--allowedTools=Glob,Grep`,...r.args],env:{CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:`1`,SHELL:`/usr/bin/bash`,...r.env},bun:!0});for(let e of c.splice(0))n.oninput?.(e);return d},cu=`playground-npm`,lu=`11.6.2`,uu={os:`linux`,cpu:`wasm32`};function du(e,t){let n=e?.packages?.[t];if(!n||n.link||!n.version||!n.resolved||!n.integrity)return null;let{resolved:r,integrity:i,link:a,...o}=n;return{...o,name:n.name??t.slice(Fu(t)),version:n.version,dist:{tarball:r,integrity:i}}}var fu=class extends Error{};const pu=new TextDecoder,mu=/* @__PURE__ */ new Map;function hu(e){let t=mu.get(e);if(!t){let n=`https://registry.npmjs.org/${e.replace(`/`,`%2f`)}`,r=`${n}?missing`,i=()=>new fu(`${e}: no such package in the npm registry`);t=(async()=>{let t=await caches.open(cu).catch(()=>null),a=await t?.match(r).catch(()=>void 0);if(a&&Date.now()-Number(await a.text())<864e5)throw i();let o=await fetch(n,{headers:{Accept:`application/vnd.npm.install-v1+json`}});if(o.status===404)throw await t?.put(r,new Response(String(Date.now()))).catch(()=>{}),i();if(!o.ok)throw new fu(`${e}: the registry answered ${o.status}`);return o.json()})(),t.catch(()=>mu.delete(e)),mu.set(e,t)}return t}function gu(e,t){if(t.startsWith(`npm:`)){let e=t.slice(4),n=e.lastIndexOf(`@`);return n>0?{name:e.slice(0,n),range:e.slice(n+1)||`*`}:{name:e,range:`*`}}if(/^(file:|link:|workspace:|git\+|git:|github:|https?:)/.test(t)||/^[\w-]+\/[\w.-]+(#.*)?$/.test(t))throw new fu(`${e}@${t}: only registry versions install in the playground`);return{name:e,range:t.trim()||`*`}}function _u(e,t){let n=e[`dist-tags`][t];if(n)return e.versions[n]??null;if(!(0,T.validRange)(t))return null;let r=e[`dist-tags`].latest;if(r&&(0,T.satisfies)(r,t))return e.versions[r];let i=(0,T.maxSatisfying)(Object.keys(e.versions),t);return i?e.versions[i]:null}function vu(e,t){if(!e?.length)return!0;let n=e.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1)),r=e.filter(e=>!e.startsWith(`!`));return!n.includes(t)&&(!r.length||r.includes(t))}const yu=e=>vu(e.os,uu.os)&&vu(e.cpu,uu.cpu),bu=/^(.+)-(?:darwin|linux|win32|freebsd|android|openharmony|sunos|aix)-[\w-]+$/,xu={lightningcss:{wasm:`lightningcss-wasm`,binding:`lightningcss-linux-x64-gnu`}};function Su(e){let t=xu[e.name];if(t)return{[t.wasm]:e.version};let n=e.optionalDependencies??{};for(let[e,t]of Object.entries(n)){let r=bu.exec(e)?.[1];if(r&&!(`${r}-wasm32-wasi`in n))return{[`${r}-wasm32-wasi`]:t}}return null}function Cu(e,t){return t?typeof t==`string`?{[e.split(`/`).pop()]:t}:t:{}}function wu(e,t){let n=[];for(let r=e;n.push(`${r?`${r}/`:``}node_modules/${t}`),r;){let e=r.lastIndexOf(`/node_modules/`);r=e===-1?``:r.slice(0,e)}return n}function Tu(e,t,n,r){for(let i of e.values()){let a=i.manifest,o=a.dependencies?.[n]??a.optionalDependencies?.[n]??a.peerDependencies?.[n];if(o===void 0)continue;let s=wu(i.location,n),c=s.indexOf(t);if(c===-1||s.findIndex(t=>e.has(t))<=c)continue;let l;try{l=gu(n,o)}catch{continue}if(r.name!==l.name||!(0,T.validRange)(l.range)||!(0,T.satisfies)(r.version,l.range,{includePrerelease:!0}))return!0}return!1}const Eu=e=>Object.fromEntries(Object.entries(e.peerDependencies??{}).filter(([t])=>!e.peerDependenciesMeta?.[t]?.optional));function Du(e,t,n){let r=_u(e,t);if(!r||e[`dist-tags`][t])return r;let i=e=>Object.entries(Eu(e)).every(([e,t])=>{let r=n[e];return r===void 0||!(0,T.validRange)(r)||!(0,T.validRange)(t)||(0,T.intersects)(r,t,{includePrerelease:!0})});if(i(r))return r;let a=Object.keys(e.versions).filter(e=>(0,T.satisfies)(e,t)).sort(T.rcompare).find(t=>i(e.versions[t]));return a?e.versions[a]:r}const Ou=e=>e.slice(0,e.lastIndexOf(`node_modules/`)).replace(/\/$/,``);async function ku(e,t,n,r){let i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=[],s=(e,t,n,r,i)=>{for(let[a,s]of Object.entries(t??{}))o.push({from:e,name:a,spec:s,dev:n,optional:r,peerOf:i})};s(``,e.dependencies,!1,!1),s(``,e.devDependencies,!0,!1),s(``,e.optionalDependencies,!1,!0);let c=e=>{let r=gu(e.name,e.spec),i=!(e.from===``&&n.has(e.name)),a=(e,t)=>{let n=t?.[`dist-tags`][r.range]??r.range;return(0,T.validRange)(n)?(0,T.satisfies)(e,n,{includePrerelease:!0}):!t};return{target:r,satisfying:a,fromLock:e=>{let n=i?du(t,e):null;return n?.name===r.name&&a(n.version,null)?n:null}}};for(;o.length;){let n=o;o=[],await Promise.all(n.map(e=>{try{let{target:t,fromLock:n}=c(e);return wu(e.from,e.name).some(n)?null:hu(t.name).catch(()=>null)}catch{return null}}));for(let o of n){let n;try{n=c(o)}catch(e){if(o.optional)continue;throw e}let{target:l,satisfying:u,fromLock:d}=n,f=wu(o.from,o.name),p=null,m=async()=>{try{return p??=await hu(l.name),!0}catch(e){if(o.optional)return!1;throw e}};if(!f.some(d)&&!await m())continue;let h=f.length,g=null;for(let e=0;e<f.length;e++){let t=i.get(f[e]);if(t){t.manifest.name===l.name&&u(t.manifest.version,p)?g=t:h=e;break}}if(g)continue;if(h===0){let e=i.get(f[0]).manifest,t=i.get(o.from)?.manifest;o.optional||r(`npm warn ERESOLVE ${o.peerOf??(t?`${t.name}@${t.version}`:`the project`)} wants ${o.name}@${o.spec}${o.peerOf?` as a peer`:``}; ${e.name}@${e.version} kept\n`);continue}let _=o.from===``?e:i.get(o.from)?.manifest,v={..._?.dependencies,..._?.optionalDependencies},y=async e=>{let n=d(e);if(n)return n;if(!await m())return null;let r=t?.packages?.[e]?.version,i=p;return r&&i.versions[r]&&u(r,i)?i.versions[r]:Du(i,l.range,v)},b=f[0],x=null;for(let e=h-1;e>=0&&(b=f[e],x=await y(b),x&&e!==0&&Tu(i,b,o.name,x));e--);if(!x){if(o.optional)continue;throw new fu(`${o.name}@${o.spec}: no version of ${l.name} matches`)}yu(x)?(x.deprecated&&r(`npm warn deprecated ${x.name}@${x.version}: ${x.deprecated}\n`),i.set(b,{location:b,manifest:x,dev:o.dev,optional:o.optional}),s(b,x.dependencies,o.dev,o.optional),s(b,x.optionalDependencies,o.dev,!0),s(b,Su(x)??void 0,o.dev,!0),s(Ou(b),Eu(x),o.dev,o.optional,`${x.name}@${x.version}`)):o.optional?a.set(b,{location:b,manifest:x,dev:o.dev,optional:!0}):r(`npm warn ${x.name}@${x.version}: not for this platform (${uu.os}, ${uu.cpu}); skipped\n`)}}for(let e of i.values())e.dev=e.optional=!0;let l=(e,t,n,r)=>{for(let a of Object.keys(t??{})){let t=wu(e,a).map(e=>i.get(e)).find(Boolean);if(!t||!(t.dev&&!n||t.optional&&!r))continue;t.dev&&=n,t.optional&&=r;let o=t.manifest;l(t.location,o.dependencies,t.dev,t.optional),l(t.location,o.optionalDependencies,t.dev,!0),l(t.location,Su(o),t.dev,!0),l(Ou(t.location),Eu(o),t.dev,t.optional)}};l(``,e.dependencies,!1,!1),l(``,e.devDependencies,!0,!1),l(``,e.optionalDependencies,!1,!0);for(let e of i.keys())a.delete(e);return{tree:i,skipped:a}}async function Au(e){let t=e.dist.tarball,n=await caches.open(cu).catch(()=>null),r=await n?.match(t),i=!1;if(!r){if(r=await fetch(t),!r.ok)throw new fu(`${e.name}@${e.version}: ${t} answered ${r.status}`);i=!0}let a=new Uint8Array(await r.clone().arrayBuffer());return await ju(e,a),i&&await n?.put(t,new Response(a)).catch(()=>{}),a}async function ju(e,t){let n=e.dist.integrity?.split(/\s+/).find(e=>e.startsWith(`sha512-`));if(n){let r=new Uint8Array(await crypto.subtle.digest(`SHA-512`,t));if(btoa(String.fromCharCode(...r))!==n.slice(7))throw new fu(`${e.name}@${e.version}: its tarball does not match its integrity`)}else if(e.dist.shasum&&[...new Uint8Array(await crypto.subtle.digest(`SHA-1`,t))].map(e=>e.toString(16).padStart(2,`0`)).join(``)!==e.dist.shasum)throw new fu(`${e.name}@${e.version}: its tarball does not match its shasum`)}async function Mu(e,t,n){let r=await lt(await Au(t)),i=[],a=/* @__PURE__ */ new Set([n]),o=null;for(let e of st(r)){if(e.type!==`0`&&e.type!==`\0`)continue;let t=e.name.split(`/`).slice(1).join(`/`);if(!t||t.split(`/`).includes(`..`))continue;let r=`${n}/${t}`;a.add(r.slice(0,r.lastIndexOf(`/`))),i.push([r,e.body]),t===`package.json`&&(o=JSON.parse(pu.decode(e.body)))}await e.remove(n).catch(()=>{});for(let t of[...a].sort())await e.mkdir(t);for(let t=0;t<i.length;t+=64)await Promise.all(i.slice(t,t+64).map(([t,n])=>e.write(t,n)));return o??{name:t.name,version:t.version}}async function Nu(e,t){try{return JSON.parse(pu.decode(await e.read(t)))}catch{return null}}async function Pu(e,t){for(let n=t;;n=n.slice(0,n.lastIndexOf(`/`))||`/`){if(await e.stat(`${n===`/`?``:n}/package.json`)===`file`)return n;if(n===`/`)return null}}const Fu=e=>e.lastIndexOf(`node_modules/`)+13;function Iu(e,t){let n=/* @__PURE__ */ new Map;for(let t of e){let e=t.location.split(`node_modules/`).length;n.set(e,[...n.get(e)??[],t])}let r=[];for(let e of[...n.keys()].sort((e,t)=>e-t)){let i=n.get(e);for(let e=0;e<i.length;e+=t)r.push(i.slice(e,e+t))}return r}function Lu(e){let t=e.indexOf(`@`,1);return t>0?[e.slice(0,t),e.slice(t+1)]:[e,`latest`]}async function Ru(e,t,n,r,i){let a=`${t}/package.json`,o=await Nu(e,a)??{},s=await Nu(e,`${t}/package-lock.json`);for(let[n,r]of Object.entries(s?.packages??{})){if(!n||!r.peerDependencies||r.peerDependenciesMeta)continue;let i=await Nu(e,`${t}/${n}/package.json`);i&&i.version===r.version&&(r.peerDependenciesMeta=i.peerDependenciesMeta??{})}let c=!1,l=/* @__PURE__ */ new Set;for(let e of n){let[t,n]=Lu(e);l.add(t);let i=gu(t,n),a=_u(await hu(i.name),i.range);if(!a)throw new fu(`${e}: no version matches`);let s=r.dev?`devDependencies`:`dependencies`,u=(0,T.valid)(i.range)||!(0,T.validRange)(i.range)||i.range===`latest`||i.range===`*`?`${r.exact?``:`^`}${a.version}`:i.range,d={...o[s],[t]:i.name===t?u:`npm:${i.name}@${u}`};o[s]=Object.fromEntries(Object.entries(d).sort(([e],[t])=>e<t?-1:1)),r.dev?delete o.dependencies?.[t]:delete o.devDependencies?.[t],c=!0}let{tree:u,skipped:d}=await ku(o,s,l,i),f=0,p=[],m=[...u.values()].sort((e,t)=>e.location.length-t.location.length),h=/* @__PURE__ */ new Map;for(let n of Iu(m,6))await Promise.all(n.map(async n=>{let r=`${t}/${n.location}`,i=await Nu(e,`${r}/package.json`);i?.version===n.manifest.version&&i.name===n.manifest.name?h.set(n.location,i):(h.set(n.location,await Mu(e,n.manifest,r)),f++,n.manifest.hasInstallScript&&p.push(`${n.manifest.name}@${n.manifest.version}`))}));for(let n of m){let r=xu[n.manifest.name];if(!r)continue;let i=`${t}/${n.location.slice(0,Fu(n.location))}${r.binding}`;await e.mkdir(i),await e.write(`${i}/package.json`,`${JSON.stringify({name:r.binding,version:n.manifest.version,main:`index.js`,description:`the playground's stand-in: ${r.wasm}`},null,2)}\n`),await e.write(`${i}/index.js`,`module.exports = require(${JSON.stringify(r.wasm)});\n`)}for(let n of m){let r=h.get(n.location),i=Fu(n.location),a=`${t}/${n.location.slice(0,i-1)}`;for(let[t,o]of Object.entries(Cu(n.manifest.name,r?.bin??n.manifest.bin))){let r=`${a}/.bin/${t}`;await e.mkdir(`${a}/.bin`),await e.unlink(r).catch(()=>{}),await e.symlink(`../${n.location.slice(i)}/${o.replace(/^\.\//,``)}`,r)}}return p.length&&i(`npm warn install scripts not run (the playground does not run them): ${p.join(`, `)}\n`),c&&r.save&&await e.write(a,`${JSON.stringify(o,null,2)}\n`),r.save&&await e.write(`${t}/package-lock.json`,`${JSON.stringify(zu(o,[...m,...d.values()]),null,2)}\n`),{added:f,total:m.length}}function zu(e,t){let n={"":{name:e.name,version:e.version,dependencies:e.dependencies,devDependencies:e.devDependencies,optionalDependencies:e.optionalDependencies}};for(let e of[...t].sort((e,t)=>e.location<t.location?-1:1)){let t=e.manifest,r=e.location.slice(Fu(e.location));n[e.location]={...r===t.name?{}:{name:t.name},version:t.version,resolved:t.dist.tarball,integrity:t.dist.integrity,...e.dev?{dev:!0}:{},...e.optional?{optional:!0}:{},...t.license?{license:t.license}:{},...t.dependencies?{dependencies:t.dependencies}:{},...t.optionalDependencies?{optionalDependencies:t.optionalDependencies}:{},...t.peerDependencies?{peerDependencies:t.peerDependencies}:{},...t.peerDependenciesMeta?{peerDependenciesMeta:t.peerDependenciesMeta}:{},...t.bin?{bin:Cu(t.name,t.bin)}:{},...t.engines?{engines:t.engines}:{},...t.os?{os:t.os}:{},...t.cpu?{cpu:t.cpu}:{},...t.hasInstallScript?{hasInstallScript:!0}:{},...t.deprecated?{deprecated:t.deprecated}:{}}}return{name:e.name,version:e.version,lockfileVersion:3,requires:!0,packages:n}}function Bu(e,t,n){return new Promise(r=>{let i=!1,a={write:e=>t.write(e),writeError:e=>(t.writeError??t.write)(e),exit:(e=0)=>{i||(i=!0,r(e))},onkill:null,onowner:null,raw:t.raw?(e,n)=>t.raw(e,n):void 0,size:t.size?()=>t.size():void 0};t.onkill=()=>a.onkill?.(),t.onowner=()=>a.onowner?.();let o=[],s=null;Object.defineProperty(a,"oninput",{get:()=>s,set:e=>{for(s=e;o.length;){let e=s;if(!e)break;e(o.shift())}}}),t.oninput=e=>s?s(e):void o.push(e),t.onresize=(e,t)=>a.onresize?.(e,t),Promise.resolve(e(a,n)).catch(e=>{a.writeError(`${e.message}\n`),a.exit(1)})})}const Vu=e=>/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`;function Hu(e,t=``){let n=[];for(let t=e;n.push(`${t===`/`?``:t}/node_modules/.bin`),t!==`/`;t=t.slice(0,t.lastIndexOf(`/`))||`/`);return[...n,t].filter(Boolean).join(`:`)}async function Uu(e,t,n){for(let r of Hu(t).split(`:`)){let t=`${r}/${n}`;if(await e.stat(t)===`file`)return t}return null}const Wu=`npm ${lu} on the playground's Node.js
|
|
1950
1940
|
|
|
1951
1941
|
npm install [PACKAGE[@VERSION]...] [-D|--save-dev] [-E|--save-exact]
|
package/git.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,n as t,o as n}from"./chunks/fs-GnBaZCKr.js";import{d as r}from"./chunks/wasi-
|
|
1
|
+
import{_ as e,n as t,o as n}from"./chunks/fs-GnBaZCKr.js";import{d as r}from"./chunks/wasi-BuobPCe8.js";import{_ as i,a,d as o,i as s,m as c,n as l,r as u,t as d,y as f}from"./chunks/git-remote-Bb9EZlDN.js";var p=[`/work`,`/tmp`,`/home`,`/shared`],m=null,h=[],g=!1,_=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},v=e=>({stream:!0,sink:t=>void e.push(t.slice())});async function y({id:e,args:t,cwd:n,env:r,stdin:o}){let s=[],l=[],u=c(o??new Uint8Array),d=m.spawn({program:`git`,args:t,cwd:n,env:{...a,...r,PWD:n},stdio:[u,v(s),v(l)]});return i(u),d?{id:e,code:await m.wait(d.pid,0)??1,stdout:_(s),stderr:_(l)}:{id:e,code:127,stdout:new Uint8Array,stderr:new Uint8Array}}async function b(){if(!g){for(g=!0;h.length;){let e=h.shift(),t;try{t=await y(e)}catch(n){let r=new TextEncoder().encode(`git: ${String(n)}\n`);t={id:e.id,code:1,stdout:new Uint8Array,stderr:r}}postMessage(t,{transfer:[t.stdout.buffer,t.stderr.buffer]})}g=!1}}onmessage=({data:i})=>{if(i.kind===`start`){let a=new t;for(let e of[...p.map(e=>e.slice(1)),`home/user`])a.mkdirs(e);a.mkdirs(`usr/share/git-core/templates`),a.put(`dev/urandom`,e()),a.put(`dev/null`,n());let c={prefixes:p,call:r(i.files.doorbell,i.files.channel)},h=()=>new Uint8Array;m=new o((e,t)=>{let n=e.split(`/`).pop();return n===`git`&&/^remote-https?$/.test(t[0]??``)?u(s(location.origin)):n!==`git`&&!l.has(n)?null:f(m,i.git,{root:a,fetch:h,shared:c,argv0:n,defaults:{GIT_PAGER:`cat`,...d}})})}else h.push(i),b()};
|
package/licenses/index.json
CHANGED
|
@@ -129,15 +129,6 @@
|
|
|
129
129
|
"fflate-0.8.2/LICENSE"
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
|
-
{
|
|
133
|
-
"name": "fzstd",
|
|
134
|
-
"version": "0.1.1",
|
|
135
|
-
"license": "MIT",
|
|
136
|
-
"url": "https://github.com/101arrowz/fzstd",
|
|
137
|
-
"texts": [
|
|
138
|
-
"fzstd-0.1.1/LICENSE"
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
132
|
{
|
|
142
133
|
"name": "get-east-asian-width",
|
|
143
134
|
"version": "1.7.0",
|