v86 0.5.43 → 0.5.64
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/build/libv86-debug.js +75 -49
- package/build/libv86-debug.mjs +109 -108
- package/build/libv86.js +15 -14
- package/build/libv86.mjs +102 -100
- package/build/v86-debug.wasm +0 -0
- package/build/v86-fallback.wasm +0 -0
- package/build/v86.wasm +0 -0
- package/package.json +1 -1
package/build/libv86.mjs
CHANGED
|
@@ -7,16 +7,16 @@ qa;if("undefined"===typeof XMLHttpRequest||"undefined"!==typeof process&&process
|
|
|
7
7
|
(a=await import("node:fs/promises"));return(await a.stat(b)).size}}else pa=async function(a,b,c){function d(){const l=c||0;setTimeout(()=>{pa(a,b,l+1)},1E3*([1,1,2,3,5,8,13,21][l]||34))}var e=new XMLHttpRequest;e.open(b.method||"get",a,!0);e.responseType=b.as_json?"json":"arraybuffer";if(b.headers)for(var f=Object.keys(b.headers),g=0;g<f.length;g++){var k=f[g];e.setRequestHeader(k,b.headers[k])}b.range&&(f=b.range.start,e.setRequestHeader("Range","bytes="+f+"-"+(f+b.range.length-1)),e.setRequestHeader("X-Accept-Encoding",
|
|
8
8
|
"identity"),e.onreadystatechange=function(){200===e.status&&(console.error("Server sent full file in response to ranged request, aborting",{filename:a}),e.abort())});e.onload=function(){if(4===e.readyState)if(200!==e.status&&206!==e.status)console.error("Loading the image "+a+" failed (status %d)",e.status),500<=e.status&&600>e.status&&d();else if(e.response){if(b.range){const l=e.getResponseHeader("Content-Encoding");l&&"identity"!==l&&console.error("Server sent Content-Encoding in response to ranged request",
|
|
9
9
|
{filename:a,enc:l})}b.done&&b.done(e.response,e)}};e.onerror=function(l){console.error("Loading the image "+a+" failed",l);d()};b.progress&&(e.onprogress=function(l){b.progress(l)});e.send(null)},qa=async function(a){return new Promise((b,c)=>{pa(a,{done:(d,e)=>{d=e.getResponseHeader("Content-Range")||"";(e=d.match(/\/(\d+)\s*$/))?b(+e[1]):c(Error("`Range: bytes=...` header not supported (Got `"+d+"`)"))},headers:{Range:"bytes=0-0","X-Accept-Encoding":"identity"}})})};function ra(){}function sa(){}
|
|
10
|
-
function ta(a,b){function c(v){v=v.toString(16);return"#"+"0".repeat(6-v.length)+v}function d(v){var t=256*na,C=8*Q,I=Sa?Sa.canvas:null;I&&I.width===t&&I.height===C||(I?(I.width=t,I.height=C):(I=new OffscreenCanvas(t,C),Sa=I.getContext("2d")),Ab=Sa.createImageData(t,C));const O=Ab.data;let N=0,R;C=Bb?function(X){R=R||X;O[N+3]=X;O[N+7]=X;N+=8}:function(X){R=R||X;O[N+3]=X;N+=4};I=32-Q;const ka=t*(Q-1)*4;t=4*(na-t*Q);const ha=1020*na;for(let X=0,
|
|
11
|
-
ka);R=!1;for(let Ka=0;Ka<Q;++Ka,++
|
|
10
|
+
function ta(a,b){function c(v){v=v.toString(16);return"#"+"0".repeat(6-v.length)+v}function d(v){var t=256*na,C=8*Q,I=Sa?Sa.canvas:null;I&&I.width===t&&I.height===C||(I?(I.width=t,I.height=C):(I=new OffscreenCanvas(t,C),Sa=I.getContext("2d")),Ab=Sa.createImageData(t,C));const O=Ab.data;let N=0,R;C=Bb?function(X){R=R||X;O[N+3]=X;O[N+7]=X;N+=8}:function(X){R=R||X;O[N+3]=X;N+=4};I=32-Q;const ka=t*(Q-1)*4;t=4*(na-t*Q);const ha=1020*na;for(let X=0,Da=0;2048>X;++X,Da+=I,N+=t){const Ea=X%256;X&&!Ea&&(N+=
|
|
11
|
+
ka);R=!1;for(let Ka=0;Ka<Q;++Ka,++Da,N+=ha){const La=v[Da];for(let ua=128;0<ua;ua>>=1)C(La&ua?255:0);Cb&&C(Db&&192<=Ea&&223>=Ea&&La&1?255:0)}Ub[X]=R?1:0}Sa.putImageData(Ab,0,0)}function e(v,t,C,I){if(t&&C){v.style.width="";v.style.height="";I&&(v.style.transform="");var O=v.getBoundingClientRect();I?v.style.transform=(1===t?"":" scaleX("+t+")")+(1===C?"":" scaleY("+C+")"):(0===t%1&&0===C%1?(g.style.imageRendering="crisp-edges",g.style.imageRendering="pixelated",g.style["-ms-interpolation-mode"]="nearest-neighbor"):
|
|
12
12
|
(g.style.imageRendering="",g.style["-ms-interpolation-mode"]=""),I=window.devicePixelRatio||1,0!==I%1&&(t/=I,C/=I));1!==t&&(v.style.width=O.width*t+"px");1!==C&&(v.style.height=O.height*C+"px")}}const f=a.container;this.screen_fill_buffer=b;console.assert(f,"options.container must be provided");this.FLAG_BLINKING=1;this.FLAG_FONT_PAGE_B=2;var g=f.getElementsByTagName("canvas")[0],k=g.getContext("2d",{alpha:!1}),l=f.getElementsByTagName("div")[0],m=document.createElement("div"),n,p,q=void 0!==a.scale?
|
|
13
13
|
a.scale:1,r=void 0!==a.scale?a.scale:1,y=1,x,u,F,w,G,P,oa,Sa,Ab,Ub=new Int8Array(2048),Q,na,Cb,Bb,Db,Eb=0,Fb=0,mb,Vb=0,nb,Gb,ob,Hb=[],pb=Hb,qb=0,Ib=!1;this.init=function(){const v=new Uint16Array([32,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788,9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660]),t=new Uint16Array([8962,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,
|
|
14
14
|
402,225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745,8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160]);for(var C=0,I;256>C;C++)I=126<C?t[C-127]:32>C?v[C]:
|
|
15
15
|
C,Hb.push(String.fromCharCode(I));m.classList.add("cursor");m.style.position="absolute";m.style.backgroundColor="#ccc";m.style.width="7px";m.style.display="inline-block";this.set_mode(!1);this.set_size_text(80,25);2===u&&this.set_size_graphical(720,400,720,400);this.set_scale(q,r);this.timer()};this.make_screenshot=function(){const v=new Image;if(1===u||2===u)v.src=g.toDataURL("image/png");else{const t=[9,16],C=document.createElement("canvas");C.width=w*t[0];C.height=G*t[1];const I=C.getContext("2d");
|
|
16
16
|
I.imageSmoothingEnabled=!1;I.font=window.getComputedStyle(l).font;I.textBaseline="top";for(let O=0;O<G;O++)for(let N=0;N<w;N++){const R=4*(O*w+N),ka=F[R+0],ha=F[R+3];I.fillStyle=c(F[R+2]);I.fillRect(N*t[0],O*t[1],t[0],t[1]);I.fillStyle=c(ha);I.fillText(pb[ka],N*t[0],O*t[1])}"none"!==m.style.display&&n<G&&p<w&&(I.fillStyle=m.style.backgroundColor,I.fillRect(p*t[0],n*t[1]+parseInt(m.style.marginTop,10),parseInt(m.style.width,10),parseInt(m.style.height,10)));v.src=C.toDataURL("image/png")}return v};
|
|
17
17
|
this.put_char=function(v,t,C,I,O,N){t=4*(v*w+t);F[t+0]=C;F[t+1]=I;F[t+2]=O;F[t+3]=N;x[v]=1};this.timer=function(){qb=requestAnimationFrame(()=>this.update_screen())};this.update_screen=function(){Ib||(0===u?this.update_text():1===u?this.update_graphical():this.update_graphical_text());this.timer()};this.update_text=function(){for(var v=0;v<G;v++)x[v]&&(this.text_update_row(v),x[v]=0)};this.update_graphical=function(){this.screen_fill_buffer()};this.update_graphical_text=function(){if(P){var v=performance.now();
|
|
18
|
-
if(266<v-Vb){mb=!mb;ob&&(x[n]=1);var t=4*w;for(let ka=0,ha=0;ka<G;++ka)if(x[ka])ha+=t;else for(var C=0;C<w;++C,ha+=4)if(F[ha+1]&1){x[ka]=1;ha+=t-4*C;break}Vb=v}v=Sa.canvas;t=oa.canvas;C=4*w;const O=w*na,N=Q;let R=0;for(let ka=0,ha=0,X=0;ka<G;++ka,ha+=Q){if(!x[ka]){X+=C;continue}++R;oa.clearRect(0,N,O,Q);let
|
|
19
|
-
ha,ua-La,Q)),Ka=Xb,La=ua);
|
|
18
|
+
if(266<v-Vb){mb=!mb;ob&&(x[n]=1);var t=4*w;for(let ka=0,ha=0;ka<G;++ka)if(x[ka])ha+=t;else for(var C=0;C<w;++C,ha+=4)if(F[ha+1]&1){x[ka]=1;ha+=t-4*C;break}Vb=v}v=Sa.canvas;t=oa.canvas;C=4*w;const O=w*na,N=Q;let R=0;for(let ka=0,ha=0,X=0;ka<G;++ka,ha+=Q){if(!x[ka]){X+=C;continue}++R;oa.clearRect(0,N,O,Q);let Da,Ea,Ka,La;for(let ua=0;ua<O;ua+=na,X+=4){const Wb=F[X+0];var I=F[X+1];const Xb=F[X+2],Yb=F[X+3],Zb=I&2?Fb:Eb;I=(!(I&1)||mb)&&Ub[(Zb<<8)+Wb];Ka!==Xb&&(void 0!==Ka&&(P.fillStyle=c(Ka),P.fillRect(La,
|
|
19
|
+
ha,ua-La,Q)),Ka=Xb,La=ua);Da!==Yb&&(void 0!==Da&&(oa.fillStyle=c(Da),oa.fillRect(Ea,0,ua-Ea,Q)),Da=Yb,Ea=ua);I&&oa.drawImage(v,Wb*na,Zb*Q,na,Q,ua,N,na,Q)}oa.fillStyle=c(Da);oa.fillRect(Ea,0,O-Ea,Q);oa.globalCompositeOperation="destination-in";oa.drawImage(t,0,N,O,Q,0,0,O,Q);oa.globalCompositeOperation="source-over";P.fillStyle=c(Ka);P.fillRect(La,ha,O-La,Q);P.drawImage(t,0,0,O,Q,0,ha,O,Q)}R&&(mb&&ob&&x[n]&&(P.fillStyle=c(F[4*(n*w+p)+3]),P.fillRect(p*na,n*Q+nb,na,Gb-nb+1)),x.fill(0));R&&k.drawImage(P.canvas,
|
|
20
20
|
0,0)}};this.destroy=function(){qb&&(cancelAnimationFrame(qb),qb=0)};this.pause=function(){Ib=!0;m.classList.remove("blinking-cursor")};this.continue=function(){Ib=!1;m.classList.add("blinking-cursor")};this.set_mode=function(v){u=v?1:a.use_graphical_text?2:0;0===u?(l.style.display="block",g.style.display="none"):(l.style.display="none",g.style.display="block",2===u&&x&&x.fill(1))};this.set_font_bitmap=function(v,t,C,I,O,N){const R=C?16:t?9:8;if(Q!==v||na!==R||Cb!==t||Bb!==C||Db!==I||N)N=na!==R||Q!==
|
|
21
21
|
v,Q=v,na=R,Cb=t,Bb=C,Db=I,2===u&&(d(O),x.fill(1),N&&this.set_size_graphical_text())};this.set_font_page=function(v,t){if(Eb!==v||Fb!==t)Eb=v,Fb=t,x.fill(1)};this.clear_screen=function(){k.fillStyle="#000";k.fillRect(0,0,g.width,g.height)};this.set_size_graphical_text=function(){if(Sa){var v=na*w,t=Q*G,C=2*Q;P&&P.canvas.width===v&&P.canvas.height===t&&oa.canvas.height===C||(P?(P.canvas.width=v,P.canvas.height=t,oa.canvas.width=v,oa.canvas.height=C):(P=(new OffscreenCanvas(v,t)).getContext("2d",{alpha:!1}),
|
|
22
22
|
oa=(new OffscreenCanvas(v,C)).getContext("2d")),this.set_size_graphical(v,t,v,t),x.fill(1))}};this.set_size_text=function(v,t){if(v!==w||t!==G)if(x=new Int8Array(t),F=new Int32Array(v*t*4),w=v,G=t,0===u){for(;l.childNodes.length>t;)l.removeChild(l.firstChild);for(;l.childNodes.length<t;)l.appendChild(document.createElement("div"));for(v=0;v<t;v++)this.text_update_row(v);e(l,q,r,!0)}else 2===u&&this.set_size_graphical_text()};this.set_size_graphical=function(v,t){g.style.display="block";g.width=v;
|
|
@@ -61,8 +61,8 @@ b)};B.prototype.port_write16=function(a,b){var c=this.ports[a];c.write16===this.
|
|
|
61
61
|
a);z(a);return b};B.prototype.port_read16=function(a){var b=this.ports[a];b.read16===this.empty_port_read16&&(z(a,4),this.get_port_description(a));b=b.read16.call(b.device,a);z(a);return b};B.prototype.port_read32=function(a){var b=this.ports[a];b.read32===this.empty_port_read32&&(z(a,4),this.get_port_description(a));return b.read32.call(b.device,a)};var Ba={4:"PORT_DMA_ADDR_2",5:"PORT_DMA_CNT_2",10:"PORT_DMA1_MASK_REG",11:"PORT_DMA1_MODE_REG",12:"PORT_DMA1_CLEAR_FF_REG",13:"PORT_DMA1_MASTER_CLEAR",
|
|
62
62
|
32:"PORT_PIC1_CMD",33:"PORT_PIC1_DATA",64:"PORT_PIT_COUNTER0",65:"PORT_PIT_COUNTER1",66:"PORT_PIT_COUNTER2",67:"PORT_PIT_MODE",96:"PORT_PS2_DATA",97:"PORT_PS2_CTRLB",100:"PORT_PS2_STATUS",112:"PORT_CMOS_INDEX",113:"PORT_CMOS_DATA",128:"PORT_DIAG",129:"PORT_DMA_PAGE_2",146:"PORT_A20",160:"PORT_PIC2_CMD",161:"PORT_PIC2_DATA",178:"PORT_SMI_CMD",179:"PORT_SMI_STATUS",212:"PORT_DMA2_MASK_REG",214:"PORT_DMA2_MODE_REG",218:"PORT_DMA2_MASTER_CLEAR",240:"PORT_MATH_CLEAR",368:"PORT_ATA2_CMD_BASE",496:"PORT_ATA1_CMD_BASE",
|
|
63
63
|
632:"PORT_LPT2",744:"PORT_SERIAL4",760:"PORT_SERIAL2",884:"PORT_ATA2_CTRL_BASE",888:"PORT_LPT1",1E3:"PORT_SERIAL3",1008:"PORT_FD_BASE",1010:"PORT_FD_DOR",1012:"PORT_FD_STATUS",1013:"PORT_FD_DATA",1014:"PORT_HD_DATA",1015:"PORT_FD_DIR",1016:"PORT_SERIAL1",3320:"PORT_PCI_CMD",3321:"PORT_PCI_REBOOT",3324:"PORT_PCI_DATA",1026:"PORT_BIOS_DEBUG",1296:"PORT_QEMU_CFG_CTL",1297:"PORT_QEMU_CFG_DATA",45056:"PORT_ACPI_PM_BASE",45312:"PORT_SMB_BASE",35072:"PORT_BIOS_APM"};B.prototype.get_port_description=function(a){return Ba[a]?
|
|
64
|
-
" ("+Ba[a]+")":""};var
|
|
65
|
-
function(a,b){setTimeout(this.send.bind(this,a,b),0)};
|
|
64
|
+
" ("+Ba[a]+")":""};var Ca={};function Fa(){this.listeners={};this.pair=void 0}Fa.prototype.register=function(a,b,c){var d=this.listeners[a];void 0===d&&(d=this.listeners[a]=[]);d.push({fn:b,this_value:c})};Fa.prototype.unregister=function(a,b){var c=this.listeners[a];void 0!==c&&(this.listeners[a]=c.filter(function(d){return d.fn!==b}))};Fa.prototype.send=function(a,b){if(this.pair&&(a=this.pair.listeners[a],void 0!==a))for(var c=0;c<a.length;c++){var d=a[c];d.fn.call(d.this_value,b)}};Fa.prototype.send_async=
|
|
65
|
+
function(a,b){setTimeout(this.send.bind(this,a,b),0)};Ca.create=function(){var a=new Fa,b=new Fa;a.pair=b;b.pair=a;return[a,b]};var Ga=new Uint8Array(256),Ha=[],Ia=[],Ja=[],Ma=new Uint8Array(256),Na=[];function D(a,b){this.cpu=a;this.bus=b;this.write_buffer=new ja(64);this.read_buffer=new ja(64);this.mixer_current_address=this.command_size=this.command=this.read_buffer_lastvalue=0;this.mixer_registers=new Uint8Array(256);this.mixer_reset();this.dummy_speaker_enabled=!1;this.test_register=0;this.dsp_signed=
|
|
66
66
|
this.dsp_16bit=this.dsp_stereo=this.dsp_highspeed=!1;this.dac_buffers=[new la(65536),new la(65536)];this.dma=a.devices.dma;this.dma_channel=this.dma_irq=this.dma_bytes_block=this.dma_bytes_left=this.dma_bytes_count=this.dma_sample_count=0;this.dma_channel_8bit=1;this.dma_channel_16bit=5;this.dma_autoinit=!1;this.dma_buffer=new ArrayBuffer(65536);this.dma_buffer_int8=new Int8Array(this.dma_buffer);this.dma_buffer_uint8=new Uint8Array(this.dma_buffer);this.dma_buffer_int16=new Int16Array(this.dma_buffer);
|
|
67
67
|
this.dma_buffer_uint16=new Uint16Array(this.dma_buffer);this.dma_syncbuffer=new va(this.dma_buffer);this.dma_paused=this.dma_waiting_transfer=!1;this.sampling_rate=22050;b.send("dac-tell-sampling-rate",this.sampling_rate);this.bytes_per_sample=1;this.e2_value=170;this.e2_count=0;this.asp_registers=new Uint8Array(256);this.mpu_read_buffer=new ja(64);this.fm_current_address1=this.fm_current_address0=this.mpu_read_buffer_lastvalue=0;this.fm_waveform_select_enable=!1;this.irq=5;this.irq_triggered=new Uint8Array(16);
|
|
68
68
|
a.io.register_read_consecutive(544,this,this.port2x0_read,this.port2x1_read,this.port2x2_read,this.port2x3_read);a.io.register_read_consecutive(904,this,this.port2x0_read,this.port2x1_read);a.io.register_read_consecutive(548,this,this.port2x4_read,this.port2x5_read);a.io.register_read(550,this,this.port2x6_read);a.io.register_read(551,this,this.port2x7_read);a.io.register_read(552,this,this.port2x8_read);a.io.register_read(553,this,this.port2x9_read);a.io.register_read(554,this,this.port2xA_read);
|
|
@@ -187,97 +187,99 @@ this.net.receive(J(this.net.eth_encoder_buf,b)),this.emit("data",a.tcp_data));th
|
|
|
187
187
|
else{this.release();return}this.send_buffer.length||this.pending?(this.delayed_send_fin=!0,this.delayed_state=a):(this.state=a,a=this.ipv4_reply(),a.tcp.fin=!0,this.net.receive(J(this.net.eth_encoder_buf,a)))}this.pump()};Rb.prototype.on_shutdown=function(){this.emit("shutdown")};Rb.prototype.on_close=function(){this.emit("close")};Rb.prototype.release=function(){this.net.tcp_conn[this.tuple]&&(this.state="closed",delete this.net.tcp_conn[this.tuple])};Rb.prototype.pump=function(){if(this.send_buffer.length&&
|
|
188
188
|
!this.pending){const a=this.send_chunk_buf,b=this.send_buffer.peek(a),c=this.ipv4_reply();c.tcp.psh=!0;c.tcp_data=a.subarray(0,b);this.net.receive(J(this.net.eth_encoder_buf,c));this.pending=!0}};function Tb(a,b){b=b||{};this.bus=a;this.id=b.id||0;this.router_mac=new Uint8Array((b.router_mac||"52:54:0:1:2:3").split(":").map(function(c){return parseInt(c,16)}));this.router_ip=new Uint8Array((b.router_ip||"192.168.86.1").split(".").map(function(c){return parseInt(c,10)}));this.vm_ip=new Uint8Array((b.vm_ip||
|
|
189
189
|
"192.168.86.100").split(".").map(function(c){return parseInt(c,10)}));this.masquerade=void 0===b.masquerade||!!b.masquerade;this.vm_mac=new Uint8Array(6);this.dns_method=b.dns_method||"static";this.doh_server=b.doh_server;this.tcp_conn={};this.eth_encoder_buf=Jb();this.fetch=(...c)=>fetch(...c);this.cors_proxy=b.cors_proxy;this.bus.register("net"+this.id+"-mac",function(c){this.vm_mac=new Uint8Array(c.split(":").map(function(d){return parseInt(d,16)}))},this);this.bus.register("net"+this.id+"-send",
|
|
190
|
-
function(c){this.send(c)},this)}Tb.prototype.destroy=function(){};Tb.prototype.on_tcp_connection=function(a,b){if(80===a.tcp.dport){let c=new Rb;c.state="syn-received";c.net=this;c.on("data",$b);c.tuple=b;c.accept(a);this.tcp_conn[b]=c;return!0}return!1};Tb.prototype.connect=function(a){return Qb(a,this)};Tb.prototype.tcp_probe=function(a){return Sb(a,this)};async function $b(a){this.read=this.read||"";if((this.read+=(new TextDecoder).decode(a))&&-1!==this.read.indexOf("\r\n\r\n")){
|
|
191
|
-
|
|
192
|
-
return}"host"===
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
a
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
(
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
b){
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
await this.
|
|
246
|
-
b.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
function(a){
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
this.
|
|
256
|
-
function(a){
|
|
257
|
-
|
|
258
|
-
a)
|
|
259
|
-
M.prototype.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
b
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
190
|
+
function(c){this.send(c)},this)}Tb.prototype.destroy=function(){};Tb.prototype.on_tcp_connection=function(a,b){if(80===a.tcp.dport){let c=new Rb;c.state="syn-received";c.net=this;c.on("data",$b);c.tuple=b;c.accept(a);this.tcp_conn[b]=c;return!0}return!1};Tb.prototype.connect=function(a){return Qb(a,this)};Tb.prototype.tcp_probe=function(a){return Sb(a,this)};async function $b(a){this.read=this.read||"";if((this.read+=(new TextDecoder).decode(a))&&-1!==this.read.indexOf("\r\n\r\n")){a=this.read.indexOf("\r\n\r\n");
|
|
191
|
+
var b=this.read.substring(0,a).split(/\r\n/);a=this.read.substring(a+4);this.read="";let c=b[0].split(" "),d;d=/^https?:/.test(c[1])?new URL(c[1]):new URL("http://host"+c[1]);"undefined"!==typeof window&&"http:"===d.protocol&&"https:"===window.location.protocol&&(d.protocol="https:");let e=new Headers;for(let k=1;k<b.length;++k){const l=this.net.parse_http_header(b[k]);if(!l){console.warn('The request contains an invalid header: "%s"',b[k]);this.net.respond_text_and_close(this,400,"Bad Request",`Invalid header in request: ${b[k]}`);
|
|
192
|
+
return}"host"===l.key.toLowerCase()?d.host=l.value:e.append(l.key,l.value)}if(!this.net.cors_proxy&&/^\d+\.external$/.test(d.hostname))if(b=parseInt(d.hostname.split(".")[0],10),!isNaN(b)&&0<b&&65536>b)d.protocol="http:",d.hostname="localhost",d.port=b.toString(10);else{console.warn('Unknown port for localhost: "%s"',d.href);this.net.respond_text_and_close(this,400,"Bad Request",`Unknown port for localhost: ${d.href}`);return}this.name=d.href;b={method:c[0],headers:e};-1!==["put","post"].indexOf(b.method.toLowerCase())&&
|
|
193
|
+
(b.body=a);const f=this.net.cors_proxy?this.net.cors_proxy+encodeURIComponent(d.href):d.href;new TextEncoder;let g=!1;this.net.fetch(f,b).then(k=>{let l=new Headers(k.headers);l.delete("content-encoding");l.delete("keep-alive");l.delete("content-length");l.delete("transfer-encoding");l.set("x-was-fetch-redirected",`${!!k.redirected}`);l.set("x-fetch-resp-url",k.url);l.set("connection","close");this.write(this.net.form_response_head(k.status,k.statusText,l));g=!0;if(k.body&&k.body.getReader){const m=
|
|
194
|
+
k.body.getReader(),n=({value:p,done:q})=>{p&&this.write(p);if(q)this.close();else return m.read().then(n)};m.read().then(n)}else k.arrayBuffer().then(m=>{this.write(new Uint8Array(m));this.close()})}).catch(k=>{console.warn("Fetch Failed: "+f+"\n"+k);g||this.net.respond_text_and_close(this,502,"Fetch Error",`Fetch ${f} failed:\n\n${k.stack||k.message}`);this.close()})}}Tb.prototype.fetch=async function(a,b){this.cors_proxy&&(a=this.cors_proxy+encodeURIComponent(a));try{const c=await fetch(a,b),d=
|
|
195
|
+
await c.arrayBuffer();return[c,d]}catch(c){return console.warn("Fetch Failed: "+a+"\n"+c),[{status:502,statusText:"Fetch Error",headers:new Headers({"Content-Type":"text/plain"})},(new TextEncoder).encode(`Fetch ${a} failed:\n\n${c.stack}`).buffer]}};Tb.prototype.form_response_head=function(a,b,c){a=[`HTTP/1.1 ${a} ${b}`];for(const [d,e]of c.entries())a.push(`${d}: ${e}`);return(new TextEncoder).encode(a.join("\r\n")+"\r\n\r\n")};Tb.prototype.respond_text_and_close=function(a,b,c,d){const e=new Headers({"content-type":"text/plain",
|
|
196
|
+
"content-length":d.length.toString(10),connection:"close"});a.writev([this.form_response_head(b,c,e),(new TextEncoder).encode(d)]);a.close()};Tb.prototype.parse_http_header=function(a){var b=a.match(/^([^:]*):(.*)$/);if(b&&(a=b[1],b=b[2].trim(),0!==a.length&&0!==b.length&&/^[\w-]+$/.test(a)&&/^[\x20-\x7E]+$/.test(b)))return{key:a,value:b}};Tb.prototype.send=function(a){Ob(a,this)};Tb.prototype.receive=function(a){this.bus.send("net"+this.id+"-receive",new Uint8Array(a))};function ac(a,b,c){this.register_ws(a);
|
|
197
|
+
this.last_stream=1;this.connections={0:{congestion:0}};this.congested_buffer=[];c=c||{};this.bus=b;this.id=c.id||0;this.router_mac=new Uint8Array((c.router_mac||"52:54:0:1:2:3").split(":").map(function(d){return parseInt(d,16)}));this.router_ip=new Uint8Array((c.router_ip||"192.168.86.1").split(".").map(function(d){return parseInt(d,10)}));this.vm_ip=new Uint8Array((c.vm_ip||"192.168.86.100").split(".").map(function(d){return parseInt(d,10)}));this.masquerade=void 0===c.masquerade||!!c.masquerade;
|
|
198
|
+
this.vm_mac=new Uint8Array(6);this.dns_method=c.dns_method||"doh";this.doh_server=c.doh_server;this.tcp_conn={};this.eth_encoder_buf=Jb();this.bus.register("net"+this.id+"-mac",function(d){this.vm_mac=new Uint8Array(d.split(":").map(function(e){return parseInt(e,16)}))},this);this.bus.register("net"+this.id+"-send",function(d){this.send(d)},this)}ac.prototype.register_ws=function(a){this.wispws=new WebSocket(a.replace("wisp://","ws://").replace("wisps://","wss://"));this.wispws.binaryType="arraybuffer";
|
|
199
|
+
this.wispws.onmessage=b=>{this.process_incoming_wisp_frame(new Uint8Array(b.data))};this.wispws.onclose=()=>{setTimeout(()=>{this.register_ws(a)},1E4)}};ac.prototype.send_packet=function(a,b,c){this.connections[c]&&(0<this.connections[c].congestion?("DATA"===b&&this.connections[c].congestion--,this.wispws.send(a)):(this.connections[c].congested=!0,this.congested_buffer.push({data:a,type:b})))};ac.prototype.process_incoming_wisp_frame=function(a){const b=new DataView(a.buffer),c=b.getUint32(1,!0);
|
|
200
|
+
switch(a[0]){case 2:if(this.connections[c])this.connections[c].data_callback(a.slice(5));else throw Error("Got a DATA packet but stream not registered. ID: "+c);break;case 3:this.connections[c]&&(this.connections[c].congestion=b.getUint32(5,!0));if(this.connections[c].congested){for(const d of this.congested_buffer)this.send_packet(d.data,d.type,c);this.connections[c].congested=!1}break;case 4:this.connections[c]&&this.connections[c].close_callback(b.getUint8(5)),delete this.connections[c]}};ac.prototype.send_wisp_frame=
|
|
201
|
+
function(a){let b,c;switch(a.type){case "CONNECT":const d=(new TextEncoder).encode(a.hostname);b=new Uint8Array(8+d.length);c=new DataView(b.buffer);c.setUint8(0,1);c.setUint32(1,a.stream_id,!0);c.setUint8(5,1);c.setUint16(6,a.port,!0);b.set(d,8);this.connections[a.stream_id]={data_callback:a.data_callback,close_callback:a.close_callback,congestion:this.connections[0].congestion};break;case "DATA":b=new Uint8Array(5+a.data.length);c=new DataView(b.buffer);c.setUint8(0,2);c.setUint32(1,a.stream_id,
|
|
202
|
+
!0);b.set(a.data,5);break;case "CLOSE":b=new Uint8Array(6),c=new DataView(b.buffer),c.setUint8(0,4),c.setUint32(1,a.stream_id,!0),c.setUint8(5,a.reason)}this.send_packet(b,a.type,a.stream_id)};ac.prototype.destroy=function(){this.wispws&&(this.wispws.onmessage=null,this.wispws.onclose=null,this.wispws.close(),this.wispws=null)};ac.prototype.on_tcp_connection=function(a,b){let c=new Rb;c.state="syn-received";c.net=this;c.tuple=b;c.stream_id=this.last_stream++;this.tcp_conn[b]=c;c.on("data",d=>{0!==
|
|
203
|
+
d.length&&this.send_wisp_frame({type:"DATA",stream_id:c.stream_id,data:d})});c.on_close=()=>{this.send_wisp_frame({type:"CLOSE",stream_id:c.stream_id,reason:2})};c.on_shutdown=c.on_close;this.send_wisp_frame({type:"CONNECT",stream_id:c.stream_id,hostname:a.ipv4.dest.join("."),port:a.tcp.dport,data_callback:d=>{c.write(d)},close_callback:()=>{c.close()}});c.accept(a);return!0};ac.prototype.send=function(a){Ob(a,this)};ac.prototype.receive=function(a){this.bus.send("net"+this.id+"-receive",new Uint8Array(a))};
|
|
204
|
+
const bc="undefined"!==typeof window&&0<=window.navigator.platform.toString().toLowerCase().search("win");function cc(a){function b(w){return w.shiftKey&&w.ctrlKey&&(73===w.keyCode||74===w.keyCode||75===w.keyCode)||!r.emu_enabled?!1:w.target?w.target.classList.contains("phone_keyboard")||"INPUT"!==w.target.nodeName&&"TEXTAREA"!==w.target.nodeName:!0}function c(w){!w.altKey&&m[56]&&k(56,!1);return f(w,!1)}function d(w){!w.altKey&&m[56]&&k(56,!1);return f(w,!0)}function e(){for(var w=Object.keys(m),
|
|
205
|
+
G,P=0;P<w.length;P++)G=+w[P],m[G]&&k(G,!1);m={}}function f(w,G){if(r.bus&&b(w)){w.preventDefault&&w.preventDefault();if(bc&&(n&&(clearTimeout(q),w.getModifierState&&w.getModifierState("AltGraph")&&p===G&&"ControlLeft"===n.code&&"AltRight"===w.code||g(n,p),n=null),"ControlLeft"===w.code))return n=w,p=G,q=setTimeout(()=>{g(n,p);n=null},10),!1;g(w,G);return!1}}function g(w,G){a:{if(void 0!==w.code){var P=F[w.code];if(void 0!==P)break a}P=y[w.keyCode]}P?k(P,G,w.repeat):console.log("Missing char in map: keyCode="+
|
|
206
|
+
(w.keyCode||-1).toString(16)+" code="+w.code)}function k(w,G,P){if(G)m[w]&&!P&&k(w,!1);else if(!m[w])return;(m[w]=G)||(w|=128);255<w?(l(w>>8),l(w&255)):l(w)}function l(w){r.bus.send("keyboard-code",w)}var m={},n=null,p=!1,q=0,r=this;this.emu_enabled=!0;const y=new Uint16Array([0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,0,58,0,0,0,0,0,0,1,0,0,0,0,57,57417,57425,57423,57415,57419,57416,57421,80,0,0,0,0,82,83,0,11,2,3,4,5,6,7,8,9,10,0,39,0,13,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,
|
|
207
|
+
19,31,20,22,47,17,45,21,44,57435,57436,57437,0,0,82,79,80,81,75,76,77,71,72,73,0,0,0,0,0,0,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,43,27,40,0,57435,57400,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),x={8:8,10:13,32:32,39:222,44:188,45:189,46:190,47:191,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,59:186,
|
|
208
|
+
61:187,91:219,92:220,93:221,96:192,97:65,98:66,99:67,100:68,101:69,102:70,103:71,104:72,105:73,106:74,107:75,108:76,109:77,110:78,111:79,112:80,113:81,114:82,115:83,116:84,117:85,118:86,119:87,120:88,121:89,122:90},u={33:49,34:222,35:51,36:52,37:53,38:55,40:57,41:48,42:56,43:187,58:186,60:188,62:190,63:191,64:50,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,94:54,95:189,123:219,124:220,125:221,
|
|
209
|
+
126:192};var F={Escape:1,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,
|
|
210
|
+
IntlRo:53,ShiftRight:54,NumpadMultiply:55,AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,NumLock:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,Numpad0:82,NumpadDecimal:83,IntlBackslash:86,F11:87,F12:88,NumpadEnter:57372,ControlRight:57373,NumpadDivide:57397,AltRight:57400,Home:57415,ArrowUp:57416,PageUp:57417,ArrowLeft:57419,ArrowRight:57421,End:57423,
|
|
211
|
+
ArrowDown:57424,PageDown:57425,Insert:57426,Delete:57427,OSLeft:57435,OSRight:57436,ContextMenu:57437};this.bus=a;this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("keyup",c,!1),window.removeEventListener("keydown",d,!1),window.removeEventListener("blur",e,!1))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("keyup",c,!1),window.addEventListener("keydown",d,!1),window.addEventListener("blur",e,!1))};this.init();this.simulate_press=
|
|
212
|
+
function(w){w={keyCode:w};f(w,!0);f(w,!1)};this.simulate_char=function(w){var G=w.charCodeAt(0);G in x?this.simulate_press(x[G]):G in u?(l(42),this.simulate_press(u[G]),l(170)):console.log("ascii -> keyCode not found: ",G,w)}}function dc(a,b){function c(u){if(!x.enabled||!x.emu_enabled)return!1;var F=b||document.body,w;if(!(w=document.pointerLockElement))a:{for(u=u.target;u.parentNode;){if(u===F){w=!0;break a}u=u.parentNode}w=!1}return w}function d(u){c(u)&&(u=u.changedTouches)&&u.length&&(u=u[u.length-
|
|
213
|
+
1],r=u.clientX,y=u.clientY)}function e(){if(n||q||p)x.bus.send("mouse-click",[!1,!1,!1]),n=q=p=!1}function f(u){if(x.bus&&c(u)&&x.is_running){var F=0,w=0,G=u.changedTouches;G?G.length&&(G=G[G.length-1],F=G.clientX-r,w=G.clientY-y,r=G.clientX,y=G.clientY,u.preventDefault()):"number"===typeof u.movementX?(F=u.movementX,w=u.movementY):"number"===typeof u.webkitMovementX?(F=u.webkitMovementX,w=u.webkitMovementY):"number"===typeof u.mozMovementX?(F=u.mozMovementX,w=u.mozMovementY):(F=u.clientX-r,w=u.clientY-
|
|
214
|
+
y,r=u.clientX,y=u.clientY);x.bus.send("mouse-delta",[.15*F,-(.15*w)]);b&&x.bus.send("mouse-absolute",[u.pageX-b.offsetLeft,u.pageY-b.offsetTop,b.offsetWidth,b.offsetHeight])}}function g(u){c(u)&&l(u,!0)}function k(u){c(u)&&l(u,!1)}function l(u,F){x.bus&&(1===u.which?n=F:2===u.which?q=F:3===u.which&&(p=F),x.bus.send("mouse-click",[n,q,p]),u.preventDefault())}function m(u){if(c(u)){var F=u.wheelDelta||-u.detail;0>F?F=-1:0<F&&(F=1);x.bus.send("mouse-wheel",[F,0]);u.preventDefault()}}var n=!1,p=!1,q=
|
|
215
|
+
!1,r=0,y=0,x=this;this.enabled=!1;this.emu_enabled=!0;this.bus=a;this.bus.register("mouse-enable",function(u){this.enabled=u},this);this.is_running=!1;this.bus.register("emulator-stopped",function(){this.is_running=!1},this);this.bus.register("emulator-started",function(){this.is_running=!0},this);this.destroy=function(){"undefined"!==typeof window&&(window.removeEventListener("touchstart",d,!1),window.removeEventListener("touchend",e,!1),window.removeEventListener("touchmove",f,!1),window.removeEventListener("mousemove",
|
|
216
|
+
f,!1),window.removeEventListener("mousedown",g,!1),window.removeEventListener("mouseup",k,!1),window.removeEventListener("wheel",m,{passive:!1}))};this.init=function(){"undefined"!==typeof window&&(this.destroy(),window.addEventListener("touchstart",d,!1),window.addEventListener("touchend",e,!1),window.addEventListener("touchmove",f,!1),window.addEventListener("mousemove",f,!1),window.addEventListener("mousedown",g,!1),window.addEventListener("mouseup",k,!1),window.addEventListener("wheel",m,{passive:!1}))};
|
|
217
|
+
this.init()}function ec(){var a,b=0,c=0;this.put_char=function(d,e,f){a[d*b+e]=f};this.destroy=function(){};this.pause=function(){};this.continue=function(){};this.set_mode=function(){};this.set_font_bitmap=function(){};this.set_font_page=function(){};this.clear_screen=function(){};this.set_size_text=function(d,e){if(d!==b||e!==c)a=new Uint8Array(d*e),b=d,c=e};this.set_size_graphical=function(){};this.set_scale=function(){};this.update_cursor_scanline=function(){};this.update_cursor=function(){};
|
|
218
|
+
this.update_buffer=function(){};this.get_text_screen=function(){for(var d=[],e=0;e<c;e++)d.push(this.get_text_row(e));return d};this.get_text_row=function(d){d*=b;return String.fromCharCode.apply(String,a.subarray(d,d+b))};this.set_size_text(80,25)}function fc(a,b){function c(k){g.bus&&g.enabled&&(g.send_char(k.which),k.preventDefault())}function d(k){var l=k.which;8===l?(g.send_char(127),k.preventDefault()):9===l&&(g.send_char(9),k.preventDefault())}function e(k){if(g.enabled){for(var l=k.clipboardData.getData("text/plain"),
|
|
219
|
+
m=0;m<l.length;m++)g.send_char(l.charCodeAt(m));k.preventDefault()}}function f(k){k.target!==a&&a.blur()}var g=this;this.enabled=!0;this.bus=b;this.text="";this.text_new_line=!1;this.last_update=0;this.bus.register("serial0-output-byte",function(k){k=String.fromCharCode(k);this.show_char(k)},this);this.destroy=function(){a.removeEventListener("keypress",c,!1);a.removeEventListener("keydown",d,!1);a.removeEventListener("paste",e,!1);window.removeEventListener("mousedown",f,!1)};this.init=function(){this.destroy();
|
|
220
|
+
a.style.display="block";a.addEventListener("keypress",c,!1);a.addEventListener("keydown",d,!1);a.addEventListener("paste",e,!1);window.addEventListener("mousedown",f,!1)};this.init();this.show_char=function(k){"\b"===k?(this.text=this.text.slice(0,-1),this.update()):"\r"!==k&&(this.text+=k,"\n"===k&&(this.text_new_line=!0),this.update())};this.update=function(){var k=Date.now(),l=k-this.last_update;16>l?void 0===this.update_timer&&(this.update_timer=setTimeout(()=>{this.update_timer=void 0;this.last_update=
|
|
221
|
+
Date.now();this.render()},16-l)):(void 0!==this.update_timer&&(clearTimeout(this.update_timer),this.update_timer=void 0),this.last_update=k,this.render())};this.render=function(){a.value=this.text;this.text_new_line&&(this.text_new_line=!1,a.scrollTop=1E9)};this.send_char=function(k){g.bus&&g.bus.send("serial0-input",k)}}function gc(a,b){this.element=a;if(window.Terminal){var c=this.term=new window.Terminal({logLevel:"off"});c.write("This is the serial console. Whatever you type or paste here will be sent to COM1");
|
|
222
|
+
var d=c.onData(function(e){for(let f=0;f<e.length;f++)b.send("serial0-input",e.charCodeAt(f))});b.register("serial0-output-byte",function(e){c.write(Uint8Array.of(e))},this);this.destroy=function(){d.dispose();c.dispose()}}}gc.prototype.show=function(){this.term&&this.term.open(this.element)};function hc(a,b){b=b.id||0;this.bus=a;this.bus_send_msgid=`net${b}-send`;this.bus_recv_msgid=`net${b}-receive`;this.channel=new BroadcastChannel(`v86-inbrowser-${b}`);this.is_open=!0;this.nic_to_hub_fn=c=>{this.channel.postMessage(c)};
|
|
223
|
+
this.bus.register(this.bus_send_msgid,this.nic_to_hub_fn,this);this.hub_to_nic_fn=c=>{this.bus.send(this.bus_recv_msgid,c.data)};this.channel.addEventListener("message",this.hub_to_nic_fn)}hc.prototype.destroy=function(){this.is_open&&(this.bus.unregister(this.bus_send_msgid,this.nic_to_hub_fn),this.channel.removeEventListener("message",this.hub_to_nic_fn),this.channel.close(),this.is_open=!1)};function ic(){this.filedata=new Map}ic.prototype.read=async function(a,b,c){return(a=this.filedata.get(a))?
|
|
224
|
+
a.subarray(b,b+c):null};ic.prototype.cache=async function(a,b){this.filedata.set(a,b)};ic.prototype.uncache=function(a){this.filedata.delete(a)};function jc(a,b){b.endsWith("/")||(b+="/");this.storage=a;this.baseurl=b}jc.prototype.load_from_server=function(a){return new Promise(b=>{pa(this.baseurl+a,{done:async c=>{c=new Uint8Array(c);await this.cache(a,c);b(c)}})})};jc.prototype.read=async function(a,b,c){const d=await this.storage.read(a,b,c);return d?d:(await this.load_from_server(a)).subarray(b,
|
|
225
|
+
b+c)};jc.prototype.cache=async function(a,b){return await this.storage.cache(a,b)};jc.prototype.uncache=function(a){this.storage.uncache(a)};const kc=new TextDecoder,lc=new TextEncoder;function K(a,b,c,d){for(var e,f=0,g=0;g<a.length;g++)switch(e=b[g],a[g]){case "w":c[d++]=e&255;c[d++]=e>>8&255;c[d++]=e>>16&255;c[d++]=e>>24&255;f+=4;break;case "d":c[d++]=e&255;c[d++]=e>>8&255;c[d++]=e>>16&255;c[d++]=e>>24&255;c[d++]=0;c[d++]=0;c[d++]=0;c[d++]=0;f+=8;break;case "h":c[d++]=e&255;c[d++]=e>>8;f+=2;break;
|
|
226
|
+
case "b":c[d++]=e;f+=1;break;case "s":var k=d,l=0;c[d++]=0;c[d++]=0;f+=2;e=lc.encode(e);f+=e.byteLength;l+=e.byteLength;c.set(e,d);d+=e.byteLength;c[k+0]=l&255;c[k+1]=l>>8&255;break;case "Q":K(["b","w","d"],[e.type,e.version,e.path],c,d),d+=13,f+=13}return f}function L(a,b,c){let d=c.offset;for(var e=[],f=0;f<a.length;f++)switch(a[f]){case "w":var g=b[d++];g+=b[d++]<<8;g+=b[d++]<<16;g+=b[d++]<<24>>>0;e.push(g);break;case "d":g=b[d++];g+=b[d++]<<8;g+=b[d++]<<16;g+=b[d++]<<24>>>0;d+=4;e.push(g);break;
|
|
227
|
+
case "h":g=b[d++];e.push(g+(b[d++]<<8));break;case "b":e.push(b[d++]);break;case "s":g=b[d++];g+=b[d++]<<8;var k=b.slice(d,d+g);d+=g;e.push(kc.decode(k));break;case "Q":c.offset=d,g=L(["b","w","d"],b,c),d=c.offset,e.push({type:g[0],version:g[1],path:g[2]})}c.offset=d;return e}const mc=new TextEncoder;function M(a,b){this.inodes=[];this.events=[];this.storage=a;this.qidcounter=b||{last_qidnumber:0};this.inodedata={};this.total_size=274877906944;this.used_size=0;this.mounts=[];this.CreateDirectory("",
|
|
228
|
+
-1)}M.prototype.get_state=function(){let a=[];a[0]=this.inodes;a[1]=this.qidcounter.last_qidnumber;a[2]=[];for(const [b,c]of Object.entries(this.inodedata))0===(this.inodes[b].mode&16384)&&a[2].push([b,c]);a[3]=this.total_size;a[4]=this.used_size;return a=a.concat(this.mounts)};M.prototype.set_state=function(a){this.inodes=a[0].map(b=>{const c=new nc(0);c.set_state(b);return c});this.qidcounter.last_qidnumber=a[1];this.inodedata={};for(let [b,c]of a[2])c.buffer.byteLength!==c.byteLength&&(c=c.slice()),
|
|
229
|
+
this.inodedata[b]=c;this.total_size=a[3];this.used_size=a[4];this.mounts=a.slice(5)};M.prototype.AddEvent=function(a,b){var c=this.inodes[a];0===c.status||2===c.status?b():this.is_forwarder(c)?this.follow_fs(c).AddEvent(c.foreign_id,b):this.events.push({id:a,OnEvent:b})};M.prototype.HandleEvent=function(a){var b=this.inodes[a];this.is_forwarder(b)&&this.follow_fs(b).HandleEvent(b.foreign_id);b=[];for(var c=0;c<this.events.length;c++)this.events[c].id===a?this.events[c].OnEvent():b.push(this.events[c]);
|
|
230
|
+
this.events=b};M.prototype.load_from_json=function(a){if(3!==a.version)throw"The filesystem JSON format has changed. Please update your fs2json (https://github.com/copy/fs2json) and recreate the filesystem JSON.";var b=a.fsroot;this.used_size=a.size;for(a=0;a<b.length;a++)this.LoadRecursive(b[a],0)};M.prototype.LoadRecursive=function(a,b){var c=this.CreateInode();const d=a[0];c.size=a[1];c.mtime=a[2];c.ctime=c.mtime;c.atime=c.mtime;c.mode=a[3];c.uid=a[4];c.gid=a[5];var e=c.mode&61440;16384===e?(this.PushInode(c,
|
|
231
|
+
b,d),this.LoadDir(this.inodes.length-1,a[6])):32768===e?(c.status=2,c.sha256sum=a[6],this.PushInode(c,b,d)):40960===e?(c.symlink=a[6],this.PushInode(c,b,d)):49152!==e&&z(e)};M.prototype.LoadDir=function(a,b){for(var c=0;c<b.length;c++)this.LoadRecursive(b[c],a)};M.prototype.should_be_linked=function(a){return!this.is_forwarder(a)||0===a.foreign_id};M.prototype.link_under_dir=function(a,b,c){const d=this.inodes[b],e=this.inodes[a];this.is_forwarder(e);this.IsDirectory(a);this.should_be_linked(d);e.direntries.has(c);
|
|
232
|
+
e.direntries.set(c,b);d.nlinks++;this.IsDirectory(b)&&(d.direntries.has(".."),d.direntries.has(".")||d.nlinks++,d.direntries.set(".",b),d.direntries.set("..",a),e.nlinks++)};M.prototype.unlink_from_dir=function(a,b){const c=this.Search(a,b),d=this.inodes[c],e=this.inodes[a];this.is_forwarder(e);this.IsDirectory(a);e.direntries.delete(b)&&(d.nlinks--,this.IsDirectory(c)&&(d.direntries.get(".."),d.direntries.delete(".."),e.nlinks--))};M.prototype.PushInode=function(a,b,c){-1!==b?(this.inodes.push(a),
|
|
233
|
+
a.fid=this.inodes.length-1,this.link_under_dir(b,a.fid,c)):0===this.inodes.length&&(this.inodes.push(a),a.direntries.set(".",0),a.direntries.set("..",0),a.nlinks=2)};function nc(a){this.direntries=new Map;this.minor=this.major=this.mtime=this.atime=this.ctime=this.fid=this.gid=this.uid=this.size=this.status=0;this.symlink="";this.mode=493;this.qid={type:0,version:0,path:a};this.caps=void 0;this.nlinks=0;this.sha256sum="";this.locks=[];this.foreign_id=this.mount_id=-1}nc.prototype.get_state=function(){const a=
|
|
234
|
+
[];a[0]=this.mode;a[1]=16384===(this.mode&61440)?[...this.direntries]:32768===(this.mode&61440)?this.sha256sum:40960===(this.mode&61440)?this.symlink:49152===(this.mode&61440)?[this.minor,this.major]:null;a[2]=this.locks;a[3]=this.status;a[4]=this.size;a[5]=this.uid;a[6]=this.gid;a[7]=this.fid;a[8]=this.ctime;a[9]=this.atime;a[10]=this.mtime;a[11]=this.qid.version;a[12]=this.qid.path;a[13]=this.nlinks;return a};nc.prototype.set_state=function(a){this.mode=a[0];if(16384===(this.mode&61440)){this.direntries=
|
|
235
|
+
new Map;for(const [b,c]of a[1])this.direntries.set(b,c)}else 32768===(this.mode&61440)?this.sha256sum=a[1]:40960===(this.mode&61440)?this.symlink=a[1]:49152===(this.mode&61440)&&([this.minor,this.major]=a[1]);this.locks=[];for(const b of a[2]){const c=new oc;c.set_state(b);this.locks.push(c)}this.status=a[3];this.size=a[4];this.uid=a[5];this.gid=a[6];this.fid=a[7];this.ctime=a[8];this.atime=a[9];this.mtime=a[10];this.qid.type=(this.mode&61440)>>8;this.qid.version=a[11];this.qid.path=a[12];this.nlinks=
|
|
236
|
+
a[13]};M.prototype.divert=function(a,b){const c=this.Search(a,b),d=this.inodes[c],e=new nc(-1);this.IsDirectory(c);Object.assign(e,d);const f=this.inodes.length;this.inodes.push(e);e.fid=f;this.is_forwarder(d)&&this.mounts[d.mount_id].backtrack.set(d.foreign_id,f);this.should_be_linked(d)&&(this.unlink_from_dir(a,b),this.link_under_dir(a,f,b));if(this.IsDirectory(c)&&!this.is_forwarder(d))for(const [g,k]of e.direntries)"."!==g&&".."!==g&&this.IsDirectory(k)&&this.inodes[k].direntries.set("..",f);
|
|
237
|
+
this.inodedata[f]=this.inodedata[c];delete this.inodedata[c];d.direntries=new Map;d.nlinks=0;return f};M.prototype.copy_inode=function(a,b){Object.assign(b,a,{fid:b.fid,direntries:b.direntries,nlinks:b.nlinks})};M.prototype.CreateInode=function(){const a=Math.round(Date.now()/1E3),b=new nc(++this.qidcounter.last_qidnumber);b.atime=b.ctime=b.mtime=a;return b};M.prototype.CreateDirectory=function(a,b){var c=this.inodes[b];if(0<=b&&this.is_forwarder(c))return b=c.foreign_id,a=this.follow_fs(c).CreateDirectory(a,
|
|
238
|
+
b),this.create_forwarder(c.mount_id,a);c=this.CreateInode();c.mode=16895;0<=b&&(c.uid=this.inodes[b].uid,c.gid=this.inodes[b].gid,c.mode=this.inodes[b].mode&511|16384);c.qid.type=64;this.PushInode(c,b,a);this.NotifyListeners(this.inodes.length-1,"newdir");return this.inodes.length-1};M.prototype.CreateFile=function(a,b){var c=this.inodes[b];if(this.is_forwarder(c))return b=c.foreign_id,a=this.follow_fs(c).CreateFile(a,b),this.create_forwarder(c.mount_id,a);c=this.CreateInode();c.uid=this.inodes[b].uid;
|
|
239
|
+
c.gid=this.inodes[b].gid;c.qid.type=128;c.mode=this.inodes[b].mode&438|32768;this.PushInode(c,b,a);this.NotifyListeners(this.inodes.length-1,"newfile");return this.inodes.length-1};M.prototype.CreateNode=function(a,b,c,d){var e=this.inodes[b];if(this.is_forwarder(e))return b=e.foreign_id,a=this.follow_fs(e).CreateNode(a,b,c,d),this.create_forwarder(e.mount_id,a);e=this.CreateInode();e.major=c;e.minor=d;e.uid=this.inodes[b].uid;e.gid=this.inodes[b].gid;e.qid.type=192;e.mode=this.inodes[b].mode&438;
|
|
240
|
+
this.PushInode(e,b,a);return this.inodes.length-1};M.prototype.CreateSymlink=function(a,b,c){var d=this.inodes[b];if(this.is_forwarder(d))return b=d.foreign_id,a=this.follow_fs(d).CreateSymlink(a,b,c),this.create_forwarder(d.mount_id,a);d=this.CreateInode();d.uid=this.inodes[b].uid;d.gid=this.inodes[b].gid;d.qid.type=160;d.symlink=c;d.mode=40960;this.PushInode(d,b,a);return this.inodes.length-1};M.prototype.CreateTextFile=async function(a,b,c){var d=this.inodes[b];if(this.is_forwarder(d))return b=
|
|
241
|
+
d.foreign_id,c=await this.follow_fs(d).CreateTextFile(a,b,c),this.create_forwarder(d.mount_id,c);d=this.CreateFile(a,b);b=this.inodes[d];a=new Uint8Array(c.length);b.size=c.length;for(b=0;b<c.length;b++)a[b]=c.charCodeAt(b);await this.set_data(d,a);return d};M.prototype.CreateBinaryFile=async function(a,b,c){var d=this.inodes[b];if(this.is_forwarder(d))return b=d.foreign_id,c=await this.follow_fs(d).CreateBinaryFile(a,b,c),this.create_forwarder(d.mount_id,c);d=this.CreateFile(a,b);a=this.inodes[d];
|
|
242
|
+
b=new Uint8Array(c.length);b.set(c);await this.set_data(d,b);a.size=c.length;return d};M.prototype.OpenInode=function(a,b){var c=this.inodes[a];if(this.is_forwarder(c))return this.follow_fs(c).OpenInode(c.foreign_id,b);16384===(c.mode&61440)&&this.FillDirectory(a);return!0};M.prototype.CloseInode=async function(a){var b=this.inodes[a];if(this.is_forwarder(b))return await this.follow_fs(b).CloseInode(b.foreign_id);2===b.status&&this.storage.uncache(b.sha256sum);4===b.status&&(b.status=-1,await this.DeleteData(a))};
|
|
243
|
+
M.prototype.Rename=async function(a,b,c,d){if(a===c&&b===d)return 0;var e=this.Search(a,b);if(-1===e)return-2;var f=this.GetFullPath(a)+"/"+b;if(-1!==this.Search(c,d)){var g=this.Unlink(c,d);if(0>g)return g}var k=this.inodes[e],l=this.inodes[a];g=this.inodes[c];if(this.is_forwarder(l)||this.is_forwarder(g))if(this.is_forwarder(l)&&l.mount_id===g.mount_id){if(a=await this.follow_fs(l).Rename(l.foreign_id,b,g.foreign_id,d),0>a)return a}else{if(this.is_a_root(e)||!this.IsDirectory(e)&&1<this.GetInode(e).nlinks)return-1;
|
|
244
|
+
l=this.divert(a,b);const m=this.GetInode(e),n=await this.Read(l,0,m.size);this.is_forwarder(g)?(c=this.follow_fs(g),d=this.IsDirectory(l)?c.CreateDirectory(d,g.foreign_id):c.CreateFile(d,g.foreign_id),c=c.GetInode(d),this.copy_inode(m,c),this.set_forwarder(e,g.mount_id,d)):(this.delete_forwarder(k),this.copy_inode(m,k),this.link_under_dir(c,e,d));await this.ChangeSize(e,m.size);n&&n.length&&await this.Write(e,0,n.length,n);if(this.IsDirectory(e))for(const p of this.GetChildren(l))if(g=await this.Rename(l,
|
|
245
|
+
p,e,p),0>g)return g;await this.DeleteData(l);a=this.Unlink(a,b);if(0>a)return a}else this.unlink_from_dir(a,b),this.link_under_dir(c,e,d),k.qid.version++;this.NotifyListeners(e,"rename",{oldpath:f});return 0};M.prototype.Write=async function(a,b,c,d){this.NotifyListeners(a,"write");var e=this.inodes[a];if(this.is_forwarder(e))a=e.foreign_id,await this.follow_fs(e).Write(a,b,c,d);else{var f=await this.get_buffer(a);!f||f.length<b+c?(await this.ChangeSize(a,Math.floor(3*(b+c)/2)),e.size=b+c,f=await this.get_buffer(a)):
|
|
246
|
+
e.size<b+c&&(e.size=b+c);d&&f.set(d.subarray(0,c),b);await this.set_data(a,f)}};M.prototype.Read=async function(a,b,c){const d=this.inodes[a];return this.is_forwarder(d)?(a=d.foreign_id,await this.follow_fs(d).Read(a,b,c)):await this.get_data(a,b,c)};M.prototype.Search=function(a,b){a=this.inodes[a];if(this.is_forwarder(a)){const c=a.foreign_id;b=this.follow_fs(a).Search(c,b);return-1===b?-1:this.get_forwarder(a.mount_id,b)}b=a.direntries.get(b);return void 0===b?-1:b};M.prototype.CountUsedInodes=
|
|
247
|
+
function(){let a=this.inodes.length;for(const {fs:b,backtrack:c}of this.mounts)a+=b.CountUsedInodes(),a-=c.size;return a};M.prototype.CountFreeInodes=function(){let a=1048576;for(const {fs:b}of this.mounts)a+=b.CountFreeInodes();return a};M.prototype.GetTotalSize=function(){let a=this.used_size;for(const {fs:b}of this.mounts)a+=b.GetTotalSize();return a};M.prototype.GetSpace=function(){let a=this.total_size;for(const {fs:b}of this.mounts)a+=b.GetSpace();return this.total_size};M.prototype.GetDirectoryName=
|
|
248
|
+
function(a){const b=this.inodes[this.GetParent(a)];if(this.is_forwarder(b))return this.follow_fs(b).GetDirectoryName(this.inodes[a].foreign_id);if(!b)return"";for(const [c,d]of b.direntries)if(d===a)return c;return""};M.prototype.GetFullPath=function(a){this.IsDirectory(a);for(var b="";0!==a;)b="/"+this.GetDirectoryName(a)+b,a=this.GetParent(a);return b.substring(1)};M.prototype.Link=function(a,b,c){if(this.IsDirectory(b))return-1;const d=this.inodes[a],e=this.inodes[b];if(this.is_forwarder(d))return this.is_forwarder(e)&&
|
|
249
|
+
e.mount_id===d.mount_id?this.follow_fs(d).Link(d.foreign_id,e.foreign_id,c):-1;if(this.is_forwarder(e))return-1;this.link_under_dir(a,b,c);return 0};M.prototype.Unlink=function(a,b){if("."===b||".."===b)return-1;const c=this.Search(a,b),d=this.inodes[c],e=this.inodes[a];if(this.is_forwarder(e))return this.is_forwarder(d),a=e.foreign_id,this.follow_fs(e).Unlink(a,b);if(this.IsDirectory(c)&&!this.IsEmpty(c))return-39;this.unlink_from_dir(a,b);0===d.nlinks&&(d.status=4,this.NotifyListeners(c,"delete"));
|
|
250
|
+
return 0};M.prototype.DeleteData=async function(a){const b=this.inodes[a];this.is_forwarder(b)?await this.follow_fs(b).DeleteData(b.foreign_id):(b.size=0,delete this.inodedata[a])};M.prototype.get_buffer=async function(a){const b=this.inodes[a];return this.inodedata[a]?this.inodedata[a]:2===b.status?await this.storage.read(b.sha256sum,0,b.size):null};M.prototype.get_data=async function(a,b,c){const d=this.inodes[a];return this.inodedata[a]?this.inodedata[a].subarray(b,b+c):2===d.status?await this.storage.read(d.sha256sum,
|
|
251
|
+
b,c):null};M.prototype.set_data=async function(a,b){this.inodedata[a]=b;2===this.inodes[a].status&&(this.inodes[a].status=0,this.storage.uncache(this.inodes[a].sha256sum))};M.prototype.GetInode=function(a){isNaN(a);a=this.inodes[a];return this.is_forwarder(a)?this.follow_fs(a).GetInode(a.foreign_id):a};M.prototype.ChangeSize=async function(a,b){var c=this.GetInode(a),d=await this.get_data(a,0,c.size);if(b!==c.size){var e=new Uint8Array(b);c.size=b;d&&e.set(d.subarray(0,Math.min(d.length,c.size)),
|
|
252
|
+
0);await this.set_data(a,e)}};M.prototype.SearchPath=function(a){a=a.replace("//","/");a=a.split("/");0<a.length&&0===a[a.length-1].length&&a.pop();0<a.length&&0===a[0].length&&a.shift();const b=a.length;var c=-1,d=0;let e=null;for(var f=0;f<b;f++)if(c=d,d=this.Search(c,a[f]),!e&&this.is_forwarder(this.inodes[c])&&(e="/"+a.slice(f).join("/")),-1===d)return f<b-1?{id:-1,parentid:-1,name:a[f],forward_path:e}:{id:-1,parentid:c,name:a[f],forward_path:e};return{id:d,parentid:c,name:a[f],forward_path:e}};
|
|
253
|
+
M.prototype.GetRecursiveList=function(a,b){if(this.is_forwarder(this.inodes[a])){const c=this.follow_fs(this.inodes[a]),d=this.inodes[a].mount_id,e=b.length;c.GetRecursiveList(this.inodes[a].foreign_id,b);for(a=e;a<b.length;a++)b[a].parentid=this.get_forwarder(d,b[a].parentid)}else for(const [c,d]of this.inodes[a].direntries)"."!==c&&".."!==c&&(b.push({parentid:a,name:c}),this.IsDirectory(d)&&this.GetRecursiveList(d,b))};M.prototype.RecursiveDelete=function(a){var b=[];a=this.SearchPath(a);if(-1!==
|
|
254
|
+
a.id)for(this.GetRecursiveList(a.id,b),a=b.length-1;0<=a;a--)this.Unlink(b[a].parentid,b[a].name)};M.prototype.DeleteNode=function(a){var b=this.SearchPath(a);-1!==b.id&&(32768===(this.inodes[b.id].mode&61440)?this.Unlink(b.parentid,b.name):16384===(this.inodes[b.id].mode&61440)&&(this.RecursiveDelete(a),this.Unlink(b.parentid,b.name)))};M.prototype.NotifyListeners=function(){};M.prototype.Check=function(){for(var a=1;a<this.inodes.length;a++)if(-1!==this.inodes[a].status&&(this.GetInode(a),this.IsDirectory(a))){const b=
|
|
255
|
+
this.GetInode(a);this.IsDirectory(a)&&this.GetParent(a);for(const [c]of b.direntries)for(const d of c);}};M.prototype.FillDirectory=function(a){var b=this.inodes[a];if(this.is_forwarder(b))this.follow_fs(b).FillDirectory(b.foreign_id);else{var c=0;for(const d of b.direntries.keys())c+=24+mc.encode(d).length;a=this.inodedata[a]=new Uint8Array(c);b.size=c;c=0;for(const [d,e]of b.direntries)b=this.GetInode(e),c+=K(["Q","d","b","s"],[b.qid,c+13+8+1+2+mc.encode(d).length,b.mode>>12,d],a,c)}};M.prototype.RoundToDirentry=
|
|
256
|
+
function(a,b){a=this.inodedata[a];if(b>=a.length)return a.length;let c=0;for(;;){const d=L(["Q","d"],a,{offset:c})[1];if(d>b)break;c=d}return c};M.prototype.IsDirectory=function(a){a=this.inodes[a];return this.is_forwarder(a)?this.follow_fs(a).IsDirectory(a.foreign_id):16384===(a.mode&61440)};M.prototype.IsEmpty=function(a){a=this.inodes[a];if(this.is_forwarder(a))return this.follow_fs(a).IsDirectory(a.foreign_id);for(const b of a.direntries.keys())if("."!==b&&".."!==b)return!1;return!0};M.prototype.GetChildren=
|
|
257
|
+
function(a){this.IsDirectory(a);a=this.inodes[a];if(this.is_forwarder(a))return this.follow_fs(a).GetChildren(a.foreign_id);const b=[];for(const c of a.direntries.keys())"."!==c&&".."!==c&&b.push(c);return b};M.prototype.GetParent=function(a){this.IsDirectory(a);a=this.inodes[a];if(this.should_be_linked(a))return a.direntries.get("..");const b=this.follow_fs(a).GetParent(a.foreign_id);return this.get_forwarder(a.mount_id,b)};M.prototype.PrepareCAPs=function(a){a=this.GetInode(a);if(a.caps)return a.caps.length;
|
|
258
|
+
a.caps=new Uint8Array(20);a.caps[0]=0;a.caps[1]=0;a.caps[2]=0;a.caps[3]=2;a.caps[4]=255;a.caps[5]=255;a.caps[6]=255;a.caps[7]=255;a.caps[8]=255;a.caps[9]=255;a.caps[10]=255;a.caps[11]=255;a.caps[12]=63;a.caps[13]=0;a.caps[14]=0;a.caps[15]=0;a.caps[16]=63;a.caps[17]=0;a.caps[18]=0;a.caps[19]=0;return a.caps.length};function pc(a){this.fs=a;this.backtrack=new Map}pc.prototype.get_state=function(){const a=[];a[0]=this.fs;a[1]=[...this.backtrack];return a};pc.prototype.set_state=function(a){this.fs=a[0];
|
|
259
|
+
this.backtrack=new Map(a[1])};M.prototype.set_forwarder=function(a,b,c){const d=this.inodes[a];this.is_forwarder(d)&&this.mounts[d.mount_id].backtrack.delete(d.foreign_id);d.status=5;d.mount_id=b;d.foreign_id=c;this.mounts[b].backtrack.set(c,a)};M.prototype.create_forwarder=function(a,b){const c=this.CreateInode(),d=this.inodes.length;this.inodes.push(c);c.fid=d;this.set_forwarder(d,a,b);return d};M.prototype.is_forwarder=function(a){return 5===a.status};M.prototype.is_a_root=function(a){return 0===
|
|
260
|
+
this.GetInode(a).fid};M.prototype.get_forwarder=function(a,b){const c=this.mounts[a].backtrack.get(b);return void 0===c?this.create_forwarder(a,b):c};M.prototype.delete_forwarder=function(a){this.is_forwarder(a);a.status=-1;this.mounts[a.mount_id].backtrack.delete(a.foreign_id)};M.prototype.follow_fs=function(a){const b=this.mounts[a.mount_id];this.is_forwarder(a);return b.fs};M.prototype.Mount=function(a,b){a=this.SearchPath(a);if(-1===a.parentid)return-2;if(-1!==a.id)return-17;if(a.forward_path){var c=
|
|
261
|
+
this.inodes[a.parentid];b=this.follow_fs(c).Mount(a.forward_path,b);return 0>b?b:this.get_forwarder(c.mount_id,b)}c=this.mounts.length;this.mounts.push(new pc(b));b=this.create_forwarder(c,0);this.link_under_dir(a.parentid,b,a.name);return b};function oc(){this.type=2;this.start=0;this.length=Infinity;this.proc_id=-1;this.client_id=""}oc.prototype.get_state=function(){const a=[];a[0]=this.type;a[1]=this.start;a[2]=Infinity===this.length?0:this.length;a[3]=this.proc_id;a[4]=this.client_id;return a};
|
|
262
|
+
oc.prototype.set_state=function(a){this.type=a[0];this.start=a[1];this.length=0===a[2]?Infinity:a[2];this.proc_id=a[3];this.client_id=a[4]};oc.prototype.clone=function(){const a=new oc;a.set_state(this.get_state());return a};oc.prototype.conflicts_with=function(a){return this.proc_id===a.proc_id&&this.client_id===a.client_id||2===this.type||2===a.type||1!==this.type&&1!==a.type||this.start+this.length<=a.start||a.start+a.length<=this.start?!1:!0};oc.prototype.is_alike=function(a){return a.proc_id===
|
|
263
|
+
this.proc_id&&a.client_id===this.client_id&&a.type===this.type};oc.prototype.may_merge_after=function(a){return this.is_alike(a)&&a.start+a.length===this.start};M.prototype.DescribeLock=function(a,b,c,d,e){const f=new oc;f.type=a;f.start=b;f.length=c;f.proc_id=d;f.client_id=e;return f};M.prototype.GetLock=function(a,b){a=this.inodes[a];if(this.is_forwarder(a)){var c=a.foreign_id;return this.follow_fs(a).GetLock(c,b)}for(c of a.locks)if(b.conflicts_with(c))return c.clone();return null};M.prototype.Lock=
|
|
264
|
+
function(a,b,c){const d=this.inodes[a];if(this.is_forwarder(d))return a=d.foreign_id,this.follow_fs(d).Lock(a,b,c);b=b.clone();if(2!==b.type&&this.GetLock(a,b))return 1;for(c=0;c<d.locks.length;c++){a=d.locks[c];if(a.start+a.length<=b.start)continue;if(b.start+b.length<=a.start)break;if(a.proc_id!==b.proc_id||a.client_id!==b.client_id){a.conflicts_with(b);continue}var e=b.start+b.length;const f=b.start-a.start,g=a.start+a.length-e;if(0<f&&0<g&&a.type===b.type)return 0;0<f&&(a.length=f);if(0>=f&&0<
|
|
265
|
+
g)a.start=e,a.length=g;else if(0<g){for(;c<d.locks.length&&d.locks[c].start<e;)c++;d.locks.splice(c,0,this.DescribeLock(a.type,e,g,a.proc_id,a.client_id))}else 0>=f&&(d.locks.splice(c,1),c--)}if(2!==b.type){c=b;a=!1;for(e=0;e<d.locks.length&&!(c.may_merge_after(d.locks[e])&&(d.locks[e].length+=b.length,c=d.locks[e],a=!0),b.start<=d.locks[e].start);e++);a||(d.locks.splice(e,0,c),e++);for(;e<d.locks.length;e++)if(d.locks[e].is_alike(c)){d.locks[e].may_merge_after(c)&&(c.length+=d.locks[e].length,d.locks.splice(e,
|
|
266
|
+
1));break}}return 0};M.prototype.read_dir=function(a){a=this.SearchPath(a);if(-1!==a.id)return a=this.GetInode(a.id),Array.from(a.direntries.keys()).filter(b=>"."!==b&&".."!==b)};M.prototype.read_file=function(a){a=this.SearchPath(a);if(-1===a.id)return Promise.resolve(null);const b=this.GetInode(a.id);return this.Read(a.id,0,b.size)};function S(a){this.cpu_is_running=!1;this.cpu_exception_hook=function(){};var b=Ca.create();this.bus=b[0];this.emulator_bus=b[1];var c,d;const e=new WebAssembly.Table({element:"anyfunc",
|
|
267
|
+
initial:1924});b={cpu_exception_hook:g=>this.cpu_exception_hook(g),run_hardware_timers:function(g,k){return c.run_hardware_timers(g,k)},cpu_event_halt:()=>{this.emulator_bus.send("cpu-event-halt")},abort:function(){},microtick:H.microtick,get_rand_int:function(){return ba()},apic_acknowledge_irq:function(){return c.devices.apic.acknowledge_irq()},stop_idling:function(){return c.stop_idling()},io_port_read8:function(g){return c.io.port_read8(g)},io_port_read16:function(g){return c.io.port_read16(g)},
|
|
268
|
+
io_port_read32:function(g){return c.io.port_read32(g)},io_port_write8:function(g,k){c.io.port_write8(g,k)},io_port_write16:function(g,k){c.io.port_write16(g,k)},io_port_write32:function(g,k){c.io.port_write32(g,k)},mmap_read8:function(g){return c.mmap_read8(g)},mmap_read16:function(g){return c.mmap_read16(g)},mmap_read32:function(g){return c.mmap_read32(g)},mmap_write8:function(g,k){c.mmap_write8(g,k)},mmap_write16:function(g,k){c.mmap_write16(g,k)},mmap_write32:function(g,k){c.mmap_write32(g,k)},
|
|
269
|
+
mmap_write64:function(g,k,l){c.mmap_write64(g,k,l)},mmap_write128:function(g,k,l,m,n){c.mmap_write128(g,k,l,m,n)},log_from_wasm:function(g,k){String.fromCharCode(...(new Uint8Array(d.buffer,g>>>0,k>>>0)))},console_log_from_wasm:function(g,k){g=String.fromCharCode(...(new Uint8Array(d.buffer,g>>>0,k>>>0)));console.error(g)},dbg_trace_from_wasm:function(){},codegen_finalize:(g,k,l,m,n)=>{c.codegen_finalize(g,k,l,m,n)},jit_clear_func:g=>c.jit_clear_func(g),jit_clear_all_funcs:()=>c.jit_clear_all_funcs(),
|
|
270
|
+
__indirect_function_table:e};let f=a.wasm_fn;f||(f=g=>new Promise(k=>{let l="v86.wasm",m="v86-fallback.wasm";a.wasm_path?(l=a.wasm_path,m=l.replace("v86.wasm","v86-fallback.wasm")):"undefined"===typeof window&&"string"===typeof __dirname?(l=__dirname+"/"+l,m=__dirname+"/"+m):(l="build/"+l,m="build/"+m);pa(l,{done:async n=>{try{const {instance:p}=await WebAssembly.instantiate(n,g);this.wasm_source=n;k(p.exports)}catch(p){pa(m,{done:async q=>{const {instance:r}=await WebAssembly.instantiate(q,g);this.wasm_source=
|
|
271
|
+
q;k(r.exports)}})}},progress:n=>{this.emulator_bus.send("download-progress",{file_index:0,file_count:1,file_name:l,lengthComputable:n.lengthComputable,total:n.total,loaded:n.loaded})}})}));f({env:b}).then(g=>{d=g.memory;g.rust_init();g=this.v86=new H(this.emulator_bus,{exports:g,wasm_table:e});c=g.cpu;this.continue_init(g,a)});this.zstd_worker=null;this.zstd_worker_request_id=0}S.prototype.continue_init=async function(a,b){function c(q,r){switch(q){case "hda":e.hda=this.disk_images.hda=r;break;case "hdb":e.hdb=
|
|
272
|
+
this.disk_images.hdb=r;break;case "cdrom":e.cdrom=this.disk_images.cdrom=r;break;case "fda":e.fda=this.disk_images.fda=r;break;case "fdb":e.fdb=this.disk_images.fdb=r;break;case "multiboot":e.multiboot=this.disk_images.multiboot=r.buffer;break;case "bzimage":e.bzimage=this.disk_images.bzimage=r.buffer;break;case "initrd":e.initrd=this.disk_images.initrd=r.buffer;break;case "bios":e.bios=r.buffer;break;case "vga_bios":e.vga_bios=r.buffer;break;case "initial_state":e.initial_state=r.buffer;break;case "fs9p_json":e.fs9p_json=
|
|
273
|
+
r}}async function d(){if(e.fs9p&&e.fs9p_json&&!e.initial_state&&(e.fs9p.load_from_json(e.fs9p_json),b.bzimage_initrd_from_filesystem)){const {bzimage_path:q,initrd_path:r}=this.get_bzimage_initrd_from_filesystem(e.fs9p),[y,x]=await Promise.all([e.fs9p.read_file(r),e.fs9p.read_file(q)]);c.call(this,"initrd",new va(y.buffer));c.call(this,"bzimage",new va(x.buffer))}this.serial_adapter&&this.serial_adapter.show&&this.serial_adapter.show();this.v86.init(e);e.initial_state&&(a.restore_state(e.initial_state),
|
|
274
|
+
e.initial_state=void 0);b.autostart&&this.v86.run();this.emulator_bus.send("emulator-loaded")}this.bus.register("emulator-stopped",function(){this.cpu_is_running=!1;this.screen_adapter.pause()},this);this.bus.register("emulator-started",function(){this.cpu_is_running=!0;this.screen_adapter.continue()},this);var e={};this.disk_images={fda:void 0,fdb:void 0,hda:void 0,hdb:void 0,cdrom:void 0};var f=b.boot_order?b.boot_order:b.fda?801:b.hda?786:291;e.acpi=b.acpi;e.disable_jit=b.disable_jit;e.load_devices=
|
|
275
|
+
!0;e.memory_size=b.memory_size||67108864;e.vga_memory_size=b.vga_memory_size||8388608;e.boot_order=f;e.fastboot=b.fastboot||!1;e.fda=void 0;e.fdb=void 0;e.uart1=b.uart1;e.uart2=b.uart2;e.uart3=b.uart3;e.cmdline=b.cmdline;e.preserve_mac_from_state_image=b.preserve_mac_from_state_image;e.mac_address_translation=b.mac_address_translation;e.cpuid_level=b.cpuid_level;e.virtio_balloon=b.virtio_balloon;e.virtio_console=b.virtio_console;e.virtio_net=b.virtio_net;e.screen_options=b.screen_options;if(f=b.network_relay_url||
|
|
276
|
+
b.net_device&&b.net_device.relay_url)"fetch"===f?this.network_adapter=new Tb(this.bus,b.net_device):"inbrowser"===f?this.network_adapter=new hc(this.bus,b.net_device):f.startsWith("wisp://")||f.startsWith("wisps://")?this.network_adapter=new ac(f,this.bus,b.net_device):this.network_adapter=new rb(f,this.bus);e.net_device=b.net_device||{type:"ne2k"};f=b.screen||{};b.screen_container&&(f.container=b.screen_container);b.disable_keyboard||(this.keyboard_adapter=new cc(this.bus));b.disable_mouse||(this.mouse_adapter=
|
|
277
|
+
new dc(this.bus,f.container));this.screen_adapter=f.container?new ta(f,()=>this.v86.cpu.devices.vga&&this.v86.cpu.devices.vga.screen_fill_buffer()):new ec;e.screen=this.screen_adapter;e.screen_options=f;b.serial_container&&(this.serial_adapter=new fc(b.serial_container,this.bus));b.serial_container_xtermjs&&(this.serial_adapter=new gc(b.serial_container_xtermjs,this.bus));b.disable_speaker||(this.speaker_adapter=new gb(this.bus));var g=[];f=(q,r)=>{if(r)if(r.get&&r.set&&r.load)g.push({name:q,loadable:r});
|
|
278
|
+
else{if("bios"===q||"vga_bios"===q||"initial_state"===q||"multiboot"===q||"bzimage"===q||"initrd"===q)r.async=!1;if("fda"===q||"fdb"===q)r.async=!1;r.url&&!r.async?g.push({name:q,url:r.url,size:r.size}):g.push({name:q,loadable:Aa(r,this.zstd_decompress_worker.bind(this))})}};b.state&&console.warn("Warning: Unknown option 'state'. Did you mean 'initial_state'?");f("bios",b.bios);f("vga_bios",b.vga_bios);f("cdrom",b.cdrom);f("hda",b.hda);f("hdb",b.hdb);f("fda",b.fda);f("fdb",b.fdb);f("initial_state",
|
|
279
|
+
b.initial_state);f("multiboot",b.multiboot);f("bzimage",b.bzimage);f("initrd",b.initrd);if(b.filesystem){f=b.filesystem.basefs;var k=b.filesystem.baseurl;let q=new ic;k&&(q=new jc(q,k));e.fs9p=this.fs9p=new M(q);if(f){if("object"===typeof f){var l=f.size;f=f.url}g.push({name:"fs9p_json",url:f,size:l,as_json:!0})}}var m=this,n=g.length,p=function(q){if(q===n)setTimeout(d.bind(this),0);else{var r=g[q];r.loadable?(r.loadable.onload=function(){c.call(this,r.name,r.loadable);p(q+1)}.bind(this),r.loadable.load()):
|
|
280
|
+
pa(r.url,{done:function(y){r.url.endsWith(".zst")&&"initial_state"!==r.name&&(y=this.zstd_decompress(r.size,new Uint8Array(y)));c.call(this,r.name,r.as_json?y:new va(y));p(q+1)}.bind(this),progress:function(y){200===y.target.status?m.emulator_bus.send("download-progress",{file_index:q,file_count:n,file_name:r.url,lengthComputable:y.lengthComputable,total:y.total||r.size,loaded:y.loaded}):m.emulator_bus.send("download-error",{file_index:q,file_count:n,file_name:r.url,request:y.target})},as_json:r.as_json})}}.bind(this);
|
|
281
|
+
p(0)};S.prototype.zstd_decompress=function(a,b){const c=this.v86.cpu;this.zstd_context=c.zstd_create_ctx(b.length);(new Uint8Array(c.wasm_memory.buffer)).set(b,c.zstd_get_src_ptr(this.zstd_context));b=c.zstd_read(this.zstd_context,a);const d=c.wasm_memory.buffer.slice(b,b+a);c.zstd_read_free(b,a);c.zstd_free_ctx(this.zstd_context);this.zstd_context=null;return d};S.prototype.zstd_decompress_worker=async function(a,b){if(!this.zstd_worker){const c=URL.createObjectURL(new Blob(["("+function(){let d;
|
|
282
|
+
globalThis.onmessage=function(e){if(d){var {src:f,decompressed_size:g,id:k}=e.data;e=d.exports;var l=e.zstd_create_ctx(f.length);(new Uint8Array(e.memory.buffer)).set(f,e.zstd_get_src_ptr(l));var m=e.zstd_read(l,g),n=e.memory.buffer.slice(m,m+g);e.zstd_read_free(m,g);e.zstd_free_ctx(l);postMessage({result:n,id:k},[n])}else l=Object.fromEntries("cpu_exception_hook run_hardware_timers cpu_event_halt microtick get_rand_int apic_acknowledge_irq stop_idling io_port_read8 io_port_read16 io_port_read32 io_port_write8 io_port_write16 io_port_write32 mmap_read8 mmap_read16 mmap_read32 mmap_write8 mmap_write16 mmap_write32 mmap_write64 mmap_write128 codegen_finalize jit_clear_func jit_clear_all_funcs".split(" ").map(p=>
|
|
281
283
|
[p,()=>console.error("zstd worker unexpectedly called "+p)])),l.__indirect_function_table=new WebAssembly.Table({element:"anyfunc",initial:1024}),l.abort=()=>{throw Error("zstd worker aborted");},l.log_from_wasm=l.console_log_from_wasm=(p,q)=>{console.log(String.fromCharCode(...(new Uint8Array(d.exports.memory.buffer,p,q))))},l.dbg_trace_from_wasm=()=>console.trace(),d=new WebAssembly.Instance(new WebAssembly.Module(e.data),{env:l})}}.toString()+")()"],{type:"text/javascript"}));this.zstd_worker=
|
|
282
284
|
new Worker(c);URL.revokeObjectURL(c);this.zstd_worker.postMessage(this.wasm_source,[this.wasm_source])}return new Promise(c=>{const d=this.zstd_worker_request_id++,e=async f=>{f.data.id===d&&(this.zstd_worker.removeEventListener("message",e),c(f.data.result))};this.zstd_worker.addEventListener("message",e);this.zstd_worker.postMessage({src:b,decompressed_size:a,id:d},[b.buffer])})};S.prototype.get_bzimage_initrd_from_filesystem=function(a){const b=(a.read_dir("/")||[]).map(e=>"/"+e);a=(a.read_dir("/boot/")||
|
|
283
285
|
[]).map(e=>"/boot/"+e);let c,d;for(const e of[].concat(b,a)){const f=/old/i.test(e)||/fallback/i.test(e),g=/vmlinuz/i.test(e)||/bzimage/i.test(e),k=/initrd/i.test(e)||/initramfs/i.test(e);!g||d&&f||(d=e);!k||c&&f||(c=e)}c&&d||(console.log("Failed to find bzimage or initrd in filesystem. Files:"),console.log(b.join(" ")),console.log(a.join(" ")));return{initrd_path:c,bzimage_path:d}};S.prototype.run=async function(){this.v86.run()};S.prototype.stop=async function(){this.cpu_is_running&&await new Promise(a=>
|
|
@@ -487,9 +489,9 @@ function(){this.diff_addr_min=this.vga_memory_size;this.diff_addr_max=0;this.dif
|
|
|
487
489
|
6};Y.prototype.vga_addr_to_pixel=function(a){var b=this.vga_addr_shift_count();if(~this.crtc_mode&3){var c=a-this.start_address;c&=this.crtc_mode<<13|-24577;c<<=b;var d=c/this.virtual_width|0;c%=this.virtual_width;switch(this.crtc_mode&3){case 2:d=d<<1|a>>13&1;break;case 1:d=d<<1|a>>14&1;break;case 0:d=d<<2|a>>13&3}return d*this.virtual_width+c+(this.start_address<<b)}return a<<b};Y.prototype.scan_line_to_screen_row=function(a){this.max_scan_line&128&&(a>>>=1);a=Math.ceil(a/(1+(this.max_scan_line&
|
|
488
490
|
31)));this.crtc_mode&1||(a<<=1);this.crtc_mode&2||(a<<=1);return a};Y.prototype.set_size_text=function(a,b){this.max_cols=a;this.max_rows=b;this.screen.set_size_text(a,b);this.bus.send("screen-set-size",[a,b,0])};Y.prototype.set_size_graphical=function(a,b,c,d,e){c=Math.max(c,1);d=Math.max(d,1);if(this.screen_width!==a||this.screen_height!==b||this.virtual_width!==c||this.virtual_height!==d){this.screen_width=a;this.screen_height=b;this.virtual_width=c;this.virtual_height=d;if("undefined"!==typeof ImageData){const f=
|
|
489
491
|
c*d,g=this.cpu.svga_allocate_dest_buffer(f)>>>0;this.dest_buffet_offset=g;this.image_data=new ImageData(new Uint8ClampedArray(this.cpu.wasm_memory.buffer,g,4*f),c,d);this.cpu.svga_mark_dirty()}this.screen.set_size_graphical(a,b,c,d);this.bus.send("screen-set-size",[a,b,e])}};Y.prototype.update_vga_size=function(){if(!this.svga_enabled){var a=Math.min(1+this.horizontal_display_enable_end,this.horizontal_blank_start),b=Math.min(1+this.vertical_display_enable_end,this.vertical_blank_start);if(a&&b)if(this.graphical_mode){a<<=
|
|
490
|
-
3;var c=this.offset_register<<4;this.attribute_mode&64
|
|
491
|
-
this.screen_width)if(!this.palette_source||this.clocking_mode&32)this.layers=[],this.screen.clear_screen();else{var a=this.start_address_latched,b=this.horizontal_panning;this.attribute_mode&64&&(b>>>=1);var c=this.preset_row_scan>>5&3,d=this.vga_addr_to_pixel(a+c);a=d/this.virtual_width|0;var e=d%this.virtual_width+b;d=this.scan_line_to_screen_row(1+this.line_compare);d=Math.min(d,this.screen_height);var f=this.screen_height-d;this.layers=[];e=-e;for(var g=0;e<this.screen_width;e+=
|
|
492
|
-
g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:0,buffer_x:0,buffer_y:a+g,buffer_width:this.virtual_width,buffer_height:d});a=0;this.attribute_mode&32||(a=this.vga_addr_to_pixel(c)+b);e=-a;for(g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:d,buffer_x:0,buffer_y:g,buffer_width:this.virtual_width,buffer_height:f})}};Y.prototype.update_vertical_retrace=function(){this.port_3DA_value|=8;this.start_address_latched!==
|
|
492
|
+
3;var c=this.offset_register<<4,d=4;this.attribute_mode&64?(a>>>=1,c>>>=1,d=8):this.attribute_mode&2&&(d=1);b=this.scan_line_to_screen_row(b);var e=Pc[0];const f=this.vga_bytes_per_line();this.set_size_graphical(a,b,c,f?Math.ceil(e/f):b,d);this.update_vertical_retrace();this.update_layers()}else this.max_scan_line&128&&(b>>>=1),c=b/(1+(this.max_scan_line&31))|0,a&&c&&this.set_size_text(a,c)}};Y.prototype.update_layers=function(){this.graphical_mode||this.text_mode_redraw();if(this.svga_enabled)this.layers=
|
|
493
|
+
[];else if(this.virtual_width&&this.screen_width)if(!this.palette_source||this.clocking_mode&32)this.layers=[],this.screen.clear_screen();else{var a=this.start_address_latched,b=this.horizontal_panning;this.attribute_mode&64&&(b>>>=1);var c=this.preset_row_scan>>5&3,d=this.vga_addr_to_pixel(a+c);a=d/this.virtual_width|0;var e=d%this.virtual_width+b;d=this.scan_line_to_screen_row(1+this.line_compare);d=Math.min(d,this.screen_height);var f=this.screen_height-d;this.layers=[];e=-e;for(var g=0;e<this.screen_width;e+=
|
|
494
|
+
this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:0,buffer_x:0,buffer_y:a+g,buffer_width:this.virtual_width,buffer_height:d});a=0;this.attribute_mode&32||(a=this.vga_addr_to_pixel(c)+b);e=-a;for(g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:d,buffer_x:0,buffer_y:g,buffer_width:this.virtual_width,buffer_height:f})}};Y.prototype.update_vertical_retrace=function(){this.port_3DA_value|=8;this.start_address_latched!==
|
|
493
495
|
this.start_address&&(this.start_address_latched=this.start_address,this.update_layers())};Y.prototype.update_cursor_scanline=function(){var a=this.max_scan_line&31;const b=Math.min(a,this.cursor_scanline_start&31);a=Math.min(a,this.cursor_scanline_end&31);this.screen.update_cursor_scanline(b,a,!(this.cursor_scanline_start&32)&&b<a)};Y.prototype.port3C0_write=function(a){if(-1===this.attribute_controller_index)z(a),this.attribute_controller_index=a&31,z(this.attribute_controller_index),this.palette_source!==
|
|
494
496
|
(a&32)&&(this.palette_source=a&32,this.update_layers());else{if(16>this.attribute_controller_index)z(this.attribute_controller_index),z(a),this.dac_map[this.attribute_controller_index]=a,this.attribute_mode&64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:z(a);if(this.attribute_mode!==a){var b=this.attribute_mode;this.attribute_mode=a;const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&
|
|
495
497
|
64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:z(a);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:z(a);this.horizontal_panning!==a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:z(a);this.color_select!==a&&(this.color_select=a,this.complete_redraw());break;default:z(this.attribute_controller_index),z(a)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){return(this.attribute_controller_index|
|