Add Ruffle support for Flash files.

Allow viewing Flash posts with the Ruffle emulator.

Known issues:

* Many flash files aren't fully supported.
* In development it sometimes spazzes out and starts triggering random
  keyboard shortcuts when you press any key. This doesn't happen with
  the browser extension.
* We have to put the .wasm file in the public/packs/js directory because
  Ruffle is hardcoded to search for it there.
* If you're running Nginx, you need to make sure you're serving the
  right MIME type for .wasm files or it won't work.
* We're using Some Random Guy's unofficial NPM package for Ruffle, since the
  Ruffle project doesn't publish an official package themselves. We
  should build our own package.

References:

* https://github.com/ruffle-rs/ruffle
* https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#configure-webassembly-mime-type
* https://www.npmjs.com/package/ruffle-mirror
This commit is contained in:
evazion
2021-03-31 20:20:22 -05:00
parent a062c040cb
commit 55980c6fbf
5 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
import "../../../node_modules/ruffle-mirror/ruffle.js";
import "../../../node_modules/ruffle-mirror/ea72e7bd92c6a211ab42071518cef232.wasm";

View File

@@ -4,3 +4,5 @@
<% end %>
<p><%= link_to "Save this flash (right click and save)", post.tagged_file_url %></p>
<%= javascript_pack_tag "flash" %>

View File

@@ -20,6 +20,12 @@ module.exports = merge(webpackConfig, {
options: {
runner: "bin/rails runner"
}
}, {
test: /\.wasm$/,
type: 'asset/resource',
generator: {
filename: 'js/[name][ext]'
}
}]
},
});

View File

@@ -27,6 +27,7 @@
"postcss-loader": "^5.0.0",
"postcss-preset-env": "^6.7.0",
"rails-erb-loader": "^5.5.0",
"ruffle-mirror": "^2021.3.31",
"sass": "^1.32.5",
"sass-loader": "^11.0.0",
"spark-md5": "^3.0.0",

View File

@@ -8340,6 +8340,7 @@ fsevents@~2.3.1:
postcss-loader: ^5.0.0
postcss-preset-env: ^6.7.0
rails-erb-loader: ^5.5.0
ruffle-mirror: ^2021.3.31
sass: ^1.32.5
sass-loader: ^11.0.0
spark-md5: ^3.0.0
@@ -8353,6 +8354,13 @@ fsevents@~2.3.1:
languageName: unknown
linkType: soft
"ruffle-mirror@npm:^2021.3.31":
version: 2021.3.31
resolution: "ruffle-mirror@npm:2021.3.31"
checksum: 2247ab90331e9e9a6c532a576ef04f31ecde95fe246b83f96f3af1facd4ab566e99e7834ddfbe8ea5932594e187c78515bac174382c630e34a7ac72b7d6bbb8e
languageName: node
linkType: hard
"run-parallel@npm:^1.1.9":
version: 1.2.0
resolution: "run-parallel@npm:1.2.0"