{"_id":"@anikthedev/nwruffle","_rev":"2-048a5e8c39bbfe33c5db12d9755a3bc0","name":"@anikthedev/nwruffle","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@anikthedev/nwruffle","version":"2.0.0","_id":"@anikthedev/nwruffle@2.0.0","maintainers":[{"name":"anikthedev","email":"morzinabegam0@gmail.com"}],"dist":{"shasum":"a90a4e8c5a3659e1c9fd44fa56627b3f424c7c1b","tarball":"https://registry.npmjs.org/@anikthedev/nwruffle/-/nwruffle-2.0.0.tgz","fileCount":6,"integrity":"sha512-rcyXKo0/BNfp2ZfjOfJc7Iy8HdVMLpShl/7miFAWR9cCdHUkwM8crwqfgcC5t7v6SjdXj3QL0pGaa/9Xb8npXg==","signatures":[{"sig":"MEYCIQDZdveU68mnKCwsZpQuBdPIpmwkwCML7++z5mhhpHxmSAIhALRTwcFlW+HnpJrUelzPQACNI1yUgS2VUW0eDhXhRDPE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":276081},"main":"bootstrap.js","gitHead":"1fa759f3b54de12924db75bbccec52529068760e","_npmUser":{"name":"anikthedev","email":"morzinabegam0@gmail.com"},"_npmVersion":"11.6.2","description":"the wonders of ruffle and nw.js mixed with an easy api","directories":{},"_nodeVersion":"24.12.0","dependencies":{"@ruffle-rs/ruffle":"0.2.0-nightly.2026.1.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nwruffle_2.0.0_1767337896935_0.5186697152372879","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@anikthedev/nwruffle","version":"2.0.1","description":"the wonders of ruffle and nw.js mixed with an easy api","main":"bootstrap.js","dependencies":{"@ruffle-rs/ruffle":"0.2.0-nightly.2026.1.2"},"gitHead":"9bd36d4866d58f5603b83a2455cc36fef9e7bffb","_id":"@anikthedev/nwruffle@2.0.1","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-rTZ9MgmT+YmJwprpt5zDHLk0jbmt6WhnO3aMQRi78DHvOwgS4UG7zdChMpyxwurB/58zSlAQS9N4CyrDlMg91A==","shasum":"dad106a8810c0077219a51cdc3a2c7b798e27fd9","tarball":"https://registry.npmjs.org/@anikthedev/nwruffle/-/nwruffle-2.0.1.tgz","fileCount":6,"unpackedSize":276275,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAOLOJyXs5s/uomSmc6+X5GLBFDS0yV+N/PB7NPXo0Z/AiEAvu521Z6GFGTPoPemELCvDqaYm4/W60kMHUuvZbErwiQ="}]},"_npmUser":{"name":"anikthedev","email":"morzinabegam0@gmail.com"},"directories":{},"maintainers":[{"name":"anikthedev","email":"morzinabegam0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nwruffle_2.0.1_1767340361038_0.8696420659497002"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-02T07:11:36.853Z","modified":"2026-01-02T07:52:41.437Z","2.0.0":"2026-01-02T07:11:37.145Z","2.0.1":"2026-01-02T07:52:41.216Z"},"description":"the wonders of ruffle and nw.js mixed with an easy api","maintainers":[{"name":"anikthedev","email":"morzinabegam0@gmail.com"}],"readme":"<p align=\"center\">\r\n  <img alt=\"Ruffle\" src=\"NWRuffle.svg\" /></a>\r\n</p>\r\n\r\n# NWRuffle\r\nThis NWRuffle project combines and helps you to add Ruffle support to your NW.js projects with adding an api that just makes it so easy to handle ruffle\r\n[![npm](https://img.shields.io/npm/v/nwruffle?logo=npm)](https://www.npmjs.com/package/nwruffle)\r\n[![commit](https://img.shields.io/github/last-commit/Anikthedev-official/NWRuffle?logo=github)](https://github.com/Anikthedev-official/NWRuffle)\r\n\r\n\r\n\r\n\r\n## 📘 Table of Contents\r\n\r\n- [Overview](#overview)\r\n- [Installation](#installation)\r\n- [Adding & Customizing Ruffle](#adding--customizing-ruffle)\r\n- [Troubleshooting & Issues](#troubleshooting--issues)\r\n- [API](#api)\r\n- [Contributing](#contributing)\r\n- [End](#end)\r\n- [Images](#images)\r\n\r\n### Overview\r\n\r\nNWRuffle provides an easy way to add Ruffle support to your NW.js projects, Once set up, it automatically includes `ruffle.js` and allows you to do all the normal ruffle stuff\r\n\r\n---\r\n\r\n### Installation\r\n\r\n1. **Download** the NWRuffle project by doing :\r\n```\r\nnpm install @anikthedev/nwruffle\r\n```\r\n2. In your NW.js `package.json`, add the dependecies\r\n```\r\n\"dependencies\": {\r\n  \"@ruffle-rs/ruffle\": \"latest\"\r\n  \"nwruffle\": \"latest\"\r\n}\r\n```\r\n3. (remember) add this in html`  <script src=\"node_modules/nwruffle/bootstrap.js\"></script>` \r\nand installation done.\r\n\r\n---\r\n\r\n### Adding & Customizing ruffle\r\nTHERE IS AN EXAMPLE [HERE!](https://github.com/Anikthedev-Official/NWRuffle-Example/).\r\nRuffle must be included in your HTML.\r\nSince NWRuffle handles script injection automatically, you only need to add the configuration and player container in your HTML file <br>\r\n**Example Setup**\r\n```\r\n<div id=\"flash-content\"></div>\r\n\r\n\r\n  <script>\r\n    function waitForRuffle(cb) {\r\n      if (window.RufflePlayer) cb();\r\n      else requestAnimationFrame(() => waitForRuffle(cb));\r\n    }\r\n\r\n    waitForRuffle(() => {\r\n      const container = document.getElementById(\"flash-content\");\r\n\r\n      const ruffle = window.RufflePlayer.newest();\r\n      const player = ruffle.createPlayer();\r\n\r\n      Object.assign(player.style, {\r\n        width: \"100%\",\r\n        height: \"100%\",\r\n        display: \"block\"\r\n      });\r\n\r\n\r\n      container.appendChild(player);\r\n\r\n\r\n      player.load(\"file.swf\");\r\n\r\n      console.log(\"[NWRuffle] SWF loaded: file.swf\");\r\n    });\r\n  </script>\r\n```\r\n\r\n### Troubleshooting & Issues\r\nIf you encounter issues:\r\n 1. Ruffle-related issues:\r\n    [Report Here](https://github.com/ruffle-rs/ruffle/issues)\r\n 2. NW.js-related issues:\r\n    [Report Here](https://github.com/nwjs/nw.js/issues)\r\n 3. NWRuffle-specific issues or feature requests:\r\n    [Report Here](https://github.com/Anikthedev-Official/NWRuffle/issues)\r\n\r\n### API\r\n**Why NWRuffle?**\r\nNormally, setting up Ruffle looks like this:\r\n```\r\n    function waitForRuffle(cb) {\r\n      if (window.RufflePlayer) cb();\r\n      else requestAnimationFrame(() => waitForRuffle(cb));\r\n    }\r\n\r\n    waitForRuffle(() => {\r\n      const container = document.getElementById(\"flash-content\");\r\n\r\n      const ruffle = window.RufflePlayer.newest();\r\n      const player = ruffle.createPlayer();\r\n\r\n      Object.assign(player.style, {\r\n        width: \"100%\",\r\n        height: \"100%\",\r\n        display: \"block\"\r\n      });\r\n\r\n\r\n      container.appendChild(player);\r\n\r\n\r\n      player.load(\"file.swf\");\r\n\r\n      console.log(\"[NWRuffle] SWF loaded: file.swf\");\r\n    });\r\n```\r\nWith **NWRuffle**, the same thing becomes:\r\n```\r\nNWRuffle.initialize(() => {\r\nNWRuffle.container(\"flash-content\");\r\n\r\nObject.assign(NWRuffle.player.style, {\r\n  width: \"100%\",\r\n  height: \"100%\",\r\n  display: \"block\"\r\n});\r\nNWRuffle.player.load(\"file.swf\");\r\n});\r\n```\r\nSo now it’s cleaner, easier to read, and nicer to work with :)\r\n\r\n---\r\n\r\n* `NWRuffle.initialize();`\r\n&nbsp;&nbsp; is **VERY important**, you must call this first.\r\n&nbsp;&nbsp;It waits for Ruffle to be ready and then runs your code.\r\n&nbsp;&nbsp;it can also be run as \r\n&nbsp;&nbsp;\r\n```\r\nNWRuffle.initialize(() => {\r\n  // cats please\r\n  });\r\n  ```\r\n---\r\n* `NWRuffle.container(\"flash-content\");` \r\n&nbsp;&nbsp;creates the Ruffle player and\r\n&nbsp;&nbsp;attaches it to your container.\r\n&nbsp;&nbsp;After this runs, \"NWRuffle.player\" will exist. ()\r\n---\r\n\r\n* `NWRuffle.player`\r\n&nbsp;&nbsp;is the Ruffle player instance.\r\n&nbsp;&nbsp;It is created after calling `NWRuffle.container(...)`.\r\n\r\n&nbsp;&nbsp;You can use it like a normal Ruffle player, for example:\r\n\r\n```\r\nObject.assign(NWRuffle.player.style, {\r\nwidth: \"100%\",\r\nheight: \"100%\",\r\ndisplay: \"block\"\r\n});\r\n```\r\n\r\n&nbsp;&nbsp;And load SWF files like this:\r\n\r\n```\r\nNWRuffle.player.load(\"file.swf\");\r\n```\r\n---\r\n* `NWRuffle.swap(swf)` \r\n&nbsp;&nbsp;Replaces the currently loaded SWF with another one\r\n&nbsp;&nbsp;without destroying the player.\r\n&nbsp;&nbsp;Example :\r\n```\r\nNWRuffle.swap(\"cats.swf\");\r\n```\r\n---\r\n* `NWRuffle.destroy()` Completely removes the Ruffle player from the DOM.\r\nAfter calling this, the player no longer exists.\r\n---\r\n* `NWRuffle.reinstate()`\r\n&nbsp;&nbsp;Recreates the player after it was\r\n&nbsp;&nbsp;destroyed.\r\n&nbsp;&nbsp;Useful if you want to reload or \r\n&nbsp;&nbsp;reset everything.\r\n\r\n sidequote - \"if it can die it can re-exist\" \r\n\r\n---\r\n* `NWRuffle.fullscreen()` \r\n&nbsp;&nbsp;Toggles fullscreen mode for the \r\n&nbsp;&nbsp;Ruffle player.\r\n\r\n---\r\n\r\n* `NWRuffle.setSize(w, h)`\r\n&nbsp;&nbsp;Manually sets the player size.\r\n\r\n&nbsp;&nbsp;Example:\r\n\r\n```\r\nNWRuffle.setSize(800, 600);\r\n```\r\n---\r\n**THE VAULT OF EVERY API I HAVE**\r\n```\r\nwindow.NWRuffle → The global object exposing all NWRuffle APIs (initialize, container, load, swap, destroy, reinstate, fullscreen, setSize, and internal references like main, player, containerEl, lastSWF)\r\n\r\nNWRuffle.initialize(cb)          → Waits for Ruffle to be loaded and initializes NWRuffle; calls optional callback when ready.\r\nNWRuffle.container(id)          → Sets the HTML element (by id) where the SWF will be injected.\r\nNWRuffle.load(swf)              → Loads the specified SWF into the container and replaces any existing player.\r\nNWRuffle.swap(swf)              → Swaps the currently loaded SWF for a new one without recreating the container.\r\nNWRuffle.destroy()               → Removes the current Ruffle player from the container.\r\nNWRuffle.reinstate()             → Recreates the last destroyed Ruffle player and reloads the last SWF.\r\nNWRuffle.fullscreen()            → Puts the container into fullscreen mode using the browser API.\r\nNWRuffle.setSize(w, h)           → Resizes the container to the specified width and height in pixels.\r\nNWRuffle.main                    → Reference to `window.RufflePlayer.newest()`, the main Ruffle instance.\r\nNWRuffle.player                  → Reference to the currently active Ruffle player (<ruffle-player> element).\r\nNWRuffle.containerEl             → Reference to the DOM element used as the container for the player.\r\nNWRuffle.lastSWF                 → Stores the path/URL of the last loaded SWF for reinstate and swap.\r\n```\r\nbye!!\r\n\r\n---\r\n### Contributing\r\nContributions, suggestions, and improvements are always welcome!\r\nFeel free to submit a pull request or open an issue.\r\n\r\n### End\r\n<p align=\"center\"> Made with ❤️ by <a href=\"https://github.com/Anikthedev-Official\">Anikthedev</a> </p> \r\nSpecial thanks:<br >\r\ndr.taco - helped me very much <br>\r\nagoknee - honest reviews <br>\r\nmy brother - its for him that i wanted to code <br>\r\n\r\n### images\r\n![me](image.png)\r\n![NW.js general gary](image-1.png)\r\n\r\n","readmeFilename":"README.md"}