<iframe src%3D"...?screen_scale%3D2" width%3D"1280" height%3D"960">`}),` `,`will result in a 640x480 screen scaled by a factor of 2 that is rendered crisply.`]}),(0,M.jsx)(`h2`,{children:`Performance`}),(0,M.jsxs)(`p`,{children:[`Infinite Mac relies on `,(0,M.jsx)(`code`,{children:`SharedArrayBuffer`}),` for maximum performance. You may need to set the`,` `,(0,M.jsx)(`code`,{children:`Cross-Origin-Embedder-Policy`}),` header in your page to `,(0,M.jsx)(`code`,{children:`require-corp`}),` and/or add the`,` `,(0,M.jsx)(`code`,{children:`allow%3D"cross-origin-isolated"`}),` attribute to the iframe to enable this. The emulator will still run without`,(0,M.jsx)(`code`,{children:`SharedArrayBuffer`}),`, but it will be be`,` `,(0,M.jsx)(`a`,{href:`https://blog.persistent.info/2021/08/worker-loop.html`,children:`hackier`}),` `,`and slower. You can look for a "SharedArrayBuffer is not available, fallback more will be used. Performance may be degraded." message in the console to determine if this is the case.`]}),(0,M.jsx)(`h2`,{children:`Sending Messages To The Iframe`}),(0,M.jsxs)(`p`,{children:[`You can send messages to the iframe using the`,` `,(0,M.jsx)(`code`,{children:`postMessage`}),` API, allowing you to control it from within the parent page.`]}),(0,M.jsxs)(`pre`,{children:[`const iframe %3D document.getElementById("my-iframe")%3B`,``,`iframe.contentWindow.postMessage(`,`{`,`type: "emulator_`,(0,M.jsx)(`i`,{children:`command`}),`"`,`}`,`, "*")%3B`]}),(0,M.jsxs)(`p`,{children:[`Currently supported message payloads (see also the`,` `,(0,M.jsx)(`a`,{href:`https://github.com/mihaip/infinite-mac/blob/main/src/embed-types.ts`,children:(0,M.jsx)(`code`,{children:`EmbedControlEvent`})}),` `,`type):`]}),(0,M.jsxs)(`ul`,{className:`EmbedDocs-MessageList`,children:[(0,M.jsxs)(`li`,{children:[$({type:`emulator_pause`}),`: Pause the emulator. May be useful if you do not want it to use resources while the user is not interacting with it. See also the`,` `,(0,M.jsx)(`code`,{children:`pause%3Dtrue`}),` (start with the emulator initially paused) and `,(0,M.jsx)(`code`,{children:`auto_pause%3Dtrue`}),` `,`(automatically pause and unpause the emulator when it out of and into view) query parameters.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_unpause`}),`: Unpause the emulator.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_mouse_move`,x:11,y:15,deltaX:2,deltaY:4}),`: Send a mouse movement to the emulator. Some emulators (Mini vMac, Basilisk II, SheepShaver) support absolute coordinates, while others (Previous, DingusPPC, PearPC) only support relative coordinates.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_mouse_down`,button:0}),` and`,` `,$({type:`emulator_mouse_up`,button:0}),`: Send mouse button up and down events. Some emulator and operating system combinations (Previous, DingusPPC with Mac OS X) support right-clicking, in which case the`,` `,(0,M.jsx)(`code`,{children:`button`}),` parameter can also be set to`,` `,(0,M.jsx)(`code`,{children:`2`}),` to control the right mouse button.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_key_down`,code:`KeyA`}),` and`,` `,$({type:`emulator_key_up`,code:`KeyA`}),`: Send key up and down events. The `,(0,M.jsx)(`code`,{children:`code`}),` property is a physical key code, based on the`,` `,(0,M.jsxs)(`a`,{href:`https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code`,children:[(0,M.jsx)(`code`,{children:`code`}),` value of a JavaScript keyboard event`]}),`. See`,` `,(0,M.jsx)(`a`,{href:`https://github.com/mihaip/infinite-mac/blob/main/src/emulator/common/key-codes.ts`,children:`the source code`}),` `,`for the full list of supported key codes.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_load_disk`,url:`...`}),`: Load a disk image into the emulator. Only supported by the Mini vMac, Basilisk II, SheepShaver and Previous emulators. The `,(0,M.jsx)(`code`,{children:`url`}),` property should be a URL to an uncompressed disk image file (e.g. a .dsk, .img, .iso, .toast, etc.).`]})]}),(0,M.jsx)(`h2`,{children:`Receiving Messages From The Iframe`}),(0,M.jsxs)(`p`,{children:[`The iframe will send messages to the parent page using the`,` `,(0,M.jsx)(`code`,{children:`postMessage`}),` API, allowing you to monitor its status and respond to changes within it.`]}),(0,M.jsxs)(`pre`,{children:[`window.addEventListener("message", e %3D`,`> { `,`switch (e.data.type) `,`{ `,`case "emulator_`,(0,M.jsx)(`i`,{children:`message`}),`: ...`,` `,`}`,`}`,`)%3B`]}),(0,M.jsxs)(`p`,{children:[`Currently supported message payloads (see also the`,` `,(0,M.jsx)(`a`,{href:`https://github.com/mihaip/infinite-mac/blob/main/src/embed-types.ts`,children:(0,M.jsx)(`code`,{children:`EmbedNotificationEvent`})}),` `,`type):`]}),(0,M.jsxs)(`ul`,{className:`EmbedDocs-MessageList`,children:[(0,M.jsxs)(`li`,{children:[$({type:`emulator_loaded`}),`: Sent when the emulator has finished loading all of its data files and has begun running the emulated machine.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_exited`}),`: Sent when the emulator exits, for example when the guest operating system shuts down.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_error`,error:`...`}),`: Sent when the emulator reports an error, including running out of memory. The `,(0,M.jsx)(`code`,{children:`error`}),` property contains a human-readable error message.`]}),(0,M.jsxs)(`li`,{children:[$({type:`emulator_screen`,data:Uint8Array,width:640,height:480}),`: Sent when the contents of the screen change. Requires`,` `,(0,M.jsx)(`code`,{children:`screen_update_messages%3Dtrue`}),` query parameter to be set. The data is a `,(0,M.jsx)(`code`,{children:`Uint8Array`}),` `,`containing the raw pixel data of the screen, in RGBA format (4 bytes per pixel).`]})]}),(0,M.jsx)(`h2`,{children:`Reporting Bugs`}),(0,M.jsxs)(`p`,{children:[`If you have run into a bug, you can`,` `,(0,M.jsx)(`a`,{href:`https://github.com/mihaip/infinite-mac/issues/new`,children:`file an issue on GitHub`}),`. Please include as much detail as possible (ideally a link to a page with a reproduction).`]})]})})}function $(e){return(0,M.jsx)(`code`,{children:JSON.stringify(e).replace(`,`,`, `).replace(`:`,`: `)})}function ar({defaultDisk:e%3Do[`System 7.1`],onDone:t}){let[n,r]%3D(0,j.useState)(!1),i%3D(0,j.useCallback)(e%3D>{e.preventDefault(),r(!0)},[])%3B(0,j.useEffect)(()%3D>{S(`embed_shown`)},[])%3Blet[a,s]%3D(0,j.useState)({machine:e.preferredMachine,ramSize:void 0,screenSize:`auto`,disks:[e],cdromURLs:[],cdromPrefetchChunks:[],includeInfiniteHD:!0,includeSavedHD:!1,includeLibrary:!1,libraryDownloadURLs:[],isCustom:!0,diskFiles:[],flags:{}}),{flags:c}%3Da,l%3D(0,j.useCallback)(e%3D>{s(t%3D> Nie oznaczono