Files
gulp-haxetool/src/impl/ruffle.ts
T
shmyga dfad6d3aba
test / test (push) Successful in 35s
docs: update README
2026-10-31 15:50:42 +03:00

65 lines
2.0 KiB
TypeScript
Executable File

import os from "os";
import path from "path";
import env from "../common/env";
import { System } from "../common/system";
import { watch } from "../common/watch";
import run from "../run";
import { FlashPlayer } from "./flashplayer";
export class RufflePlayer extends FlashPlayer {
static ID = "ruffle";
static VERSION_2026_05_15 = "nightly-2026_05_15";
static VERSION_2026_10_13 = "nightly-2026_10_13";
static VERSION_0_5_0 = "0.5.0";
static VERSION_0_6_0 = "0.6.0";
static VERSION_0_7_1 = "0.7.1";
static VERSION = RufflePlayer.VERSION_0_7_1;
BASE_URL = "https://github.com/ruffle-rs/ruffle/releases/download";
constructor(debug: boolean, version: string) {
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
this.baseUrl = env.get("RUFFLE_URL") || this.BASE_URL;
}
get link(): string {
const nightly = this.version.includes("nightly");
const baseUrl = `${this.baseUrl}/${nightly ? "" : "v"}${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(): string {
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(): string {
return path.join(os.homedir(), ".cache/ruffle/log/ruffle.log");
}
run(filename: string, params: any) {
this.log.i("_run_ *%s*", filename);
return run(`${this.flashPlayerBin} ${filename}`, params)
.exec()
.pipe(
watch(RufflePlayer.log, (line: string) => {
if (line.includes("avm_trace")) {
return line.split("avm_trace: ").pop();
}
}),
);
}
}