@live-codes/pascal-wasm 0.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/LICENSE +501 -0
- package/README.md +278 -0
- package/THIRD-PARTY-NOTICES.md +48 -0
- package/assets/pas2js.wasm +0 -0
- package/assets/rtl/Rtl.BrowserLoadHelper.pas +179 -0
- package/assets/rtl/browserconsole.pas +190 -0
- package/assets/rtl/classes.pas +11371 -0
- package/assets/rtl/js.pas +2211 -0
- package/assets/rtl/manifest.json +19 -0
- package/assets/rtl/math.pas +903 -0
- package/assets/rtl/p2jsres.pp +334 -0
- package/assets/rtl/rtl.js +1563 -0
- package/assets/rtl/rtlconsts.pas +97 -0
- package/assets/rtl/simplelinkedlist.pas +152 -0
- package/assets/rtl/system.pas +1166 -0
- package/assets/rtl/sysutils.pas +8959 -0
- package/assets/rtl/types.pas +2296 -0
- package/assets/rtl/typinfo.pas +1680 -0
- package/assets/rtl/web.pas +3586 -0
- package/assets/rtl/weborworker.pas +2101 -0
- package/dist/pascal-wasm.iife.min.js +6 -0
- package/dist/pascal-wasm.iife.min.js.map +7 -0
- package/package.json +54 -0
- package/src/assets.js +119 -0
- package/src/compiler.js +142 -0
- package/src/config.js +24 -0
- package/src/iife.js +27 -0
- package/src/index.js +130 -0
- package/src/vendor/browser_wasi_shim/debug.js +1 -0
- package/src/vendor/browser_wasi_shim/fd.js +1 -0
- package/src/vendor/browser_wasi_shim/fs_mem.js +1 -0
- package/src/vendor/browser_wasi_shim/fs_opfs.js +1 -0
- package/src/vendor/browser_wasi_shim/index.js +1 -0
- package/src/vendor/browser_wasi_shim/strace.js +1 -0
- package/src/vendor/browser_wasi_shim/wasi.js +1 -0
- package/src/vendor/browser_wasi_shim/wasi_defs.js +1 -0
- package/types/index.d.ts +89 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(()=>{var Mt=Object.create;var Ot=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var jt=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var ht=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var Kt=(_,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of kt(t))!Wt.call(_,c)&&c!==e&&Ot(_,c,{get:()=>t[c],enumerable:!(i=Vt(t,c))||i.enumerable});return _};var St=(_,t,e)=>(e=_!=null?Mt(jt(_)):{},Kt(t||!_||!_.__esModule?Ot(e,"default",{value:_,enumerable:!0}):e,_));var tt={baseUrl:null,flags:[]};function et(_={}){_.baseUrl!==void 0&&(tt.baseUrl=_.baseUrl),_.flags!==void 0&&(tt.flags=[..._.flags])}function $(){return tt}var vt={};function X(_,t){return _ instanceof URL?_:new URL(_,t)}function M(){let{baseUrl:_}=$();if(_)return X(_,xt());let t=zt();if(t)return new URL("../assets/",t);throw new Error('@live-codes/pascal-wasm: cannot locate the compiler assets. Pass a location, e.g. createCompiler({ baseUrl: "\u2026/assets/" }) or configure({ baseUrl: "\u2026" }).')}async function Tt({baseUrl:_,wasmUrl:t,rtlUrl:e}={}){let i=_?X(_,xt()):M(),c=e?X(e,i):new URL("rtl/",i),r=t?X(t,i):new URL("pas2js.wasm",i),n=new URL("manifest.json",c),s=JSON.parse(await $t(n));if(!Array.isArray(s.units))throw new Error(`Invalid RTL manifest at ${n}`);let[o,...a]=await Promise.all([Xt(r),...s.units.map(async({filename:f})=>[f,await It(new URL(f,c))])]);return{baseUrl:i,wasm:o,rtl:new Map(a)}}function xt(){return globalThis.location?.href}function zt(){try{return vt.url||null}catch{return null}}async function $t(_){if(_.protocol==="file:"){let{readFile:e}=await import("node:fs/promises");return e(_,"utf8")}let t=await fetch(_);if(!t.ok)throw new Error(`Failed to load ${_}: HTTP ${t.status}`);return t.text()}async function It(_){if(_.protocol==="file:"){let{readFile:e}=await import("node:fs/promises");return new Uint8Array(await e(_))}let t=await fetch(_);if(!t.ok)throw new Error(`Failed to load ${_}: HTTP ${t.status}`);return new Uint8Array(await t.arrayBuffer())}async function Xt(_){if(_.protocol==="http:"||_.protocol==="https:")try{return await WebAssembly.compileStreaming(fetch(_))}catch{}return WebAssembly.compile(await It(_))}var V=class _{static read_bytes(t,e){let i=new _;return i.buf=t.getUint32(e,!0),i.buf_len=t.getUint32(e+4,!0),i}static read_bytes_array(t,e,i){let c=[];for(let r=0;r<i;r++)c.push(_.read_bytes(t,e+8*r));return c}},k=class _{static read_bytes(t,e){let i=new _;return i.buf=t.getUint32(e,!0),i.buf_len=t.getUint32(e+4,!0),i}static read_bytes_array(t,e,i){let c=[];for(let r=0;r<i;r++)c.push(_.read_bytes(t,e+8*r));return c}},At=0,mt=1,nt=2;var st=2,I=3,j=4;var C=class{head_length(){return 24}name_length(){return this.dir_name.byteLength}write_head_bytes(t,e){t.setBigUint64(e,this.d_next,!0),t.setBigUint64(e+8,this.d_ino,!0),t.setUint32(e+16,this.dir_name.length,!0),t.setUint8(e+20,this.d_type)}write_name_bytes(t,e,i){t.set(this.dir_name.slice(0,Math.min(this.dir_name.byteLength,i)),e)}constructor(t,e,i,c){let r=new TextEncoder().encode(i);this.d_next=t,this.d_ino=e,this.d_namlen=r.byteLength,this.d_type=c,this.dir_name=r}};var yt=1;var F=class{write_bytes(t,e){t.setUint8(e,this.fs_filetype),t.setUint16(e+2,this.fs_flags,!0),t.setBigUint64(e+8,this.fs_rights_base,!0),t.setBigUint64(e+16,this.fs_rights_inherited,!0)}constructor(t,e){this.fs_rights_base=0n,this.fs_rights_inherited=0n,this.fs_filetype=t,this.fs_flags=e}};var Z=1,G=2,it=4,ot=8,P=class{write_bytes(t,e){t.setBigUint64(e,this.dev,!0),t.setBigUint64(e+8,this.ino,!0),t.setUint8(e+16,this.filetype),t.setBigUint64(e+24,this.nlink,!0),t.setBigUint64(e+32,this.size,!0),t.setBigUint64(e+38,this.atim,!0),t.setBigUint64(e+46,this.mtim,!0),t.setBigUint64(e+52,this.ctim,!0)}constructor(t,e,i){this.dev=0n,this.nlink=0n,this.atim=0n,this.mtim=0n,this.ctim=0n,this.ino=t,this.filetype=e,this.size=i}},gt=0;var Dt=1,v=class _{static read_bytes(t,e){return new _(t.getBigUint64(e,!0),t.getUint8(e+8),t.getUint32(e+16,!0),t.getBigUint64(e+24,!0),t.getUint16(e+36,!0))}constructor(t,e,i,c,r){this.userdata=t,this.eventtype=e,this.clockid=i,this.timeout=c,this.flags=r}},J=class{write_bytes(t,e){t.setBigUint64(e,this.userdata,!0),t.setUint16(e+8,this.error,!0),t.setUint8(e+10,this.eventtype)}constructor(t,e,i){this.userdata=t,this.error=e,this.eventtype=i}};var Jt=0,rt=class{write_bytes(t,e){t.setUint32(e,this.pr_name.byteLength,!0)}constructor(t){this.pr_name=new TextEncoder().encode(t)}},Q=class _{static dir(t){let e=new _;return e.tag=Jt,e.inner=new rt(t),e}write_bytes(t,e){t.setUint32(e,this.tag,!0),this.inner.write_bytes(t,e+4)}};var Qt=class{enable(t){this.log=Zt(t===void 0?!0:t,this.prefix)}get enabled(){return this.isEnabled}constructor(t){this.isEnabled=t,this.prefix="wasi:",this.enable(t)}};function Zt(_,t){return _?console.log.bind(console,"%c%s","color: #265BA0",t):()=>{}}var T=new Qt(!1);var U=class extends Error{constructor(t){super("exit with exit code "+t),this.code=t}},ct=class{start(t){this.inst=t;try{return t.exports._start(),0}catch(e){if(e instanceof U)return e.code;throw e}}initialize(t){this.inst=t,t.exports._initialize&&t.exports._initialize()}constructor(t,e,i,c={}){this.args=[],this.env=[],this.fds=[],T.enable(c.debug),this.args=t,this.env=e,this.fds=i;let r=this;this.wasiImport={args_sizes_get(n,s){let o=new DataView(r.inst.exports.memory.buffer);o.setUint32(n,r.args.length,!0);let a=0;for(let f of r.args)a+=f.length+1;return o.setUint32(s,a,!0),T.log(o.getUint32(n,!0),o.getUint32(s,!0)),0},args_get(n,s){let o=new DataView(r.inst.exports.memory.buffer),a=new Uint8Array(r.inst.exports.memory.buffer),f=s;for(let l=0;l<r.args.length;l++){o.setUint32(n,s,!0),n+=4;let R=new TextEncoder().encode(r.args[l]);a.set(R,s),o.setUint8(s+R.length,0),s+=R.length+1}return T.enabled&&T.log(new TextDecoder("utf-8").decode(a.slice(f,s))),0},environ_sizes_get(n,s){let o=new DataView(r.inst.exports.memory.buffer);o.setUint32(n,r.env.length,!0);let a=0;for(let f of r.env)a+=new TextEncoder().encode(f).length+1;return o.setUint32(s,a,!0),T.log(o.getUint32(n,!0),o.getUint32(s,!0)),0},environ_get(n,s){let o=new DataView(r.inst.exports.memory.buffer),a=new Uint8Array(r.inst.exports.memory.buffer),f=s;for(let l=0;l<r.env.length;l++){o.setUint32(n,s,!0),n+=4;let R=new TextEncoder().encode(r.env[l]);a.set(R,s),o.setUint8(s+R.length,0),s+=R.length+1}return T.enabled&&T.log(new TextDecoder("utf-8").decode(a.slice(f,s))),0},clock_res_get(n,s){let o;switch(n){case 1:{o=5000n;break}case 0:{o=1000000n;break}default:return 52}return new DataView(r.inst.exports.memory.buffer).setBigUint64(s,o,!0),0},clock_time_get(n,s,o){let a=new DataView(r.inst.exports.memory.buffer);if(n===0)a.setBigUint64(o,BigInt(new Date().getTime())*1000000n,!0);else if(n==1){let f;try{f=BigInt(Math.round(performance.now()*1e6))}catch{f=0n}a.setBigUint64(o,f,!0)}else a.setBigUint64(o,0n,!0);return 0},fd_advise(n,s,o,a){return r.fds[n]!=null?0:8},fd_allocate(n,s,o){return r.fds[n]!=null?r.fds[n].fd_allocate(s,o):8},fd_close(n){if(r.fds[n]!=null){let s=r.fds[n].fd_close();return r.fds[n]=void 0,s}else return 8},fd_datasync(n){return r.fds[n]!=null?r.fds[n].fd_sync():8},fd_fdstat_get(n,s){if(r.fds[n]!=null){let{ret:o,fdstat:a}=r.fds[n].fd_fdstat_get();return a?.write_bytes(new DataView(r.inst.exports.memory.buffer),s),o}else return 8},fd_fdstat_set_flags(n,s){return r.fds[n]!=null?r.fds[n].fd_fdstat_set_flags(s):8},fd_fdstat_set_rights(n,s,o){return r.fds[n]!=null?r.fds[n].fd_fdstat_set_rights(s,o):8},fd_filestat_get(n,s){if(r.fds[n]!=null){let{ret:o,filestat:a}=r.fds[n].fd_filestat_get();return a?.write_bytes(new DataView(r.inst.exports.memory.buffer),s),o}else return 8},fd_filestat_set_size(n,s){return r.fds[n]!=null?r.fds[n].fd_filestat_set_size(s):8},fd_filestat_set_times(n,s,o,a){return r.fds[n]!=null?r.fds[n].fd_filestat_set_times(s,o,a):8},fd_pread(n,s,o,a,f){let l=new DataView(r.inst.exports.memory.buffer),R=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let d=V.read_bytes_array(l,s,o),p=0;for(let u of d){let{ret:w,data:h}=r.fds[n].fd_pread(u.buf_len,a);if(w!=0)return l.setUint32(f,p,!0),w;if(R.set(h,u.buf),p+=h.length,a+=BigInt(h.length),h.length!=u.buf_len)break}return l.setUint32(f,p,!0),0}else return 8},fd_prestat_get(n,s){let o=new DataView(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let{ret:a,prestat:f}=r.fds[n].fd_prestat_get();return f?.write_bytes(o,s),a}else return 8},fd_prestat_dir_name(n,s,o){if(r.fds[n]!=null){let{ret:a,prestat:f}=r.fds[n].fd_prestat_get();if(f==null)return a;let l=f.inner.pr_name;return new Uint8Array(r.inst.exports.memory.buffer).set(l.slice(0,o),s),l.byteLength>o?37:0}else return 8},fd_pwrite(n,s,o,a,f){let l=new DataView(r.inst.exports.memory.buffer),R=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let d=k.read_bytes_array(l,s,o),p=0;for(let u of d){let w=R.slice(u.buf,u.buf+u.buf_len),{ret:h,nwritten:S}=r.fds[n].fd_pwrite(w,a);if(h!=0)return l.setUint32(f,p,!0),h;if(p+=S,a+=BigInt(S),S!=w.byteLength)break}return l.setUint32(f,p,!0),0}else return 8},fd_read(n,s,o,a){let f=new DataView(r.inst.exports.memory.buffer),l=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let R=V.read_bytes_array(f,s,o),d=0;for(let p of R){let{ret:u,data:w}=r.fds[n].fd_read(p.buf_len);if(u!=0)return f.setUint32(a,d,!0),u;if(l.set(w,p.buf),d+=w.length,w.length!=p.buf_len)break}return f.setUint32(a,d,!0),0}else return 8},fd_readdir(n,s,o,a,f){let l=new DataView(r.inst.exports.memory.buffer),R=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let d=0;for(;;){let{ret:p,dirent:u}=r.fds[n].fd_readdir_single(a);if(p!=0)return l.setUint32(f,d,!0),p;if(u==null)break;if(o-d<u.head_length()){d=o;break}let w=new ArrayBuffer(u.head_length());if(u.write_head_bytes(new DataView(w),0),R.set(new Uint8Array(w).slice(0,Math.min(w.byteLength,o-d)),s),s+=u.head_length(),d+=u.head_length(),o-d<u.name_length()){d=o;break}u.write_name_bytes(R,s,o-d),s+=u.name_length(),d+=u.name_length(),a=u.d_next}return l.setUint32(f,d,!0),0}else return 8},fd_renumber(n,s){if(r.fds[n]!=null&&r.fds[s]!=null){let o=r.fds[s].fd_close();return o!=0?o:(r.fds[s]=r.fds[n],r.fds[n]=void 0,0)}else return 8},fd_seek(n,s,o,a){let f=new DataView(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let{ret:l,offset:R}=r.fds[n].fd_seek(s,o);return f.setBigInt64(a,R,!0),l}else return 8},fd_sync(n){return r.fds[n]!=null?r.fds[n].fd_sync():8},fd_tell(n,s){let o=new DataView(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let{ret:a,offset:f}=r.fds[n].fd_tell();return o.setBigUint64(s,f,!0),a}else return 8},fd_write(n,s,o,a){let f=new DataView(r.inst.exports.memory.buffer),l=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let R=k.read_bytes_array(f,s,o),d=0;for(let p of R){let u=l.slice(p.buf,p.buf+p.buf_len),{ret:w,nwritten:h}=r.fds[n].fd_write(u);if(w!=0)return f.setUint32(a,d,!0),w;if(d+=h,h!=u.byteLength)break}return f.setUint32(a,d,!0),0}else return 8},path_create_directory(n,s,o){let a=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let f=new TextDecoder("utf-8").decode(a.slice(s,s+o));return r.fds[n].path_create_directory(f)}else return 8},path_filestat_get(n,s,o,a,f){let l=new DataView(r.inst.exports.memory.buffer),R=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let d=new TextDecoder("utf-8").decode(R.slice(o,o+a)),{ret:p,filestat:u}=r.fds[n].path_filestat_get(s,d);return u?.write_bytes(l,f),p}else return 8},path_filestat_set_times(n,s,o,a,f,l,R){let d=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let p=new TextDecoder("utf-8").decode(d.slice(o,o+a));return r.fds[n].path_filestat_set_times(s,p,f,l,R)}else return 8},path_link(n,s,o,a,f,l,R){let d=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null&&r.fds[f]!=null){let p=new TextDecoder("utf-8").decode(d.slice(o,o+a)),u=new TextDecoder("utf-8").decode(d.slice(l,l+R)),{ret:w,inode_obj:h}=r.fds[n].path_lookup(p,s);return h==null?w:r.fds[f].path_link(u,h,!1)}else return 8},path_open(n,s,o,a,f,l,R,d,p){let u=new DataView(r.inst.exports.memory.buffer),w=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let h=new TextDecoder("utf-8").decode(w.slice(o,o+a));T.log(h);let{ret:S,fd_obj:D}=r.fds[n].path_open(s,h,f,l,R,d);if(S!=0)return S;r.fds.push(D);let Yt=r.fds.length-1;return u.setUint32(p,Yt,!0),0}else return 8},path_readlink(n,s,o,a,f,l){let R=new DataView(r.inst.exports.memory.buffer),d=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let p=new TextDecoder("utf-8").decode(d.slice(s,s+o));T.log(p);let{ret:u,data:w}=r.fds[n].path_readlink(p);if(w!=null){let h=new TextEncoder().encode(w);if(h.length>f)return R.setUint32(l,0,!0),8;d.set(h,a),R.setUint32(l,h.length,!0)}return u}else return 8},path_remove_directory(n,s,o){let a=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let f=new TextDecoder("utf-8").decode(a.slice(s,s+o));return r.fds[n].path_remove_directory(f)}else return 8},path_rename(n,s,o,a,f,l){let R=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null&&r.fds[a]!=null){let d=new TextDecoder("utf-8").decode(R.slice(s,s+o)),p=new TextDecoder("utf-8").decode(R.slice(f,f+l)),{ret:u,inode_obj:w}=r.fds[n].path_unlink(d);if(w==null)return u;if(u=r.fds[a].path_link(p,w,!0),u!=0&&r.fds[n].path_link(d,w,!0)!=0)throw"path_link should always return success when relinking an inode back to the original place";return u}else return 8},path_symlink(n,s,o,a,f){let l=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[o]!=null){let R=new TextDecoder("utf-8").decode(l.slice(n,n+s)),d=new TextDecoder("utf-8").decode(l.slice(a,a+f));return 58}else return 8},path_unlink_file(n,s,o){let a=new Uint8Array(r.inst.exports.memory.buffer);if(r.fds[n]!=null){let f=new TextDecoder("utf-8").decode(a.slice(s,s+o));return r.fds[n].path_unlink_file(f)}else return 8},poll_oneoff(n,s,o){if(o===0)return 28;if(o>1)return T.log("poll_oneoff: only a single subscription is supported"),58;let a=new DataView(r.inst.exports.memory.buffer),f=v.read_bytes(a,n),l=f.eventtype,R=f.clockid,d=f.timeout;if(l!==gt)return T.log("poll_oneoff: only clock subscriptions are supported"),58;let p;if(R===1)p=()=>BigInt(Math.round(performance.now()*1e6));else if(R===0)p=()=>BigInt(new Date().getTime())*1000000n;else return 28;let u=(f.flags&Dt)!==0?d:p()+d;for(;u>p(););return new J(f.userdata,0,l).write_bytes(a,s),0},proc_exit(n){throw new U(n)},proc_raise(n){throw"raised signal "+n},sched_yield(){},random_get(n,s){let o=new Uint8Array(r.inst.exports.memory.buffer).subarray(n,n+s);if("crypto"in globalThis&&(typeof SharedArrayBuffer>"u"||!(r.inst.exports.memory.buffer instanceof SharedArrayBuffer)))for(let a=0;a<s;a+=65536)crypto.getRandomValues(o.subarray(a,a+65536));else for(let a=0;a<s;a++)o[a]=Math.random()*256|0},sock_recv(n,s,o){throw"sockets not supported"},sock_send(n,s,o){throw"sockets not supported"},sock_shutdown(n,s){throw"sockets not supported"},sock_accept(n,s){throw"sockets not supported"}}}};var B=class{fd_allocate(t,e){return 58}fd_close(){return 0}fd_fdstat_get(){return{ret:58,fdstat:null}}fd_fdstat_set_flags(t){return 58}fd_fdstat_set_rights(t,e){return 58}fd_filestat_get(){return{ret:58,filestat:null}}fd_filestat_set_size(t){return 58}fd_filestat_set_times(t,e,i){return 58}fd_pread(t,e){return{ret:58,data:new Uint8Array}}fd_prestat_get(){return{ret:58,prestat:null}}fd_pwrite(t,e){return{ret:58,nwritten:0}}fd_read(t){return{ret:58,data:new Uint8Array}}fd_readdir_single(t){return{ret:58,dirent:null}}fd_seek(t,e){return{ret:58,offset:0n}}fd_sync(){return 0}fd_tell(){return{ret:58,offset:0n}}fd_write(t){return{ret:58,nwritten:0}}path_create_directory(t){return 58}path_filestat_get(t,e){return{ret:58,filestat:null}}path_filestat_set_times(t,e,i,c,r){return 58}path_link(t,e,i){return 58}path_unlink(t){return{ret:58,inode_obj:null}}path_lookup(t,e){return{ret:58,inode_obj:null}}path_open(t,e,i,c,r,n){return{ret:54,fd_obj:null}}path_readlink(t){return{ret:58,data:null}}path_remove_directory(t){return 58}path_rename(t,e,i){return 58}path_unlink_file(t){return 58}},m=class _{static issue_ino(){return _.next_ino++}static root_ino(){return 0n}constructor(){this.ino=_.issue_ino()}};m.next_ino=1n;var H=class extends B{fd_allocate(t,e){if(!(this.file.size>t+e)){let i=new Uint8Array(Number(t+e));i.set(this.file.data,0),this.file.data=i}return 0}fd_fdstat_get(){return{ret:0,fdstat:new F(j,0)}}fd_filestat_set_size(t){if(this.file.size>t)this.file.data=new Uint8Array(this.file.data.buffer.slice(0,Number(t)));else{let e=new Uint8Array(Number(t));e.set(this.file.data,0),this.file.data=e}return 0}fd_read(t){let e=this.file.data.slice(Number(this.file_pos),Number(this.file_pos+BigInt(t)));return this.file_pos+=BigInt(e.length),{ret:0,data:e}}fd_pread(t,e){return{ret:0,data:this.file.data.slice(Number(e),Number(e+BigInt(t)))}}fd_seek(t,e){let i;switch(e){case At:i=t;break;case mt:i=this.file_pos+t;break;case nt:i=BigInt(this.file.data.byteLength)+t;break;default:return{ret:28,offset:0n}}return i<0?{ret:28,offset:0n}:(this.file_pos=i,{ret:0,offset:this.file_pos})}fd_tell(){return{ret:0,offset:this.file_pos}}fd_write(t){if(this.file.readonly)return{ret:8,nwritten:0};if(this.file_pos+BigInt(t.byteLength)>this.file.size){let e=this.file.data;this.file.data=new Uint8Array(Number(this.file_pos+BigInt(t.byteLength))),this.file.data.set(e)}return this.file.data.set(t,Number(this.file_pos)),this.file_pos+=BigInt(t.byteLength),{ret:0,nwritten:t.byteLength}}fd_pwrite(t,e){if(this.file.readonly)return{ret:8,nwritten:0};if(e+BigInt(t.byteLength)>this.file.size){let i=this.file.data;this.file.data=new Uint8Array(Number(e+BigInt(t.byteLength))),this.file.data.set(i)}return this.file.data.set(t,Number(e)),{ret:0,nwritten:t.byteLength}}fd_filestat_get(){return{ret:0,filestat:this.file.stat()}}constructor(t){super(),this.file_pos=0n,this.file=t}},W=class extends B{fd_seek(t,e){return{ret:8,offset:0n}}fd_tell(){return{ret:8,offset:0n}}fd_allocate(t,e){return 8}fd_fdstat_get(){return{ret:0,fdstat:new F(I,0)}}fd_readdir_single(t){if(T.enabled&&(T.log("readdir_single",t),T.log(t,this.dir.contents.keys())),t==0n)return{ret:0,dirent:new C(1n,this.dir.ino,".",I)};if(t==1n)return{ret:0,dirent:new C(2n,this.dir.parent_ino(),"..",I)};if(t>=BigInt(this.dir.contents.size)+2n)return{ret:0,dirent:null};let[e,i]=Array.from(this.dir.contents.entries())[Number(t-2n)];return{ret:0,dirent:new C(t+1n,i.ino,e,i.stat().filetype)}}path_filestat_get(t,e){let{ret:i,path:c}=g.from(e);if(c==null)return{ret:i,filestat:null};let{ret:r,entry:n}=this.dir.get_entry_for_path(c);return n==null?{ret:r,filestat:null}:{ret:0,filestat:n.stat()}}path_lookup(t,e){let{ret:i,path:c}=g.from(t);if(c==null)return{ret:i,inode_obj:null};let{ret:r,entry:n}=this.dir.get_entry_for_path(c);return n==null?{ret:r,inode_obj:null}:{ret:0,inode_obj:n}}path_open(t,e,i,c,r,n){let{ret:s,path:o}=g.from(e);if(o==null)return{ret:s,fd_obj:null};let{ret:a,entry:f}=this.dir.get_entry_for_path(o);if(f==null){if(a!=44)return{ret:a,fd_obj:null};if((i&Z)==Z){let{ret:l,entry:R}=this.dir.create_entry_for_path(e,(i&G)==G);if(R==null)return{ret:l,fd_obj:null};f=R}else return{ret:44,fd_obj:null}}else if((i&it)==it)return{ret:20,fd_obj:null};return(i&G)==G&&f.stat().filetype!==I?{ret:54,fd_obj:null}:f.path_open(i,c,n)}path_create_directory(t){return this.path_open(0,t,Z|G,0n,0n,0).ret}path_link(t,e,i){let{ret:c,path:r}=g.from(t);if(r==null)return c;if(r.is_dir)return 44;let{ret:n,parent_entry:s,filename:o,entry:a}=this.dir.get_parent_dir_and_entry_for_path(r,!0);if(s==null||o==null)return n;if(a!=null){let f=e.stat().filetype==I,l=a.stat().filetype==I;if(f&&l)if(i&&a instanceof x){if(a.contents.size!=0)return 55}else return 20;else{if(f&&!l)return 54;if(!f&&l)return 31;if(!(e.stat().filetype==j&&a.stat().filetype==j))return 20}}return!i&&e.stat().filetype==I?63:(s.contents.set(o,e),0)}path_unlink(t){let{ret:e,path:i}=g.from(t);if(i==null)return{ret:e,inode_obj:null};let{ret:c,parent_entry:r,filename:n,entry:s}=this.dir.get_parent_dir_and_entry_for_path(i,!0);return r==null||n==null?{ret:c,inode_obj:null}:s==null?{ret:44,inode_obj:null}:(r.contents.delete(n),{ret:0,inode_obj:s})}path_unlink_file(t){let{ret:e,path:i}=g.from(t);if(i==null)return e;let{ret:c,parent_entry:r,filename:n,entry:s}=this.dir.get_parent_dir_and_entry_for_path(i,!1);return r==null||n==null||s==null?c:s.stat().filetype===I?31:(r.contents.delete(n),0)}path_remove_directory(t){let{ret:e,path:i}=g.from(t);if(i==null)return e;let{ret:c,parent_entry:r,filename:n,entry:s}=this.dir.get_parent_dir_and_entry_for_path(i,!1);return r==null||n==null||s==null?c:!(s instanceof x)||s.stat().filetype!==I?54:s.contents.size!==0?55:r.contents.delete(n)?0:44}fd_filestat_get(){return{ret:0,filestat:this.dir.stat()}}fd_filestat_set_size(t){return 8}fd_read(t){return{ret:8,data:new Uint8Array}}fd_pread(t,e){return{ret:8,data:new Uint8Array}}fd_write(t){return{ret:8,nwritten:0}}fd_pwrite(t,e){return{ret:8,nwritten:0}}constructor(t){super(),this.dir=t}},K=class extends W{fd_prestat_get(){return{ret:0,prestat:Q.dir(this.prestat_name)}}constructor(t,e){super(new x(e)),this.prestat_name=t}},A=class extends m{path_open(t,e,i){if(this.readonly&&(e&BigInt(64))==BigInt(64))return{ret:63,fd_obj:null};if((t&ot)==ot){if(this.readonly)return{ret:63,fd_obj:null};this.data=new Uint8Array([])}let c=new H(this);return i&yt&&c.fd_seek(0n,nt),{ret:0,fd_obj:c}}get size(){return BigInt(this.data.byteLength)}stat(){return new P(this.ino,j,this.size)}constructor(t,e){super(),this.data=new Uint8Array(t),this.readonly=!!e?.readonly}},g=class Ct{static from(t){let e=new Ct;if(e.is_dir=t.endsWith("/"),t.startsWith("/"))return{ret:76,path:null};if(t.includes("\0"))return{ret:28,path:null};for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."){if(e.parts.pop()==null)return{ret:76,path:null};continue}e.parts.push(i)}return{ret:0,path:e}}to_path_string(){let t=this.parts.join("/");return this.is_dir&&(t+="/"),t}constructor(){this.parts=[],this.is_dir=!1}},x=class _ extends m{parent_ino(){return this.parent==null?m.root_ino():this.parent.ino}path_open(t,e,i){return{ret:0,fd_obj:new W(this)}}stat(){return new P(this.ino,I,0n)}get_entry_for_path(t){let e=this;for(let i of t.parts){if(!(e instanceof _))return{ret:54,entry:null};let c=e.contents.get(i);if(c!==void 0)e=c;else return T.log(i),{ret:44,entry:null}}return t.is_dir&&e.stat().filetype!=I?{ret:54,entry:null}:{ret:0,entry:e}}get_parent_dir_and_entry_for_path(t,e){let i=t.parts.pop();if(i===void 0)return{ret:28,parent_entry:null,filename:null,entry:null};let{ret:c,entry:r}=this.get_entry_for_path(t);if(r==null)return{ret:c,parent_entry:null,filename:null,entry:null};if(!(r instanceof _))return{ret:54,parent_entry:null,filename:null,entry:null};let n=r.contents.get(i);return n===void 0?e?{ret:0,parent_entry:r,filename:i,entry:null}:{ret:44,parent_entry:null,filename:null,entry:null}:t.is_dir&&n.stat().filetype!=I?{ret:54,parent_entry:null,filename:null,entry:null}:{ret:0,parent_entry:r,filename:i,entry:n}}create_entry_for_path(t,e){let{ret:i,path:c}=g.from(t);if(c==null)return{ret:i,entry:null};let{ret:r,parent_entry:n,filename:s,entry:o}=this.get_parent_dir_and_entry_for_path(c,!0);if(n==null||s==null)return{ret:r,entry:null};if(o!=null)return{ret:20,entry:null};T.log("create",c);let a;return e?a=new _(new Map):a=new A(new ArrayBuffer(0)),n.contents.set(s,a),o=a,{ret:0,entry:o}}constructor(t){super(),this.parent=null,t instanceof Array?this.contents=new Map(t):this.contents=t;for(let e of this.contents.values())e instanceof _&&(e.parent=this)}},Y=class _ extends B{fd_filestat_get(){return{ret:0,filestat:new P(this.ino,st,BigInt(0))}}fd_fdstat_get(){let t=new F(st,0);return t.fs_rights_base=BigInt(64),{ret:0,fdstat:t}}fd_write(t){return this.write(t),{ret:0,nwritten:t.byteLength}}static lineBuffered(t){let e=new TextDecoder("utf-8",{fatal:!1}),i="";return new _(c=>{i+=e.decode(c,{stream:!0});let r=i.split(`
|
|
2
|
+
`);for(let[n,s]of r.entries())n<r.length-1?t(s):i=s})}constructor(t){super(),this.ino=m.issue_ino(),this.write=t}};var z=new TextEncoder,Rt=new TextDecoder,ee="/pas2js",re="/p2js/units",Ft="/p2js/userunits",Pt="/tmp",Gt="main.pp",dt="main.js",ne=["-Jminclude","-Jmbasedir=/","-Jmxssiheader-"];async function pt({source:_="",wasm:t,rtl:e,units:i,flags:c=[],sourceMap:r=!1}){let n=[],s=[],o=S=>D=>S.push(Rt.decode(D)),a=(S,D)=>[S,new A(D)],f=new K("/",[["bin",new x([a("pas2js",z.encode("stub"))])],["pas2js",new x([])],["p2js",new x([["units",new x([...e].map(([S,D])=>a(S,D)))],["userunits",new x(se(i))]])],["tmp",new x([a(Gt,z.encode(_))])]]),l=[ee,"-n","-TBrowser","-Jc","-Jirtl.js",`-Fu${re}`,`-Fu${Ft}`,`-Fi${Ft}`,...r?ne:[],...c,`${Pt}/${Gt}`,`-o${Pt}/${dt}`],R=[new H(new A([])),Y.lineBuffered(S=>o(n)(z.encode(`${S}
|
|
3
|
+
`))),Y.lineBuffered(S=>o(s)(z.encode(`${S}
|
|
4
|
+
`))),f],d=new ct(l,[],R,{debug:!1}),p=await WebAssembly.instantiate(t,{wasi_snapshot_preview1:d.wasiImport}),u=0;try{u=d.start(p)}catch(S){if(S instanceof U)u=S.code;else throw S}let w=Et(f.dir,dt),h=Et(f.dir,`${dt}.map`);return{exitCode:u,js:w?Rt.decode(w.data):null,sourceMap:h?Rt.decode(h.data):null,diagnostics:n.join("")+s.join("")}}function se(_){return _?(_ instanceof Map?[..._]:Object.entries(_)).map(([e,i])=>[e,new A(typeof i=="string"?z.encode(i):i)]):[]}function Et(_,t){for(let[e,i]of _.contents){if(i instanceof A&&e===t)return i;if(i instanceof x){let c=Et(i,t);if(c)return c}}return null}var Nt=new Map;async function wt(_={}){let t=oe(_),e=Nt.get(t);e||(e=Tt(_),Nt.set(t,e),e.catch(()=>Nt.delete(t)));let i=await e;return{baseUrl:i.baseUrl,compile:(c,r={})=>{let{flags:n,...s}=r;return pt({source:c,wasm:i.wasm,rtl:i.rtl,...s,flags:ie(n)})},version:async()=>{let{diagnostics:c}=await pt({wasm:i.wasm,rtl:i.rtl,flags:["-iV"]});return c.trim()}}}async function Bt(_,t={}){return(await wt(t)).compile(_,t)}function Ht(_){let t=[];for(let e of String(_??"").split(`
|
|
5
|
+
`)){let i=e.trim();if(!i)continue;let c=/^(.*?)\((\d+),(\d+)\)\s+(Error|Warning|Hint|Note)\s*:\s*(.*)$/.exec(i);if(c){t.push({file:c[1],line:Number(c[2]),column:Number(c[3]),severity:c[4].toLowerCase(),message:c[5]});continue}let r=/^Fatal\s*:\s*(.*)$/.exec(i);r&&t.push({file:null,line:null,column:null,severity:"fatal",message:r[1]})}return t}function ie(_){let{flags:t}=$();return t.length?[...t,..._??[]]:_??[]}function oe({baseUrl:_,wasmUrl:t,rtlUrl:e}){let i=_;if(!i)try{i=M().href}catch{i="default"}return[i,t??"",e??""].join("|")}globalThis.pascalWasm={compile:Bt,createCompiler:wt,defaultBaseUrl:M,configure:et,parseDiagnostics:Ht};})();
|
|
6
|
+
//# sourceMappingURL=pascal-wasm.iife.min.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/config.js", "../src/assets.js", "../src/vendor/browser_wasi_shim/wasi_defs.js", "../src/vendor/browser_wasi_shim/debug.js", "../src/vendor/browser_wasi_shim/wasi.js", "../src/vendor/browser_wasi_shim/fd.js", "../src/vendor/browser_wasi_shim/fs_mem.js", "../src/compiler.js", "../src/index.js", "../src/iife.js"],
|
|
4
|
+
"sourcesContent": ["// Package-wide defaults, settable with `configure()`. Useful where options\n// cannot be passed per call \u2014 most notably in a classic worker, where the bundle\n// is loaded with `importScripts()` and only a global API is available.\n\nconst config = {\n baseUrl: null,\n flags: [],\n};\n\n/**\n * Set defaults for every subsequent compile.\n *\n * @param {object} [options]\n * @param {string|URL} [options.baseUrl] Where `pas2js.wasm` and `rtl/` live.\n * @param {string[]} [options.flags] Extra compiler options to always pass.\n */\nexport function configure(options = {}) {\n if (options.baseUrl !== undefined) config.baseUrl = options.baseUrl;\n if (options.flags !== undefined) config.flags = [...options.flags];\n}\n\nexport function getConfig() {\n return config;\n}\n", "// Loading of the bundled compiler artifacts \u2014 `pas2js.wasm` and the Pascal RTL\n// sources \u2014 resolved against `baseUrl`, or against this module's own location\n// when it is loaded as an ES module.\n//\n// Works in browsers, in Web Workers, and in Node (where the assets are read from\n// disk instead of fetched). The classic-script (IIFE) build has no module URL,\n// so it requires `baseUrl` to be passed in.\n\nimport { getConfig } from './config.js';\n\n/** Accept a path or URL and resolve it against `base`. */\nexport function toUrl(value, base) {\n return value instanceof URL ? value : new URL(value, base);\n}\n\n/**\n * The asset location used when none is given explicitly: this module's own\n * directory, when that is knowable.\n *\n * @returns {URL}\n */\nexport function defaultBaseUrl() {\n const { baseUrl } = getConfig();\n if (baseUrl) return toUrl(baseUrl, here());\n\n const location = moduleLocation();\n if (location) return new URL('../assets/', location);\n\n throw new Error(\n '@live-codes/pascal-wasm: cannot locate the compiler assets. Pass a location, ' +\n 'e.g. createCompiler({ baseUrl: \"\u2026/assets/\" }) or configure({ baseUrl: \"\u2026\" }).',\n );\n}\n\n/**\n * Load the RTL sources and compile the compiler binary.\n *\n * @param {object} [options]\n * @param {string|URL} [options.baseUrl] Directory holding `pas2js.wasm` and `rtl/`.\n * @param {string|URL} [options.wasmUrl] Override the compiler binary location.\n * @param {string|URL} [options.rtlUrl] Override the RTL directory location.\n * @returns {Promise<{baseUrl: URL, wasm: WebAssembly.Module, rtl: Map<string, Uint8Array>}>}\n */\nexport async function loadAssets({ baseUrl, wasmUrl, rtlUrl } = {}) {\n const base = baseUrl ? toUrl(baseUrl, here()) : defaultBaseUrl();\n const rtlDir = rtlUrl ? toUrl(rtlUrl, base) : new URL('rtl/', base);\n const wasmLocation = wasmUrl ? toUrl(wasmUrl, base) : new URL('pas2js.wasm', base);\n\n const manifestLocation = new URL('manifest.json', rtlDir);\n const manifest = JSON.parse(await readText(manifestLocation));\n if (!Array.isArray(manifest.units)) {\n throw new Error(`Invalid RTL manifest at ${manifestLocation}`);\n }\n\n const [wasm, ...files] = await Promise.all([\n compileWasm(wasmLocation),\n ...manifest.units.map(async ({ filename }) => [\n filename,\n await readBinary(new URL(filename, rtlDir)),\n ]),\n ]);\n\n return { baseUrl: base, wasm, rtl: new Map(files) };\n}\n\n/** Used to resolve a relative `baseUrl`, in a page or a worker. */\nfunction here() {\n return globalThis.location?.href;\n}\n\n/**\n * The URL of this module, when it is an ES module. A classic script cannot\n * contain `import.meta`, so the bundled build has no equivalent \u2014 which is why\n * it needs `baseUrl`.\n */\nfunction moduleLocation() {\n try {\n return import.meta.url || null;\n } catch {\n return null;\n }\n}\n\nasync function readText(location) {\n if (location.protocol === 'file:') {\n const { readFile } = await import('node:fs/promises');\n return readFile(location, 'utf8');\n }\n const response = await fetch(location);\n if (!response.ok) {\n throw new Error(`Failed to load ${location}: HTTP ${response.status}`);\n }\n return response.text();\n}\n\nasync function readBinary(location) {\n if (location.protocol === 'file:') {\n const { readFile } = await import('node:fs/promises');\n return new Uint8Array(await readFile(location));\n }\n const response = await fetch(location);\n if (!response.ok) {\n throw new Error(`Failed to load ${location}: HTTP ${response.status}`);\n }\n return new Uint8Array(await response.arrayBuffer());\n}\n\nasync function compileWasm(location) {\n if (location.protocol === 'http:' || location.protocol === 'https:') {\n try {\n // Streaming lets the engine compile while the ~9 MB download is in flight.\n return await WebAssembly.compileStreaming(fetch(location));\n } catch {\n // Some hosts do not serve .wasm as application/wasm, which\n // compileStreaming requires. Fall back to downloading the bytes.\n }\n }\n return WebAssembly.compile(await readBinary(location));\n}\n", "export const FD_STDIN=0;export const FD_STDOUT=1;export const FD_STDERR=2;export const CLOCKID_REALTIME=0;export const CLOCKID_MONOTONIC=1;export const CLOCKID_PROCESS_CPUTIME_ID=2;export const CLOCKID_THREAD_CPUTIME_ID=3;export const ERRNO_SUCCESS=0;export const ERRNO_2BIG=1;export const ERRNO_ACCES=2;export const ERRNO_ADDRINUSE=3;export const ERRNO_ADDRNOTAVAIL=4;export const ERRNO_AFNOSUPPORT=5;export const ERRNO_AGAIN=6;export const ERRNO_ALREADY=7;export const ERRNO_BADF=8;export const ERRNO_BADMSG=9;export const ERRNO_BUSY=10;export const ERRNO_CANCELED=11;export const ERRNO_CHILD=12;export const ERRNO_CONNABORTED=13;export const ERRNO_CONNREFUSED=14;export const ERRNO_CONNRESET=15;export const ERRNO_DEADLK=16;export const ERRNO_DESTADDRREQ=17;export const ERRNO_DOM=18;export const ERRNO_DQUOT=19;export const ERRNO_EXIST=20;export const ERRNO_FAULT=21;export const ERRNO_FBIG=22;export const ERRNO_HOSTUNREACH=23;export const ERRNO_IDRM=24;export const ERRNO_ILSEQ=25;export const ERRNO_INPROGRESS=26;export const ERRNO_INTR=27;export const ERRNO_INVAL=28;export const ERRNO_IO=29;export const ERRNO_ISCONN=30;export const ERRNO_ISDIR=31;export const ERRNO_LOOP=32;export const ERRNO_MFILE=33;export const ERRNO_MLINK=34;export const ERRNO_MSGSIZE=35;export const ERRNO_MULTIHOP=36;export const ERRNO_NAMETOOLONG=37;export const ERRNO_NETDOWN=38;export const ERRNO_NETRESET=39;export const ERRNO_NETUNREACH=40;export const ERRNO_NFILE=41;export const ERRNO_NOBUFS=42;export const ERRNO_NODEV=43;export const ERRNO_NOENT=44;export const ERRNO_NOEXEC=45;export const ERRNO_NOLCK=46;export const ERRNO_NOLINK=47;export const ERRNO_NOMEM=48;export const ERRNO_NOMSG=49;export const ERRNO_NOPROTOOPT=50;export const ERRNO_NOSPC=51;export const ERRNO_NOSYS=52;export const ERRNO_NOTCONN=53;export const ERRNO_NOTDIR=54;export const ERRNO_NOTEMPTY=55;export const ERRNO_NOTRECOVERABLE=56;export const ERRNO_NOTSOCK=57;export const ERRNO_NOTSUP=58;export const ERRNO_NOTTY=59;export const ERRNO_NXIO=60;export const ERRNO_OVERFLOW=61;export const ERRNO_OWNERDEAD=62;export const ERRNO_PERM=63;export const ERRNO_PIPE=64;export const ERRNO_PROTO=65;export const ERRNO_PROTONOSUPPORT=66;export const ERRNO_PROTOTYPE=67;export const ERRNO_RANGE=68;export const ERRNO_ROFS=69;export const ERRNO_SPIPE=70;export const ERRNO_SRCH=71;export const ERRNO_STALE=72;export const ERRNO_TIMEDOUT=73;export const ERRNO_TXTBSY=74;export const ERRNO_XDEV=75;export const ERRNO_NOTCAPABLE=76;export const RIGHTS_FD_DATASYNC=1<<0;export const RIGHTS_FD_READ=1<<1;export const RIGHTS_FD_SEEK=1<<2;export const RIGHTS_FD_FDSTAT_SET_FLAGS=1<<3;export const RIGHTS_FD_SYNC=1<<4;export const RIGHTS_FD_TELL=1<<5;export const RIGHTS_FD_WRITE=1<<6;export const RIGHTS_FD_ADVISE=1<<7;export const RIGHTS_FD_ALLOCATE=1<<8;export const RIGHTS_PATH_CREATE_DIRECTORY=1<<9;export const RIGHTS_PATH_CREATE_FILE=1<<10;export const RIGHTS_PATH_LINK_SOURCE=1<<11;export const RIGHTS_PATH_LINK_TARGET=1<<12;export const RIGHTS_PATH_OPEN=1<<13;export const RIGHTS_FD_READDIR=1<<14;export const RIGHTS_PATH_READLINK=1<<15;export const RIGHTS_PATH_RENAME_SOURCE=1<<16;export const RIGHTS_PATH_RENAME_TARGET=1<<17;export const RIGHTS_PATH_FILESTAT_GET=1<<18;export const RIGHTS_PATH_FILESTAT_SET_SIZE=1<<19;export const RIGHTS_PATH_FILESTAT_SET_TIMES=1<<20;export const RIGHTS_FD_FILESTAT_GET=1<<21;export const RIGHTS_FD_FILESTAT_SET_SIZE=1<<22;export const RIGHTS_FD_FILESTAT_SET_TIMES=1<<23;export const RIGHTS_PATH_SYMLINK=1<<24;export const RIGHTS_PATH_REMOVE_DIRECTORY=1<<25;export const RIGHTS_PATH_UNLINK_FILE=1<<26;export const RIGHTS_POLL_FD_READWRITE=1<<27;export const RIGHTS_SOCK_SHUTDOWN=1<<28;export class Iovec{static read_bytes(view,ptr){const iovec=new Iovec;iovec.buf=view.getUint32(ptr,true);iovec.buf_len=view.getUint32(ptr+4,true);return iovec}static read_bytes_array(view,ptr,len){const iovecs=[];for(let i=0;i<len;i++){iovecs.push(Iovec.read_bytes(view,ptr+8*i))}return iovecs}}export class Ciovec{static read_bytes(view,ptr){const iovec=new Ciovec;iovec.buf=view.getUint32(ptr,true);iovec.buf_len=view.getUint32(ptr+4,true);return iovec}static read_bytes_array(view,ptr,len){const iovecs=[];for(let i=0;i<len;i++){iovecs.push(Ciovec.read_bytes(view,ptr+8*i))}return iovecs}}export const WHENCE_SET=0;export const WHENCE_CUR=1;export const WHENCE_END=2;export const FILETYPE_UNKNOWN=0;export const FILETYPE_BLOCK_DEVICE=1;export const FILETYPE_CHARACTER_DEVICE=2;export const FILETYPE_DIRECTORY=3;export const FILETYPE_REGULAR_FILE=4;export const FILETYPE_SOCKET_DGRAM=5;export const FILETYPE_SOCKET_STREAM=6;export const FILETYPE_SYMBOLIC_LINK=7;export class Dirent{head_length(){return 24}name_length(){return this.dir_name.byteLength}write_head_bytes(view,ptr){view.setBigUint64(ptr,this.d_next,true);view.setBigUint64(ptr+8,this.d_ino,true);view.setUint32(ptr+16,this.dir_name.length,true);view.setUint8(ptr+20,this.d_type)}write_name_bytes(view8,ptr,buf_len){view8.set(this.dir_name.slice(0,Math.min(this.dir_name.byteLength,buf_len)),ptr)}constructor(next_cookie,d_ino,name,type){const encoded_name=new TextEncoder().encode(name);this.d_next=next_cookie;this.d_ino=d_ino;this.d_namlen=encoded_name.byteLength;this.d_type=type;this.dir_name=encoded_name}}export const ADVICE_NORMAL=0;export const ADVICE_SEQUENTIAL=1;export const ADVICE_RANDOM=2;export const ADVICE_WILLNEED=3;export const ADVICE_DONTNEED=4;export const ADVICE_NOREUSE=5;export const FDFLAGS_APPEND=1<<0;export const FDFLAGS_DSYNC=1<<1;export const FDFLAGS_NONBLOCK=1<<2;export const FDFLAGS_RSYNC=1<<3;export const FDFLAGS_SYNC=1<<4;export class Fdstat{write_bytes(view,ptr){view.setUint8(ptr,this.fs_filetype);view.setUint16(ptr+2,this.fs_flags,true);view.setBigUint64(ptr+8,this.fs_rights_base,true);view.setBigUint64(ptr+16,this.fs_rights_inherited,true)}constructor(filetype,flags){this.fs_rights_base=0n;this.fs_rights_inherited=0n;this.fs_filetype=filetype;this.fs_flags=flags}}export const FSTFLAGS_ATIM=1<<0;export const FSTFLAGS_ATIM_NOW=1<<1;export const FSTFLAGS_MTIM=1<<2;export const FSTFLAGS_MTIM_NOW=1<<3;export const OFLAGS_CREAT=1<<0;export const OFLAGS_DIRECTORY=1<<1;export const OFLAGS_EXCL=1<<2;export const OFLAGS_TRUNC=1<<3;export class Filestat{write_bytes(view,ptr){view.setBigUint64(ptr,this.dev,true);view.setBigUint64(ptr+8,this.ino,true);view.setUint8(ptr+16,this.filetype);view.setBigUint64(ptr+24,this.nlink,true);view.setBigUint64(ptr+32,this.size,true);view.setBigUint64(ptr+38,this.atim,true);view.setBigUint64(ptr+46,this.mtim,true);view.setBigUint64(ptr+52,this.ctim,true)}constructor(ino,filetype,size){this.dev=0n;this.nlink=0n;this.atim=0n;this.mtim=0n;this.ctim=0n;this.ino=ino;this.filetype=filetype;this.size=size}}export const EVENTTYPE_CLOCK=0;export const EVENTTYPE_FD_READ=1;export const EVENTTYPE_FD_WRITE=2;export const EVENTRWFLAGS_FD_READWRITE_HANGUP=1<<0;export const SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME=1<<0;export class Subscription{static read_bytes(view,ptr){return new Subscription(view.getBigUint64(ptr,true),view.getUint8(ptr+8),view.getUint32(ptr+16,true),view.getBigUint64(ptr+24,true),view.getUint16(ptr+36,true))}constructor(userdata,eventtype,clockid,timeout,flags){this.userdata=userdata;this.eventtype=eventtype;this.clockid=clockid;this.timeout=timeout;this.flags=flags}}export class Event{write_bytes(view,ptr){view.setBigUint64(ptr,this.userdata,true);view.setUint16(ptr+8,this.error,true);view.setUint8(ptr+10,this.eventtype)}constructor(userdata,error,eventtype){this.userdata=userdata;this.error=error;this.eventtype=eventtype}}export const SIGNAL_NONE=0;export const SIGNAL_HUP=1;export const SIGNAL_INT=2;export const SIGNAL_QUIT=3;export const SIGNAL_ILL=4;export const SIGNAL_TRAP=5;export const SIGNAL_ABRT=6;export const SIGNAL_BUS=7;export const SIGNAL_FPE=8;export const SIGNAL_KILL=9;export const SIGNAL_USR1=10;export const SIGNAL_SEGV=11;export const SIGNAL_USR2=12;export const SIGNAL_PIPE=13;export const SIGNAL_ALRM=14;export const SIGNAL_TERM=15;export const SIGNAL_CHLD=16;export const SIGNAL_CONT=17;export const SIGNAL_STOP=18;export const SIGNAL_TSTP=19;export const SIGNAL_TTIN=20;export const SIGNAL_TTOU=21;export const SIGNAL_URG=22;export const SIGNAL_XCPU=23;export const SIGNAL_XFSZ=24;export const SIGNAL_VTALRM=25;export const SIGNAL_PROF=26;export const SIGNAL_WINCH=27;export const SIGNAL_POLL=28;export const SIGNAL_PWR=29;export const SIGNAL_SYS=30;export const RIFLAGS_RECV_PEEK=1<<0;export const RIFLAGS_RECV_WAITALL=1<<1;export const ROFLAGS_RECV_DATA_TRUNCATED=1<<0;export const SDFLAGS_RD=1<<0;export const SDFLAGS_WR=1<<1;export const PREOPENTYPE_DIR=0;export class PrestatDir{write_bytes(view,ptr){view.setUint32(ptr,this.pr_name.byteLength,true)}constructor(name){this.pr_name=new TextEncoder().encode(name)}}export class Prestat{static dir(name){const prestat=new Prestat;prestat.tag=PREOPENTYPE_DIR;prestat.inner=new PrestatDir(name);return prestat}write_bytes(view,ptr){view.setUint32(ptr,this.tag,true);this.inner.write_bytes(view,ptr+4)}}", "let Debug=class Debug{enable(enabled){this.log=createLogger(enabled===undefined?true:enabled,this.prefix)}get enabled(){return this.isEnabled}constructor(isEnabled){this.isEnabled=isEnabled;this.prefix=\"wasi:\";this.enable(isEnabled)}};function createLogger(enabled,prefix){if(enabled){const a=console.log.bind(console,\"%c%s\",\"color: #265BA0\",prefix);return a}else{return()=>{}}}export const debug=new Debug(false);", "import*as wasi from\"./wasi_defs.js\";import{debug}from\"./debug.js\";export class WASIProcExit extends Error{constructor(code){super(\"exit with exit code \"+code);this.code=code}}let WASI=class WASI{start(instance){this.inst=instance;try{instance.exports._start();return 0}catch(e){if(e instanceof WASIProcExit){return e.code}else{throw e}}}initialize(instance){this.inst=instance;if(instance.exports._initialize){instance.exports._initialize()}}constructor(args,env,fds,options={}){this.args=[];this.env=[];this.fds=[];debug.enable(options.debug);this.args=args;this.env=env;this.fds=fds;const self=this;this.wasiImport={args_sizes_get(argc,argv_buf_size){const buffer=new DataView(self.inst.exports.memory.buffer);buffer.setUint32(argc,self.args.length,true);let buf_size=0;for(const arg of self.args){buf_size+=arg.length+1}buffer.setUint32(argv_buf_size,buf_size,true);debug.log(buffer.getUint32(argc,true),buffer.getUint32(argv_buf_size,true));return 0},args_get(argv,argv_buf){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);const orig_argv_buf=argv_buf;for(let i=0;i<self.args.length;i++){buffer.setUint32(argv,argv_buf,true);argv+=4;const arg=new TextEncoder().encode(self.args[i]);buffer8.set(arg,argv_buf);buffer.setUint8(argv_buf+arg.length,0);argv_buf+=arg.length+1}if(debug.enabled){debug.log(new TextDecoder(\"utf-8\").decode(buffer8.slice(orig_argv_buf,argv_buf)))}return 0},environ_sizes_get(environ_count,environ_size){const buffer=new DataView(self.inst.exports.memory.buffer);buffer.setUint32(environ_count,self.env.length,true);let buf_size=0;for(const environ of self.env){buf_size+=new TextEncoder().encode(environ).length+1}buffer.setUint32(environ_size,buf_size,true);debug.log(buffer.getUint32(environ_count,true),buffer.getUint32(environ_size,true));return 0},environ_get(environ,environ_buf){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);const orig_environ_buf=environ_buf;for(let i=0;i<self.env.length;i++){buffer.setUint32(environ,environ_buf,true);environ+=4;const e=new TextEncoder().encode(self.env[i]);buffer8.set(e,environ_buf);buffer.setUint8(environ_buf+e.length,0);environ_buf+=e.length+1}if(debug.enabled){debug.log(new TextDecoder(\"utf-8\").decode(buffer8.slice(orig_environ_buf,environ_buf)))}return 0},clock_res_get(id,res_ptr){let resolutionValue;switch(id){case wasi.CLOCKID_MONOTONIC:{resolutionValue=5000n;break}case wasi.CLOCKID_REALTIME:{resolutionValue=1000000n;break}default:return wasi.ERRNO_NOSYS}const view=new DataView(self.inst.exports.memory.buffer);view.setBigUint64(res_ptr,resolutionValue,true);return wasi.ERRNO_SUCCESS},clock_time_get(id,precision,time){const buffer=new DataView(self.inst.exports.memory.buffer);if(id===wasi.CLOCKID_REALTIME){buffer.setBigUint64(time,BigInt(new Date().getTime())*1000000n,true)}else if(id==wasi.CLOCKID_MONOTONIC){let monotonic_time;try{monotonic_time=BigInt(Math.round(performance.now()*1e6))}catch(e){monotonic_time=0n}buffer.setBigUint64(time,monotonic_time,true)}else{buffer.setBigUint64(time,0n,true)}return 0},fd_advise(fd,offset,len,advice){if(self.fds[fd]!=undefined){return wasi.ERRNO_SUCCESS}else{return wasi.ERRNO_BADF}},fd_allocate(fd,offset,len){if(self.fds[fd]!=undefined){return self.fds[fd].fd_allocate(offset,len)}else{return wasi.ERRNO_BADF}},fd_close(fd){if(self.fds[fd]!=undefined){const ret=self.fds[fd].fd_close();self.fds[fd]=undefined;return ret}else{return wasi.ERRNO_BADF}},fd_datasync(fd){if(self.fds[fd]!=undefined){return self.fds[fd].fd_sync()}else{return wasi.ERRNO_BADF}},fd_fdstat_get(fd,fdstat_ptr){if(self.fds[fd]!=undefined){const{ret,fdstat}=self.fds[fd].fd_fdstat_get();if(fdstat!=null){fdstat.write_bytes(new DataView(self.inst.exports.memory.buffer),fdstat_ptr)}return ret}else{return wasi.ERRNO_BADF}},fd_fdstat_set_flags(fd,flags){if(self.fds[fd]!=undefined){return self.fds[fd].fd_fdstat_set_flags(flags)}else{return wasi.ERRNO_BADF}},fd_fdstat_set_rights(fd,fs_rights_base,fs_rights_inheriting){if(self.fds[fd]!=undefined){return self.fds[fd].fd_fdstat_set_rights(fs_rights_base,fs_rights_inheriting)}else{return wasi.ERRNO_BADF}},fd_filestat_get(fd,filestat_ptr){if(self.fds[fd]!=undefined){const{ret,filestat}=self.fds[fd].fd_filestat_get();if(filestat!=null){filestat.write_bytes(new DataView(self.inst.exports.memory.buffer),filestat_ptr)}return ret}else{return wasi.ERRNO_BADF}},fd_filestat_set_size(fd,size){if(self.fds[fd]!=undefined){return self.fds[fd].fd_filestat_set_size(size)}else{return wasi.ERRNO_BADF}},fd_filestat_set_times(fd,atim,mtim,fst_flags){if(self.fds[fd]!=undefined){return self.fds[fd].fd_filestat_set_times(atim,mtim,fst_flags)}else{return wasi.ERRNO_BADF}},fd_pread(fd,iovs_ptr,iovs_len,offset,nread_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const iovecs=wasi.Iovec.read_bytes_array(buffer,iovs_ptr,iovs_len);let nread=0;for(const iovec of iovecs){const{ret,data}=self.fds[fd].fd_pread(iovec.buf_len,offset);if(ret!=wasi.ERRNO_SUCCESS){buffer.setUint32(nread_ptr,nread,true);return ret}buffer8.set(data,iovec.buf);nread+=data.length;offset+=BigInt(data.length);if(data.length!=iovec.buf_len){break}}buffer.setUint32(nread_ptr,nread,true);return wasi.ERRNO_SUCCESS}else{return wasi.ERRNO_BADF}},fd_prestat_get(fd,buf_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const{ret,prestat}=self.fds[fd].fd_prestat_get();if(prestat!=null){prestat.write_bytes(buffer,buf_ptr)}return ret}else{return wasi.ERRNO_BADF}},fd_prestat_dir_name(fd,path_ptr,path_len){if(self.fds[fd]!=undefined){const{ret,prestat}=self.fds[fd].fd_prestat_get();if(prestat==null){return ret}const prestat_dir_name=prestat.inner.pr_name;const buffer8=new Uint8Array(self.inst.exports.memory.buffer);buffer8.set(prestat_dir_name.slice(0,path_len),path_ptr);return prestat_dir_name.byteLength>path_len?wasi.ERRNO_NAMETOOLONG:wasi.ERRNO_SUCCESS}else{return wasi.ERRNO_BADF}},fd_pwrite(fd,iovs_ptr,iovs_len,offset,nwritten_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const iovecs=wasi.Ciovec.read_bytes_array(buffer,iovs_ptr,iovs_len);let nwritten=0;for(const iovec of iovecs){const data=buffer8.slice(iovec.buf,iovec.buf+iovec.buf_len);const{ret,nwritten:nwritten_part}=self.fds[fd].fd_pwrite(data,offset);if(ret!=wasi.ERRNO_SUCCESS){buffer.setUint32(nwritten_ptr,nwritten,true);return ret}nwritten+=nwritten_part;offset+=BigInt(nwritten_part);if(nwritten_part!=data.byteLength){break}}buffer.setUint32(nwritten_ptr,nwritten,true);return wasi.ERRNO_SUCCESS}else{return wasi.ERRNO_BADF}},fd_read(fd,iovs_ptr,iovs_len,nread_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const iovecs=wasi.Iovec.read_bytes_array(buffer,iovs_ptr,iovs_len);let nread=0;for(const iovec of iovecs){const{ret,data}=self.fds[fd].fd_read(iovec.buf_len);if(ret!=wasi.ERRNO_SUCCESS){buffer.setUint32(nread_ptr,nread,true);return ret}buffer8.set(data,iovec.buf);nread+=data.length;if(data.length!=iovec.buf_len){break}}buffer.setUint32(nread_ptr,nread,true);return wasi.ERRNO_SUCCESS}else{return wasi.ERRNO_BADF}},fd_readdir(fd,buf,buf_len,cookie,bufused_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){let bufused=0;while(true){const{ret,dirent}=self.fds[fd].fd_readdir_single(cookie);if(ret!=0){buffer.setUint32(bufused_ptr,bufused,true);return ret}if(dirent==null){break}if(buf_len-bufused<dirent.head_length()){bufused=buf_len;break}const head_bytes=new ArrayBuffer(dirent.head_length());dirent.write_head_bytes(new DataView(head_bytes),0);buffer8.set(new Uint8Array(head_bytes).slice(0,Math.min(head_bytes.byteLength,buf_len-bufused)),buf);buf+=dirent.head_length();bufused+=dirent.head_length();if(buf_len-bufused<dirent.name_length()){bufused=buf_len;break}dirent.write_name_bytes(buffer8,buf,buf_len-bufused);buf+=dirent.name_length();bufused+=dirent.name_length();cookie=dirent.d_next}buffer.setUint32(bufused_ptr,bufused,true);return 0}else{return wasi.ERRNO_BADF}},fd_renumber(fd,to){if(self.fds[fd]!=undefined&&self.fds[to]!=undefined){const ret=self.fds[to].fd_close();if(ret!=0){return ret}self.fds[to]=self.fds[fd];self.fds[fd]=undefined;return 0}else{return wasi.ERRNO_BADF}},fd_seek(fd,offset,whence,offset_out_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const{ret,offset:offset_out}=self.fds[fd].fd_seek(offset,whence);buffer.setBigInt64(offset_out_ptr,offset_out,true);return ret}else{return wasi.ERRNO_BADF}},fd_sync(fd){if(self.fds[fd]!=undefined){return self.fds[fd].fd_sync()}else{return wasi.ERRNO_BADF}},fd_tell(fd,offset_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const{ret,offset}=self.fds[fd].fd_tell();buffer.setBigUint64(offset_ptr,offset,true);return ret}else{return wasi.ERRNO_BADF}},fd_write(fd,iovs_ptr,iovs_len,nwritten_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const iovecs=wasi.Ciovec.read_bytes_array(buffer,iovs_ptr,iovs_len);let nwritten=0;for(const iovec of iovecs){const data=buffer8.slice(iovec.buf,iovec.buf+iovec.buf_len);const{ret,nwritten:nwritten_part}=self.fds[fd].fd_write(data);if(ret!=wasi.ERRNO_SUCCESS){buffer.setUint32(nwritten_ptr,nwritten,true);return ret}nwritten+=nwritten_part;if(nwritten_part!=data.byteLength){break}}buffer.setUint32(nwritten_ptr,nwritten,true);return wasi.ERRNO_SUCCESS}else{return wasi.ERRNO_BADF}},path_create_directory(fd,path_ptr,path_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));return self.fds[fd].path_create_directory(path)}else{return wasi.ERRNO_BADF}},path_filestat_get(fd,flags,path_ptr,path_len,filestat_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));const{ret,filestat}=self.fds[fd].path_filestat_get(flags,path);if(filestat!=null){filestat.write_bytes(buffer,filestat_ptr)}return ret}else{return wasi.ERRNO_BADF}},path_filestat_set_times(fd,flags,path_ptr,path_len,atim,mtim,fst_flags){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));return self.fds[fd].path_filestat_set_times(flags,path,atim,mtim,fst_flags)}else{return wasi.ERRNO_BADF}},path_link(old_fd,old_flags,old_path_ptr,old_path_len,new_fd,new_path_ptr,new_path_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[old_fd]!=undefined&&self.fds[new_fd]!=undefined){const old_path=new TextDecoder(\"utf-8\").decode(buffer8.slice(old_path_ptr,old_path_ptr+old_path_len));const new_path=new TextDecoder(\"utf-8\").decode(buffer8.slice(new_path_ptr,new_path_ptr+new_path_len));const{ret,inode_obj}=self.fds[old_fd].path_lookup(old_path,old_flags);if(inode_obj==null){return ret}return self.fds[new_fd].path_link(new_path,inode_obj,false)}else{return wasi.ERRNO_BADF}},path_open(fd,dirflags,path_ptr,path_len,oflags,fs_rights_base,fs_rights_inheriting,fd_flags,opened_fd_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));debug.log(path);const{ret,fd_obj}=self.fds[fd].path_open(dirflags,path,oflags,fs_rights_base,fs_rights_inheriting,fd_flags);if(ret!=0){return ret}self.fds.push(fd_obj);const opened_fd=self.fds.length-1;buffer.setUint32(opened_fd_ptr,opened_fd,true);return 0}else{return wasi.ERRNO_BADF}},path_readlink(fd,path_ptr,path_len,buf_ptr,buf_len,nread_ptr){const buffer=new DataView(self.inst.exports.memory.buffer);const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));debug.log(path);const{ret,data}=self.fds[fd].path_readlink(path);if(data!=null){const data_buf=new TextEncoder().encode(data);if(data_buf.length>buf_len){buffer.setUint32(nread_ptr,0,true);return wasi.ERRNO_BADF}buffer8.set(data_buf,buf_ptr);buffer.setUint32(nread_ptr,data_buf.length,true)}return ret}else{return wasi.ERRNO_BADF}},path_remove_directory(fd,path_ptr,path_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));return self.fds[fd].path_remove_directory(path)}else{return wasi.ERRNO_BADF}},path_rename(fd,old_path_ptr,old_path_len,new_fd,new_path_ptr,new_path_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined&&self.fds[new_fd]!=undefined){const old_path=new TextDecoder(\"utf-8\").decode(buffer8.slice(old_path_ptr,old_path_ptr+old_path_len));const new_path=new TextDecoder(\"utf-8\").decode(buffer8.slice(new_path_ptr,new_path_ptr+new_path_len));let{ret,inode_obj}=self.fds[fd].path_unlink(old_path);if(inode_obj==null){return ret}ret=self.fds[new_fd].path_link(new_path,inode_obj,true);if(ret!=wasi.ERRNO_SUCCESS){if(self.fds[fd].path_link(old_path,inode_obj,true)!=wasi.ERRNO_SUCCESS){throw\"path_link should always return success when relinking an inode back to the original place\"}}return ret}else{return wasi.ERRNO_BADF}},path_symlink(old_path_ptr,old_path_len,fd,new_path_ptr,new_path_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const old_path=new TextDecoder(\"utf-8\").decode(buffer8.slice(old_path_ptr,old_path_ptr+old_path_len));const new_path=new TextDecoder(\"utf-8\").decode(buffer8.slice(new_path_ptr,new_path_ptr+new_path_len));return wasi.ERRNO_NOTSUP}else{return wasi.ERRNO_BADF}},path_unlink_file(fd,path_ptr,path_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer);if(self.fds[fd]!=undefined){const path=new TextDecoder(\"utf-8\").decode(buffer8.slice(path_ptr,path_ptr+path_len));return self.fds[fd].path_unlink_file(path)}else{return wasi.ERRNO_BADF}},poll_oneoff(in_ptr,out_ptr,nsubscriptions){if(nsubscriptions===0){return wasi.ERRNO_INVAL}if(nsubscriptions>1){debug.log(\"poll_oneoff: only a single subscription is supported\");return wasi.ERRNO_NOTSUP}const buffer=new DataView(self.inst.exports.memory.buffer);const s=wasi.Subscription.read_bytes(buffer,in_ptr);const eventtype=s.eventtype;const clockid=s.clockid;const timeout=s.timeout;if(eventtype!==wasi.EVENTTYPE_CLOCK){debug.log(\"poll_oneoff: only clock subscriptions are supported\");return wasi.ERRNO_NOTSUP}let getNow=undefined;if(clockid===wasi.CLOCKID_MONOTONIC){getNow=()=>BigInt(Math.round(performance.now()*1e6))}else if(clockid===wasi.CLOCKID_REALTIME){getNow=()=>BigInt(new Date().getTime())*1000000n}else{return wasi.ERRNO_INVAL}const endTime=(s.flags&wasi.SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME)!==0?timeout:getNow()+timeout;while(endTime>getNow()){}const event=new wasi.Event(s.userdata,wasi.ERRNO_SUCCESS,eventtype);event.write_bytes(buffer,out_ptr);return wasi.ERRNO_SUCCESS},proc_exit(exit_code){throw new WASIProcExit(exit_code)},proc_raise(sig){throw\"raised signal \"+sig},sched_yield(){},random_get(buf,buf_len){const buffer8=new Uint8Array(self.inst.exports.memory.buffer).subarray(buf,buf+buf_len);if(\"crypto\"in globalThis&&(typeof SharedArrayBuffer===\"undefined\"||!(self.inst.exports.memory.buffer instanceof SharedArrayBuffer))){for(let i=0;i<buf_len;i+=65536){crypto.getRandomValues(buffer8.subarray(i,i+65536))}}else{for(let i=0;i<buf_len;i++){buffer8[i]=Math.random()*256|0}}},sock_recv(fd,ri_data,ri_flags){throw\"sockets not supported\"},sock_send(fd,si_data,si_flags){throw\"sockets not supported\"},sock_shutdown(fd,how){throw\"sockets not supported\"},sock_accept(fd,flags){throw\"sockets not supported\"}}}};export{WASI as default};", "import*as wasi from\"./wasi_defs.js\";export class Fd{fd_allocate(offset,len){return wasi.ERRNO_NOTSUP}fd_close(){return 0}fd_fdstat_get(){return{ret:wasi.ERRNO_NOTSUP,fdstat:null}}fd_fdstat_set_flags(flags){return wasi.ERRNO_NOTSUP}fd_fdstat_set_rights(fs_rights_base,fs_rights_inheriting){return wasi.ERRNO_NOTSUP}fd_filestat_get(){return{ret:wasi.ERRNO_NOTSUP,filestat:null}}fd_filestat_set_size(size){return wasi.ERRNO_NOTSUP}fd_filestat_set_times(atim,mtim,fst_flags){return wasi.ERRNO_NOTSUP}fd_pread(size,offset){return{ret:wasi.ERRNO_NOTSUP,data:new Uint8Array}}fd_prestat_get(){return{ret:wasi.ERRNO_NOTSUP,prestat:null}}fd_pwrite(data,offset){return{ret:wasi.ERRNO_NOTSUP,nwritten:0}}fd_read(size){return{ret:wasi.ERRNO_NOTSUP,data:new Uint8Array}}fd_readdir_single(cookie){return{ret:wasi.ERRNO_NOTSUP,dirent:null}}fd_seek(offset,whence){return{ret:wasi.ERRNO_NOTSUP,offset:0n}}fd_sync(){return 0}fd_tell(){return{ret:wasi.ERRNO_NOTSUP,offset:0n}}fd_write(data){return{ret:wasi.ERRNO_NOTSUP,nwritten:0}}path_create_directory(path){return wasi.ERRNO_NOTSUP}path_filestat_get(flags,path){return{ret:wasi.ERRNO_NOTSUP,filestat:null}}path_filestat_set_times(flags,path,atim,mtim,fst_flags){return wasi.ERRNO_NOTSUP}path_link(path,inode,allow_dir){return wasi.ERRNO_NOTSUP}path_unlink(path){return{ret:wasi.ERRNO_NOTSUP,inode_obj:null}}path_lookup(path,dirflags){return{ret:wasi.ERRNO_NOTSUP,inode_obj:null}}path_open(dirflags,path,oflags,fs_rights_base,fs_rights_inheriting,fd_flags){return{ret:wasi.ERRNO_NOTDIR,fd_obj:null}}path_readlink(path){return{ret:wasi.ERRNO_NOTSUP,data:null}}path_remove_directory(path){return wasi.ERRNO_NOTSUP}path_rename(old_path,new_fd,new_path){return wasi.ERRNO_NOTSUP}path_unlink_file(path){return wasi.ERRNO_NOTSUP}}export class Inode{static issue_ino(){return Inode.next_ino++}static root_ino(){return 0n}constructor(){this.ino=Inode.issue_ino()}}Inode.next_ino=1n;", "import{debug}from\"./debug.js\";import*as wasi from\"./wasi_defs.js\";import{Fd,Inode}from\"./fd.js\";export class OpenFile extends Fd{fd_allocate(offset,len){if(this.file.size>offset+len){}else{const new_data=new Uint8Array(Number(offset+len));new_data.set(this.file.data,0);this.file.data=new_data}return wasi.ERRNO_SUCCESS}fd_fdstat_get(){return{ret:0,fdstat:new wasi.Fdstat(wasi.FILETYPE_REGULAR_FILE,0)}}fd_filestat_set_size(size){if(this.file.size>size){this.file.data=new Uint8Array(this.file.data.buffer.slice(0,Number(size)))}else{const new_data=new Uint8Array(Number(size));new_data.set(this.file.data,0);this.file.data=new_data}return wasi.ERRNO_SUCCESS}fd_read(size){const slice=this.file.data.slice(Number(this.file_pos),Number(this.file_pos+BigInt(size)));this.file_pos+=BigInt(slice.length);return{ret:0,data:slice}}fd_pread(size,offset){const slice=this.file.data.slice(Number(offset),Number(offset+BigInt(size)));return{ret:0,data:slice}}fd_seek(offset,whence){let calculated_offset;switch(whence){case wasi.WHENCE_SET:calculated_offset=offset;break;case wasi.WHENCE_CUR:calculated_offset=this.file_pos+offset;break;case wasi.WHENCE_END:calculated_offset=BigInt(this.file.data.byteLength)+offset;break;default:return{ret:wasi.ERRNO_INVAL,offset:0n}}if(calculated_offset<0){return{ret:wasi.ERRNO_INVAL,offset:0n}}this.file_pos=calculated_offset;return{ret:0,offset:this.file_pos}}fd_tell(){return{ret:0,offset:this.file_pos}}fd_write(data){if(this.file.readonly)return{ret:wasi.ERRNO_BADF,nwritten:0};if(this.file_pos+BigInt(data.byteLength)>this.file.size){const old=this.file.data;this.file.data=new Uint8Array(Number(this.file_pos+BigInt(data.byteLength)));this.file.data.set(old)}this.file.data.set(data,Number(this.file_pos));this.file_pos+=BigInt(data.byteLength);return{ret:0,nwritten:data.byteLength}}fd_pwrite(data,offset){if(this.file.readonly)return{ret:wasi.ERRNO_BADF,nwritten:0};if(offset+BigInt(data.byteLength)>this.file.size){const old=this.file.data;this.file.data=new Uint8Array(Number(offset+BigInt(data.byteLength)));this.file.data.set(old)}this.file.data.set(data,Number(offset));return{ret:0,nwritten:data.byteLength}}fd_filestat_get(){return{ret:0,filestat:this.file.stat()}}constructor(file){super();this.file_pos=0n;this.file=file}}export class OpenDirectory extends Fd{fd_seek(offset,whence){return{ret:wasi.ERRNO_BADF,offset:0n}}fd_tell(){return{ret:wasi.ERRNO_BADF,offset:0n}}fd_allocate(offset,len){return wasi.ERRNO_BADF}fd_fdstat_get(){return{ret:0,fdstat:new wasi.Fdstat(wasi.FILETYPE_DIRECTORY,0)}}fd_readdir_single(cookie){if(debug.enabled){debug.log(\"readdir_single\",cookie);debug.log(cookie,this.dir.contents.keys())}if(cookie==0n){return{ret:wasi.ERRNO_SUCCESS,dirent:new wasi.Dirent(1n,this.dir.ino,\".\",wasi.FILETYPE_DIRECTORY)}}else if(cookie==1n){return{ret:wasi.ERRNO_SUCCESS,dirent:new wasi.Dirent(2n,this.dir.parent_ino(),\"..\",wasi.FILETYPE_DIRECTORY)}}if(cookie>=BigInt(this.dir.contents.size)+2n){return{ret:0,dirent:null}}const[name,entry]=Array.from(this.dir.contents.entries())[Number(cookie-2n)];return{ret:0,dirent:new wasi.Dirent(cookie+1n,entry.ino,name,entry.stat().filetype)}}path_filestat_get(flags,path_str){const{ret:path_err,path}=Path.from(path_str);if(path==null){return{ret:path_err,filestat:null}}const{ret,entry}=this.dir.get_entry_for_path(path);if(entry==null){return{ret,filestat:null}}return{ret:0,filestat:entry.stat()}}path_lookup(path_str,dirflags){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return{ret:path_ret,inode_obj:null}}const{ret,entry}=this.dir.get_entry_for_path(path);if(entry==null){return{ret,inode_obj:null}}return{ret:wasi.ERRNO_SUCCESS,inode_obj:entry}}path_open(dirflags,path_str,oflags,fs_rights_base,fs_rights_inheriting,fd_flags){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return{ret:path_ret,fd_obj:null}}let{ret,entry}=this.dir.get_entry_for_path(path);if(entry==null){if(ret!=wasi.ERRNO_NOENT){return{ret,fd_obj:null}}if((oflags&wasi.OFLAGS_CREAT)==wasi.OFLAGS_CREAT){const{ret,entry:new_entry}=this.dir.create_entry_for_path(path_str,(oflags&wasi.OFLAGS_DIRECTORY)==wasi.OFLAGS_DIRECTORY);if(new_entry==null){return{ret,fd_obj:null}}entry=new_entry}else{return{ret:wasi.ERRNO_NOENT,fd_obj:null}}}else if((oflags&wasi.OFLAGS_EXCL)==wasi.OFLAGS_EXCL){return{ret:wasi.ERRNO_EXIST,fd_obj:null}}if((oflags&wasi.OFLAGS_DIRECTORY)==wasi.OFLAGS_DIRECTORY&&entry.stat().filetype!==wasi.FILETYPE_DIRECTORY){return{ret:wasi.ERRNO_NOTDIR,fd_obj:null}}return entry.path_open(oflags,fs_rights_base,fd_flags)}path_create_directory(path){return this.path_open(0,path,wasi.OFLAGS_CREAT|wasi.OFLAGS_DIRECTORY,0n,0n,0).ret}path_link(path_str,inode,allow_dir){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return path_ret}if(path.is_dir){return wasi.ERRNO_NOENT}const{ret:parent_ret,parent_entry,filename,entry}=this.dir.get_parent_dir_and_entry_for_path(path,true);if(parent_entry==null||filename==null){return parent_ret}if(entry!=null){const source_is_dir=inode.stat().filetype==wasi.FILETYPE_DIRECTORY;const target_is_dir=entry.stat().filetype==wasi.FILETYPE_DIRECTORY;if(source_is_dir&&target_is_dir){if(allow_dir&&entry instanceof Directory){if(entry.contents.size==0){}else{return wasi.ERRNO_NOTEMPTY}}else{return wasi.ERRNO_EXIST}}else if(source_is_dir&&!target_is_dir){return wasi.ERRNO_NOTDIR}else if(!source_is_dir&&target_is_dir){return wasi.ERRNO_ISDIR}else if(inode.stat().filetype==wasi.FILETYPE_REGULAR_FILE&&entry.stat().filetype==wasi.FILETYPE_REGULAR_FILE){}else{return wasi.ERRNO_EXIST}}if(!allow_dir&&inode.stat().filetype==wasi.FILETYPE_DIRECTORY){return wasi.ERRNO_PERM}parent_entry.contents.set(filename,inode);return wasi.ERRNO_SUCCESS}path_unlink(path_str){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return{ret:path_ret,inode_obj:null}}const{ret:parent_ret,parent_entry,filename,entry}=this.dir.get_parent_dir_and_entry_for_path(path,true);if(parent_entry==null||filename==null){return{ret:parent_ret,inode_obj:null}}if(entry==null){return{ret:wasi.ERRNO_NOENT,inode_obj:null}}parent_entry.contents.delete(filename);return{ret:wasi.ERRNO_SUCCESS,inode_obj:entry}}path_unlink_file(path_str){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return path_ret}const{ret:parent_ret,parent_entry,filename,entry}=this.dir.get_parent_dir_and_entry_for_path(path,false);if(parent_entry==null||filename==null||entry==null){return parent_ret}if(entry.stat().filetype===wasi.FILETYPE_DIRECTORY){return wasi.ERRNO_ISDIR}parent_entry.contents.delete(filename);return wasi.ERRNO_SUCCESS}path_remove_directory(path_str){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return path_ret}const{ret:parent_ret,parent_entry,filename,entry}=this.dir.get_parent_dir_and_entry_for_path(path,false);if(parent_entry==null||filename==null||entry==null){return parent_ret}if(!(entry instanceof Directory)||entry.stat().filetype!==wasi.FILETYPE_DIRECTORY){return wasi.ERRNO_NOTDIR}if(entry.contents.size!==0){return wasi.ERRNO_NOTEMPTY}if(!parent_entry.contents.delete(filename)){return wasi.ERRNO_NOENT}return wasi.ERRNO_SUCCESS}fd_filestat_get(){return{ret:0,filestat:this.dir.stat()}}fd_filestat_set_size(size){return wasi.ERRNO_BADF}fd_read(size){return{ret:wasi.ERRNO_BADF,data:new Uint8Array}}fd_pread(size,offset){return{ret:wasi.ERRNO_BADF,data:new Uint8Array}}fd_write(data){return{ret:wasi.ERRNO_BADF,nwritten:0}}fd_pwrite(data,offset){return{ret:wasi.ERRNO_BADF,nwritten:0}}constructor(dir){super();this.dir=dir}}export class PreopenDirectory extends OpenDirectory{fd_prestat_get(){return{ret:0,prestat:wasi.Prestat.dir(this.prestat_name)}}constructor(name,contents){super(new Directory(contents));this.prestat_name=name}}export class File extends Inode{path_open(oflags,fs_rights_base,fd_flags){if(this.readonly&&(fs_rights_base&BigInt(wasi.RIGHTS_FD_WRITE))==BigInt(wasi.RIGHTS_FD_WRITE)){return{ret:wasi.ERRNO_PERM,fd_obj:null}}if((oflags&wasi.OFLAGS_TRUNC)==wasi.OFLAGS_TRUNC){if(this.readonly)return{ret:wasi.ERRNO_PERM,fd_obj:null};this.data=new Uint8Array([])}const file=new OpenFile(this);if(fd_flags&wasi.FDFLAGS_APPEND)file.fd_seek(0n,wasi.WHENCE_END);return{ret:wasi.ERRNO_SUCCESS,fd_obj:file}}get size(){return BigInt(this.data.byteLength)}stat(){return new wasi.Filestat(this.ino,wasi.FILETYPE_REGULAR_FILE,this.size)}constructor(data,options){super();this.data=new Uint8Array(data);this.readonly=!!options?.readonly}}let Path=class Path{static from(path){const self=new Path;self.is_dir=path.endsWith(\"/\");if(path.startsWith(\"/\")){return{ret:wasi.ERRNO_NOTCAPABLE,path:null}}if(path.includes(\"\\x00\")){return{ret:wasi.ERRNO_INVAL,path:null}}for(const component of path.split(\"/\")){if(component===\"\"||component===\".\"){continue}if(component===\"..\"){if(self.parts.pop()==undefined){return{ret:wasi.ERRNO_NOTCAPABLE,path:null}}continue}self.parts.push(component)}return{ret:wasi.ERRNO_SUCCESS,path:self}}to_path_string(){let s=this.parts.join(\"/\");if(this.is_dir){s+=\"/\"}return s}constructor(){this.parts=[];this.is_dir=false}};export class Directory extends Inode{parent_ino(){if(this.parent==null){return Inode.root_ino()}return this.parent.ino}path_open(oflags,fs_rights_base,fd_flags){return{ret:wasi.ERRNO_SUCCESS,fd_obj:new OpenDirectory(this)}}stat(){return new wasi.Filestat(this.ino,wasi.FILETYPE_DIRECTORY,0n)}get_entry_for_path(path){let entry=this;for(const component of path.parts){if(!(entry instanceof Directory)){return{ret:wasi.ERRNO_NOTDIR,entry:null}}const child=entry.contents.get(component);if(child!==undefined){entry=child}else{debug.log(component);return{ret:wasi.ERRNO_NOENT,entry:null}}}if(path.is_dir){if(entry.stat().filetype!=wasi.FILETYPE_DIRECTORY){return{ret:wasi.ERRNO_NOTDIR,entry:null}}}return{ret:wasi.ERRNO_SUCCESS,entry}}get_parent_dir_and_entry_for_path(path,allow_undefined){const filename=path.parts.pop();if(filename===undefined){return{ret:wasi.ERRNO_INVAL,parent_entry:null,filename:null,entry:null}}const{ret:entry_ret,entry:parent_entry}=this.get_entry_for_path(path);if(parent_entry==null){return{ret:entry_ret,parent_entry:null,filename:null,entry:null}}if(!(parent_entry instanceof Directory)){return{ret:wasi.ERRNO_NOTDIR,parent_entry:null,filename:null,entry:null}}const entry=parent_entry.contents.get(filename);if(entry===undefined){if(!allow_undefined){return{ret:wasi.ERRNO_NOENT,parent_entry:null,filename:null,entry:null}}else{return{ret:wasi.ERRNO_SUCCESS,parent_entry,filename,entry:null}}}if(path.is_dir){if(entry.stat().filetype!=wasi.FILETYPE_DIRECTORY){return{ret:wasi.ERRNO_NOTDIR,parent_entry:null,filename:null,entry:null}}}return{ret:wasi.ERRNO_SUCCESS,parent_entry,filename,entry}}create_entry_for_path(path_str,is_dir){const{ret:path_ret,path}=Path.from(path_str);if(path==null){return{ret:path_ret,entry:null}}let{ret:parent_ret,parent_entry,filename,entry}=this.get_parent_dir_and_entry_for_path(path,true);if(parent_entry==null||filename==null){return{ret:parent_ret,entry:null}}if(entry!=null){return{ret:wasi.ERRNO_EXIST,entry:null}}debug.log(\"create\",path);let new_child;if(!is_dir){new_child=new File(new ArrayBuffer(0))}else{new_child=new Directory(new Map)}parent_entry.contents.set(filename,new_child);entry=new_child;return{ret:wasi.ERRNO_SUCCESS,entry}}constructor(contents){super();this.parent=null;if(contents instanceof Array){this.contents=new Map(contents)}else{this.contents=contents}for(const entry of this.contents.values()){if(entry instanceof Directory){entry.parent=this}}}}export class ConsoleStdout extends Fd{fd_filestat_get(){const filestat=new wasi.Filestat(this.ino,wasi.FILETYPE_CHARACTER_DEVICE,BigInt(0));return{ret:0,filestat}}fd_fdstat_get(){const fdstat=new wasi.Fdstat(wasi.FILETYPE_CHARACTER_DEVICE,0);fdstat.fs_rights_base=BigInt(wasi.RIGHTS_FD_WRITE);return{ret:0,fdstat}}fd_write(data){this.write(data);return{ret:0,nwritten:data.byteLength}}static lineBuffered(write){const dec=new TextDecoder(\"utf-8\",{fatal:false});let line_buf=\"\";return new ConsoleStdout(buffer=>{line_buf+=dec.decode(buffer,{stream:true});const lines=line_buf.split(\"\\n\");for(const[i,line]of lines.entries()){if(i<lines.length-1){write(line)}else{line_buf=line}}})}constructor(write){super();this.ino=Inode.issue_ino();this.write=write}}", "// Runs the pas2js compiler \u2014 the Free Pascal transpiler built by the FPC team as\n// a wasm32-wasi binary \u2014 against an in-memory filesystem.\n\nimport {\n WASI,\n File,\n Directory,\n PreopenDirectory,\n OpenFile,\n ConsoleStdout,\n WASIProcExit,\n} from './vendor/browser_wasi_shim/index.js';\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n// The guest layout the compiler expects. This mirrors the official FPC browser\n// compiler demo: the compiler resolves argv[0] to find its own directory, and\n// looks for units on the -Fu paths.\nconst COMPILER_PATH = '/pas2js';\nconst RTL_DIR = '/p2js/units';\nconst USER_DIR = '/p2js/userunits';\nconst BUILD_DIR = '/tmp';\nconst MAIN_FILE = 'main.pp';\nconst OUTPUT_FILE = 'main.js';\n\n// Source maps need an explicit base directory: the RTL sources live outside the\n// build directory, and every name has to be expressible relative to that base.\nconst SOURCE_MAP_FLAGS = ['-Jminclude', '-Jmbasedir=/', '-Jmxssiheader-'];\n\n/**\n * Compile Pascal source to JavaScript.\n *\n * @param {object} options\n * @param {string} options.source Pascal program to compile.\n * @param {WebAssembly.Module} options.wasm The compiled pas2js compiler.\n * @param {Map<string, Uint8Array>} options.rtl RTL sources from `loadAssets`.\n * @param {Record<string, string|Uint8Array>|Map<string, string|Uint8Array>} [options.units]\n * Extra units, by filename; they land on the compiler's search path.\n * @param {string[]} [options.flags] Extra pas2js command-line options.\n * @param {boolean} [options.sourceMap] Emit `main.js.map`.\n * @returns {Promise<{exitCode: number, js: string|null, sourceMap: string|null, diagnostics: string}>}\n */\nexport async function runCompiler({\n source = '',\n wasm,\n rtl,\n units,\n flags = [],\n sourceMap = false,\n}) {\n const stdout = [];\n const stderr = [];\n const collect = (sink) => (chunk) => sink.push(decoder.decode(chunk));\n const file = (name, data) => [name, new File(data)];\n\n const root = new PreopenDirectory('/', [\n // The compiler stats argv[0], so both the path and a file at /bin/pas2js\n // have to exist.\n ['bin', new Directory([file('pas2js', encoder.encode('stub'))])],\n ['pas2js', new Directory([])],\n [\n 'p2js',\n new Directory([\n ['units', new Directory([...rtl].map(([name, data]) => file(name, data)))],\n ['userunits', new Directory(toEntries(units))],\n ]),\n ],\n ['tmp', new Directory([file(MAIN_FILE, encoder.encode(source))])],\n ]);\n\n const args = [\n COMPILER_PATH,\n '-n', // do not read a pas2js.cfg\n '-TBrowser',\n '-Jc', // emit JavaScript\n '-Jirtl.js', // inline the RTL so the output is self-contained\n `-Fu${RTL_DIR}`,\n `-Fu${USER_DIR}`,\n `-Fi${USER_DIR}`,\n ...(sourceMap ? SOURCE_MAP_FLAGS : []),\n ...flags,\n `${BUILD_DIR}/${MAIN_FILE}`,\n `-o${BUILD_DIR}/${OUTPUT_FILE}`,\n ];\n\n // fds 0-2 are the standard streams; fd 3 is the preopened root.\n const fds = [\n new OpenFile(new File([])),\n ConsoleStdout.lineBuffered((line) => collect(stdout)(encoder.encode(`${line}\\n`))),\n ConsoleStdout.lineBuffered((line) => collect(stderr)(encoder.encode(`${line}\\n`))),\n root,\n ];\n\n // `debug: false` matters: the shim turns syscall tracing on when its options\n // argument is omitted.\n const wasi = new WASI(args, [], fds, { debug: false });\n\n // Instantiation has to be asynchronous: Chrome rejects a synchronous\n // `new WebAssembly.Instance` for buffers over 8 MB, and this one is ~9 MB.\n const instance = await WebAssembly.instantiate(wasm, {\n wasi_snapshot_preview1: wasi.wasiImport,\n });\n\n let exitCode = 0;\n try {\n exitCode = wasi.start(instance);\n } catch (error) {\n if (error instanceof WASIProcExit) exitCode = error.code;\n else throw error;\n }\n\n const js = locate(root.dir, OUTPUT_FILE);\n const map = locate(root.dir, `${OUTPUT_FILE}.map`);\n\n return {\n exitCode,\n js: js ? decoder.decode(js.data) : null,\n sourceMap: map ? decoder.decode(map.data) : null,\n diagnostics: stdout.join('') + stderr.join(''),\n };\n}\n\nfunction toEntries(units) {\n if (!units) return [];\n const entries = units instanceof Map ? [...units] : Object.entries(units);\n return entries.map(([name, content]) => [\n name,\n new File(typeof content === 'string' ? encoder.encode(content) : content),\n ]);\n}\n\nfunction locate(dir, name) {\n for (const [entryName, inode] of dir.contents) {\n if (inode instanceof File && entryName === name) return inode;\n if (inode instanceof Directory) {\n const nested = locate(inode, name);\n if (nested) return nested;\n }\n }\n return null;\n}\n", "// @live-codes/pascal-wasm \u2014 the Free Pascal `pas2js` compiler compiled to\n// WebAssembly, for use in browsers and Web Workers. Compilation happens entirely\n// on the client; nothing is sent to a server.\n//\n// import { compile } from '@live-codes/pascal-wasm';\n//\n// const { js, diagnostics } = await compile('begin Writeln(42) end.');\n\nimport { defaultBaseUrl, loadAssets } from './assets.js';\nimport { configure, getConfig } from './config.js';\nimport { runCompiler } from './compiler.js';\n\nexport { configure, defaultBaseUrl };\n\n// One compiler per asset location: loading is expensive (a ~9 MB binary) and the\n// result is reusable, so `compile()` shares it across calls.\nconst compilers = new Map();\n\n/**\n * Create a reusable compiler.\n *\n * @param {import('../types/index.d.ts').CompilerOptions} [options]\n * @returns {Promise<import('../types/index.d.ts').Compiler>}\n */\nexport async function createCompiler(options = {}) {\n const key = cacheKey(options);\n let pending = compilers.get(key);\n if (!pending) {\n pending = loadAssets(options);\n compilers.set(key, pending);\n // Never cache a failed load.\n pending.catch(() => compilers.delete(key));\n }\n\n const assets = await pending;\n\n return {\n baseUrl: assets.baseUrl,\n compile: (source, compileOptions = {}) => {\n const { flags, ...rest } = compileOptions;\n return runCompiler({\n source,\n wasm: assets.wasm,\n rtl: assets.rtl,\n ...rest,\n flags: mergeFlags(flags),\n });\n },\n version: async () => {\n const { diagnostics } = await runCompiler({\n wasm: assets.wasm,\n rtl: assets.rtl,\n flags: ['-iV'], // write the short compiler version and halt\n });\n return diagnostics.trim();\n },\n };\n}\n\n/**\n * Compile a single program, reusing a shared compiler.\n *\n * @param {string} source\n * @param {import('../types/index.d.ts').CompileOptions} [options]\n * @returns {Promise<import('../types/index.d.ts').CompileResult>}\n */\nexport async function compile(source, options = {}) {\n const compiler = await createCompiler(options);\n return compiler.compile(source, options);\n}\n\n/**\n * Turn the compiler's text output into structured messages.\n *\n * Lines look like `main.pp(5,11) Error: identifier not found \"x\"`, alongside\n * informational chatter which is ignored.\n *\n * @param {string} diagnostics\n * @returns {import('../types/index.d.ts').DiagnosticMessage[]}\n */\nexport function parseDiagnostics(diagnostics) {\n const messages = [];\n for (const raw of String(diagnostics ?? '').split('\\n')) {\n const line = raw.trim();\n if (!line) continue;\n\n const located = /^(.*?)\\((\\d+),(\\d+)\\)\\s+(Error|Warning|Hint|Note)\\s*:\\s*(.*)$/.exec(line);\n if (located) {\n messages.push({\n file: located[1],\n line: Number(located[2]),\n column: Number(located[3]),\n severity: located[4].toLowerCase(),\n message: located[5],\n });\n continue;\n }\n\n const fatal = /^Fatal\\s*:\\s*(.*)$/.exec(line);\n if (fatal) {\n messages.push({\n file: null,\n line: null,\n column: null,\n severity: 'fatal',\n message: fatal[1],\n });\n }\n }\n return messages;\n}\n\n/** Options passed per compile are appended to the configured defaults. */\nfunction mergeFlags(flags) {\n const { flags: configured } = getConfig();\n if (!configured.length) return flags ?? [];\n return [...configured, ...(flags ?? [])];\n}\n\nfunction cacheKey({ baseUrl, wasmUrl, rtlUrl }) {\n let key = baseUrl;\n if (!key) {\n try {\n key = defaultBaseUrl().href;\n } catch {\n key = 'default';\n }\n }\n return [key, wasmUrl ?? '', rtlUrl ?? ''].join('|');\n}\n", "// Classic-script entry point, built into `dist/pascal-wasm.iife.min.js`.\n//\n// Exposes the same API as the ES module on a global named `pascalWasm`, so it\n// can be pulled into a non-module worker:\n//\n// importScripts('\u2026/pascal-wasm.iife.min.js');\n// pascalWasm.configure({ baseUrl: '\u2026/assets/' });\n// pascalWasm.compile('begin Writeln(42) end.').then(console.log);\n//\n// This build has no module URL to resolve the assets against, so `baseUrl` is\n// required \u2014 see `assets.js`.\n\nimport {\n compile,\n createCompiler,\n defaultBaseUrl,\n configure,\n parseDiagnostics,\n} from './index.js';\n\nglobalThis.pascalWasm = {\n compile,\n createCompiler,\n defaultBaseUrl,\n configure,\n parseDiagnostics,\n};\n"],
|
|
5
|
+
"mappings": "2tBAIA,IAAMA,GAAS,CACb,QAAS,KACT,MAAO,CAAC,CACV,EASO,SAASC,GAAUC,EAAU,CAAC,EAAG,CAClCA,EAAQ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QAAWC,KAAO,OAAOJ,GAAe,EAAE,EAAE,MAAM;AAAA,CAAI,EAAG,CACvD,IAAMK,EAAOD,EAAI,KAAK,EACtB,GAAI,CAACC,EAAM,SAEX,IAAMC,EAAU,gEAAgE,KAAKD,CAAI,EACzF,GAAIC,EAAS,CACXH,EAAS,KAAK,CACZ,KAAMG,EAAQ,CAAC,EACf,KAAM,OAAOA,EAAQ,CAAC,CAAC,EACvB,OAAQ,OAAOA,EAAQ,CAAC,CAAC,EACzB,SAAUA,EAAQ,CAAC,EAAE,YAAY,EACjC,QAASA,EAAQ,CAAC,CACpB,CAAC,EACD,QACF,CAEA,IAAMC,EAAQ,qBAAqB,KAAKF,CAAI,EACxCE,GACFJ,EAAS,KAAK,CACZ,KAAM,KACN,KAAM,KACN,OAAQ,KACR,SAAU,QACV,QAASI,EAAM,CAAC,CAClB,CAAC,CAEL,CACA,OAAOJ,CACT,CAGA,SAASJ,GAAWH,EAAO,CACzB,GAAM,CAAE,MAAOY,CAAW,EAAIC,EAAU,EACxC,OAAKD,EAAW,OACT,CAAC,GAAGA,EAAY,GAAIZ,GAAS,CAAC,CAAE,EADRA,GAAS,CAAC,CAE3C,CAEA,SAASN,GAAS,CAAE,QAAAoB,EAAS,QAAAC,EAAS,OAAAC,CAAO,EAAG,CAC9C,IAAIvB,EAAMqB,EACV,GAAI,CAACrB,EACH,GAAI,CACFA,EAAMwB,EAAe,EAAE,IACzB,MAAQ,CACNxB,EAAM,SACR,CAEF,MAAO,CAACA,EAAKsB,GAAW,GAAIC,GAAU,EAAE,EAAE,KAAK,GAAG,CACpD,CC7GA,WAAW,WAAa,CACtB,QAAAE,GACA,eAAAC,GACA,eAAAC,EACA,UAAAC,GACA,iBAAAC,EACF",
|
|
6
|
+
"names": ["config", "configure", "options", "getConfig", "import_meta", "toUrl", "value", "base", "defaultBaseUrl", "baseUrl", "getConfig", "here", "location", "moduleLocation", "loadAssets", "wasmUrl", "rtlUrl", "rtlDir", "wasmLocation", "manifestLocation", "manifest", "readText", "wasm", "files", "compileWasm", "filename", "readBinary", "readFile", "response", "Iovec", "_Iovec", "view", "ptr", "iovec", "len", "iovecs", "i", "Ciovec", "_Ciovec", "WHENCE_SET", "WHENCE_CUR", "WHENCE_END", "FILETYPE_CHARACTER_DEVICE", "FILETYPE_DIRECTORY", "FILETYPE_REGULAR_FILE", "Dirent", "view", "ptr", "view8", "buf_len", "next_cookie", "d_ino", "name", "type", "encoded_name", "FDFLAGS_APPEND", "Fdstat", "view", "ptr", "filetype", "flags", "OFLAGS_CREAT", "OFLAGS_DIRECTORY", "OFLAGS_EXCL", "OFLAGS_TRUNC", "Filestat", "view", "ptr", "ino", "filetype", "size", "EVENTTYPE_CLOCK", "SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME", "Subscription", "_Subscription", "view", "ptr", "userdata", "eventtype", "clockid", "timeout", "flags", "Event", "error", "PREOPENTYPE_DIR", "PrestatDir", "view", "ptr", "name", "Prestat", "_Prestat", "prestat", "Debug", "enabled", "createLogger", "isEnabled", "prefix", "debug", "WASIProcExit", "code", "WASI", "instance", "args", "env", "fds", "options", "debug", "self", "argc", "argv_buf_size", "buffer", "buf_size", "arg", "argv", "argv_buf", "buffer8", "orig_argv_buf", "i", "environ_count", "environ_size", "environ", "environ_buf", "orig_environ_buf", "e", "id", "res_ptr", "resolutionValue", "precision", "time", "monotonic_time", "fd", "offset", "len", "advice", "ret", "fdstat_ptr", "fdstat", "flags", "fs_rights_base", "fs_rights_inheriting", "filestat_ptr", "filestat", "size", "atim", "mtim", "fst_flags", "iovs_ptr", "iovs_len", "nread_ptr", "iovecs", "Iovec", "nread", "iovec", "data", "buf_ptr", "prestat", "path_ptr", "path_len", "prestat_dir_name", "nwritten_ptr", "Ciovec", "nwritten", "nwritten_part", "buf", "buf_len", "cookie", "bufused_ptr", "bufused", "dirent", "head_bytes", "to", "whence", "offset_out_ptr", "offset_out", "offset_ptr", "path", "old_fd", "old_flags", "old_path_ptr", "old_path_len", "new_fd", "new_path_ptr", "new_path_len", "old_path", "new_path", "inode_obj", "dirflags", "oflags", "fd_flags", "opened_fd_ptr", "fd_obj", "opened_fd", "data_buf", "in_ptr", "out_ptr", "nsubscriptions", "s", "Subscription", "eventtype", "clockid", "timeout", "EVENTTYPE_CLOCK", "getNow", "endTime", "SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME", "Event", "exit_code", "sig", "ri_data", "ri_flags", "si_data", "si_flags", "how", "Fd", "offset", "len", "flags", "fs_rights_base", "fs_rights_inheriting", "size", "atim", "mtim", "fst_flags", "data", "cookie", "whence", "path", "inode", "allow_dir", "dirflags", "oflags", "fd_flags", "old_path", "new_fd", "new_path", "Inode", "_Inode", "OpenFile", "Fd", "offset", "len", "new_data", "Fdstat", "FILETYPE_REGULAR_FILE", "size", "slice", "whence", "calculated_offset", "WHENCE_SET", "WHENCE_CUR", "WHENCE_END", "data", "old", "file", "OpenDirectory", "FILETYPE_DIRECTORY", "cookie", "debug", "Dirent", "name", "entry", "flags", "path_str", "path_err", "path", "Path", "ret", "dirflags", "path_ret", "oflags", "fs_rights_base", "fs_rights_inheriting", "fd_flags", "OFLAGS_CREAT", "new_entry", "OFLAGS_DIRECTORY", "OFLAGS_EXCL", "inode", "allow_dir", "parent_ret", "parent_entry", "filename", "source_is_dir", "target_is_dir", "Directory", "dir", "PreopenDirectory", "Prestat", "contents", "File", "Inode", "OFLAGS_TRUNC", "FDFLAGS_APPEND", "Filestat", "options", "self", "component", "s", "_Directory", "child", "allow_undefined", "entry_ret", "is_dir", "new_child", "ConsoleStdout", "_ConsoleStdout", "FILETYPE_CHARACTER_DEVICE", "fdstat", "write", "dec", "line_buf", "buffer", "lines", "i", "line", "encoder", "decoder", "COMPILER_PATH", "RTL_DIR", "USER_DIR", "BUILD_DIR", "MAIN_FILE", "OUTPUT_FILE", "SOURCE_MAP_FLAGS", "runCompiler", "source", "wasm", "rtl", "units", "flags", "sourceMap", "stdout", "stderr", "collect", "sink", "chunk", "file", "name", "data", "File", "root", "PreopenDirectory", "Directory", "toEntries", "args", "fds", "OpenFile", "ConsoleStdout", "line", "wasi", "WASI", "instance", "exitCode", "error", "WASIProcExit", "js", "locate", "map", "content", "dir", "entryName", "inode", "nested", "compilers", "createCompiler", "options", "key", "cacheKey", "pending", "loadAssets", "assets", "source", "compileOptions", "flags", "rest", "runCompiler", "mergeFlags", "diagnostics", "compile", "parseDiagnostics", "messages", "raw", "line", "located", "fatal", "configured", "getConfig", "baseUrl", "wasmUrl", "rtlUrl", "defaultBaseUrl", "compile", "createCompiler", "defaultBaseUrl", "configure", "parseDiagnostics"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@live-codes/pascal-wasm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Free Pascal pas2js compiler compiled to WebAssembly, for browsers and Web Workers. Compiles Pascal entirely client-side.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "LGPL-2.1-or-later",
|
|
7
|
+
"main": "./src/index.js",
|
|
8
|
+
"module": "./src/index.js",
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./types/index.d.ts",
|
|
13
|
+
"default": "./src/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./assets/*": "./assets/*",
|
|
16
|
+
"./dist/*": "./dist/*",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"unpkg": "./dist/pascal-wasm.iife.min.js",
|
|
20
|
+
"jsdelivr": "./dist/pascal-wasm.iife.min.js",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"dist",
|
|
25
|
+
"assets",
|
|
26
|
+
"types",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md",
|
|
29
|
+
"THIRD-PARTY-NOTICES.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "node scripts/build.mjs",
|
|
33
|
+
"pretest": "npm run build",
|
|
34
|
+
"test": "node --experimental-wasm-exnref --no-warnings test/test.mjs"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"pascal",
|
|
38
|
+
"pas2js",
|
|
39
|
+
"freepascal",
|
|
40
|
+
"compiler",
|
|
41
|
+
"transpiler",
|
|
42
|
+
"wasm",
|
|
43
|
+
"webassembly",
|
|
44
|
+
"wasi",
|
|
45
|
+
"browser",
|
|
46
|
+
"web-worker"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"esbuild": "^0.28.2"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/assets.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Loading of the bundled compiler artifacts — `pas2js.wasm` and the Pascal RTL
|
|
2
|
+
// sources — resolved against `baseUrl`, or against this module's own location
|
|
3
|
+
// when it is loaded as an ES module.
|
|
4
|
+
//
|
|
5
|
+
// Works in browsers, in Web Workers, and in Node (where the assets are read from
|
|
6
|
+
// disk instead of fetched). The classic-script (IIFE) build has no module URL,
|
|
7
|
+
// so it requires `baseUrl` to be passed in.
|
|
8
|
+
|
|
9
|
+
import { getConfig } from './config.js';
|
|
10
|
+
|
|
11
|
+
/** Accept a path or URL and resolve it against `base`. */
|
|
12
|
+
export function toUrl(value, base) {
|
|
13
|
+
return value instanceof URL ? value : new URL(value, base);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The asset location used when none is given explicitly: this module's own
|
|
18
|
+
* directory, when that is knowable.
|
|
19
|
+
*
|
|
20
|
+
* @returns {URL}
|
|
21
|
+
*/
|
|
22
|
+
export function defaultBaseUrl() {
|
|
23
|
+
const { baseUrl } = getConfig();
|
|
24
|
+
if (baseUrl) return toUrl(baseUrl, here());
|
|
25
|
+
|
|
26
|
+
const location = moduleLocation();
|
|
27
|
+
if (location) return new URL('../assets/', location);
|
|
28
|
+
|
|
29
|
+
throw new Error(
|
|
30
|
+
'@live-codes/pascal-wasm: cannot locate the compiler assets. Pass a location, ' +
|
|
31
|
+
'e.g. createCompiler({ baseUrl: "…/assets/" }) or configure({ baseUrl: "…" }).',
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Load the RTL sources and compile the compiler binary.
|
|
37
|
+
*
|
|
38
|
+
* @param {object} [options]
|
|
39
|
+
* @param {string|URL} [options.baseUrl] Directory holding `pas2js.wasm` and `rtl/`.
|
|
40
|
+
* @param {string|URL} [options.wasmUrl] Override the compiler binary location.
|
|
41
|
+
* @param {string|URL} [options.rtlUrl] Override the RTL directory location.
|
|
42
|
+
* @returns {Promise<{baseUrl: URL, wasm: WebAssembly.Module, rtl: Map<string, Uint8Array>}>}
|
|
43
|
+
*/
|
|
44
|
+
export async function loadAssets({ baseUrl, wasmUrl, rtlUrl } = {}) {
|
|
45
|
+
const base = baseUrl ? toUrl(baseUrl, here()) : defaultBaseUrl();
|
|
46
|
+
const rtlDir = rtlUrl ? toUrl(rtlUrl, base) : new URL('rtl/', base);
|
|
47
|
+
const wasmLocation = wasmUrl ? toUrl(wasmUrl, base) : new URL('pas2js.wasm', base);
|
|
48
|
+
|
|
49
|
+
const manifestLocation = new URL('manifest.json', rtlDir);
|
|
50
|
+
const manifest = JSON.parse(await readText(manifestLocation));
|
|
51
|
+
if (!Array.isArray(manifest.units)) {
|
|
52
|
+
throw new Error(`Invalid RTL manifest at ${manifestLocation}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const [wasm, ...files] = await Promise.all([
|
|
56
|
+
compileWasm(wasmLocation),
|
|
57
|
+
...manifest.units.map(async ({ filename }) => [
|
|
58
|
+
filename,
|
|
59
|
+
await readBinary(new URL(filename, rtlDir)),
|
|
60
|
+
]),
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
return { baseUrl: base, wasm, rtl: new Map(files) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Used to resolve a relative `baseUrl`, in a page or a worker. */
|
|
67
|
+
function here() {
|
|
68
|
+
return globalThis.location?.href;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The URL of this module, when it is an ES module. A classic script cannot
|
|
73
|
+
* contain `import.meta`, so the bundled build has no equivalent — which is why
|
|
74
|
+
* it needs `baseUrl`.
|
|
75
|
+
*/
|
|
76
|
+
function moduleLocation() {
|
|
77
|
+
try {
|
|
78
|
+
return import.meta.url || null;
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function readText(location) {
|
|
85
|
+
if (location.protocol === 'file:') {
|
|
86
|
+
const { readFile } = await import('node:fs/promises');
|
|
87
|
+
return readFile(location, 'utf8');
|
|
88
|
+
}
|
|
89
|
+
const response = await fetch(location);
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
throw new Error(`Failed to load ${location}: HTTP ${response.status}`);
|
|
92
|
+
}
|
|
93
|
+
return response.text();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function readBinary(location) {
|
|
97
|
+
if (location.protocol === 'file:') {
|
|
98
|
+
const { readFile } = await import('node:fs/promises');
|
|
99
|
+
return new Uint8Array(await readFile(location));
|
|
100
|
+
}
|
|
101
|
+
const response = await fetch(location);
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
throw new Error(`Failed to load ${location}: HTTP ${response.status}`);
|
|
104
|
+
}
|
|
105
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function compileWasm(location) {
|
|
109
|
+
if (location.protocol === 'http:' || location.protocol === 'https:') {
|
|
110
|
+
try {
|
|
111
|
+
// Streaming lets the engine compile while the ~9 MB download is in flight.
|
|
112
|
+
return await WebAssembly.compileStreaming(fetch(location));
|
|
113
|
+
} catch {
|
|
114
|
+
// Some hosts do not serve .wasm as application/wasm, which
|
|
115
|
+
// compileStreaming requires. Fall back to downloading the bytes.
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return WebAssembly.compile(await readBinary(location));
|
|
119
|
+
}
|
package/src/compiler.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Runs the pas2js compiler — the Free Pascal transpiler built by the FPC team as
|
|
2
|
+
// a wasm32-wasi binary — against an in-memory filesystem.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
WASI,
|
|
6
|
+
File,
|
|
7
|
+
Directory,
|
|
8
|
+
PreopenDirectory,
|
|
9
|
+
OpenFile,
|
|
10
|
+
ConsoleStdout,
|
|
11
|
+
WASIProcExit,
|
|
12
|
+
} from './vendor/browser_wasi_shim/index.js';
|
|
13
|
+
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
const decoder = new TextDecoder();
|
|
16
|
+
|
|
17
|
+
// The guest layout the compiler expects. This mirrors the official FPC browser
|
|
18
|
+
// compiler demo: the compiler resolves argv[0] to find its own directory, and
|
|
19
|
+
// looks for units on the -Fu paths.
|
|
20
|
+
const COMPILER_PATH = '/pas2js';
|
|
21
|
+
const RTL_DIR = '/p2js/units';
|
|
22
|
+
const USER_DIR = '/p2js/userunits';
|
|
23
|
+
const BUILD_DIR = '/tmp';
|
|
24
|
+
const MAIN_FILE = 'main.pp';
|
|
25
|
+
const OUTPUT_FILE = 'main.js';
|
|
26
|
+
|
|
27
|
+
// Source maps need an explicit base directory: the RTL sources live outside the
|
|
28
|
+
// build directory, and every name has to be expressible relative to that base.
|
|
29
|
+
const SOURCE_MAP_FLAGS = ['-Jminclude', '-Jmbasedir=/', '-Jmxssiheader-'];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Compile Pascal source to JavaScript.
|
|
33
|
+
*
|
|
34
|
+
* @param {object} options
|
|
35
|
+
* @param {string} options.source Pascal program to compile.
|
|
36
|
+
* @param {WebAssembly.Module} options.wasm The compiled pas2js compiler.
|
|
37
|
+
* @param {Map<string, Uint8Array>} options.rtl RTL sources from `loadAssets`.
|
|
38
|
+
* @param {Record<string, string|Uint8Array>|Map<string, string|Uint8Array>} [options.units]
|
|
39
|
+
* Extra units, by filename; they land on the compiler's search path.
|
|
40
|
+
* @param {string[]} [options.flags] Extra pas2js command-line options.
|
|
41
|
+
* @param {boolean} [options.sourceMap] Emit `main.js.map`.
|
|
42
|
+
* @returns {Promise<{exitCode: number, js: string|null, sourceMap: string|null, diagnostics: string}>}
|
|
43
|
+
*/
|
|
44
|
+
export async function runCompiler({
|
|
45
|
+
source = '',
|
|
46
|
+
wasm,
|
|
47
|
+
rtl,
|
|
48
|
+
units,
|
|
49
|
+
flags = [],
|
|
50
|
+
sourceMap = false,
|
|
51
|
+
}) {
|
|
52
|
+
const stdout = [];
|
|
53
|
+
const stderr = [];
|
|
54
|
+
const collect = (sink) => (chunk) => sink.push(decoder.decode(chunk));
|
|
55
|
+
const file = (name, data) => [name, new File(data)];
|
|
56
|
+
|
|
57
|
+
const root = new PreopenDirectory('/', [
|
|
58
|
+
// The compiler stats argv[0], so both the path and a file at /bin/pas2js
|
|
59
|
+
// have to exist.
|
|
60
|
+
['bin', new Directory([file('pas2js', encoder.encode('stub'))])],
|
|
61
|
+
['pas2js', new Directory([])],
|
|
62
|
+
[
|
|
63
|
+
'p2js',
|
|
64
|
+
new Directory([
|
|
65
|
+
['units', new Directory([...rtl].map(([name, data]) => file(name, data)))],
|
|
66
|
+
['userunits', new Directory(toEntries(units))],
|
|
67
|
+
]),
|
|
68
|
+
],
|
|
69
|
+
['tmp', new Directory([file(MAIN_FILE, encoder.encode(source))])],
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const args = [
|
|
73
|
+
COMPILER_PATH,
|
|
74
|
+
'-n', // do not read a pas2js.cfg
|
|
75
|
+
'-TBrowser',
|
|
76
|
+
'-Jc', // emit JavaScript
|
|
77
|
+
'-Jirtl.js', // inline the RTL so the output is self-contained
|
|
78
|
+
`-Fu${RTL_DIR}`,
|
|
79
|
+
`-Fu${USER_DIR}`,
|
|
80
|
+
`-Fi${USER_DIR}`,
|
|
81
|
+
...(sourceMap ? SOURCE_MAP_FLAGS : []),
|
|
82
|
+
...flags,
|
|
83
|
+
`${BUILD_DIR}/${MAIN_FILE}`,
|
|
84
|
+
`-o${BUILD_DIR}/${OUTPUT_FILE}`,
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
// fds 0-2 are the standard streams; fd 3 is the preopened root.
|
|
88
|
+
const fds = [
|
|
89
|
+
new OpenFile(new File([])),
|
|
90
|
+
ConsoleStdout.lineBuffered((line) => collect(stdout)(encoder.encode(`${line}\n`))),
|
|
91
|
+
ConsoleStdout.lineBuffered((line) => collect(stderr)(encoder.encode(`${line}\n`))),
|
|
92
|
+
root,
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
// `debug: false` matters: the shim turns syscall tracing on when its options
|
|
96
|
+
// argument is omitted.
|
|
97
|
+
const wasi = new WASI(args, [], fds, { debug: false });
|
|
98
|
+
|
|
99
|
+
// Instantiation has to be asynchronous: Chrome rejects a synchronous
|
|
100
|
+
// `new WebAssembly.Instance` for buffers over 8 MB, and this one is ~9 MB.
|
|
101
|
+
const instance = await WebAssembly.instantiate(wasm, {
|
|
102
|
+
wasi_snapshot_preview1: wasi.wasiImport,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
let exitCode = 0;
|
|
106
|
+
try {
|
|
107
|
+
exitCode = wasi.start(instance);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (error instanceof WASIProcExit) exitCode = error.code;
|
|
110
|
+
else throw error;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const js = locate(root.dir, OUTPUT_FILE);
|
|
114
|
+
const map = locate(root.dir, `${OUTPUT_FILE}.map`);
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
exitCode,
|
|
118
|
+
js: js ? decoder.decode(js.data) : null,
|
|
119
|
+
sourceMap: map ? decoder.decode(map.data) : null,
|
|
120
|
+
diagnostics: stdout.join('') + stderr.join(''),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function toEntries(units) {
|
|
125
|
+
if (!units) return [];
|
|
126
|
+
const entries = units instanceof Map ? [...units] : Object.entries(units);
|
|
127
|
+
return entries.map(([name, content]) => [
|
|
128
|
+
name,
|
|
129
|
+
new File(typeof content === 'string' ? encoder.encode(content) : content),
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function locate(dir, name) {
|
|
134
|
+
for (const [entryName, inode] of dir.contents) {
|
|
135
|
+
if (inode instanceof File && entryName === name) return inode;
|
|
136
|
+
if (inode instanceof Directory) {
|
|
137
|
+
const nested = locate(inode, name);
|
|
138
|
+
if (nested) return nested;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|