ruffle/web/packages/core
Mike Welsh c2b768c453 web: Fallback to instantiate with improper MIME type
Use --target web in wasm-bindgen and file-loader for WASM files,
allowing wasm-bindgen's built-in fallback from
WebAssembly.instantiateStreaming to instantiate.

file-loader spits out the WASM file directly in the output folder,
and imports will resolve to the URL, so that we can load the file
directly, avoiding webpack's built-in wasm loaders.

This allows Ruffle to function on web servers even if they serve
WASM files with the incorrect MIME type, fixing one of our biggest
support requests (#400, #1458). There is some performance impact
on loading with the fallback, but this is preferable to not
working at all.
2021-01-16 15:30:11 -08:00
..
src web: Fallback to instantiate with improper MIME type 2021-01-16 15:30:11 -08:00
test web: Rename VersionRange.from_requirement_string to 2020-11-24 16:36:33 -08:00
tools web: Embed build/version info inside the js 2020-11-24 16:36:33 -08:00
.eslintrc.json web: Include git details into the build 2020-11-04 16:46:14 -08:00
README.md docs: Update `streamSwfUrl` to `load` 2020-12-07 15:22:51 -08:00
package.json web: Fallback to instantiate with improper MIME type 2021-01-16 15:30:11 -08:00
tsconfig.json build(deps-dev): bump @wdio/cli from 6.10.5 to 6.10.11 in /web 2020-12-19 13:19:11 -08:00
typedoc.json chore: Fix typedoc config for typedoc 0.20 2020-12-29 17:27:48 -08:00

README.md

ruffle-core

ruffle-core is the core javascript bindings to the Wasm ruffle-web binary, and contains the actual public API.

Using ruffle-core

For more examples and in-depth documentation on how to use Ruffle on your website, please check out our wiki.

Host Ruffle

The core package is configured for websites that build and bundle their files themselves. Simply add ruffle to an npm package, and use something like Webpack to actually bundle and serve the files.

If you wish to use Ruffle on a website that doesn't use npm, we have a pre-bundled version which we call 'selfhosted'. Please refer to its documentation.

Please note that the .wasm file must be served properly, and some web servers may not do that correctly out of the box. Please see our wiki for instructions on how to configure this, if you encounter a Incorrect response MIME type error.

"Plug and Play"

If you have an existing website with flash content, you can simply include Ruffle as a script and our polyfill magic will replace everything for you. No fuss, no mess.

<script src="path/to/ruffle/ruffle.js"></script>

Javascript API

If you want to control the Ruffle player, you may use our Javascript API.

<script>
    window.RufflePlayer = window.RufflePlayer || {};

    window.addEventListener("DOMContentLoaded", () => {
        let ruffle = window.RufflePlayer.newest();
        let player = ruffle.createPlayer();
        let container = document.getElementById("container");
        container.appendChild(player);
        player.load("movie.swf");
    });
</script>
<script src="path/to/ruffle/ruffle.js"></script>

Building, testing or contributing

Please see the ruffle-web README.