Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-95-fiber

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-95-fiber - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

binaries/.DS_Store

2

dist/index.js

@@ -1,1 +0,1 @@

import e,{useContext as t,forwardRef as n,useRef as o,useLayoutEffect as r,createContext as s}from"react";import{V86Starter as a}from"v86-module";import i from"react-reconciler";import{unstable_now as l}from"scheduler";const u=8388608,d=12582912,p=1073741824,c=1073741824,m=33554432,y=67108864,v=134217728,C=4194304,f=131072,w=1048576,_=536870912,I=16777216,g=65536,h=536870912,x=131072,U=0,P=2147483648,b=262144,W=524288,S=65536,M=262144,E=0,R=13565952,T=268435456,A=2097152,B=13565952,F=-2138570752,D=32768,k=6,H=28,z=864,N=895,j=780,L=75,O=31,V=533,X=781,Y=258,q=47,G=34,J=771,K=16,Q=273,Z=68,$=65,ee=57,te=123,ne=769,oe=74,re=1,se=309,ae=310,ie=307,le=308,ue=306,de=311,pe=312,ce=768,me=259,ye=45,ve=2,Ce=775,fe=537,we=27,_e=126,Ie=776,ge=43,he=563,xe=10,Ue=22,Pe=289,be=529,We=561,Se=20,Me=530,Ee=562,Re=29,Te=135,Ae=49,Be=51,Fe=127,De=36,ke=13,He=14,ze=856,Ne=863,je=83,Le=786,Oe=276,Ve=782,Xe=39,Ye=272,qe=278,Ge=279,Je=81,Ke=80,Qe=256,Ze=257,$e=8,et=546,tt=551,nt=544,ot=545,rt=553,st=552,at=549,it=548,lt=564,ut=547,dt=560,pt=550,ct=44,mt=293,yt=290,vt=294,Ct=292,ft=291,wt=288,_t=287,It=531,gt=3,ht=534,xt=134,Ut=131,Pt=129,bt=130,Wt=132,St=163,Mt=161,Et=162,Rt=169,Tt=167,At=168,Bt=160,Ft=133,Dt=166,kt=164,Ht=165,zt=40,Nt=78,jt=85,Lt=0,Ot=15,Vt=777,Xt=38,Yt=785,qt=784,Gt=528,Jt=770,Kt=896,Qt=911,Zt=72,$t=536,en=791,tn=792,nn=55,on=17,rn=783,sn=19,an=35,ln=18,un=774,dn=773,pn=32,cn=7,mn=48,yn=50,vn=128,Cn=11,fn=12,wn=26,_n=24,In=5,gn=779,hn=532,xn=42,Un=125,Pn=124,bn=262,Wn=21,Sn=274,Mn=263,En=260,Rn=261,Tn=82,An=794,Bn=30,Fn=275,Dn=772,kn=1024,Hn=84,zn=46,Nn=277,jn=778,Ln=71,On=70,Vn=26,Xn=256,Yn=264,qn=136,Gn=33,Jn=512,Kn=513,Qn=514,Zn=515,$n=516,eo=517,to=518,no=519,oo=520,ro=521,so=522,ao=512,io=522,lo=673,uo=675,po=16,co=262144,mo=512,yo=1024,vo=65536,Co=1,fo=0,wo=16384,_o=0,Io=64,go=4,ho=768,xo=392,Uo=4096,Po=0,bo=8192,Wo=131072,So=128,Mo=8,Eo=32,Ro=256;let To,Ao,Bo;function Fo(e,t){const n=t.map((e=>4+(e.type===Ao.String?e.value.length+1+4:4))).reduce(((e,t)=>e+t),0),o=new ArrayBuffer(12+n+1),r=new DataView(o);r.setUint32(0,49325,!0),r.setUint32(4,e,!0),r.setUint32(8,t.length,!0);let s=o.byteLength-1;for(let e=0;e<t.length;e++){const n=t[e];if(r.setUint32(12+8*e,n.type,!0),n.type===Ao.Int)r.setInt32(12+8*e+4,n.value,!0);else if(n.type===Ao.UInt)r.setUint32(12+8*e+4,n.value,!0);else if(n.type===Ao.Float)r.setFloat32(12+8*e+4,n.value,!0);else if(n.type===Ao.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 r.setUint8(o.byteLength-1,"\r".charCodeAt(0)),o}function Do(e,t,n,o){void 0===o&&(o={scale:.5,mouseUpdateInterval:20,fromState:!1});const r=new a({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});var s;const i={v86Emulator:r,mousePos:[0,0],ready:!1},l=[];function u(e){const t=new Uint8Array(e);for(let e=0;e<t.length;e++)r.bus.send("serial0-input",t[e])}r.add_listener("serial0-output-char",(e=>{"\r"===e?(16===l.length&&(null==t.onEvent||t.onEvent(function(e){const t=new DataView(e),n=t.getUint32(0,!0);return n===Bo.Res_WinProc?{type:n,message:t.getUint32(4,!0),wParam:t.getUint32(8,!0),lParam:t.getInt32(12,!0)}:{type:n}}(new Uint8Array(l).buffer)),i.ready||(null==t.onReady||t.onReady(),i.ready=!0)),l.splice(0,l.length)):l.push(e.charCodeAt(0))}));const d={sendSerial:u,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.mousePos=[e,t]},setWindowPos(e,t,n,o,r){u(Fo(To.Cmd_SetWindowPos,[{type:Ao.UInt,value:e},{type:Ao.Int,value:t},{type:Ao.Int,value:n},{type:Ao.Int,value:o},{type:Ao.Int,value:r}]))},createWindow(e){u(Fo(To.Cmd_CreateWindow,[{type:Ao.UInt,value:e.id},{type:Ao.UInt,value:e.extStyle},{type:Ao.String,value:e.type},{type:Ao.String,value:e.text},{type:Ao.UInt,value:e.params},{type:Ao.Int,value:e.x},{type:Ao.Int,value:e.y},{type:Ao.Int,value:e.w},{type:Ao.Int,value:e.h},{type:Ao.UInt,value:e.parentId},{type:Ao.UInt,value:e.menuId}]))},destroyWindow(e){u(Fo(To.Cmd_DestroyWindow,[{type:Ao.UInt,value:e}]))},setWindowText(e,t){u(Fo(To.Cmd_SetWindowText,[{type:Ao.UInt,value:e},{type:Ao.String,value:t}]))},sendMouseEvent(e,t){e?0===t?u(Fo(To.Cmd_MouseEvent,[{type:Ao.UInt,value:2}])):2===t&&u(Fo(To.Cmd_MouseEvent,[{type:Ao.UInt,value:8}])):0===t?u(Fo(To.Cmd_MouseEvent,[{type:Ao.UInt,value:4}])):2===t&&u(Fo(To.Cmd_MouseEvent,[{type:Ao.UInt,value:16}]))}};return setInterval((()=>{i.ready&&u(Fo(To.Cmd_SetCursorPos,[{type:Ao.Int,value:i.mousePos[0]},{type:Ao.Int,value:i.mousePos[1]}]))}),o.mouseUpdateInterval),setInterval((()=>{u(Fo(To.Cmd_Ping,[]))}),2e3),{state:i,api:d}}!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_MessageBoxEx=7]="Cmd_MessageBoxEx",e[e.Cmd_Ping=8]="Cmd_Ping"}(To||(To={})),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"}(Ao||(Ao={})),function(e){e[e.Res_Invalid=0]="Res_Invalid",e[e.Res_PingResponse=1]="Res_PingResponse",e[e.Res_WinProc=2]="Res_WinProc"}(Bo||(Bo={}));let ko=3;function Ho(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,menuId:t.id,extStyle:t.props.extStyle||0}),t.props.onCommand&&t.root.events.set(t.id,t.props.onCommand)),"text"===t.type&&"w95Window"===e.type&&(e.props.text=t.content)}function zo(e,t){"w95Window"===t.type&&"text"!==e.type&&(t.root.events.delete(t.id),e.root.api.destroyWindow(t.id))}function No(e,t,n){console.log("insertBefore",{parentInstance:e,child:t,beforeChild:n})}const jo=i({supportsMutation:!0,isPrimaryRenderer:!1,getPublicInstance:e=>e,getRootHostContext:()=>({}),getChildHostContext:()=>({}),prepareUpdate:(e,t,n,o)=>!0,prepareForCommit:()=>null,resetAfterCommit:()=>({}),shouldSetTextContent:(e,t)=>!1,finalizeInitialChildren:()=>!1,clearContainer:()=>!1,createInstance:function(e,t,n){let{type:o,...r}=t;return{type:e,props:{windowType:o,...r},id:ko++,root:n.root}},createTextInstance:function(e,t){return{type:"text",content:e}},appendChild:Ho,appendInitialChild:Ho,appendChildToContainer:Ho,removeChild:zo,removeChildFromContainer:zo,insertBefore:No,insertInContainerBefore:(e,t,n)=>No(e,t,n),commitUpdate(e,t,n,o,r,s){!function(e,t,n){console.log("applyProps",{instance:e,newProps:t,oldProps:n})}(e,r,o)},commitTextUpdate(e,t,n){console.log(e,n,t)},hideInstance(e){},unhideInstance(e,t){},hideTextInstance(){},supportsPersistence:!1,supportsHydration:!1,preparePortalMount(){},now:l,scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1}),Lo=s(null),Oo=new Map;function Vo(){const e=t(Lo);if(!e)throw new Error("No context available!");return e}function Xo(t,n,o,r){var s;const a=Oo.get(n);let i=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,!i){const s=Do(n,{onReady:()=>{null==o.onReady||o.onReady(),jo.updateContainer(e.createElement(Lo.Provider,{value:l},t),i,null,(()=>{}))},onEvent:e=>{if(e.type===Bo.Res_WinProc&&273===e.message){const t=l.events.get(e.wParam);t&&t()}}},r);Object.assign(l,s),i=jo.createContainer(l,1,!1,null)}return Oo.set(n,{root:i,state:l}),null!=(s=l.state)&&s.ready&&jo.updateContainer(e.createElement(Lo.Provider,{value:l},t),i,null,(()=>{})),l}function Yo(e){const t=Oo.get(e);if(!t)return;const{root:n}=t;jo.updateContainer(null,n,null,(()=>{Oo.delete(e)}))}const qo=n((function(t,n){let{children:s,style:a,onReady:i,binaries:l}=t;const u=o(null),d=o(null);return r((()=>{d.current=Xo(s,u.current,{onReady:i},l),"function"==typeof n?n(d.current):n.current=d.current}),[s,i]),r((()=>{const e=u.current;return()=>Yo(e)}),[]),e.createElement("div",{ref:u,onContextMenu:e=>e.preventDefault(),onMouseMove:function(e){if(!d.current||!d.current.api)return;const t=u.current.getBoundingClientRect();d.current.api.setMousePos(e.clientX-t.x,e.clientY-t.y)},onMouseDown:e=>d.current.api.sendMouseEvent(!0,e.button),onMouseUp:e=>d.current.api.sendMouseEvent(!1,e.button)},e.createElement("div",{style:{whiteSpace:"pre",font:"14px monospace",lineHeight:"14px",...a||{}}}),e.createElement("canvas",{style:{display:"none"}}))}));var Go=Object.freeze({__proto__:null});function Jo(t){let{onClick:n,x:o,y:r,w:s,h:a,children:i}=t;return e.createElement("w95Window",{type:"Button",onCommand:n,params:1342177280,x:o,y:r,w:s,h:a},i)}export{Jo as Button,To as CommandType,Ao as DataType,Go as React95Fiber,Bo as ResponseType,k as WM_ACTIVATE,H as WM_ACTIVATEAPP,z as WM_AFXFIRST,N as WM_AFXLAST,D as WM_APP,j as WM_ASKCBFORMATNAME,L as WM_CANCELJOURNAL,O as WM_CANCELMODE,V as WM_CAPTURECHANGED,X as WM_CHANGECBCHAIN,Y as WM_CHAR,q as WM_CHARTOITEM,G as WM_CHILDACTIVATE,J as WM_CLEAR,K as WM_CLOSE,Q as WM_COMMAND,Z as WM_COMMNOTIFY,$ as WM_COMPACTING,ee as WM_COMPAREITEM,te as WM_CONTEXTMENU,ne as WM_COPY,oe as WM_COPYDATA,re as WM_CREATE,se as WM_CTLCOLORBTN,ae as WM_CTLCOLORDLG,ie as WM_CTLCOLOREDIT,le as WM_CTLCOLORLISTBOX,ue as WM_CTLCOLORMSGBOX,de as WM_CTLCOLORSCROLLBAR,pe as WM_CTLCOLORSTATIC,ce as WM_CUT,me as WM_DEADCHAR,ye as WM_DELETEITEM,ve as WM_DESTROY,Ce as WM_DESTROYCLIPBOARD,fe as WM_DEVICECHANGE,we as WM_DEVMODECHANGE,_e as WM_DISPLAYCHANGE,Ie as WM_DRAWCLIPBOARD,ge as WM_DRAWITEM,he as WM_DROPFILES,xe as WM_ENABLE,Ue as WM_ENDSESSION,Pe as WM_ENTERIDLE,be as WM_ENTERMENULOOP,We as WM_ENTERSIZEMOVE,Se as WM_ERASEBKGND,Me as WM_EXITMENULOOP,Ee as WM_EXITSIZEMOVE,Re as WM_FONTCHANGE,Te as WM_GETDLGCODE,Ae as WM_GETFONT,Be as WM_GETHOTKEY,Fe as WM_GETICON,De as WM_GETMINMAXINFO,ke as WM_GETTEXT,He as WM_GETTEXTLENGTH,ze as WM_HANDHELDFIRST,Ne as WM_HANDHELDLAST,je as WM_HELP,Le as WM_HOTKEY,Oe as WM_HSCROLL,Ve as WM_HSCROLLCLIPBOARD,Xe as WM_ICONERASEBKGND,Ye as WM_INITDIALOG,qe as WM_INITMENU,Ge as WM_INITMENUPOPUP,Je as WM_INPUTLANGCHANGE,Ke as WM_INPUTLANGCHANGEREQUEST,Qe as WM_KEYDOWN,Xn as WM_KEYFIRST,Yn as WM_KEYLAST,Ze as WM_KEYUP,$e as WM_KILLFOCUS,Zn as WM_LBUTTONDBLCLK,Kn as WM_LBUTTONDOWN,Qn as WM_LBUTTONUP,ro as WM_MBUTTONDBLCLK,no as WM_MBUTTONDOWN,oo as WM_MBUTTONUP,et as WM_MDIACTIVATE,tt as WM_MDICASCADE,nt as WM_MDICREATE,ot as WM_MDIDESTROY,rt as WM_MDIGETACTIVE,st as WM_MDIICONARRANGE,at as WM_MDIMAXIMIZE,it as WM_MDINEXT,lt as WM_MDIREFRESHMENU,ut as WM_MDIRESTORE,dt as WM_MDISETMENU,pt as WM_MDITILE,ct as WM_MEASUREITEM,wt as WM_MENUCHAR,vt as WM_MENUCOMMAND,ft as WM_MENUDRAG,Ct as WM_MENUGETOBJECT,yt as WM_MENURBUTTONUP,_t as WM_MENUSELECT,Gn as WM_MOUSEACTIVATE,ao as WM_MOUSEFIRST,lo as WM_MOUSEHOVER,io as WM_MOUSELAST,uo as WM_MOUSELEAVE,Jn as WM_MOUSEMOVE,so as WM_MOUSEWHEEL,gt as WM_MOVE,ht as WM_MOVING,xt as WM_NCACTIVATE,Ut as WM_NCCALCSIZE,Pt as WM_NCCREATE,bt as WM_NCDESTROY,Wt as WM_NCHITTEST,St as WM_NCLBUTTONDBLCLK,Mt as WM_NCLBUTTONDOWN,Et as WM_NCLBUTTONUP,Rt as WM_NCMBUTTONDBLCLK,Tt as WM_NCMBUTTONDOWN,At as WM_NCMBUTTONUP,Bt as WM_NCMOUSEMOVE,Ft as WM_NCPAINT,Dt as WM_NCRBUTTONDBLCLK,kt as WM_NCRBUTTONDOWN,Ht as WM_NCRBUTTONUP,zt as WM_NEXTDLGCTL,It as WM_NEXTMENU,Nt as WM_NOTIFY,jt as WM_NOTIFYFORMAT,Lt as WM_NULL,Ot as WM_PAINT,Vt as WM_PAINTCLIPBOARD,Xt as WM_PAINTICON,Yt as WM_PALETTECHANGED,qt as WM_PALETTEISCHANGING,Gt as WM_PARENTNOTIFY,Jt as WM_PASTE,Kt as WM_PENWINFIRST,Qt as WM_PENWINLAST,Zt as WM_POWER,$t as WM_POWERBROADCAST,en as WM_PRINT,tn as WM_PRINTCLIENT,nn as WM_QUERYDRAGICON,on as WM_QUERYENDSESSION,rn as WM_QUERYNEWPALETTE,sn as WM_QUERYOPEN,an as WM_QUEUESYNC,ln as WM_QUIT,to as WM_RBUTTONDBLCLK,$n as WM_RBUTTONDOWN,eo as WM_RBUTTONUP,un as WM_RENDERALLFORMATS,dn as WM_RENDERFORMAT,pn as WM_SETCURSOR,cn as WM_SETFOCUS,mn as WM_SETFONT,yn as WM_SETHOTKEY,vn as WM_SETICON,Cn as WM_SETREDRAW,fn as WM_SETTEXT,wn as WM_SETTINGCHANGE,_n as WM_SHOWWINDOW,In as WM_SIZE,gn as WM_SIZECLIPBOARD,hn as WM_SIZING,xn as WM_SPOOLERSTATUS,Un as WM_STYLECHANGED,Pn as WM_STYLECHANGING,qn as WM_SYNCPAINT,bn as WM_SYSCHAR,Wn as WM_SYSCOLORCHANGE,Sn as WM_SYSCOMMAND,Mn as WM_SYSDEADCHAR,En as WM_SYSKEYDOWN,Rn as WM_SYSKEYUP,Tn as WM_TCARD,An as WM_THEMECHANGED,Bn as WM_TIMECHANGE,Fn as WM_TIMER,Dn as WM_UNDO,mt as WM_UNINITMENUPOPUP,kn as WM_USER,Hn as WM_USERCHANGED,zn as WM_VKEYTOITEM,Nn as WM_VSCROLL,jn as WM_VSCROLLCLIPBOARD,Ln as WM_WINDOWPOSCHANGED,On as WM_WINDOWPOSCHANGING,Vn as WM_WININICHANGE,u as WS_BORDER,d as WS_CAPTION,p as WS_CHILD,c as WS_CHILDWINDOW,m as WS_CLIPCHILDREN,y as WS_CLIPSIBLINGS,v as WS_DISABLED,C as WS_DLGFRAME,po as WS_EX_ACCEPTFILES,co as WS_EX_APPWINDOW,mo as WS_EX_CLIENTEDGE,yo as WS_EX_CONTEXTHELP,vo as WS_EX_CONTROLPARENT,Co as WS_EX_DLGMODALFRAME,fo as WS_EX_LEFT,wo as WS_EX_LEFTSCROLLBAR,_o as WS_EX_LTRREADING,Io as WS_EX_MDICHILD,go as WS_EX_NOPARENTNOTIFY,ho as WS_EX_OVERLAPPEDWINDOW,xo as WS_EX_PALETTEWINDOW,Uo as WS_EX_RIGHT,Po as WS_EX_RIGHTSCROLLBAR,bo as WS_EX_RTLREADING,Wo as WS_EX_STATICEDGE,So as WS_EX_TOOLWINDOW,Mo as WS_EX_TOPMOST,Eo as WS_EX_TRANSPARENT,Ro as WS_EX_WINDOWEDGE,f as WS_GROUP,w as WS_HSCROLL,_ as WS_ICONIC,I as WS_MAXIMIZE,g as WS_MAXIMIZEBOX,h as WS_MINIMIZE,x as WS_MINIMIZEBOX,U as WS_OVERLAPPED,B as WS_OVERLAPPEDWINDOW,P as WS_POPUP,F as WS_POPUPWINDOW,b as WS_SIZEBOX,W as WS_SYSMENU,S as WS_TABSTOP,M as WS_THICKFRAME,E as WS_TILED,R as WS_TILEDWINDOW,T as WS_VISIBLE,A as WS_VSCROLL,qo as Win95,Do as initEmulator,Xo as render,Yo as unmountComponentAtNode,Vo as useWin95};
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}from"react";import{V86Starter as a}from"v86";import l from"react-reconciler";import{unstable_now as d}from"scheduler";const u=8388608,c=12582912,p=1073741824,m=1073741824,y=33554432,v=67108864,h=134217728,C=4194304,w=131072,f=1048576,g=536870912,I=16777216,_=65536,x=536870912,b=131072,U=0,P=2147483648,W=262144,S=524288,M=65536,T=262144,E=0,R=13565952,B=268435456,D=2097152,A=13565952,Q=-2138570752,F=32768,k=6,H=28,z=864,L=895,N=780,j=75,O=31,V=533,X=781,Y=258,q=47,G=34,J=771,K=16,Z=273,$=68,ee=65,te=57,ne=123,oe=769,re=74,se=1,ie=309,ae=310,le=307,de=308,ue=306,ce=311,pe=312,me=768,ye=259,ve=45,he=2,Ce=775,we=537,fe=27,ge=126,Ie=776,_e=43,xe=563,be=10,Ue=22,Pe=289,We=529,Se=561,Me=20,Te=530,Ee=562,Re=29,Be=135,De=49,Ae=51,Qe=127,Fe=36,ke=13,He=14,ze=856,Le=863,Ne=83,je=786,Oe=276,Ve=782,Xe=39,Ye=272,qe=278,Ge=279,Je=81,Ke=80,Ze=256,$e=257,et=8,tt=546,nt=551,ot=544,rt=545,st=553,it=552,at=549,lt=548,dt=564,ut=547,ct=560,pt=550,mt=44,yt=293,vt=290,ht=294,Ct=292,wt=291,ft=288,gt=287,It=531,_t=3,xt=534,bt=134,Ut=131,Pt=129,Wt=130,St=132,Mt=163,Tt=161,Et=162,Rt=169,Bt=167,Dt=168,At=160,Qt=133,Ft=166,kt=164,Ht=165,zt=40,Lt=78,Nt=85,jt=0,Ot=15,Vt=777,Xt=38,Yt=785,qt=784,Gt=528,Jt=770,Kt=896,Zt=911,$t=72,en=536,tn=791,nn=792,on=55,rn=17,sn=783,an=19,ln=35,dn=18,un=774,cn=773,pn=32,mn=7,yn=48,vn=50,hn=128,Cn=11,wn=12,fn=26,gn=24,In=5,_n=779,xn=532,bn=42,Un=125,Pn=124,Wn=262,Sn=21,Mn=274,Tn=263,En=260,Rn=261,Bn=82,Dn=794,An=30,Qn=275,Fn=772,kn=1024,Hn=84,zn=46,Ln=277,Nn=778,jn=71,On=70,Vn=26,Xn=256,Yn=264,qn=136,Gn=33,Jn=512,Kn=513,Zn=514,$n=515,eo=516,to=517,no=518,oo=519,ro=520,so=521,io=522,ao=512,lo=522,uo=673,co=675,po=16,mo=262144,yo=512,vo=1024,ho=65536,Co=1,wo=0,fo=16384,go=0,Io=64,_o=4,xo=768,bo=392,Uo=4096,Po=0,Wo=8192,So=131072,Mo=128,To=8,Eo=32,Ro=256,Bo=2147483648,Do=new TextEncoder;new TextDecoder;class Ao{constructor(e,t){this.outQueue=[],this.inQueue=[],e.io.register_write(1282,this,(()=>console.warn("Invalid 8 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)),(()=>{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|Math.min(255,t.length+1)<<8}))}sendData(e){const t=new Uint8ClampedArray(e);this.outQueue.push(Array.from(t))}sendString(e){this.sendData(Do.encode(e).buffer)}}let Qo,Fo,ko;function Ho(e,t){const n=t.map((e=>4+(e.type===Fo.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===Fo.Int)r.setInt32(12+8*e+4,n.value,!0);else if(n.type===Fo.UInt)r.setUint32(12+8*e+4,n.value,!0);else if(n.type===Fo.Float)r.setFloat32(12+8*e+4,n.value,!0);else if(n.type===Fo.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 zo(e,t,n,o){void 0===o&&(o={scale:.5,mouseUpdateInterval:20,fromState:!1});const r=new a({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 Ao(r.v86.cpu,(e=>{8!==e.byteLength&&16!==e.byteLength||(null==t.onEvent||t.onEvent(function(e){const t=new DataView(e),n=t.getUint32(0,!0);return n===ko.Res_WinProc?{type:n,message:t.getUint32(4,!0),wParam:t.getUint32(8,!0),lParam:t.getInt32(12,!0)}:{type:n}}(e)),i.ready||(null==t.onReady||t.onReady(),i.ready=!0))}))}));const i={v86Emulator:r,ready:!1};function l(e){const t=r.v86.cpu.devices.commBus;t&&t.sendData(e)}const d={sendSerial:l,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&&l(Ho(Qo.Cmd_SetCursorPos,[{type:Fo.Int,value:e},{type:Fo.Int,value:t}]))},setWindowPos(e,t,n,o,r){l(Ho(Qo.Cmd_SetWindowPos,[{type:Fo.UInt,value:e},{type:Fo.Int,value:t},{type:Fo.Int,value:n},{type:Fo.Int,value:o},{type:Fo.Int,value:r}]))},createWindow(e){l(Ho(Qo.Cmd_CreateWindow,[{type:Fo.UInt,value:e.id},{type:Fo.UInt,value:e.extStyle},{type:Fo.String,value:e.type},{type:Fo.String,value:e.text},{type:Fo.UInt,value:e.params},{type:Fo.Int,value:e.x},{type:Fo.Int,value:e.y},{type:Fo.Int,value:e.w},{type:Fo.Int,value:e.h},{type:Fo.UInt,value:e.parentId},{type:Fo.UInt,value:e.menuId}]))},destroyWindow(e){l(Ho(Qo.Cmd_DestroyWindow,[{type:Fo.UInt,value:e}]))},setWindowText(e,t){l(Ho(Qo.Cmd_SetWindowText,[{type:Fo.UInt,value:e},{type:Fo.String,value:t}]))},sendMouseEvent(e,t){e?0===t?l(Ho(Qo.Cmd_MouseEvent,[{type:Fo.UInt,value:2}])):2===t&&l(Ho(Qo.Cmd_MouseEvent,[{type:Fo.UInt,value:8}])):0===t?l(Ho(Qo.Cmd_MouseEvent,[{type:Fo.UInt,value:4}])):2===t&&l(Ho(Qo.Cmd_MouseEvent,[{type:Fo.UInt,value:16}]))}};return setInterval((()=>{l(Ho(Qo.Cmd_Ping,[]))}),2e3),{state:i,api:d}}!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_MessageBoxEx=7]="Cmd_MessageBoxEx",e[e.Cmd_Ping=8]="Cmd_Ping"}(Qo||(Qo={})),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"}(Fo||(Fo={})),function(e){e[e.Res_Invalid=0]="Res_Invalid",e[e.Res_PingResponse=1]="Res_PingResponse",e[e.Res_WinProc=2]="Res_WinProc"}(ko||(ko={}));let Lo=3;function No(e,t){console.log("appendChild",{parentInstance:e,child: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.onCommand&&t.root.events.set(t.id,t.props.onCommand))}const jo=l({getPublicInstance:e=>e,getRootHostContext:()=>({}),getChildHostContext:()=>({}),prepareForCommit:()=>null,resetAfterCommit:()=>({}),scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,now:d,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:Lo++,root:n.root}},createTextInstance:(e,t)=>({type:"text",content:e}),appendInitialChild(e,t){console.log("appendInitialChild",{parentInstance:e,child: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)=>(console.log("prepareUpdate",{instance:e,type:t,oldProps:n,newProps:o}),!0),shouldSetTextContent:(e,t)=>!1,appendChild:No,appendChildToContainer:function e(t,n){var o;console.log("appendChildToContainer",{parentInstance:t,child:n}),No(t,n),null==(o=n.children)||o.forEach((t=>e(n,t)))},commitTextUpdate(e,t,n){console.log("commitTextUpdate",{instance:e,oldText:t,newText:n})},commitMount:e=>console.log("commitMount",e),commitUpdate(e,t,n,o,r,s){console.log("commitUpdate",{instance:e,diff:t,type:n,oldProps:o,newProps:r,fiber: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:e=>console.log("removeChild",e),removeChildFromContainer:e=>console.log("removeChildFromContainer",e),resetTextContent:e=>console.log("resetTextContent",e)}),Oo=i(null),Vo=new Map;function Xo(){const e=n(Oo);if(!e)throw new Error("No context available!");return e}function Yo(e,n,o,r){var s;const i=Vo.get(n);let a=null==i?void 0:i.root;const l=(null==i?void 0:i.state)||{state:null,api:null,type:"root",root:null,id:0,events:new Map};if(l.root=l,!a){const s=zo(n,{onReady:()=>{null==o.onReady||o.onReady(),jo.updateContainer(t.createElement(Oo.Provider,{value:l},e),a,null,(()=>{}))},onEvent:e=>{if(e.type===ko.Res_WinProc&&273===e.message){const t=l.events.get(e.wParam);t&&t()}}},r);Object.assign(l,s),a=jo.createContainer(l,1,!1,null)}return Vo.set(n,{root:a,state:l}),null!=(s=l.state)&&s.ready&&jo.updateContainer(t.createElement(Oo.Provider,{value:l},e),a,null,(()=>{})),l}function qo(e){const t=Vo.get(e);if(!t)return;const{root:n}=t;jo.updateContainer(null,n,null,(()=>{Vo.delete(e)}))}const Go=o((function(n,o){let{children:i,style:a,onReady:l,binaries:d,...u}=n;const c=r(null),p=r(null);return s((()=>{p.current=Yo(i,c.current,{onReady:l},d),"function"==typeof o?o(p.current):o.current=p.current}),[i,l]),s((()=>{const e=c.current;return()=>qo(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)},u),t.createElement("div",{style:{whiteSpace:"pre",font:"14px monospace",lineHeight:"14px",...a||{}}}),t.createElement("canvas",{style:{display:"none"}}))}));var Jo=Object.freeze({__proto__:null});function Ko(e){let{onClick:n,x:o,y:r,w:s,h:i,children:a}=e;return t.createElement("w95Window",{type:"Button",onCommand:n,params:1342177280,x:o,y:r,w:s,h:i},a)}export{Ko as Button,Bo as CW_USEDEFAULT,Qo as CommandType,Fo as DataType,Jo as React95Fiber,ko as ResponseType,k as WM_ACTIVATE,H as WM_ACTIVATEAPP,z as WM_AFXFIRST,L as WM_AFXLAST,F as WM_APP,N as WM_ASKCBFORMATNAME,j as WM_CANCELJOURNAL,O as WM_CANCELMODE,V as WM_CAPTURECHANGED,X as WM_CHANGECBCHAIN,Y as WM_CHAR,q as WM_CHARTOITEM,G as WM_CHILDACTIVATE,J as WM_CLEAR,K as WM_CLOSE,Z as WM_COMMAND,$ as WM_COMMNOTIFY,ee as WM_COMPACTING,te as WM_COMPAREITEM,ne as WM_CONTEXTMENU,oe as WM_COPY,re as WM_COPYDATA,se as WM_CREATE,ie as WM_CTLCOLORBTN,ae as WM_CTLCOLORDLG,le as WM_CTLCOLOREDIT,de as WM_CTLCOLORLISTBOX,ue as WM_CTLCOLORMSGBOX,ce as WM_CTLCOLORSCROLLBAR,pe as WM_CTLCOLORSTATIC,me as WM_CUT,ye as WM_DEADCHAR,ve as WM_DELETEITEM,he as WM_DESTROY,Ce as WM_DESTROYCLIPBOARD,we as WM_DEVICECHANGE,fe as WM_DEVMODECHANGE,ge as WM_DISPLAYCHANGE,Ie as WM_DRAWCLIPBOARD,_e as WM_DRAWITEM,xe as WM_DROPFILES,be as WM_ENABLE,Ue as WM_ENDSESSION,Pe as WM_ENTERIDLE,We as WM_ENTERMENULOOP,Se as WM_ENTERSIZEMOVE,Me as WM_ERASEBKGND,Te as WM_EXITMENULOOP,Ee as WM_EXITSIZEMOVE,Re as WM_FONTCHANGE,Be as WM_GETDLGCODE,De as WM_GETFONT,Ae as WM_GETHOTKEY,Qe as WM_GETICON,Fe as WM_GETMINMAXINFO,ke as WM_GETTEXT,He as WM_GETTEXTLENGTH,ze as WM_HANDHELDFIRST,Le as WM_HANDHELDLAST,Ne as WM_HELP,je as WM_HOTKEY,Oe as WM_HSCROLL,Ve as WM_HSCROLLCLIPBOARD,Xe as WM_ICONERASEBKGND,Ye as WM_INITDIALOG,qe as WM_INITMENU,Ge as WM_INITMENUPOPUP,Je as WM_INPUTLANGCHANGE,Ke as WM_INPUTLANGCHANGEREQUEST,Ze as WM_KEYDOWN,Xn as WM_KEYFIRST,Yn as WM_KEYLAST,$e as WM_KEYUP,et as WM_KILLFOCUS,$n as WM_LBUTTONDBLCLK,Kn as WM_LBUTTONDOWN,Zn as WM_LBUTTONUP,so as WM_MBUTTONDBLCLK,oo as WM_MBUTTONDOWN,ro as WM_MBUTTONUP,tt as WM_MDIACTIVATE,nt as WM_MDICASCADE,ot as WM_MDICREATE,rt as WM_MDIDESTROY,st as WM_MDIGETACTIVE,it as WM_MDIICONARRANGE,at as WM_MDIMAXIMIZE,lt as WM_MDINEXT,dt as WM_MDIREFRESHMENU,ut as WM_MDIRESTORE,ct as WM_MDISETMENU,pt as WM_MDITILE,mt as WM_MEASUREITEM,ft as WM_MENUCHAR,ht as WM_MENUCOMMAND,wt as WM_MENUDRAG,Ct as WM_MENUGETOBJECT,vt as WM_MENURBUTTONUP,gt as WM_MENUSELECT,Gn as WM_MOUSEACTIVATE,ao as WM_MOUSEFIRST,uo as WM_MOUSEHOVER,lo as WM_MOUSELAST,co as WM_MOUSELEAVE,Jn as WM_MOUSEMOVE,io as WM_MOUSEWHEEL,_t as WM_MOVE,xt as WM_MOVING,bt as WM_NCACTIVATE,Ut as WM_NCCALCSIZE,Pt as WM_NCCREATE,Wt as WM_NCDESTROY,St as WM_NCHITTEST,Mt as WM_NCLBUTTONDBLCLK,Tt as WM_NCLBUTTONDOWN,Et as WM_NCLBUTTONUP,Rt as WM_NCMBUTTONDBLCLK,Bt as WM_NCMBUTTONDOWN,Dt as WM_NCMBUTTONUP,At as WM_NCMOUSEMOVE,Qt as WM_NCPAINT,Ft as WM_NCRBUTTONDBLCLK,kt as WM_NCRBUTTONDOWN,Ht as WM_NCRBUTTONUP,zt as WM_NEXTDLGCTL,It as WM_NEXTMENU,Lt as WM_NOTIFY,Nt as WM_NOTIFYFORMAT,jt as WM_NULL,Ot as WM_PAINT,Vt as WM_PAINTCLIPBOARD,Xt as WM_PAINTICON,Yt as WM_PALETTECHANGED,qt as WM_PALETTEISCHANGING,Gt as WM_PARENTNOTIFY,Jt as WM_PASTE,Kt as WM_PENWINFIRST,Zt as WM_PENWINLAST,$t as WM_POWER,en as WM_POWERBROADCAST,tn as WM_PRINT,nn as WM_PRINTCLIENT,on as WM_QUERYDRAGICON,rn as WM_QUERYENDSESSION,sn as WM_QUERYNEWPALETTE,an as WM_QUERYOPEN,ln as WM_QUEUESYNC,dn as WM_QUIT,no as WM_RBUTTONDBLCLK,eo as WM_RBUTTONDOWN,to as WM_RBUTTONUP,un as WM_RENDERALLFORMATS,cn as WM_RENDERFORMAT,pn as WM_SETCURSOR,mn as WM_SETFOCUS,yn as WM_SETFONT,vn as WM_SETHOTKEY,hn as WM_SETICON,Cn as WM_SETREDRAW,wn as WM_SETTEXT,fn as WM_SETTINGCHANGE,gn as WM_SHOWWINDOW,In as WM_SIZE,_n as WM_SIZECLIPBOARD,xn as WM_SIZING,bn as WM_SPOOLERSTATUS,Un as WM_STYLECHANGED,Pn as WM_STYLECHANGING,qn as WM_SYNCPAINT,Wn as WM_SYSCHAR,Sn as WM_SYSCOLORCHANGE,Mn as WM_SYSCOMMAND,Tn as WM_SYSDEADCHAR,En as WM_SYSKEYDOWN,Rn as WM_SYSKEYUP,Bn as WM_TCARD,Dn as WM_THEMECHANGED,An as WM_TIMECHANGE,Qn as WM_TIMER,Fn as WM_UNDO,yt as WM_UNINITMENUPOPUP,kn as WM_USER,Hn as WM_USERCHANGED,zn as WM_VKEYTOITEM,Ln as WM_VSCROLL,Nn as WM_VSCROLLCLIPBOARD,jn as WM_WINDOWPOSCHANGED,On as WM_WINDOWPOSCHANGING,Vn as WM_WININICHANGE,u as WS_BORDER,c as WS_CAPTION,p as WS_CHILD,m as WS_CHILDWINDOW,y as WS_CLIPCHILDREN,v as WS_CLIPSIBLINGS,h as WS_DISABLED,C as WS_DLGFRAME,po as WS_EX_ACCEPTFILES,mo as WS_EX_APPWINDOW,yo as WS_EX_CLIENTEDGE,vo as WS_EX_CONTEXTHELP,ho as WS_EX_CONTROLPARENT,Co as WS_EX_DLGMODALFRAME,wo as WS_EX_LEFT,fo as WS_EX_LEFTSCROLLBAR,go as WS_EX_LTRREADING,Io as WS_EX_MDICHILD,_o as WS_EX_NOPARENTNOTIFY,xo as WS_EX_OVERLAPPEDWINDOW,bo as WS_EX_PALETTEWINDOW,Uo as WS_EX_RIGHT,Po as WS_EX_RIGHTSCROLLBAR,Wo as WS_EX_RTLREADING,So as WS_EX_STATICEDGE,Mo as WS_EX_TOOLWINDOW,To as WS_EX_TOPMOST,Eo as WS_EX_TRANSPARENT,Ro as WS_EX_WINDOWEDGE,w as WS_GROUP,f as WS_HSCROLL,g as WS_ICONIC,I as WS_MAXIMIZE,_ as WS_MAXIMIZEBOX,x as WS_MINIMIZE,b as WS_MINIMIZEBOX,U as WS_OVERLAPPED,A as WS_OVERLAPPEDWINDOW,P as WS_POPUP,Q as WS_POPUPWINDOW,W as WS_SIZEBOX,S as WS_SYSMENU,M as WS_TABSTOP,T as WS_THICKFRAME,E as WS_TILED,R as WS_TILEDWINDOW,B as WS_VISIBLE,D as WS_VSCROLL,Go as Win95,zo as initEmulator,Yo as render,qo as unmountComponentAtNode,Xo as useWin95};
{
"name": "react-95-fiber",
"version": "0.0.5",
"version": "0.0.6",
"description": "Work in progress!",

@@ -34,3 +34,3 @@ "keywords": [],

"utility-types": "^3.10.0",
"v86-module": "^0.1.2"
"v86": "^0.3.6"
},

@@ -37,0 +37,0 @@ "devDependencies": {

# react95-fiber
**Work in progress!**
## Building with Docker
```bash
tools/build-tools.sh # or tools/build-tools-arm.sh on M1 Macs
tools/build-binaries.sh
yarn install
yarn build
```
## Running the Example
After build is completed:
```bash
cd example
yarn install
yarn start
```

@@ -296,1 +296,3 @@ // The window has a thin-line border.

export const WS_EX_WINDOWEDGE = 256;
export const CW_USEDEFAULT = 0x80000000;

@@ -1,2 +0,3 @@

import { V86Starter } from 'v86-module';
import { V86Starter } from 'v86';
import { CommBus } from './commBus';

@@ -26,3 +27,3 @@ export enum CommandType {

const paramsByteLength = params.map(p => 4 + (p.type === DataType.String ? (p.value as string).length + 1 + 4 : 4)).reduce((a, b) => a + b, 0);
const buffer = new ArrayBuffer(4 + 4 + 4 + paramsByteLength + 1);
const buffer = new ArrayBuffer(4 + 4 + 4 + paramsByteLength);
const view = new DataView(buffer);

@@ -32,3 +33,3 @@ view.setUint32(0, magic, true);

view.setUint32(8, params.length, true);
let stringPos = buffer.byteLength - 1;
let stringPos = buffer.byteLength;
for (let i = 0; i < params.length; i++) {

@@ -54,3 +55,2 @@ const param = params[i];

}
view.setUint8(buffer.byteLength - 1, '\r'.charCodeAt(0));
return buffer;

@@ -61,3 +61,2 @@ }

v86Emulator: V86Starter;
mousePos: [number, number];
ready: boolean;

@@ -136,29 +135,10 @@ }

// disable_keyboard: true,
autostart: options.fromState,
autostart: options.fromState || true,
});
// v86Emulator.add_listener('screen-set-mode', isGraphical => {
// if (isGraphical) {
// v86Emulator.screen_set_scale(options.scale, options.scale);
// } else {
// v86Emulator.screen_set_scale(1, 1);
// }
// });
v86Emulator.add_listener('emulator-started', () => {
v86Emulator.v86.cpu.devices.commBus = new CommBus(v86Emulator.v86.cpu, pkg => {
if (pkg.byteLength !== 8 && pkg.byteLength !== 16) return;
events.onEvent?.(parseEventPayload(pkg));
const emuState: EmulatorState = {
v86Emulator,
mousePos: [0, 0],
ready: false,
};
const buffer: number[] = [];
v86Emulator.add_listener('serial0-output-char', char => {
if (char !== '\r') {
buffer.push(char.charCodeAt(0));
return;
}
if (buffer.length === 16) {
events.onEvent?.(parseEventPayload(new Uint8Array(buffer).buffer));
if (!emuState.ready) {

@@ -168,11 +148,13 @@ events.onReady?.();

}
}
buffer.splice(0, buffer.length);
});
});
const emuState: EmulatorState = {
v86Emulator,
ready: false,
};
function sendSerial(data: ArrayBuffer) {
const bytes = new Uint8Array(data);
for (let i = 0; i < bytes.length; i++) {
v86Emulator.bus.send('serial0-input', bytes[i]);
}
const commBus = v86Emulator.v86.cpu.devices.commBus as CommBus;
commBus && commBus.sendData(data);
}

@@ -192,3 +174,9 @@

setMousePos(x: number, y: number) {
emuState.mousePos = [x, y];
if (!emuState.ready) return;
sendSerial(
buildRemoteCommand(CommandType.Cmd_SetCursorPos, [
{ type: DataType.Int, value: x },
{ type: DataType.Int, value: y },
]),
);
},

@@ -269,12 +257,2 @@

setInterval(() => {
if (!emuState.ready) return;
sendSerial(
buildRemoteCommand(CommandType.Cmd_SetCursorPos, [
{ type: DataType.Int, value: emuState.mousePos[0] },
{ type: DataType.Int, value: emuState.mousePos[1] },
]),
);
}, options.mouseUpdateInterval);
setInterval(() => {
sendSerial(buildRemoteCommand(CommandType.Cmd_Ping, []));

@@ -281,0 +259,0 @@ }, 2000);

type V86StarterEventParams = {
'serial0-output-char': string;
'screen-set-mode': boolean;
'emulator-started': undefined;
};

@@ -32,3 +33,3 @@

declare module 'v86-module' {
declare module 'v86' {
class V86Starter {

@@ -35,0 +36,0 @@ constructor(options: V86StarterOptions);

@@ -22,6 +22,7 @@ import Reconciler from 'react-reconciler';

h: number;
menuId?: number;
onCommand?: () => void;
};
}
) & { root: RootNode };
) & { root: RootNode; children?: NodeType[] };

@@ -33,16 +34,5 @@ let incremental = 3;

function createInstance(type: string, { type: windowType, ...props }: any, rootContainer: any) {
return {
type: type,
props: { windowType, ...props },
id: getIncremental(),
root: rootContainer.root,
};
}
function appendChild(parentInstance: NodeType, child: NodeType) {
console.log('appendChild', { parentInstance, child });
function createTextInstance(newText: string, rootContainerInstance: RootNode) {
return { type: 'text', content: newText };
}
function appendChild(parentInstance: NodeType, child: NodeType) {
if (child.type === 'w95Window' && parentInstance.type !== 'text') {

@@ -58,4 +48,4 @@ child.root.api.createWindow({

h: child.props.h,
parentId: parentInstance.id,
menuId: child.id,
parentId: parentInstance.id || 0,
menuId: child.props.menuId !== undefined ? child.props.menuId : child.id || 0,
extStyle: child.props.extStyle || 0,

@@ -67,6 +57,9 @@ });

}
}
if (child.type === 'text' && parentInstance.type === 'w95Window') {
parentInstance.props.text = child.content;
}
function appendChildToContainer(parentInstance: NodeType, child: NodeType) {
console.log('appendChildToContainer', { parentInstance, child });
appendChild(parentInstance, child);
child.children?.forEach(c => appendChildToContainer(child, c));
}

@@ -81,77 +74,94 @@

function insertBefore(parentInstance: NodeType, child: NodeType, beforeChild: NodeType) {
console.log('insertBefore', { parentInstance, child, beforeChild });
}
function applyProps(instance: NodeType, newProps: any, oldProps: any) {
console.log('applyProps', { instance, newProps, oldProps });
}
export const reconciler = Reconciler({
supportsMutation: true,
// We set this to false because this can work on top of react-dom
isPrimaryRenderer: false,
// We can modify the ref here, but we return it instead (no-op)
getPublicInstance: instance => instance,
// This object that's passed into the reconciler is the host context.
// We don't need to expose it though
getPublicInstance: i => i,
getRootHostContext: () => ({}),
getChildHostContext: () => ({}),
prepareForCommit: () => null,
resetAfterCommit: () => ({}),
scheduleTimeout: setTimeout,
cancelTimeout: clearTimeout,
noTimeout: -1,
now,
isPrimaryRenderer: false,
supportsMutation: true,
supportsPersistence: false,
supportsHydration: false,
preparePortalMount: () => {},
hideInstance: () => {},
hideTextInstance: () => {},
unhideInstance: () => {},
unhideTextInstance: () => {},
clearContainer: () => false,
prepareUpdate(instance: NodeType, type: string, oldProps: any, newProps: any) {
return true;
createInstance(type: string, { type: windowType, ...props }: any, rootContainer: any) {
return {
type: type as any,
props: { windowType, ...props },
id: getIncremental(),
root: rootContainer.root,
};
},
createTextInstance(newText: string, rootContainerInstance: RootNode) {
return { type: 'text', content: newText };
},
prepareForCommit: () => null,
resetAfterCommit: () => ({}),
appendInitialChild(parentInstance: NodeType, child: NodeType) {
console.log('appendInitialChild', { parentInstance, child });
if (child.type === 'text' && parentInstance.type === 'w95Window') {
parentInstance.props.text = child.content;
} else {
parentInstance.children = parentInstance.children || [];
parentInstance.children.push(child);
}
},
shouldSetTextContent: (type: string, props: any) => false,
// We can mutate objects once they're assembled into the scene graph here.
// applyProps removes the need for this though
finalizeInitialChildren: () => false,
finalizeInitialChildren(instance, type, props) {
// console.log('finalizeInitialChildren', { instance, type, props });
return false;
},
// This can modify the container and clear children.
// Might be useful for disposing on demand later
clearContainer: () => false,
prepareUpdate: (instance: NodeType, type: string, oldProps: any, newProps: any) => {
console.log('prepareUpdate', { instance, type, oldProps, newProps });
return true;
},
// This is where we'll create an element from a React element
createInstance,
createTextInstance,
shouldSetTextContent: (type: string, props: any) => {
// console.log('shouldSetTextContent', { type, props });
return false;
},
// These methods add elements to the scene
// -------------------
// Mutation
// (optional)
// -------------------
appendChild,
appendInitialChild: appendChild,
appendChildToContainer: appendChild,
appendChildToContainer,
// These methods remove elements from the scene
removeChild,
removeChildFromContainer: removeChild,
commitTextUpdate(instance: NodeType, oldText: string, newText: string) {
console.log('commitTextUpdate', { instance, oldText, newText });
},
insertBefore,
commitMount: p => console.log('commitMount', p),
insertInContainerBefore: (parentInstance, child, beforeChild) => insertBefore(parentInstance, child, beforeChild),
commitUpdate(instance: NodeType, diff, type, oldProps: Record<string, unknown>, newProps: Record<string, unknown>, fiber: Reconciler.Fiber) {
console.log('commitUpdate', { instance, diff, type, oldProps, newProps, fiber });
commitUpdate(instance: any, diff, type, oldProps: Record<string, unknown>, newProps: Record<string, unknown>, fiber: Reconciler.Fiber) {
applyProps(instance, newProps, oldProps);
if (instance.type === 'w95Window') {
if (typeof newProps.children === 'string' && newProps.children !== oldProps.children) {
instance.root.api.setWindowText(instance.id, newProps.children);
} 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);
}
}
},
commitTextUpdate(instance: any, oldText: string, newText: string) {
console.log(instance, newText, oldText);
},
insertBefore: p => console.log('insertBefore', p),
insertInContainerBefore: (parentInstance, child, beforeChild) => console.log('insertInContainerBefore', { parentInstance, child, beforeChild }),
hideInstance(instance: any) {},
unhideInstance(instance: any, props: Record<string, unknown>) {},
hideTextInstance() {},
removeChild: p => console.log('removeChild', p),
removeChildFromContainer: p => console.log('removeChildFromContainer', p),
supportsPersistence: false,
supportsHydration: false,
preparePortalMount() {},
now,
scheduleTimeout: setTimeout,
cancelTimeout: clearTimeout,
noTimeout: -1,
resetTextContent: p => console.log('resetTextContent', p),
});

@@ -6,3 +6,3 @@ declare global {

w95Window: {
type: 'Button' | 'Static' | 'Edit';
type: 'Button' | 'Static' | 'Edit' | 'WindowsApp';
text?: string;

@@ -15,3 +15,4 @@ extStyle?: number;

h: number;
children?: JSX.Element | string;
menuId?: number;
children?: JSX.Element[] | JSX.Element | string;
onCommand?: () => void;

@@ -18,0 +19,0 @@ };

@@ -12,3 +12,3 @@ export function shallowCompare(a: any, b: any) {

export function pruneKeys<T>(obj: T, ...keys: string[][]) {
export function pruneKeys<T extends {}>(obj: T, ...keys: string[][]) {
const keysToRemove = new Set(keys.flat());

@@ -15,0 +15,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc