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.3 to 0.0.4

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,_=131072,w=1048576,f=536870912,I=16777216,g=65536,h=536870912,x=131072,U=0,P=2147483648,W=262144,S=524288,b=65536,M=262144,E=0,R=13565952,T=268435456,B=2097152,A=13565952,D=-2138570752,F=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,_e=537,we=27,fe=126,Ie=776,ge=43,he=563,xe=10,Ue=22,Pe=289,We=529,Se=561,be=20,Me=530,Ee=562,Re=29,Te=135,Be=49,Ae=51,De=127,Fe=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,_t=291,wt=288,ft=287,It=531,gt=3,ht=534,xt=134,Ut=131,Pt=129,Wt=130,St=132,bt=163,Mt=161,Et=162,Rt=169,Tt=167,Bt=168,At=160,Dt=133,Ft=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,_n=12,wn=26,fn=24,In=5,gn=779,hn=532,xn=42,Un=125,Pn=124,Wn=262,Sn=21,bn=274,Mn=263,En=260,Rn=261,Tn=82,Bn=794,An=30,Dn=275,Fn=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,_o=0,wo=16384,fo=0,Io=64,go=4,ho=768,xo=392,Uo=4096,Po=0,Wo=8192,So=131072,bo=128,Mo=8,Eo=32,Ro=256;let To,Bo,Ao;function Do(e,t){const n=t.map((e=>4+(e.type===Bo.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===Bo.Int)r.setInt32(12+8*e+4,n.value,!0);else if(n.type===Bo.UInt)r.setUint32(12+8*e+4,n.value,!0);else if(n.type===Bo.Float)r.setFloat32(12+8*e+4,n.value,!0);else if(n.type===Bo.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 Fo(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,bios:{url:n.seabios},vga_bios:{url:n.vgabios},hda:{url:n.osImg},boot_order:306,memory_size:33554432,disable_mouse:!0,autostart:o.fromState}),s={v86Emulator:r,mousePos:[0,0],ready:!1},i=[];function l(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===i.length&&(null==t.onEvent||t.onEvent(function(e){const t=new DataView(e),n=t.getUint32(0,!0);return n===Ao.Res_WinProc?{type:n,message:t.getUint32(4,!0),wParam:t.getUint32(8,!0),lParam:t.getInt32(12,!0)}:{type:n}}(new Uint8Array(i).buffer)),s.ready||(null==t.onReady||t.onReady(),s.ready=!0)),i.splice(0,i.length)):i.push(e.charCodeAt(0))}));const u={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){s.mousePos=[e,t]},setWindowPos(e,t,n,o,r){l(Do(To.Cmd_SetWindowPos,[{type:Bo.UInt,value:e},{type:Bo.Int,value:t},{type:Bo.Int,value:n},{type:Bo.Int,value:o},{type:Bo.Int,value:r}]))},createWindow(e){l(Do(To.Cmd_CreateWindow,[{type:Bo.UInt,value:e.id},{type:Bo.UInt,value:e.extStyle},{type:Bo.String,value:e.type},{type:Bo.String,value:e.text},{type:Bo.UInt,value:e.params},{type:Bo.Int,value:e.x},{type:Bo.Int,value:e.y},{type:Bo.Int,value:e.w},{type:Bo.Int,value:e.h},{type:Bo.UInt,value:e.parentId},{type:Bo.UInt,value:e.menuId}]))},destroyWindow(e){l(Do(To.Cmd_DestroyWindow,[{type:Bo.UInt,value:e}]))},setWindowText(e,t){l(Do(To.Cmd_SetWindowText,[{type:Bo.UInt,value:e},{type:Bo.String,value:t}]))},sendMouseEvent(e,t){e?0===t?l(Do(To.Cmd_MouseEvent,[{type:Bo.UInt,value:2}])):2===t&&l(Do(To.Cmd_MouseEvent,[{type:Bo.UInt,value:8}])):0===t?l(Do(To.Cmd_MouseEvent,[{type:Bo.UInt,value:4}])):2===t&&l(Do(To.Cmd_MouseEvent,[{type:Bo.UInt,value:16}]))}};return setInterval((()=>{s.ready&&l(Do(To.Cmd_SetCursorPos,[{type:Bo.Int,value:s.mousePos[0]},{type:Bo.Int,value:s.mousePos[1]}]))}),o.mouseUpdateInterval),setInterval((()=>{l(Do(To.Cmd_Ping,[]))}),2e3),{state:s,api:u}}!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"}(Bo||(Bo={})),function(e){e[e.Res_Invalid=0]="Res_Invalid",e[e.Res_PingResponse=1]="Res_PingResponse",e[e.Res_WinProc=2]="Res_WinProc"}(Ao||(Ao={}));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=Fo(n,{onReady:()=>{null==o.onReady||o.onReady(),jo.updateContainer(e.createElement(Lo.Provider,{value:l},t),i,null,(()=>{}))},onEvent:e=>{if(e.type===Ao.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,Bo as DataType,Go as React95Fiber,Ao as ResponseType,k as WM_ACTIVATE,H as WM_ACTIVATEAPP,z as WM_AFXFIRST,N as WM_AFXLAST,F 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,_e as WM_DEVICECHANGE,we as WM_DEVMODECHANGE,fe 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,We as WM_ENTERMENULOOP,Se as WM_ENTERSIZEMOVE,be as WM_ERASEBKGND,Me as WM_EXITMENULOOP,Ee as WM_EXITSIZEMOVE,Re as WM_FONTCHANGE,Te as WM_GETDLGCODE,Be as WM_GETFONT,Ae as WM_GETHOTKEY,De as WM_GETICON,Fe 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,_t as WM_MENUDRAG,Ct as WM_MENUGETOBJECT,yt as WM_MENURBUTTONUP,ft 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,Wt as WM_NCDESTROY,St as WM_NCHITTEST,bt as WM_NCLBUTTONDBLCLK,Mt as WM_NCLBUTTONDOWN,Et as WM_NCLBUTTONUP,Rt as WM_NCMBUTTONDBLCLK,Tt as WM_NCMBUTTONDOWN,Bt as WM_NCMBUTTONUP,At as WM_NCMOUSEMOVE,Dt as WM_NCPAINT,Ft 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,_n as WM_SETTEXT,wn as WM_SETTINGCHANGE,fn 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,Wn as WM_SYSCHAR,Sn as WM_SYSCOLORCHANGE,bn as WM_SYSCOMMAND,Mn as WM_SYSDEADCHAR,En as WM_SYSKEYDOWN,Rn as WM_SYSKEYUP,Tn as WM_TCARD,Bn as WM_THEMECHANGED,An as WM_TIMECHANGE,Dn as WM_TIMER,Fn 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,_o as WS_EX_LEFT,wo as WS_EX_LEFTSCROLLBAR,fo 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,Wo as WS_EX_RTLREADING,So as WS_EX_STATICEDGE,bo as WS_EX_TOOLWINDOW,Mo as WS_EX_TOPMOST,Eo as WS_EX_TRANSPARENT,Ro as WS_EX_WINDOWEDGE,_ as WS_GROUP,w as WS_HSCROLL,f as WS_ICONIC,I as WS_MAXIMIZE,g as WS_MAXIMIZEBOX,h as WS_MINIMIZE,x as WS_MINIMIZEBOX,U as WS_OVERLAPPED,A as WS_OVERLAPPEDWINDOW,P as WS_POPUP,D as WS_POPUPWINDOW,W as WS_SIZEBOX,S as WS_SYSMENU,b as WS_TABSTOP,M as WS_THICKFRAME,E as WS_TILED,R as WS_TILEDWINDOW,T as WS_VISIBLE,B as WS_VSCROLL,qo as Win95,Fo as initEmulator,Xo as render,Yo as unmountComponentAtNode,Vo as useWin95};
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};
{
"name": "react-95-fiber",
"version": "0.0.3",
"version": "0.0.4",
"description": "Work in progress!",

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

"utility-types": "^3.10.0",
"v86-module": "^0.1.0"
"v86-module": "^0.1.1"
},

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

@@ -99,8 +99,16 @@ import { V86Starter } from 'v86-module';

export type Binaries = {
v86WASM: any;
seabios: string;
vgabios: string;
osImg: string;
v86WASM?: ArrayBuffer;
v86WASMFn?: any;
seabios?: ArrayBuffer;
seabiosUrl?: string;
vgabios?: ArrayBuffer;
vgabiosUrl?: string;
osImg?: ArrayBuffer;
osImgUrl?: string;
};
function wrapWasm(wasmAB: ArrayBuffer) {
return async (param: any) => (await WebAssembly.instantiate(wasmAB, param)).instance.exports;
}
export type EmulatorAPI = ReturnType<typeof initEmulator>['api'];

@@ -116,6 +124,6 @@

screen_container: screenContainer,
wasm_fn: binaries.v86WASM,
bios: { url: binaries.seabios },
vga_bios: { url: binaries.vgabios },
hda: { url: binaries.osImg },
wasm_fn: binaries.v86WASM ? wrapWasm(binaries.v86WASM) : binaries.v86WASMFn,
bios: binaries.seabios ? { buffer: binaries.seabios } : { url: binaries.seabiosUrl },
vga_bios: binaries.vgabios ? { buffer: binaries.vgabios } : { url: binaries.vgabiosUrl },
hda: binaries.osImg ? { buffer: binaries.osImg } : { url: binaries.osImgUrl },
// initial_state: options.fromState && { url: './state.bin' },

@@ -122,0 +130,0 @@ boot_order: 0x132,

@@ -6,3 +6,3 @@ type V86StarterEventParams = {

type URLOrArrayBuffer = { url: string; async?: boolean; size?: number } | ArrayBuffer | File;
type URLOrArrayBuffer = { url?: string; async?: boolean; size?: number } | { buffer: ArrayBuffer } | File;

@@ -9,0 +9,0 @@ type V86StarterOptions = {

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