feat(ruffle): add alternative ruffle flash target runner
This commit is contained in:
75
haxetool/ruffle.js
Executable file
75
haxetool/ruffle.js
Executable file
@@ -0,0 +1,75 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const fse = require("fs-extra");
|
||||
const os = require("os");
|
||||
const through = require("through2");
|
||||
const Sdk = require("./sdk");
|
||||
const System = require("./system");
|
||||
const Env = require('./env');
|
||||
const run = require("../run/index");
|
||||
const { TailVinyl } = require("./tail");
|
||||
const FlashPlayer = require("./flashplayer");
|
||||
|
||||
class RufflePlayer extends FlashPlayer {
|
||||
BASE_URL = 'https://github.com/ruffle-rs/ruffle/releases/download';
|
||||
|
||||
constructor(debug, version) {
|
||||
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
|
||||
this.debug = debug;
|
||||
this.baseUrl = Env.get('RUFFLE_URL') || this.BASE_URL;
|
||||
}
|
||||
|
||||
get link() {
|
||||
const baseUrl = `${baseUrl}/${this.version.replaceAll('_', '-')}`;
|
||||
if (System.isWindows) {
|
||||
return baseUrl + `/ruffle-${this.version}-windows-x86_64.zip`;
|
||||
} else if (System.isLinux) {
|
||||
return baseUrl + `/ruffle-${this.version}-linux-x86_64.tar.gz`;
|
||||
} else {
|
||||
throw `Unsupported os '${os.type()}'`;
|
||||
}
|
||||
}
|
||||
|
||||
get flashPlayerBin() {
|
||||
if (System.isWindows) {
|
||||
return path.join(this.path, "ruffle.exe");
|
||||
} else if (System.isLinux) {
|
||||
return path.join(this.path, "ruffle");
|
||||
} else {
|
||||
throw `Unsupported os '${os.type()}'`;
|
||||
}
|
||||
}
|
||||
|
||||
static get log() {
|
||||
return path.join(os.homedir(), ".cache/ruffle/log/ruffle.log");
|
||||
}
|
||||
|
||||
run(filename, params) {
|
||||
this.log.i("_run_ *%s*", filename);
|
||||
return run(`${this.flashPlayerBin} ${filename}`, params)
|
||||
.exec()
|
||||
.pipe(
|
||||
through.obj(function (file, enc, callback) {
|
||||
const log = new TailVinyl({
|
||||
path: RufflePlayer.log,
|
||||
handler: (line) => {
|
||||
if (line.includes("avm_trace")) {
|
||||
return line.split("avm_trace: ").pop();
|
||||
}
|
||||
},
|
||||
});
|
||||
this.on("end", () => log.dispose());
|
||||
this.push(log);
|
||||
callback();
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RufflePlayer.ID = "ruffle";
|
||||
|
||||
RufflePlayer.VERSION_2026_05_15 = "nightly-2026_05_15";
|
||||
|
||||
RufflePlayer.VERSION = RufflePlayer.VERSION_2026_05_15;
|
||||
|
||||
module.exports = RufflePlayer;
|
||||
Reference in New Issue
Block a user