react-95-fiber
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,1 +0,1 @@ | ||
import e from"@babel/runtime/helpers/esm/extends";import t,{useContext as n,forwardRef as o,useRef as r,useLayoutEffect as s,createContext as i,useCallback as a,useEffect as d}from"react";import{V86Starter as u}from"v86";import l from"react-reconciler";import{unstable_now as c}from"scheduler";const p=e=>65535&e,y=e=>e>>16&65535,m=e=>255&e,v=e=>e>>8&255,w=8388608,h=12582912,C=1073741824,g=1073741824,_=33554432,I=67108864,f=134217728,x=4194304,U=131072,W=1048576,b=536870912,E=16777216,M=65536,P=536870912,S=131072,R=0,T=2147483648,B=262144,D=524288,O=65536,A=262144,H=0,L=13565952,Q=268435456,F=2097152,k=13565952,q=-2138570752,z=32768,G=6,N=28,j=864,V=895,X=780,Y=75,J=31,K=533,Z=781,$=258,ee=47,te=34,ne=771,oe=16,re=273,se=68,ie=65,ae=57,de=123,ue=769,le=74,ce=1,pe=309,ye=310,me=307,ve=308,we=306,he=311,Ce=312,ge=768,_e=259,Ie=45,fe=2,xe=775,Ue=537,We=27,be=126,Ee=776,Me=43,Pe=563,Se=10,Re=22,Te=289,Be=529,De=561,Oe=20,Ae=530,He=562,Le=29,Qe=135,Fe=49,ke=51,qe=127,ze=36,Ge=13,Ne=14,je=856,Ve=863,Xe=83,Ye=786,Je=276,Ke=782,Ze=39,$e=272,et=278,tt=279,nt=81,ot=80,rt=256,st=257,it=8,at=546,dt=551,ut=544,lt=545,ct=553,pt=552,yt=549,mt=548,vt=564,wt=547,ht=560,Ct=550,gt=44,_t=293,It=290,ft=294,xt=292,Ut=291,Wt=288,bt=287,Et=531,Mt=3,Pt=534,St=134,Rt=131,Tt=129,Bt=130,Dt=132,Ot=163,At=161,Ht=162,Lt=169,Qt=167,Ft=168,kt=160,qt=133,zt=166,Gt=164,Nt=165,jt=40,Vt=78,Xt=85,Yt=0,Jt=15,Kt=777,Zt=38,$t=785,en=784,tn=528,nn=770,on=896,rn=911,sn=72,an=536,dn=791,un=792,ln=55,cn=17,pn=783,yn=19,mn=35,vn=18,wn=774,hn=773,Cn=32,gn=7,_n=48,In=50,fn=128,xn=11,Un=12,Wn=26,bn=24,En=5,Mn=779,Pn=532,Sn=42,Rn=125,Tn=124,Bn=262,Dn=21,On=274,An=263,Hn=260,Ln=261,Qn=82,Fn=794,kn=30,qn=275,zn=772,Gn=1024,Nn=84,jn=46,Vn=277,Xn=778,Yn=71,Jn=70,Kn=26,Zn=256,$n=264,eo=136,to=33,no=512,oo=513,ro=514,so=515,io=516,ao=517,uo=518,lo=519,co=520,po=521,yo=522,mo=512,vo=522,wo=673,ho=675,Co=16,go=262144,_o=512,Io=1024,fo=65536,xo=1,Uo=0,Wo=16384,bo=0,Eo=64,Mo=4,Po=768,So=392,Ro=4096,To=0,Bo=8192,Do=131072,Oo=128,Ao=8,Ho=32,Lo=256,Qo=2147483648,Fo=0,ko=1,qo=2,zo=4,Go=8,No=16,jo=32,Vo=64,Xo=128,Yo=256,Jo=1024,Ko=2048,Zo=4096,$o=8192,er=256,tr=512,nr=768,or=1024,rr=1280,sr=1281,ir=1537,ar=1538,dr=1,ur=2,lr=65535,cr=1,pr=1,yr=2,mr=4,vr=176,wr=177,hr=178,Cr=179,gr=180,_r=181,Ir=182,fr=183,xr=184,Ur=185,Wr=186,br=187,Er=188,Mr=189,Pr=190,Sr=193,Rr=194,Tr=196,Br=197,Dr=198,Or=199,Ar=200,Hr=201,Lr=203,Qr=204,Fr=205,kr=206,qr=207,zr=208,Gr=209,Nr=210,jr=211,Vr=212,Xr=197,Yr=213,Jr=214,Kr=215,Zr=216,$r=217,es=0,ts=1,ns=2,os=0,rs=1,ss=2,is=3,as=4,ds=5,us=6,ls=7,cs=8,ps=9,ys=11,ms=32,vs=0,ws=64,hs=128,Cs=256,gs=512,_s=768,Is=1024,fs=2048,xs=3072,Us=4096,Ws=8192,bs=16384,Es=32768,Ms=32,Ps=0,Ss=1,Rs=2,Ts=3,Bs=4,Ds=5,Os=2,As=3,Hs=5,Ls=6,Qs=7,Fs=240,ks=241,qs=242,zs=243,Gs=244,Ns=245,js=246,Vs=247,Xs=0,Ys=1,Js=2,Ks=4,Zs=8,$s=0,ei=1,ti=2,ni=3,oi=4,ri=5,si=6,ii=7,ai=8,di=9,ui=10,li=11,ci=12,pi=13,yi=14,mi=15,vi=16,wi=17,hi=18,Ci=31,gi=128,_i=256,Ii=512,fi=1024,xi=2048,Ui=4096,Wi=16384,bi=32768,Ei=49152,Mi=49152,Pi=368,Si=369,Ri=370,Ti=371,Bi=0,Di=1,Oi=2,Ai=3,Hi=372,Li=32770,Qi=0,Fi=4,ki=8;class qi{constructor(e,t){this.outQueue=[],this.inQueue=[],e.io.register_write(1284,this,(()=>console.warn("Invalid 8 bit write!")),(()=>console.warn("Invalid 16 bit write!")),(e=>{const n=255&e;e>>8>0?this.inQueue.push(n):this.inQueue.length>0&&(t(new Uint8ClampedArray(this.inQueue).buffer),this.inQueue=[])})),e.io.register_read(1280,this,(()=>(console.warn("Invalid 8 bit read!"),0)),(()=>(console.warn("Invalid 16 bit read!"),0)),(()=>{var e;const t=(null==(e=this.outQueue[0])?void 0:e.length)>0&&this.outQueue[0]||this.outQueue.shift();if(!t)return 0;const n=t.shift();return void 0===n?0:n|t.length+1<<8}))}sendData(e){const t=new Uint8ClampedArray(e);this.outQueue.push(Array.from(t))}}new TextEncoder;const zi=new TextDecoder;let Gi,Ni;function ji(e,t){const n=t.map((e=>4+(e.type===Ni.String?e.value.length+1+4:4))).reduce(((e,t)=>e+t),0),o=new ArrayBuffer(12+n),r=new DataView(o);r.setUint32(0,49325,!0),r.setUint32(4,e,!0),r.setUint32(8,t.length,!0);let s=o.byteLength;for(let e=0;e<t.length;e++){const n=t[e];if(r.setUint32(12+8*e,n.type,!0),n.type===Ni.Int)r.setInt32(12+8*e+4,n.value,!0);else if(n.type===Ni.UInt)r.setUint32(12+8*e+4,n.value,!0);else if(n.type===Ni.Float)r.setFloat32(12+8*e+4,n.value,!0);else if(n.type===Ni.String){const t=n.value;s--,r.setUint8(s,0);for(let e=t.length-1;e>=0;e--)s--,r.setUint8(s,t.charCodeAt(e));r.setUint32(12+8*e+4,s,!0)}}return o}!function(e){e[e.Cmd_Invalid=0]="Cmd_Invalid",e[e.Cmd_SetCursorPos=1]="Cmd_SetCursorPos",e[e.Cmd_MouseEvent=2]="Cmd_MouseEvent",e[e.Cmd_SetWindowPos=3]="Cmd_SetWindowPos",e[e.Cmd_CreateWindow=4]="Cmd_CreateWindow",e[e.Cmd_DestroyWindow=5]="Cmd_DestroyWindow",e[e.Cmd_SetWindowText=6]="Cmd_SetWindowText",e[e.Cmd_GetWindowText=7]="Cmd_GetWindowText",e[e.Cmd_MessageBoxEx=8]="Cmd_MessageBoxEx",e[e.Cmd_Ping=9]="Cmd_Ping",e[e.Cmd_ExtractIcon=10]="Cmd_ExtractIcon",e[e.Cmd_DestroyIcon=11]="Cmd_DestroyIcon",e[e.Cmd_SendMessage=12]="Cmd_SendMessage"}(Gi||(Gi={})),function(e){e[e.Null=0]="Null",e[e.Int=1]="Int",e[e.UInt=2]="UInt",e[e.Float=3]="Float",e[e.String=4]="String"}(Ni||(Ni={}));let Vi=0;function Xi(){const e=Vi;return Vi=Vi+1&16777215,e}const Yi=new Map;let Ji;function Ki(e,t,n,o){void 0===o&&(o={scale:.5,fromState:!1});const r=new u({screen_container:e,wasm_fn:n.v86WASM?(s=n.v86WASM,async e=>(await WebAssembly.instantiate(s,e)).instance.exports):n.v86WASMFn,bios:n.seabios?{buffer:n.seabios}:{url:n.seabiosUrl},vga_bios:n.vgabios?{buffer:n.vgabios}:{url:n.vgabiosUrl},hda:n.osImg?{buffer:n.osImg}:{url:n.osImgUrl},boot_order:306,memory_size:33554432,disable_mouse:!0,autostart:o.fromState||!0});var s;r.add_listener("emulator-started",(()=>{r.v86.cpu.devices.commBus=new qi(r.v86.cpu,(e=>{const n=function(e){if(e.byteLength<4)return null;const t=new DataView(e),n=t.getUint32(0,!0);return n===Ji.Res_WinProc?16!==e.byteLength?null:{type:n,message:t.getUint32(4,!0),wParam:t.getUint32(8,!0),lParam:t.getInt32(12,!0)}:n===Ji.Res_CmdOutputHandle?12!==e.byteLength?null:{type:n,seq:t.getUint32(4,!0),handle:t.getUint32(8,!0)}:n===Ji.Res_CmdOutputLong?e.byteLength!==12+t.getUint32(8,!0)?null:{type:n,seq:t.getUint32(4,!0),length:t.getUint32(8,!0),data:e.slice(12)}:{type:n}}(e);if(n){var o;if(null==t.onEvent||t.onEvent(n),(n.type===Ji.Res_CmdOutputHandle||n.type===Ji.Res_CmdOutputLong)&&Yi.has(n.seq))null==(o=Yi.get(n.seq))||o(n),Yi.delete(n.seq);i.ready||(null==t.onReady||t.onReady(),i.ready=!0)}}))}));const i={v86Emulator:r,ready:!1};function a(e){const t=r.v86.cpu.devices.commBus;t&&t.sendData(e)}const d={sendSerial:a,startBridge(){r.keyboard_send_scancodes([29,19]),r.keyboard_send_scancodes([157,147]),r.keyboard_send_text('"c:\\windows\\start menu\\Programs\\StartUp\\bridge.exe"'),r.keyboard_send_scancodes([28]),r.keyboard_send_scancodes([156])},setMousePos(e,t){i.ready&&a(ji(Gi.Cmd_SetCursorPos,[{type:Ni.Int,value:e},{type:Ni.Int,value:t}]))},setWindowPos(e,t,n,o,r){a(ji(Gi.Cmd_SetWindowPos,[{type:Ni.UInt,value:e},{type:Ni.Int,value:t},{type:Ni.Int,value:n},{type:Ni.Int,value:o},{type:Ni.Int,value:r}]))},createWindow(e){a(ji(Gi.Cmd_CreateWindow,[{type:Ni.UInt,value:e.id},{type:Ni.UInt,value:e.extStyle},{type:Ni.String,value:e.type},{type:Ni.String,value:e.text},{type:Ni.UInt,value:e.params},{type:Ni.Int,value:e.x},{type:Ni.Int,value:e.y},{type:Ni.Int,value:e.w},{type:Ni.Int,value:e.h},{type:Ni.UInt,value:e.parentId},{type:Ni.UInt,value:e.menuId}]))},destroyWindow(e){a(ji(Gi.Cmd_DestroyWindow,[{type:Ni.UInt,value:e}]))},setWindowText(e,t){a(ji(Gi.Cmd_SetWindowText,[{type:Ni.UInt,value:e},{type:Ni.String,value:t}]))},getWindowText:e=>new Promise((t=>{const n=Xi();Yi.set(n,(e=>{e.type===Ji.Res_CmdOutputLong&&t(zi.decode(e.data).split("\0")[0])})),a(ji(Gi.Cmd_GetWindowText,[{type:Ni.UInt,value:e},{type:Ni.UInt,value:n}]))})),extractIcon:(e,t)=>new Promise((n=>{const o=Xi();Yi.set(o,(e=>{e.type===Ji.Res_CmdOutputHandle&&n(e.handle)})),a(ji(Gi.Cmd_ExtractIcon,[{type:Ni.UInt,value:o},{type:Ni.String,value:e},{type:Ni.UInt,value:t}]))})),destroyIcon(e){a(ji(Gi.Cmd_DestroyIcon,[{type:Ni.UInt,value:e}]))},sendMessage:(e,t,n,o)=>new Promise((r=>{const s=Xi();Yi.set(s,(e=>{e.type===Ji.Res_CmdOutputHandle&&r(e.handle)})),a(ji(Gi.Cmd_SendMessage,[{type:Ni.UInt,value:e},{type:Ni.UInt,value:t},{type:Ni.UInt,value:n},{type:Ni.Int,value:o},{type:Ni.UInt,value:s}]))})),sendMouseEvent(e,t){e?0===t?a(ji(Gi.Cmd_MouseEvent,[{type:Ni.UInt,value:2}])):2===t&&a(ji(Gi.Cmd_MouseEvent,[{type:Ni.UInt,value:8}])):0===t?a(ji(Gi.Cmd_MouseEvent,[{type:Ni.UInt,value:4}])):2===t&&a(ji(Gi.Cmd_MouseEvent,[{type:Ni.UInt,value:16}]))}};return setInterval((()=>{a(ji(Gi.Cmd_Ping,[]))}),2e3),{state:i,api:d}}!function(e){e[e.Res_Invalid=0]="Res_Invalid",e[e.Res_Ping=1]="Res_Ping",e[e.Res_WinProc=2]="Res_WinProc",e[e.Res_CmdOutputHandle=3]="Res_CmdOutputHandle",e[e.Res_CmdOutputLong=4]="Res_CmdOutputLong"}(Ji||(Ji={}));let Zi=3;function $i(e,t){"w95Window"===t.type&&"text"!==e.type&&(t.root.api.createWindow({id:t.id,type:t.props.windowType,text:t.props.text||"",params:t.props.params,x:t.props.x,y:t.props.y,w:t.props.w,h:t.props.h,parentId:e.id||0,menuId:void 0!==t.props.menuId?t.props.menuId:t.id||0,extStyle:t.props.extStyle||0}),t.props.onEvent&&t.root.events.set(t.id,t.props.onEvent))}function ea(e,t){"w95Window"===t.type&&"text"!==e.type&&(t.root.events.delete(t.id),e.root.api.destroyWindow(t.id))}const ta=l({getPublicInstance:e=>e,getRootHostContext:()=>({}),getChildHostContext:()=>({}),prepareForCommit:()=>null,resetAfterCommit:()=>({}),scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,now:c,isPrimaryRenderer:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,preparePortalMount:()=>{},hideInstance:()=>{},hideTextInstance:()=>{},unhideInstance:()=>{},unhideTextInstance:()=>{},clearContainer:()=>!1,createInstance(e,t,n){let{type:o,...r}=t;return{type:e,props:{windowType:o,...r},id:Zi++,root:n.root}},createTextInstance:(e,t)=>({type:"text",content:e}),appendInitialChild(e,t){"text"===t.type&&"w95Window"===e.type?e.props.text=t.content:(e.children=e.children||[],e.children.push(t))},finalizeInitialChildren:(e,t,n)=>!1,prepareUpdate:(e,t,n,o)=>!0,shouldSetTextContent:(e,t)=>!1,appendChild:$i,appendChildToContainer:function e(t,n){var o;$i(t,n),null==(o=n.children)||o.forEach((t=>e(n,t)))},commitTextUpdate(e,t,n){},commitMount:e=>console.log("commitMount",e),commitUpdate(e,t,n,o,r,s){"w95Window"===e.type&&("string"==typeof r.children&&r.children!==o.children?e.root.api.setWindowText(e.id,r.children):r.x===o.x&&r.y===o.y&&r.w===o.w&&r.h===o.h||e.root.api.setWindowPos(e.id,r.x,r.y,r.w,r.h))},insertBefore:e=>console.log("insertBefore",e),insertInContainerBefore:(e,t,n)=>console.log("insertInContainerBefore",{parentInstance:e,child:t,beforeChild:n}),removeChild:ea,removeChildFromContainer:ea,resetTextContent:e=>console.log("resetTextContent",e)}),na=i(null),oa=new Map;function ra(){const e=n(na);if(!e)throw new Error("No context available!");return e}function sa(e,n,o,r){var s;const i=oa.get(n);let a=null==i?void 0:i.root;const d=(null==i?void 0:i.state)||{state:null,api:null,type:"root",root:null,id:0,events:new Map};if(d.root=d,!a){const s=Ki(n,{onReady:()=>{null==o.onReady||o.onReady(),ta.updateContainer(t.createElement(na.Provider,{value:d},e),a,null,(()=>{}))},onEvent:e=>{if(e.type===Ji.Res_WinProc){const t=p(e.wParam),n=d.events.get(t);n&&n(e,d)}}},r);Object.assign(d,s),a=ta.createContainer(d,1,!1,null)}return oa.set(n,{root:a,state:d}),null!=(s=d.state)&&s.ready&&ta.updateContainer(t.createElement(na.Provider,{value:d},e),a,null,(()=>{})),d}function ia(e){const t=oa.get(e);if(!t)return;const{root:n}=t;ta.updateContainer(null,n,null,(()=>{oa.delete(e)}))}const aa=o((function(n,o){let{children:i,style:a,onReady:d,binaries:u,...l}=n;const c=r(null),p=r(null);return s((()=>{p.current=sa(i,c.current,{onReady:d},u),"function"==typeof o?o(p.current):o.current=p.current}),[i,d]),s((()=>{const e=c.current;return()=>ia(e)}),[]),t.createElement("div",e({ref:c,onContextMenu:e=>e.preventDefault(),onMouseMove:function(e){if(!p.current||!p.current.api)return;const t=c.current.getBoundingClientRect();p.current.api.setMousePos(e.clientX-t.x,e.clientY-t.y)},onMouseDown:e=>p.current.api.sendMouseEvent(!0,e.button),onMouseUp:e=>p.current.api.sendMouseEvent(!1,e.button)},l),t.createElement("div",{style:{whiteSpace:"pre",font:"14px monospace",lineHeight:"14px",...a||{}}}),t.createElement("canvas",{style:{display:"none"}}))}));var da=Object.freeze({__proto__:null});function ua(e){let{onClick:n,x:o,y:r,w:s,h:i,children:a}=e;return t.createElement("w95Window",{type:"Button",onEvent:e=>273===e.message&&n&&n(),params:1342177280,x:o,y:r,w:s,h:i},a)}function la(e){let{title:n,x:o,y:r,w:s,h:i,children:a,params:d}=e;return t.createElement("w95Window",{type:"WindowsApp",text:n||"",params:void 0===d?282001408:d,menuId:0,x:void 0===o?2147483648:o,y:void 0===r?2147483648:r,w:s,h:i},a)}function ca(e){let{onChange:n,x:o,y:s,w:i,h:d,children:u}=e;const l=r(),c=a((async(e,t)=>{if(l.current&&e.type===Ji.Res_WinProc&&273===e.message&&768===y(e.wParam)&&n){const e=await t.api.getWindowText(l.current.id);n(e)}}),[n]);return t.createElement("w95Window",{ref:l,type:"Edit",params:1342177280,extStyle:512,x:o,y:s,w:i,h:d,onEvent:c},u)}function pa(e){let{x:n,y:o,w:r,h:s,children:i}=e;return t.createElement("w95Window",{type:"Static",params:1342177280,x:n,y:o,w:r,h:s},i)}function ya(e){let{iconId:n,iconFile:o="shell32.dll",x:s,y:i,w:a,h:u}=e;const{api:l}=ra(),c=r();return d((()=>{!async function(){const e=await l.extractIcon(o,n);e&&c.current&&l.sendMessage(c.current.id,368,e,0)}()}),[]),t.createElement("w95Window",{ref:c,type:"Static",params:1342177283,x:s,y:i,w:a,h:u})}function ma(e){let{value:n,onChange:o,x:s,y:i,w:u,h:l,children:c}=e;const p=r(),y=a((async(e,t)=>{if(p.current&&e.type===Ji.Res_WinProc&&273===e.message){const e=await t.api.sendMessage(p.current.id,240,0,0);t.api.sendMessage(p.current.id,241,e?0:1,0),o&&o(0===e)}}),[o]),{api:m}=ra();return d((()=>{p.current&&m.sendMessage(p.current.id,241,n?1:0,0)}),[n]),t.createElement("w95Window",{ref:p,type:"Button",onEvent:y,params:1342177282,x:s,y:i,w:u,h:l},c)}export{Ns as BM_CLICK,Fs as BM_GETCHECK,js as BM_GETIMAGE,qs as BM_GETSTATE,ks as BM_SETCHECK,Vs as BM_SETIMAGE,zs as BM_SETSTATE,Gs as BM_SETSTYLE,Ps as BN_CLICKED,Hs as BN_DBLCLK,Bs as BN_DISABLE,Ds as BN_DOUBLECLICKED,Rs as BN_HILITE,Qs as BN_KILLFOCUS,Ss as BN_PAINT,Os as BN_PUSHED,Ls as BN_SETFOCUS,Ts as BN_UNHILITE,As as BN_UNPUSHED,Ys as BST_CHECKED,Zs as BST_FOCUS,Js as BST_INDETERMINATE,Ks as BST_PUSHED,Xs as BST_UNCHECKED,ds as BS_3STATE,us as BS_AUTO3STATE,is as BS_AUTOCHECKBOX,ps as BS_AUTORADIOBUTTON,hs as BS_BITMAP,fs as BS_BOTTOM,_s as BS_CENTER,ss as BS_CHECKBOX,rs as BS_DEFPUSHBUTTON,Es as BS_FLAT,ls as BS_GROUPBOX,ws as BS_ICON,Cs as BS_LEFT,ms as BS_LEFTTEXT,Ws as BS_MULTILINE,bs as BS_NOTIFY,ys as BS_OWNERDRAW,os as BS_PUSHBUTTON,Us as BS_PUSHLIKE,as as BS_RADIOBUTTON,gs as BS_RIGHT,Ms as BS_RIGHTBUTTON,vs as BS_TEXT,Is as BS_TOP,cs as BS_USERBUTTON,xs as BS_VCENTER,ua as Button,Qo as CW_USEDEFAULT,ma as Checkbox,Gi as CommandType,Fi as DWL_DLGPROC,Qi as DWL_MSGRESULT,ki as DWL_USER,Ni as DataType,dr as EC_LEFTMARGIN,ur as EC_RIGHTMARGIN,lr as EC_USEFONTINFO,yr as EIMES_CANCELCOMPSTRINFOCUS,mr as EIMES_COMPLETECOMPSTRKILLFOCUS,pr as EIMES_GETCOMPSTRATONCE,cr as EMSIS_COMPOSITIONSTRING,Dr as EM_CANUNDO,Kr as EM_CHARFROMPOS,Fr as EM_EMPTYUNDOBUFFER,Ar as EM_FMTLINES,kr as EM_GETFIRSTVISIBLELINE,Mr as EM_GETHANDLE,$r as EM_GETIMESTATUS,Yr as EM_GETLIMITTEXT,Tr as EM_GETLINE,Wr as EM_GETLINECOUNT,Vr as EM_GETMARGINS,xr as EM_GETMODIFY,Nr as EM_GETPASSWORDCHAR,hr as EM_GETRECT,vr as EM_GETSEL,Pr as EM_GETTHUMB,Gr as EM_GETWORDBREAKPROC,Br as EM_LIMITTEXT,Hr as EM_LINEFROMCHAR,br as EM_LINEINDEX,Sr as EM_LINELENGTH,Ir as EM_LINESCROLL,Jr as EM_POSFROMCHAR,Rr as EM_REPLACESEL,_r as EM_SCROLL,fr as EM_SCROLLCARET,Er as EM_SETHANDLE,Zr as EM_SETIMESTATUS,Xr as EM_SETLIMITTEXT,jr as EM_SETMARGINS,Ur as EM_SETMODIFY,Qr as EM_SETPASSWORDCHAR,qr as EM_SETREADONLY,Cr as EM_SETRECT,gr as EM_SETRECTNP,wr as EM_SETSEL,Lr as EM_SETTABSTOPS,zr as EM_SETWORDBREAKPROC,Or as EM_UNDO,nr as EN_CHANGE,rr as EN_ERRSPACE,ir as EN_HSCROLL,tr as EN_KILLFOCUS,sr as EN_MAXTEXT,er as EN_SETFOCUS,or as EN_UPDATE,ar as EN_VSCROLL,Xo as ES_AUTOHSCROLL,Vo as ES_AUTOVSCROLL,ko as ES_CENTER,Fo as ES_LEFT,No as ES_LOWERCASE,zo as ES_MULTILINE,Yo as ES_NOHIDESEL,$o as ES_NUMBER,Jo as ES_OEMCONVERT,jo as ES_PASSWORD,Ko as ES_READONLY,qo as ES_RIGHT,Go as ES_UPPERCASE,Zo as ES_WANTRETURN,ca as Edit,v as HIBYTE,y as HIWORD,ya as Icon,m as LOBYTE,p as LOWORD,pa as Label,da as React95Fiber,Ji as ResponseType,yi as SS_BITMAP,ii as SS_BLACKFRAME,oi as SS_BLACKRECT,ei as SS_CENTER,Ii as SS_CENTERIMAGE,Mi as SS_ELLIPSISMASK,Wi as SS_ENDELLIPSIS,mi as SS_ENHMETAFILE,hi as SS_ETCHEDFRAME,vi as SS_ETCHEDHORZ,wi as SS_ETCHEDVERT,ai as SS_GRAYFRAME,ri as SS_GRAYRECT,ni as SS_ICON,$s as SS_LEFT,ci as SS_LEFTNOWORDWRAP,gi as SS_NOPREFIX,_i as SS_NOTIFY,pi as SS_OWNERDRAW,bi as SS_PATHELLIPSIS,xi as SS_REALSIZEIMAGE,ti as SS_RIGHT,fi as SS_RIGHTJUST,li as SS_SIMPLE,Ui as SS_SUNKEN,Ci as SS_TYPEMASK,ui as SS_USERITEM,di as SS_WHITEFRAME,si as SS_WHITERECT,Ei as SS_WORDELLIPSIS,Si as STM_GETICON,Ti as STM_GETIMAGE,Hi as STM_MSGMAX,Pi as STM_SETICON,Ri as STM_SETIMAGE,Bi as STN_CLICKED,Di as STN_DBLCLK,Ai as STN_DISABLE,Oi as STN_ENABLE,ns as WB_ISDELIMITER,es as WB_LEFT,ts as WB_RIGHT,Li as WC_DIALOG,G as WM_ACTIVATE,N as WM_ACTIVATEAPP,j as WM_AFXFIRST,V as WM_AFXLAST,z as WM_APP,X as WM_ASKCBFORMATNAME,Y as WM_CANCELJOURNAL,J as WM_CANCELMODE,K as WM_CAPTURECHANGED,Z as WM_CHANGECBCHAIN,$ as WM_CHAR,ee as WM_CHARTOITEM,te as WM_CHILDACTIVATE,ne as WM_CLEAR,oe as WM_CLOSE,re as WM_COMMAND,se as WM_COMMNOTIFY,ie as WM_COMPACTING,ae as WM_COMPAREITEM,de as WM_CONTEXTMENU,ue as WM_COPY,le as WM_COPYDATA,ce as WM_CREATE,pe as WM_CTLCOLORBTN,ye as WM_CTLCOLORDLG,me as WM_CTLCOLOREDIT,ve as WM_CTLCOLORLISTBOX,we as WM_CTLCOLORMSGBOX,he as WM_CTLCOLORSCROLLBAR,Ce as WM_CTLCOLORSTATIC,ge as WM_CUT,_e as WM_DEADCHAR,Ie as WM_DELETEITEM,fe as WM_DESTROY,xe as WM_DESTROYCLIPBOARD,Ue as WM_DEVICECHANGE,We as WM_DEVMODECHANGE,be as WM_DISPLAYCHANGE,Ee as WM_DRAWCLIPBOARD,Me as WM_DRAWITEM,Pe as WM_DROPFILES,Se as WM_ENABLE,Re as WM_ENDSESSION,Te as WM_ENTERIDLE,Be as WM_ENTERMENULOOP,De as WM_ENTERSIZEMOVE,Oe as WM_ERASEBKGND,Ae as WM_EXITMENULOOP,He as WM_EXITSIZEMOVE,Le as WM_FONTCHANGE,Qe as WM_GETDLGCODE,Fe as WM_GETFONT,ke as WM_GETHOTKEY,qe as WM_GETICON,ze as WM_GETMINMAXINFO,Ge as WM_GETTEXT,Ne as WM_GETTEXTLENGTH,je as WM_HANDHELDFIRST,Ve as WM_HANDHELDLAST,Xe as WM_HELP,Ye as WM_HOTKEY,Je as WM_HSCROLL,Ke as WM_HSCROLLCLIPBOARD,Ze as WM_ICONERASEBKGND,$e as WM_INITDIALOG,et as WM_INITMENU,tt as WM_INITMENUPOPUP,nt as WM_INPUTLANGCHANGE,ot as WM_INPUTLANGCHANGEREQUEST,rt as WM_KEYDOWN,Zn as WM_KEYFIRST,$n as WM_KEYLAST,st as WM_KEYUP,it as WM_KILLFOCUS,so as WM_LBUTTONDBLCLK,oo as WM_LBUTTONDOWN,ro as WM_LBUTTONUP,po as WM_MBUTTONDBLCLK,lo as WM_MBUTTONDOWN,co as WM_MBUTTONUP,at as WM_MDIACTIVATE,dt as WM_MDICASCADE,ut as WM_MDICREATE,lt as WM_MDIDESTROY,ct as WM_MDIGETACTIVE,pt as WM_MDIICONARRANGE,yt as WM_MDIMAXIMIZE,mt as WM_MDINEXT,vt as WM_MDIREFRESHMENU,wt as WM_MDIRESTORE,ht as WM_MDISETMENU,Ct as WM_MDITILE,gt as WM_MEASUREITEM,Wt as WM_MENUCHAR,ft as WM_MENUCOMMAND,Ut as WM_MENUDRAG,xt as WM_MENUGETOBJECT,It as WM_MENURBUTTONUP,bt as WM_MENUSELECT,to as WM_MOUSEACTIVATE,mo as WM_MOUSEFIRST,wo as WM_MOUSEHOVER,vo as WM_MOUSELAST,ho as WM_MOUSELEAVE,no as WM_MOUSEMOVE,yo as WM_MOUSEWHEEL,Mt as WM_MOVE,Pt as WM_MOVING,St as WM_NCACTIVATE,Rt as WM_NCCALCSIZE,Tt as WM_NCCREATE,Bt as WM_NCDESTROY,Dt as WM_NCHITTEST,Ot as WM_NCLBUTTONDBLCLK,At as WM_NCLBUTTONDOWN,Ht as WM_NCLBUTTONUP,Lt as WM_NCMBUTTONDBLCLK,Qt as WM_NCMBUTTONDOWN,Ft as WM_NCMBUTTONUP,kt as WM_NCMOUSEMOVE,qt as WM_NCPAINT,zt as WM_NCRBUTTONDBLCLK,Gt as WM_NCRBUTTONDOWN,Nt as WM_NCRBUTTONUP,jt as WM_NEXTDLGCTL,Et as WM_NEXTMENU,Vt as WM_NOTIFY,Xt as WM_NOTIFYFORMAT,Yt as WM_NULL,Jt as WM_PAINT,Kt as WM_PAINTCLIPBOARD,Zt as WM_PAINTICON,$t as WM_PALETTECHANGED,en as WM_PALETTEISCHANGING,tn as WM_PARENTNOTIFY,nn as WM_PASTE,on as WM_PENWINFIRST,rn as WM_PENWINLAST,sn as WM_POWER,an as WM_POWERBROADCAST,dn as WM_PRINT,un as WM_PRINTCLIENT,ln as WM_QUERYDRAGICON,cn as WM_QUERYENDSESSION,pn as WM_QUERYNEWPALETTE,yn as WM_QUERYOPEN,mn as WM_QUEUESYNC,vn as WM_QUIT,uo as WM_RBUTTONDBLCLK,io as WM_RBUTTONDOWN,ao as WM_RBUTTONUP,wn as WM_RENDERALLFORMATS,hn as WM_RENDERFORMAT,Cn as WM_SETCURSOR,gn as WM_SETFOCUS,_n as WM_SETFONT,In as WM_SETHOTKEY,fn as WM_SETICON,xn as WM_SETREDRAW,Un as WM_SETTEXT,Wn as WM_SETTINGCHANGE,bn as WM_SHOWWINDOW,En as WM_SIZE,Mn as WM_SIZECLIPBOARD,Pn as WM_SIZING,Sn as WM_SPOOLERSTATUS,Rn as WM_STYLECHANGED,Tn as WM_STYLECHANGING,eo as WM_SYNCPAINT,Bn as WM_SYSCHAR,Dn as WM_SYSCOLORCHANGE,On as WM_SYSCOMMAND,An as WM_SYSDEADCHAR,Hn as WM_SYSKEYDOWN,Ln as WM_SYSKEYUP,Qn as WM_TCARD,Fn as WM_THEMECHANGED,kn as WM_TIMECHANGE,qn as WM_TIMER,zn as WM_UNDO,_t as WM_UNINITMENUPOPUP,Gn as WM_USER,Nn as WM_USERCHANGED,jn as WM_VKEYTOITEM,Vn as WM_VSCROLL,Xn as WM_VSCROLLCLIPBOARD,Yn as WM_WINDOWPOSCHANGED,Jn as WM_WINDOWPOSCHANGING,Kn as WM_WININICHANGE,w as WS_BORDER,h as WS_CAPTION,C as WS_CHILD,g as WS_CHILDWINDOW,_ as WS_CLIPCHILDREN,I as WS_CLIPSIBLINGS,f as WS_DISABLED,x as WS_DLGFRAME,Co as WS_EX_ACCEPTFILES,go as WS_EX_APPWINDOW,_o as WS_EX_CLIENTEDGE,Io as WS_EX_CONTEXTHELP,fo as WS_EX_CONTROLPARENT,xo as WS_EX_DLGMODALFRAME,Uo as WS_EX_LEFT,Wo as WS_EX_LEFTSCROLLBAR,bo as WS_EX_LTRREADING,Eo as WS_EX_MDICHILD,Mo as WS_EX_NOPARENTNOTIFY,Po as WS_EX_OVERLAPPEDWINDOW,So as WS_EX_PALETTEWINDOW,Ro as WS_EX_RIGHT,To as WS_EX_RIGHTSCROLLBAR,Bo as WS_EX_RTLREADING,Do as WS_EX_STATICEDGE,Oo as WS_EX_TOOLWINDOW,Ao as WS_EX_TOPMOST,Ho as WS_EX_TRANSPARENT,Lo as WS_EX_WINDOWEDGE,U as WS_GROUP,W as WS_HSCROLL,b as WS_ICONIC,E as WS_MAXIMIZE,M as WS_MAXIMIZEBOX,P as WS_MINIMIZE,S as WS_MINIMIZEBOX,R as WS_OVERLAPPED,k as WS_OVERLAPPEDWINDOW,T as WS_POPUP,q as WS_POPUPWINDOW,B as WS_SIZEBOX,D as WS_SYSMENU,O as WS_TABSTOP,A as WS_THICKFRAME,H as WS_TILED,L as WS_TILEDWINDOW,Q as WS_VISIBLE,F as WS_VSCROLL,aa as Win95,la as Window,Ki as initEmulator,sa as render,ia as unmountComponentAtNode,ra as useWin95}; | ||
import e from"@babel/runtime/helpers/esm/extends";import t,{useContext as n,forwardRef as o,useRef as r,useLayoutEffect as i,createContext as a,useEffect as s,useCallback as l}from"react";import{V86Starter as d}from"v86";import u from"react-reconciler";import{unstable_now as p}from"scheduler";const c=e=>65535&e,m=e=>e>>16&65535,y=e=>255&e,w=e=>e>>8&255,v=8388608,h=12582912,f=1073741824,g=1073741824,C=33554432,I=67108864,_=134217728,x=4194304,W=131072,U=1048576,S=536870912,b=16777216,E=65536,P=536870912,M=131072,R=0,T=2147483648,O=262144,F=524288,L=65536,D=262144,H=0,B=13565952,k=268435456,A=2097152,Q=13565952,N=-2138570752,j=32768,G=6,q=28,z=864,V=895,X=780,Y=75,J=31,K=533,Z=781,$=258,ee=47,te=34,ne=771,oe=16,re=273,ie=68,ae=65,se=57,le=123,de=769,ue=74,pe=1,ce=309,me=310,ye=307,we=308,ve=306,he=311,fe=312,ge=768,Ce=259,Ie=45,_e=2,xe=775,We=537,Ue=27,Se=126,be=776,Ee=43,Pe=563,Me=10,Re=22,Te=289,Oe=529,Fe=561,Le=20,De=530,He=562,Be=29,ke=135,Ae=49,Qe=51,Ne=127,je=36,Ge=13,qe=14,ze=856,Ve=863,Xe=83,Ye=786,Je=276,Ke=782,Ze=39,$e=272,et=278,tt=279,nt=81,ot=80,rt=256,it=257,at=8,st=546,lt=551,dt=544,ut=545,pt=553,ct=552,mt=549,yt=548,wt=564,vt=547,ht=560,ft=550,gt=44,Ct=293,It=290,_t=294,xt=292,Wt=291,Ut=288,St=287,bt=531,Et=3,Pt=534,Mt=134,Rt=131,Tt=129,Ot=130,Ft=132,Lt=163,Dt=161,Ht=162,Bt=169,kt=167,At=168,Qt=160,Nt=133,jt=166,Gt=164,qt=165,zt=40,Vt=78,Xt=85,Yt=0,Jt=15,Kt=777,Zt=38,$t=785,en=784,tn=528,nn=770,on=896,rn=911,an=72,sn=536,ln=791,dn=792,un=55,pn=17,cn=783,mn=19,yn=35,wn=18,vn=774,hn=773,fn=32,gn=7,Cn=48,In=50,_n=128,xn=11,Wn=12,Un=26,Sn=24,bn=5,En=779,Pn=532,Mn=42,Rn=125,Tn=124,On=262,Fn=21,Ln=274,Dn=263,Hn=260,Bn=261,kn=82,An=794,Qn=30,Nn=275,jn=772,Gn=1024,qn=84,zn=46,Vn=277,Xn=778,Yn=71,Jn=70,Kn=26,Zn=256,$n=264,eo=136,to=33,no=512,oo=513,ro=514,io=515,ao=516,so=517,lo=518,uo=519,po=520,co=521,mo=522,yo=512,wo=522,vo=673,ho=675,fo=16,go=262144,Co=512,Io=1024,_o=65536,xo=1,Wo=0,Uo=16384,So=0,bo=64,Eo=4,Po=768,Mo=392,Ro=4096,To=0,Oo=8192,Fo=131072,Lo=128,Do=8,Ho=32,Bo=256,ko=2147483648,Ao=0,Qo=1,No=2,jo=4,Go=8,qo=16,zo=32,Vo=64,Xo=128,Yo=256,Jo=1024,Ko=2048,Zo=4096,$o=8192,er=256,tr=512,nr=768,or=1024,rr=1280,ir=1281,ar=1537,sr=1538,lr=1,dr=2,ur=65535,pr=1,cr=1,mr=2,yr=4,wr=176,vr=177,hr=178,fr=179,gr=180,Cr=181,Ir=182,_r=183,xr=184,Wr=185,Ur=186,Sr=187,br=188,Er=189,Pr=190,Mr=193,Rr=194,Tr=196,Or=197,Fr=198,Lr=199,Dr=200,Hr=201,Br=203,kr=204,Ar=205,Qr=206,Nr=207,jr=208,Gr=209,qr=210,zr=211,Vr=212,Xr=197,Yr=213,Jr=214,Kr=215,Zr=216,$r=217,ei=0,ti=1,ni=2,oi=0,ri=1,ii=2,ai=3,si=4,li=5,di=6,ui=7,pi=8,ci=9,mi=11,yi=32,wi=0,vi=64,hi=128,fi=256,gi=512,Ci=768,Ii=1024,_i=2048,xi=3072,Wi=4096,Ui=8192,Si=16384,bi=32768,Ei=32,Pi=0,Mi=1,Ri=2,Ti=3,Oi=4,Fi=5,Li=2,Di=3,Hi=5,Bi=6,ki=7,Ai=240,Qi=241,Ni=242,ji=243,Gi=244,qi=245,zi=246,Vi=247,Xi=0,Yi=1,Ji=2,Ki=4,Zi=8,$i=0,ea=1,ta=2,na=3,oa=4,ra=5,ia=6,aa=7,sa=8,la=9,da=10,ua=11,pa=12,ca=13,ma=14,ya=15,wa=16,va=17,ha=18,fa=31,ga=128,Ca=256,Ia=512,_a=1024,xa=2048,Wa=4096,Ua=16384,Sa=32768,ba=49152,Ea=49152,Pa=368,Ma=369,Ra=370,Ta=371,Oa=0,Fa=1,La=2,Da=3,Ha=372,Ba=32770,ka=0,Aa=4,Qa=8,Na=-4,ja=-6,Ga=-8,qa=-16,za=-20,Va=-21,Xa=-12;class Ya{constructor(e,t){this.outQueue=[],this.inQueue=[],e.io.register_write(1284,this,(()=>console.warn("Invalid 8 bit write!")),(()=>console.warn("Invalid 16 bit write!")),(e=>{const n=255&e;e>>8>0?this.inQueue.push(n):this.inQueue.length>0&&(t(new Uint8ClampedArray(this.inQueue).buffer),this.inQueue=[])})),e.io.register_read(1280,this,(()=>(console.warn("Invalid 8 bit read!"),0)),(()=>(console.warn("Invalid 16 bit read!"),0)),(()=>{var e;const t=(null==(e=this.outQueue[0])?void 0:e.length)>0&&this.outQueue[0]||this.outQueue.shift();if(!t)return 0;const n=t.shift();return void 0===n?0:n|t.length+1<<8}))}sendData(e){const t=new Uint8ClampedArray(e);this.outQueue.push(Array.from(t))}}new TextEncoder;const Ja=new TextDecoder;let Ka,Za,$a;function es(e,t){const n=t.map((e=>4+(e.type===Za.String?e.value.length+1+4:4))).reduce(((e,t)=>e+t),0),o=new ArrayBuffer(12+n),r=new DataView(o);r.setUint32(0,49325,!0),r.setUint32(4,e,!0),r.setUint32(8,t.length,!0);let i=o.byteLength;for(let e=0;e<t.length;e++){const n=t[e];if(r.setUint32(12+8*e,n.type,!0),n.type===Za.Int)r.setInt32(12+8*e+4,n.value,!0);else if(n.type===Za.UInt)r.setUint32(12+8*e+4,n.value,!0);else if(n.type===Za.Float)r.setFloat32(12+8*e+4,n.value,!0);else if(n.type===Za.String){const t=n.value;i--,r.setUint8(i,0);for(let e=t.length-1;e>=0;e--)i--,r.setUint8(i,t.charCodeAt(e));r.setUint32(12+8*e+4,i,!0)}}return o}function ts(e,t,n,o){void 0===o&&(o={scale:.5,fromState:!1});const r=new d({screen_container:e,wasm_fn:n.v86WASM?(i=n.v86WASM,async e=>(await WebAssembly.instantiate(i,e)).instance.exports):n.v86WASMFn,bios:n.seabios?{buffer:n.seabios}:{url:n.seabiosUrl},vga_bios:n.vgabios?{buffer:n.vgabios}:{url:n.vgabiosUrl},hda:n.osImg?{buffer:n.osImg}:{url:n.osImgUrl},boot_order:306,memory_size:33554432,disable_mouse:!0,autostart:o.fromState||!0});var i;r.add_listener("emulator-started",(()=>{r.v86.cpu.devices.commBus=new Ya(r.v86.cpu,(e=>{const n=function(e){if(e.byteLength<4)return null;const t=new DataView(e),n=t.getUint32(0,!0);return n===$a.Res_WinProc?20!==e.byteLength?null:{type:n,hwnd:t.getUint32(4,!0),message:t.getUint32(8,!0),wParam:t.getUint32(12,!0),lParam:t.getInt32(16,!0)}:n===$a.Res_CmdOutputHandle?12!==e.byteLength?null:{type:n,seq:t.getUint32(4,!0),handle:t.getUint32(8,!0)}:n===$a.Res_CmdOutputLong?e.byteLength!==12+t.getUint32(8,!0)?null:{type:n,seq:t.getUint32(4,!0),length:t.getUint32(8,!0),data:e.slice(12)}:{type:n}}(e);if(n){var o;if(null==t.onEvent||t.onEvent(n),(n.type===$a.Res_CmdOutputHandle||n.type===$a.Res_CmdOutputLong)&&p.has(n.seq))null==(o=p.get(n.seq))||o(n),p.delete(n.seq);a.ready||(null==t.onReady||t.onReady(),a.ready=!0)}}))}));const a={v86Emulator:r,ready:!1};function s(e){const t=r.v86.cpu.devices.commBus;t&&t.sendData(e)}let l=0;function u(){const e=l;return l=l+1&16777215,e}const p=new Map,c=[],m={sendSerial:s,startBridge(){r.keyboard_send_scancodes([29,19]),r.keyboard_send_scancodes([157,147]),r.keyboard_send_text('"c:\\windows\\start menu\\Programs\\StartUp\\bridge.exe"'),r.keyboard_send_scancodes([28]),r.keyboard_send_scancodes([156])},setMousePos(e,t){a.ready&&s(es(Ka.Cmd_SetCursorPos,[{type:Za.Int,value:e},{type:Za.Int,value:t}]))},setWindowPos(e,t,n,o,r){s(es(Ka.Cmd_SetWindowPos,[{type:Za.UInt,value:e},{type:Za.Int,value:t},{type:Za.Int,value:n},{type:Za.Int,value:o},{type:Za.Int,value:r}]))},createWindow(e){s(es(Ka.Cmd_CreateWindow,[{type:Za.UInt,value:e.id},{type:Za.UInt,value:e.extStyle},{type:Za.String,value:e.type},{type:Za.String,value:e.text},{type:Za.UInt,value:e.params},{type:Za.Int,value:e.x},{type:Za.Int,value:e.y},{type:Za.Int,value:e.w},{type:Za.Int,value:e.h},{type:Za.UInt,value:e.parentId},{type:Za.UInt,value:e.menuId}]))},destroyWindow(e){s(es(Ka.Cmd_DestroyWindow,[{type:Za.UInt,value:e}]))},setWindowText(e,t){s(es(Ka.Cmd_SetWindowText,[{type:Za.UInt,value:e},{type:Za.String,value:t}]))},getWindowText:e=>new Promise((t=>{const n=u();p.set(n,(e=>{e.type===$a.Res_CmdOutputLong&&t(Ja.decode(e.data).split("\0")[0])})),s(es(Ka.Cmd_GetWindowText,[{type:Za.UInt,value:e},{type:Za.UInt,value:n}]))})),extractIcon:(e,t)=>new Promise((n=>{const o=u();p.set(o,(o=>{o.type===$a.Res_CmdOutputHandle&&(console.timeEnd("extractIcon"+e+t),n(o.handle))})),console.time("extractIcon"+e+t),s(es(Ka.Cmd_ExtractIcon,[{type:Za.UInt,value:o},{type:Za.String,value:e},{type:Za.UInt,value:t}]))})),destroyIcon(e){s(es(Ka.Cmd_DestroyIcon,[{type:Za.UInt,value:e}]))},sendMessage:(e,t,n,o)=>new Promise((r=>{const i=u();p.set(i,(e=>{e.type===$a.Res_CmdOutputHandle&&r(e.handle)})),s(es(Ka.Cmd_SendMessage,[{type:Za.UInt,value:e},{type:Za.UInt,value:t},{type:Za.UInt,value:n},{type:Za.Int,value:o},{type:Za.UInt,value:i}]))})),setWindowLong(e,t,n){s(es(Ka.Cmd_SetWindowLong,[{type:Za.UInt,value:e},{type:Za.Int,value:t},{type:Za.UInt,value:n}]))},getWindowLong:(e,t)=>new Promise((n=>{const o=u();p.set(o,(e=>{e.type===$a.Res_CmdOutputHandle&&n(e.handle)})),s(es(Ka.Cmd_GetWindowLong,[{type:Za.UInt,value:e},{type:Za.Int,value:t},{type:Za.UInt,value:o}]))})),createFont(e){const t=c.find((t=>t.lfWidth===e.lfWidth&&t.lfHeight===e.lfHeight&&t.lfWeight===e.lfWeight&&t.lfItalic===e.lfItalic&&t.lfUnderline===e.lfUnderline&&t.lfStrikeOut===e.lfStrikeOut&&t.lfFaceName===e.lfFaceName));return t?t.handle:new Promise((t=>{const n=u();p.set(n,(n=>{n.type===$a.Res_CmdOutputHandle&&(c.push({...e,handle:n.handle}),t(n.handle))})),s(es(Ka.Cmd_CreateFont,[{type:Za.UInt,value:n},{type:Za.Int,value:e.lfWidth},{type:Za.Int,value:e.lfHeight},{type:Za.Int,value:e.lfWeight},{type:Za.Int,value:e.lfItalic},{type:Za.Int,value:e.lfUnderline},{type:Za.Int,value:e.lfStrikeOut},...e.lfFaceName?[{type:Za.String,value:e.lfFaceName}]:[]]))}))},deleteObject(e){s(es(Ka.Cmd_DeleteObject,[{type:Za.UInt,value:e}]))},showWindow(e,t){s(es(Ka.Cmd_ShowWindow,[{type:Za.UInt,value:e},{type:Za.Int,value:t}]))},sendMouseEvent(e,t){e?0===t?s(es(Ka.Cmd_MouseEvent,[{type:Za.UInt,value:2}])):2===t&&s(es(Ka.Cmd_MouseEvent,[{type:Za.UInt,value:8}])):0===t?s(es(Ka.Cmd_MouseEvent,[{type:Za.UInt,value:4}])):2===t&&s(es(Ka.Cmd_MouseEvent,[{type:Za.UInt,value:16}]))}};return setInterval((()=>{s(es(Ka.Cmd_Ping,[]))}),2e3),{state:a,api:m}}!function(e){e[e.Cmd_Invalid=0]="Cmd_Invalid",e[e.Cmd_SetCursorPos=1]="Cmd_SetCursorPos",e[e.Cmd_MouseEvent=2]="Cmd_MouseEvent",e[e.Cmd_SetWindowPos=3]="Cmd_SetWindowPos",e[e.Cmd_CreateWindow=4]="Cmd_CreateWindow",e[e.Cmd_DestroyWindow=5]="Cmd_DestroyWindow",e[e.Cmd_SetWindowText=6]="Cmd_SetWindowText",e[e.Cmd_GetWindowText=7]="Cmd_GetWindowText",e[e.Cmd_MessageBoxEx=8]="Cmd_MessageBoxEx",e[e.Cmd_Ping=9]="Cmd_Ping",e[e.Cmd_ExtractIcon=10]="Cmd_ExtractIcon",e[e.Cmd_DestroyIcon=11]="Cmd_DestroyIcon",e[e.Cmd_SendMessage=12]="Cmd_SendMessage",e[e.Cmd_SetWindowLong=13]="Cmd_SetWindowLong",e[e.Cmd_GetWindowLong=14]="Cmd_GetWindowLong",e[e.Cmd_CreateFont=15]="Cmd_CreateFont",e[e.Cmd_DeleteObject=16]="Cmd_DeleteObject",e[e.Cmd_ShowWindow=17]="Cmd_ShowWindow"}(Ka||(Ka={})),function(e){e[e.Null=0]="Null",e[e.Int=1]="Int",e[e.UInt=2]="UInt",e[e.Float=3]="Float",e[e.String=4]="String"}(Za||(Za={})),function(e){e[e.Res_Invalid=0]="Res_Invalid",e[e.Res_Ping=1]="Res_Ping",e[e.Res_WinProc=2]="Res_WinProc",e[e.Res_CmdOutputHandle=3]="Res_CmdOutputHandle",e[e.Res_CmdOutputLong=4]="Res_CmdOutputLong"}($a||($a={}));let ns=3;async function os(e,t){if("w95Window"===t.type){const o=void 0!==t.props.menuId?t.props.menuId:t.id||0;var n;if(t.root.api.createWindow({id:t.id,type:t.props.windowType,text:t.props.text||"",params:t.props.params,x:t.props.x,y:t.props.y,w:t.props.w,h:t.props.h,parentId:"w95Window"===e.type?e.id:0,menuId:o,extStyle:t.props.extStyle||0}),t.props.onEvent)t.root.events.get(o)||t.root.events.set(o,[]),null==(n=t.root.events.get(o))||n.push(t.props.onEvent)}if("w95Font"===t.type&&"w95Window"===e.type){const n=await t.root.api.createFont({lfWidth:t.props.width||0,lfHeight:t.props.height||0,lfWeight:t.props.weight||0,lfItalic:t.props.italic?1:0,lfUnderline:t.props.underline?1:0,lfStrikeOut:t.props.strikeOut?1:0,lfFaceName:t.props.faceName});await t.root.api.sendMessage(e.id,48,n,1)}}function rs(e,t){if("w95Window"===t.type){if(t.props.onEvent){const e=t.root.events.get(t.id);if(e){const n=e.filter((e=>e!==t.props.onEvent));n.length>0?t.root.events.set(t.id,n):t.root.events.delete(t.id)}}t.root.api.destroyWindow(t.id)}}const is=u({getPublicInstance:e=>e,getRootHostContext:()=>({}),getChildHostContext:()=>({}),prepareForCommit:()=>null,resetAfterCommit:()=>({}),scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,now:p,isPrimaryRenderer:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,preparePortalMount:()=>{},hideInstance:()=>{},hideTextInstance:()=>{},unhideInstance:()=>{},unhideTextInstance:()=>{},clearContainer:()=>!1,createInstance(e,t,n){let{type:o,...r}=t;if("w95Window"===e)return{type:e,props:{windowType:o,...r},id:ns++,root:n.root};if("w95Font"===e)return{type:e,props:r,root:n.root};throw new Error("Unknown type!")},createTextInstance:e=>({type:"text",content:e}),appendInitialChild(e,t){"text"===t.type&&"w95Window"===e.type?e.props.text=t.content:(e.children=e.children||[],e.children.push(t))},finalizeInitialChildren:(e,t,n)=>!1,prepareUpdate:(e,t,n,o)=>!0,shouldSetTextContent:(e,t)=>!1,appendChild:os,appendChildToContainer:function e(t,n){var o;os(t,n),null==(o=n.children)||o.forEach((t=>e(n,t)))},commitTextUpdate(e,t,n){},commitMount:e=>console.log("commitMount",e),commitUpdate(e,t,n,o,r,i){"w95Window"===e.type&&("string"==typeof r.children&&r.children!==o.children?e.root.api.setWindowText(e.id,r.children):"string"==typeof r.text&&r.text!==o.text?e.root.api.setWindowText(e.id,r.text):r.x!==o.x||r.y!==o.y||r.w!==o.w||r.h!==o.h?e.root.api.setWindowPos(e.id,r.x,r.y,r.w,r.h):r.params!==o.params?e.root.api.setWindowLong(e.id,-16,r.params):"number"==typeof r.extStyle&&r.extStyle!==o.extStyle&&e.root.api.setWindowLong(e.id,-20,r.extStyle))},insertBefore:e=>console.log("insertBefore",e),insertInContainerBefore:(e,t,n)=>console.log("insertInContainerBefore",{parentInstance:e,child:t,beforeChild:n}),removeChild:rs,removeChildFromContainer:rs,resetTextContent:e=>console.log("resetTextContent",e)}),as=a(null),ss=new Map;function ls(){const e=n(as);if(!e)throw new Error("No context available!");return e}function ds(e,n,o,r){var i;const a=ss.get(n);let s=null==a?void 0:a.root;const l=(null==a?void 0:a.state)||{state:null,api:null,type:"root",root:null,id:0,events:new Map};if(l.root=l,!s){const i=ts(n,{onReady:()=>{null==o.onReady||o.onReady(),is.updateContainer(t.createElement(as.Provider,{value:l},e),s,null,(()=>{}))},onEvent:e=>{if(e.type===$a.Res_WinProc){const t=c(e.wParam),n=l.events.get(t);n&&n.forEach((t=>t(e)))}}},r);Object.assign(l,i),s=is.createContainer(l,1,!1,null)}return ss.set(n,{root:s,state:l}),null!=(i=l.state)&&i.ready&&is.updateContainer(t.createElement(as.Provider,{value:l},e),s,null,(()=>{})),l}function us(e){const t=ss.get(e);if(!t)return;const{root:n}=t;is.updateContainer(null,n,null,(()=>{ss.delete(e)}))}const ps=o((function(n,o){let{children:a,style:s,onReady:l,binaries:d,...u}=n;const p=r(null),c=r(null);return i((()=>{c.current=ds(a,p.current,{onReady:l},d),"function"==typeof o?o(c.current):o&&(o.current=c.current)}),[a,l]),i((()=>{const e=p.current;return()=>us(e)}),[]),t.createElement("div",e({ref:p,onContextMenu:e=>e.preventDefault(),onMouseMove:function(e){if(!c.current||!c.current.api)return;const t=p.current.getBoundingClientRect();c.current.api.setMousePos(e.clientX-t.x,e.clientY-t.y)},onMouseDown:e=>c.current.api.sendMouseEvent(!0,e.button),onMouseUp:e=>c.current.api.sendMouseEvent(!1,e.button)},u),t.createElement("div",{style:{whiteSpace:"pre",font:"14px monospace",lineHeight:"14px",...s||{}}}),t.createElement("canvas",{style:{display:"none"}}))}));var cs=Object.freeze({__proto__:null});function ms(e){let{onClick:n,x:o,y:r,w:i,h:a,children:s}=e;return t.createElement("w95Window",{type:"Button",onEvent:e=>273===e.message&&n&&n(),params:1342177280,x:o,y:r,w:i,h:a},s)}function ys(e){let{title:n,x:o,y:i,w:a,h:d,children:u,params:p,open:c,onClose:m}=e;const y=r(),{api:w}=ls();s((()=>{var e;y.current&&w.showWindow(null==(e=y.current)?void 0:e.id,!1===c?0:1)}),[c]);const v=l((e=>{var t;e.type===$a.Res_WinProc&&16===e.message&&e.hwnd===(null==(t=y.current)?void 0:t.id)&&m&&m()}),[m]);return t.createElement("w95Window",{ref:y,type:"WindowsApp",text:n||"",params:void 0===p?13565952:p,menuId:0,x:void 0===o?2147483648:o,y:void 0===i?2147483648:i,w:a,h:d,onEvent:v},u)}function ws(e){let{onChange:n,x:o,y:i,w:a,h:s,children:d,params:u=0}=e;const p=r(),c=l((async(e,t)=>{if(p.current&&e.type===$a.Res_WinProc&&273===e.message&&768===m(e.wParam)&&n){const e=await t.api.getWindowText(p.current.id);n(e)}}),[n]);return t.createElement("w95Window",{ref:p,type:"Edit",params:1342177280|u,extStyle:512,x:o,y:i,w:a,h:s,onEvent:c},d)}function vs(e){let{x:n,y:o,w:r,h:i,children:a}=e;return t.createElement("w95Window",{type:"Static",params:1342177280,x:n,y:o,w:r,h:i},a)}function hs(e){let{iconId:n,iconFile:o="shell32.dll",x:i,y:a,w:l,h:d}=e;const{api:u}=ls(),p=r();return s((()=>{!async function(){const e=await u.extractIcon(o,n);e&&p.current&&u.sendMessage(p.current.id,368,e,0)}()}),[]),t.createElement("w95Window",{ref:p,type:"Static",params:1342177283,x:i,y:a,w:l,h:d})}function fs(e){let{value:n,onChange:o,x:i,y:a,w:d,h:u,children:p}=e;const{api:c}=ls(),m=r(),y=l((async e=>{if(m.current&&e.type===$a.Res_WinProc&&273===e.message){const e=await c.sendMessage(m.current.id,240,0,0);c.sendMessage(m.current.id,241,e?0:1,0),o&&o(0===e)}}),[o]);return s((()=>{m.current&&c.sendMessage(m.current.id,241,n?1:0,0)}),[n]),t.createElement("w95Window",{ref:m,type:"Button",onEvent:y,params:1342177282,x:i,y:a,w:d,h:u},p)}export{qi as BM_CLICK,Ai as BM_GETCHECK,zi as BM_GETIMAGE,Ni as BM_GETSTATE,Qi as BM_SETCHECK,Vi as BM_SETIMAGE,ji as BM_SETSTATE,Gi as BM_SETSTYLE,Pi as BN_CLICKED,Hi as BN_DBLCLK,Oi as BN_DISABLE,Fi as BN_DOUBLECLICKED,Ri as BN_HILITE,ki as BN_KILLFOCUS,Mi as BN_PAINT,Li as BN_PUSHED,Bi as BN_SETFOCUS,Ti as BN_UNHILITE,Di as BN_UNPUSHED,Yi as BST_CHECKED,Zi as BST_FOCUS,Ji as BST_INDETERMINATE,Ki as BST_PUSHED,Xi as BST_UNCHECKED,li as BS_3STATE,di as BS_AUTO3STATE,ai as BS_AUTOCHECKBOX,ci as BS_AUTORADIOBUTTON,hi as BS_BITMAP,_i as BS_BOTTOM,Ci as BS_CENTER,ii as BS_CHECKBOX,ri as BS_DEFPUSHBUTTON,bi as BS_FLAT,ui as BS_GROUPBOX,vi as BS_ICON,fi as BS_LEFT,yi as BS_LEFTTEXT,Ui as BS_MULTILINE,Si as BS_NOTIFY,mi as BS_OWNERDRAW,oi as BS_PUSHBUTTON,Wi as BS_PUSHLIKE,si as BS_RADIOBUTTON,gi as BS_RIGHT,Ei as BS_RIGHTBUTTON,wi as BS_TEXT,Ii as BS_TOP,pi as BS_USERBUTTON,xi as BS_VCENTER,ms as Button,ko as CW_USEDEFAULT,fs as Checkbox,Ka as CommandType,Aa as DWL_DLGPROC,ka as DWL_MSGRESULT,Qa as DWL_USER,Za as DataType,lr as EC_LEFTMARGIN,dr as EC_RIGHTMARGIN,ur as EC_USEFONTINFO,mr as EIMES_CANCELCOMPSTRINFOCUS,yr as EIMES_COMPLETECOMPSTRKILLFOCUS,cr as EIMES_GETCOMPSTRATONCE,pr as EMSIS_COMPOSITIONSTRING,Fr as EM_CANUNDO,Kr as EM_CHARFROMPOS,Ar as EM_EMPTYUNDOBUFFER,Dr as EM_FMTLINES,Qr as EM_GETFIRSTVISIBLELINE,Er as EM_GETHANDLE,$r as EM_GETIMESTATUS,Yr as EM_GETLIMITTEXT,Tr as EM_GETLINE,Ur as EM_GETLINECOUNT,Vr as EM_GETMARGINS,xr as EM_GETMODIFY,qr as EM_GETPASSWORDCHAR,hr as EM_GETRECT,wr as EM_GETSEL,Pr as EM_GETTHUMB,Gr as EM_GETWORDBREAKPROC,Or as EM_LIMITTEXT,Hr as EM_LINEFROMCHAR,Sr as EM_LINEINDEX,Mr as EM_LINELENGTH,Ir as EM_LINESCROLL,Jr as EM_POSFROMCHAR,Rr as EM_REPLACESEL,Cr as EM_SCROLL,_r as EM_SCROLLCARET,br as EM_SETHANDLE,Zr as EM_SETIMESTATUS,Xr as EM_SETLIMITTEXT,zr as EM_SETMARGINS,Wr as EM_SETMODIFY,kr as EM_SETPASSWORDCHAR,Nr as EM_SETREADONLY,fr as EM_SETRECT,gr as EM_SETRECTNP,vr as EM_SETSEL,Br as EM_SETTABSTOPS,jr as EM_SETWORDBREAKPROC,Lr as EM_UNDO,nr as EN_CHANGE,rr as EN_ERRSPACE,ar as EN_HSCROLL,tr as EN_KILLFOCUS,ir as EN_MAXTEXT,er as EN_SETFOCUS,or as EN_UPDATE,sr as EN_VSCROLL,Xo as ES_AUTOHSCROLL,Vo as ES_AUTOVSCROLL,Qo as ES_CENTER,Ao as ES_LEFT,qo as ES_LOWERCASE,jo as ES_MULTILINE,Yo as ES_NOHIDESEL,$o as ES_NUMBER,Jo as ES_OEMCONVERT,zo as ES_PASSWORD,Ko as ES_READONLY,No as ES_RIGHT,Go as ES_UPPERCASE,Zo as ES_WANTRETURN,ws as Edit,za as GWL_EXSTYLE,ja as GWL_HINSTANCE,Ga as GWL_HWNDPARENT,Xa as GWL_ID,qa as GWL_STYLE,Va as GWL_USERDATA,Na as GWL_WNDPROC,w as HIBYTE,m as HIWORD,hs as Icon,y as LOBYTE,c as LOWORD,vs as Label,cs as React95Fiber,$a as ResponseType,ma as SS_BITMAP,aa as SS_BLACKFRAME,oa as SS_BLACKRECT,ea as SS_CENTER,Ia as SS_CENTERIMAGE,Ea as SS_ELLIPSISMASK,Ua as SS_ENDELLIPSIS,ya as SS_ENHMETAFILE,ha as SS_ETCHEDFRAME,wa as SS_ETCHEDHORZ,va as SS_ETCHEDVERT,sa as SS_GRAYFRAME,ra as SS_GRAYRECT,na as SS_ICON,$i as SS_LEFT,pa as SS_LEFTNOWORDWRAP,ga as SS_NOPREFIX,Ca as SS_NOTIFY,ca as SS_OWNERDRAW,Sa as SS_PATHELLIPSIS,xa as SS_REALSIZEIMAGE,ta as SS_RIGHT,_a as SS_RIGHTJUST,ua as SS_SIMPLE,Wa as SS_SUNKEN,fa as SS_TYPEMASK,da as SS_USERITEM,la as SS_WHITEFRAME,ia as SS_WHITERECT,ba as SS_WORDELLIPSIS,Ma as STM_GETICON,Ta as STM_GETIMAGE,Ha as STM_MSGMAX,Pa as STM_SETICON,Ra as STM_SETIMAGE,Oa as STN_CLICKED,Fa as STN_DBLCLK,Da as STN_DISABLE,La as STN_ENABLE,ni as WB_ISDELIMITER,ei as WB_LEFT,ti as WB_RIGHT,Ba as WC_DIALOG,G as WM_ACTIVATE,q as WM_ACTIVATEAPP,z as WM_AFXFIRST,V as WM_AFXLAST,j as WM_APP,X as WM_ASKCBFORMATNAME,Y as WM_CANCELJOURNAL,J as WM_CANCELMODE,K as WM_CAPTURECHANGED,Z as WM_CHANGECBCHAIN,$ as WM_CHAR,ee as WM_CHARTOITEM,te as WM_CHILDACTIVATE,ne as WM_CLEAR,oe as WM_CLOSE,re as WM_COMMAND,ie as WM_COMMNOTIFY,ae as WM_COMPACTING,se as WM_COMPAREITEM,le as WM_CONTEXTMENU,de as WM_COPY,ue as WM_COPYDATA,pe as WM_CREATE,ce as WM_CTLCOLORBTN,me as WM_CTLCOLORDLG,ye as WM_CTLCOLOREDIT,we as WM_CTLCOLORLISTBOX,ve as WM_CTLCOLORMSGBOX,he as WM_CTLCOLORSCROLLBAR,fe as WM_CTLCOLORSTATIC,ge as WM_CUT,Ce as WM_DEADCHAR,Ie as WM_DELETEITEM,_e as WM_DESTROY,xe as WM_DESTROYCLIPBOARD,We as WM_DEVICECHANGE,Ue as WM_DEVMODECHANGE,Se as WM_DISPLAYCHANGE,be as WM_DRAWCLIPBOARD,Ee as WM_DRAWITEM,Pe as WM_DROPFILES,Me as WM_ENABLE,Re as WM_ENDSESSION,Te as WM_ENTERIDLE,Oe as WM_ENTERMENULOOP,Fe as WM_ENTERSIZEMOVE,Le as WM_ERASEBKGND,De as WM_EXITMENULOOP,He as WM_EXITSIZEMOVE,Be as WM_FONTCHANGE,ke as WM_GETDLGCODE,Ae as WM_GETFONT,Qe as WM_GETHOTKEY,Ne as WM_GETICON,je as WM_GETMINMAXINFO,Ge as WM_GETTEXT,qe as WM_GETTEXTLENGTH,ze as WM_HANDHELDFIRST,Ve as WM_HANDHELDLAST,Xe as WM_HELP,Ye as WM_HOTKEY,Je as WM_HSCROLL,Ke as WM_HSCROLLCLIPBOARD,Ze as WM_ICONERASEBKGND,$e as WM_INITDIALOG,et as WM_INITMENU,tt as WM_INITMENUPOPUP,nt as WM_INPUTLANGCHANGE,ot as WM_INPUTLANGCHANGEREQUEST,rt as WM_KEYDOWN,Zn as WM_KEYFIRST,$n as WM_KEYLAST,it as WM_KEYUP,at as WM_KILLFOCUS,io as WM_LBUTTONDBLCLK,oo as WM_LBUTTONDOWN,ro as WM_LBUTTONUP,co as WM_MBUTTONDBLCLK,uo as WM_MBUTTONDOWN,po as WM_MBUTTONUP,st as WM_MDIACTIVATE,lt as WM_MDICASCADE,dt as WM_MDICREATE,ut as WM_MDIDESTROY,pt as WM_MDIGETACTIVE,ct as WM_MDIICONARRANGE,mt as WM_MDIMAXIMIZE,yt as WM_MDINEXT,wt as WM_MDIREFRESHMENU,vt as WM_MDIRESTORE,ht as WM_MDISETMENU,ft as WM_MDITILE,gt as WM_MEASUREITEM,Ut as WM_MENUCHAR,_t as WM_MENUCOMMAND,Wt as WM_MENUDRAG,xt as WM_MENUGETOBJECT,It as WM_MENURBUTTONUP,St as WM_MENUSELECT,to as WM_MOUSEACTIVATE,yo as WM_MOUSEFIRST,vo as WM_MOUSEHOVER,wo as WM_MOUSELAST,ho as WM_MOUSELEAVE,no as WM_MOUSEMOVE,mo as WM_MOUSEWHEEL,Et as WM_MOVE,Pt as WM_MOVING,Mt as WM_NCACTIVATE,Rt as WM_NCCALCSIZE,Tt as WM_NCCREATE,Ot as WM_NCDESTROY,Ft as WM_NCHITTEST,Lt as WM_NCLBUTTONDBLCLK,Dt as WM_NCLBUTTONDOWN,Ht as WM_NCLBUTTONUP,Bt as WM_NCMBUTTONDBLCLK,kt as WM_NCMBUTTONDOWN,At as WM_NCMBUTTONUP,Qt as WM_NCMOUSEMOVE,Nt as WM_NCPAINT,jt as WM_NCRBUTTONDBLCLK,Gt as WM_NCRBUTTONDOWN,qt as WM_NCRBUTTONUP,zt as WM_NEXTDLGCTL,bt as WM_NEXTMENU,Vt as WM_NOTIFY,Xt as WM_NOTIFYFORMAT,Yt as WM_NULL,Jt as WM_PAINT,Kt as WM_PAINTCLIPBOARD,Zt as WM_PAINTICON,$t as WM_PALETTECHANGED,en as WM_PALETTEISCHANGING,tn as WM_PARENTNOTIFY,nn as WM_PASTE,on as WM_PENWINFIRST,rn as WM_PENWINLAST,an as WM_POWER,sn as WM_POWERBROADCAST,ln as WM_PRINT,dn as WM_PRINTCLIENT,un as WM_QUERYDRAGICON,pn as WM_QUERYENDSESSION,cn as WM_QUERYNEWPALETTE,mn as WM_QUERYOPEN,yn as WM_QUEUESYNC,wn as WM_QUIT,lo as WM_RBUTTONDBLCLK,ao as WM_RBUTTONDOWN,so as WM_RBUTTONUP,vn as WM_RENDERALLFORMATS,hn as WM_RENDERFORMAT,fn as WM_SETCURSOR,gn as WM_SETFOCUS,Cn as WM_SETFONT,In as WM_SETHOTKEY,_n as WM_SETICON,xn as WM_SETREDRAW,Wn as WM_SETTEXT,Un as WM_SETTINGCHANGE,Sn as WM_SHOWWINDOW,bn as WM_SIZE,En as WM_SIZECLIPBOARD,Pn as WM_SIZING,Mn as WM_SPOOLERSTATUS,Rn as WM_STYLECHANGED,Tn as WM_STYLECHANGING,eo as WM_SYNCPAINT,On as WM_SYSCHAR,Fn as WM_SYSCOLORCHANGE,Ln as WM_SYSCOMMAND,Dn as WM_SYSDEADCHAR,Hn as WM_SYSKEYDOWN,Bn as WM_SYSKEYUP,kn as WM_TCARD,An as WM_THEMECHANGED,Qn as WM_TIMECHANGE,Nn as WM_TIMER,jn as WM_UNDO,Ct as WM_UNINITMENUPOPUP,Gn as WM_USER,qn as WM_USERCHANGED,zn as WM_VKEYTOITEM,Vn as WM_VSCROLL,Xn as WM_VSCROLLCLIPBOARD,Yn as WM_WINDOWPOSCHANGED,Jn as WM_WINDOWPOSCHANGING,Kn as WM_WININICHANGE,v as WS_BORDER,h as WS_CAPTION,f as WS_CHILD,g as WS_CHILDWINDOW,C as WS_CLIPCHILDREN,I as WS_CLIPSIBLINGS,_ as WS_DISABLED,x as WS_DLGFRAME,fo as WS_EX_ACCEPTFILES,go as WS_EX_APPWINDOW,Co as WS_EX_CLIENTEDGE,Io as WS_EX_CONTEXTHELP,_o as WS_EX_CONTROLPARENT,xo as WS_EX_DLGMODALFRAME,Wo as WS_EX_LEFT,Uo as WS_EX_LEFTSCROLLBAR,So as WS_EX_LTRREADING,bo as WS_EX_MDICHILD,Eo as WS_EX_NOPARENTNOTIFY,Po as WS_EX_OVERLAPPEDWINDOW,Mo as WS_EX_PALETTEWINDOW,Ro as WS_EX_RIGHT,To as WS_EX_RIGHTSCROLLBAR,Oo as WS_EX_RTLREADING,Fo as WS_EX_STATICEDGE,Lo as WS_EX_TOOLWINDOW,Do as WS_EX_TOPMOST,Ho as WS_EX_TRANSPARENT,Bo as WS_EX_WINDOWEDGE,W as WS_GROUP,U as WS_HSCROLL,S as WS_ICONIC,b as WS_MAXIMIZE,E as WS_MAXIMIZEBOX,P as WS_MINIMIZE,M as WS_MINIMIZEBOX,R as WS_OVERLAPPED,Q as WS_OVERLAPPEDWINDOW,T as WS_POPUP,N as WS_POPUPWINDOW,O as WS_SIZEBOX,F as WS_SYSMENU,L as WS_TABSTOP,D as WS_THICKFRAME,H as WS_TILED,B as WS_TILEDWINDOW,k as WS_VISIBLE,A as WS_VSCROLL,ps as Win95,ys as Window,ts as initEmulator,ds as render,us as unmountComponentAtNode,ls as useWin95}; |
{ | ||
"name": "react-95-fiber", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Work in progress!", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -468,1 +468,9 @@ export const LOWORD = (l: number) => l & 0xffff; | ||
export const DWL_USER = 8; | ||
export const GWL_WNDPROC = -4; | ||
export const GWL_HINSTANCE = -6; | ||
export const GWL_HWNDPARENT = -8; | ||
export const GWL_STYLE = -16; | ||
export const GWL_EXSTYLE = -20; | ||
export const GWL_USERDATA = -21; | ||
export const GWL_ID = -12; |
@@ -21,2 +21,7 @@ import { V86Starter } from 'v86'; | ||
Cmd_SendMessage = 12, | ||
Cmd_SetWindowLong = 13, | ||
Cmd_GetWindowLong = 14, | ||
Cmd_CreateFont = 15, | ||
Cmd_DeleteObject = 16, | ||
Cmd_ShowWindow = 17, | ||
} | ||
@@ -69,10 +74,2 @@ | ||
let seqNumber = 0; | ||
function getSeqNumber() { | ||
const s = seqNumber; | ||
seqNumber = (seqNumber + 1) & 0xffffff; | ||
return s; | ||
} | ||
const seqListeners = new Map<number, (e: EventPayload) => void>(); | ||
export enum ResponseType { | ||
@@ -89,2 +86,3 @@ Res_Invalid = 0, | ||
type: ResponseType.Res_WinProc; | ||
hwnd: number; | ||
message: number; | ||
@@ -113,8 +111,9 @@ wParam: number; | ||
if (type === ResponseType.Res_WinProc) { | ||
if (data.byteLength !== 16) return null; | ||
if (data.byteLength !== 20) return null; | ||
return { | ||
type, | ||
message: dv.getUint32(4, true), | ||
wParam: dv.getUint32(8, true), | ||
lParam: dv.getInt32(12, true), | ||
hwnd: dv.getUint32(4, true), | ||
message: dv.getUint32(8, true), | ||
wParam: dv.getUint32(12, true), | ||
lParam: dv.getInt32(16, true), | ||
}; | ||
@@ -206,2 +205,21 @@ } else if (type === ResponseType.Res_CmdOutputHandle) { | ||
let seqNumber = 0; | ||
function getSeqNumber() { | ||
const s = seqNumber; | ||
seqNumber = (seqNumber + 1) & 0xffffff; | ||
return s; | ||
} | ||
const seqListeners = new Map<number, (e: EventPayload) => void>(); | ||
const createdFonts: { | ||
lfWidth: number; | ||
lfHeight: number; | ||
lfWeight: number; | ||
lfItalic: number; | ||
lfUnderline: number; | ||
lfStrikeOut: number; | ||
lfFaceName?: string; | ||
handle: number; | ||
}[] = []; | ||
const api = { | ||
@@ -305,5 +323,7 @@ sendSerial, | ||
if (e.type === ResponseType.Res_CmdOutputHandle) { | ||
console.timeEnd('extractIcon' + file + id); | ||
resolve(e.handle); | ||
} | ||
}); | ||
console.time('extractIcon' + file + id); | ||
sendSerial( | ||
@@ -343,2 +363,87 @@ buildRemoteCommand(CommandType.Cmd_ExtractIcon, [ | ||
setWindowLong(id: number, nIndex: number, newLong: number) { | ||
sendSerial( | ||
buildRemoteCommand(CommandType.Cmd_SetWindowLong, [ | ||
{ type: DataType.UInt, value: id }, | ||
{ type: DataType.Int, value: nIndex }, | ||
{ type: DataType.UInt, value: newLong }, | ||
]), | ||
); | ||
}, | ||
getWindowLong(id: number, nIndex: number) { | ||
return new Promise<number>(resolve => { | ||
const seq = getSeqNumber(); | ||
seqListeners.set(seq, e => { | ||
if (e.type === ResponseType.Res_CmdOutputHandle) { | ||
resolve(e.handle); | ||
} | ||
}); | ||
sendSerial( | ||
buildRemoteCommand(CommandType.Cmd_GetWindowLong, [ | ||
{ type: DataType.UInt, value: id }, | ||
{ type: DataType.Int, value: nIndex }, | ||
{ type: DataType.UInt, value: seq }, | ||
]), | ||
); | ||
}); | ||
}, | ||
createFont(params: { | ||
lfWidth: number; | ||
lfHeight: number; | ||
lfWeight: number; | ||
lfItalic: number; | ||
lfUnderline: number; | ||
lfStrikeOut: number; | ||
lfFaceName?: string; | ||
}) { | ||
const found = createdFonts.find( | ||
f => | ||
f.lfWidth === params.lfWidth && | ||
f.lfHeight === params.lfHeight && | ||
f.lfWeight === params.lfWeight && | ||
f.lfItalic === params.lfItalic && | ||
f.lfUnderline === params.lfUnderline && | ||
f.lfStrikeOut === params.lfStrikeOut && | ||
f.lfFaceName === params.lfFaceName, | ||
); | ||
if (found) return found.handle; | ||
return new Promise<number>(resolve => { | ||
const seq = getSeqNumber(); | ||
seqListeners.set(seq, e => { | ||
if (e.type === ResponseType.Res_CmdOutputHandle) { | ||
createdFonts.push({ ...params, handle: e.handle }); | ||
resolve(e.handle); | ||
} | ||
}); | ||
sendSerial( | ||
buildRemoteCommand(CommandType.Cmd_CreateFont, [ | ||
{ type: DataType.UInt, value: seq }, | ||
{ type: DataType.Int, value: params.lfWidth }, | ||
{ type: DataType.Int, value: params.lfHeight }, | ||
{ type: DataType.Int, value: params.lfWeight }, | ||
{ type: DataType.Int, value: params.lfItalic }, | ||
{ type: DataType.Int, value: params.lfUnderline }, | ||
{ type: DataType.Int, value: params.lfStrikeOut }, | ||
...(params.lfFaceName ? [{ type: DataType.String, value: params.lfFaceName }] : []), | ||
]), | ||
); | ||
}); | ||
}, | ||
deleteObject(handle: number) { | ||
sendSerial(buildRemoteCommand(CommandType.Cmd_DeleteObject, [{ type: DataType.UInt, value: handle }])); | ||
}, | ||
showWindow(id: number, state: number) { | ||
sendSerial( | ||
buildRemoteCommand(CommandType.Cmd_ShowWindow, [ | ||
{ type: DataType.UInt, value: id }, | ||
{ type: DataType.Int, value: state }, | ||
]), | ||
); | ||
}, | ||
sendMouseEvent(down: boolean, button: 0 | 2) { | ||
@@ -345,0 +450,0 @@ if (down) { |
import Reconciler from 'react-reconciler'; | ||
import { unstable_now as now } from 'scheduler'; | ||
import { GWL_EXSTYLE, GWL_STYLE, WM_SETFONT } from '../emulator95/constants'; | ||
@@ -26,2 +27,15 @@ import { RootNode } from './Win95'; | ||
} | ||
| { | ||
type: 'w95Font'; | ||
handle: number; | ||
props: { | ||
width?: number; | ||
height?: number; | ||
weight?: number; | ||
italic?: boolean; | ||
underline?: boolean; | ||
strikeOut?: boolean; | ||
faceName?: string; | ||
}; | ||
} | ||
) & { root: RootNode; children?: NodeType[] }; | ||
@@ -34,6 +48,7 @@ | ||
function appendChild(parentInstance: NodeType, child: NodeType) { | ||
async function appendChild(parentInstance: NodeType, child: NodeType) { | ||
// console.log('appendChild', { parentInstance, child }); | ||
if (child.type === 'w95Window' && parentInstance.type !== 'text') { | ||
if (child.type === 'w95Window') { | ||
const menuId = child.props.menuId !== undefined ? child.props.menuId : child.id || 0; | ||
child.root.api.createWindow({ | ||
@@ -48,10 +63,24 @@ id: child.id, | ||
h: child.props.h, | ||
parentId: parentInstance.id || 0, | ||
menuId: child.props.menuId !== undefined ? child.props.menuId : child.id || 0, | ||
parentId: parentInstance.type === 'w95Window' ? parentInstance.id : 0, | ||
menuId, | ||
extStyle: child.props.extStyle || 0, | ||
}); | ||
if (child.props.onEvent) { | ||
child.root.events.set(child.id, child.props.onEvent); | ||
if (!child.root.events.get(menuId)) child.root.events.set(menuId, []); | ||
child.root.events.get(menuId)?.push(child.props.onEvent); | ||
} | ||
} | ||
if (child.type === 'w95Font' && parentInstance.type === 'w95Window') { | ||
const fontHandle = await child.root.api.createFont({ | ||
lfWidth: child.props.width || 0, | ||
lfHeight: child.props.height || 0, | ||
lfWeight: child.props.weight || 0, | ||
lfItalic: child.props.italic ? 1 : 0, | ||
lfUnderline: child.props.underline ? 1 : 0, | ||
lfStrikeOut: child.props.strikeOut ? 1 : 0, | ||
lfFaceName: child.props.faceName, | ||
}); | ||
await child.root.api.sendMessage(parentInstance.id, WM_SETFONT, fontHandle, 1); | ||
} | ||
} | ||
@@ -67,5 +96,13 @@ | ||
function removeChild(parentInstance: NodeType, child: NodeType) { | ||
if (child.type === 'w95Window' && parentInstance.type !== 'text') { | ||
child.root.events.delete(child.id); | ||
parentInstance.root.api.destroyWindow(child.id); | ||
if (child.type === 'w95Window') { | ||
if (child.props.onEvent) { | ||
const eventChain = child.root.events.get(child.id); | ||
if (eventChain) { | ||
const newEventChain = eventChain.filter(e => e !== child.props.onEvent); | ||
if (newEventChain.length > 0) child.root.events.set(child.id, newEventChain); | ||
else child.root.events.delete(child.id); | ||
} | ||
} | ||
child.root.api.destroyWindow(child.id); | ||
} | ||
@@ -96,10 +133,21 @@ } | ||
createInstance(type: string, { type: windowType, ...props }: any, rootContainer: any) { | ||
return { | ||
type: type as any, | ||
props: { windowType, ...props }, | ||
id: getIncremental(), | ||
root: rootContainer.root, | ||
}; | ||
if (type === 'w95Window') { | ||
return { | ||
type, | ||
props: { windowType, ...props }, | ||
id: getIncremental(), | ||
root: rootContainer.root, | ||
}; | ||
} else if (type === 'w95Font') { | ||
return { | ||
type, | ||
props, | ||
root: rootContainer.root, | ||
}; | ||
} else { | ||
throw new Error('Unknown type!'); | ||
} | ||
}, | ||
createTextInstance(newText: string, rootContainerInstance: RootNode) { | ||
createTextInstance(newText: string) { | ||
return { type: 'text', content: newText }; | ||
@@ -110,2 +158,3 @@ }, | ||
// console.log('appendInitialChild', { parentInstance, child }); | ||
if (child.type === 'text' && parentInstance.type === 'w95Window') { | ||
@@ -149,3 +198,10 @@ parentInstance.props.text = child.content; | ||
commitUpdate(instance: NodeType, diff, type, oldProps: Record<string, unknown>, newProps: Record<string, unknown>, fiber: Reconciler.Fiber) { | ||
commitUpdate( | ||
instance: NodeType, | ||
diff, | ||
type, | ||
oldProps: JSX.IntrinsicElements['w95Window'], | ||
newProps: JSX.IntrinsicElements['w95Window'], | ||
fiber: Reconciler.Fiber, | ||
) { | ||
// console.log('commitUpdate', { instance, diff, type, oldProps, newProps, fiber }); | ||
@@ -156,4 +212,10 @@ | ||
instance.root.api.setWindowText(instance.id, newProps.children); | ||
} else if (typeof newProps.text === 'string' && newProps.text !== oldProps.text) { | ||
instance.root.api.setWindowText(instance.id, newProps.text); | ||
} else if (newProps.x !== oldProps.x || newProps.y !== oldProps.y || newProps.w !== oldProps.w || newProps.h !== oldProps.h) { | ||
instance.root.api.setWindowPos(instance.id, newProps.x, newProps.y, newProps.w, newProps.h); | ||
} else if (newProps.params !== oldProps.params) { | ||
instance.root.api.setWindowLong(instance.id, GWL_STYLE, newProps.params); | ||
} else if (typeof newProps.extStyle === 'number' && newProps.extStyle !== oldProps.extStyle) { | ||
instance.root.api.setWindowLong(instance.id, GWL_EXSTYLE, newProps.extStyle); | ||
} | ||
@@ -160,0 +222,0 @@ } |
@@ -16,5 +16,16 @@ declare global { | ||
menuId?: number; | ||
children?: JSX.Element[] | JSX.Element | string; | ||
children?: null | string | JSX.Element | (string | JSX.Element | null)[]; | ||
onEvent?: (e: EventPayload, ref: Win95Ref) => void; | ||
}; | ||
w95Font: { | ||
ref?: React.Ref<{ id: number } | null | undefined>; | ||
width?: number; | ||
height?: number; | ||
weight?: number; | ||
italic?: boolean; | ||
underline?: boolean; | ||
strikeOut?: boolean; | ||
faceName?: string; | ||
}; | ||
} | ||
@@ -21,0 +32,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27045656
149
1749
121