feat(ruffle): add alternative ruffle flash target runner

This commit is contained in:
2026-05-15 21:55:38 +03:00
parent 715f6807d8
commit ca61b68cd9
8 changed files with 115 additions and 12 deletions

View File

@@ -78,7 +78,7 @@ class Config {
afterUpdate() {
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 1.777777778);
if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222);
}
branch(params) {

View File

@@ -5,15 +5,18 @@ 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');
class FlashPlayer extends Sdk {
BASE_URL = 'https://fpdownload.macromedia.com/pub/flashplayer/updaters';
constructor(debug, version) {
super(FlashPlayer.ID, version || FlashPlayer.VERSION);
constructor(debug, version, playerId = FlashPlayer.ID) {
super(playerId, version || FlashPlayer.VERSION);
this.debug = debug;
this.baseUrl = Env.get('FLASHPLAYER_URL') || this.BASE_URL;
}
prepare() {
@@ -29,22 +32,22 @@ class FlashPlayer extends Sdk {
}
get link() {
const baseUrl = `https://fpdownload.macromedia.com/pub/flashplayer/updaters/${this.version}/`;
const baseUrl = `${this.baseUrl}/${this.version}`;
if (System.isWindows) {
return baseUrl + `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
return this.baseUrl + `/flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
} else if (System.isLinux) {
return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`;
return this.baseUrl + `/flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`;
} else {
throw `Unsupported os '${os.type()}'`;
}
}
get flashPlayerBin() {
if (os.type() === 'Windows_NT') {
if (System.isWindows) {
const v = this.version.split('.');
const playerName = `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
return path.join(this.path, playerName);
} else if (os.type() === 'Linux') {
} else if (System.isLinux) {
const binPath = path.join(this.path, `flashplayer${this.debug ? 'debugger' : ''}`);
fs.chmodSync(binPath, 0o755);
return binPath;

View File

@@ -5,6 +5,7 @@ const fs = require('fs');
const fse = require('fs-extra');
const Haxe = require('./haxe');
const FlashPlayer = require('./flashplayer');
const RufflePlayer = require('./ruffle');
const Android = require('./android');
const Neko = require('./neko');
const InnoSetup = require('./innosetup');
@@ -332,9 +333,9 @@ Runner.factory = {};
*/
class FlashRunner extends Runner {
constructor(config, debug) {
constructor(config, debug, player = FlashPlayer) {
super(config, Platform.FLASH, debug);
this.player = new FlashPlayer(debug);
this.player = new player(debug);
}
prepare() {
@@ -349,6 +350,12 @@ class FlashRunner extends Runner {
}
}
class RuffleRunner extends FlashRunner {
constructor(config, debug) {
super(config, debug, RufflePlayer);
}
}
Runner.register(Platform.FLASH, FlashRunner);
/**
@@ -532,6 +539,10 @@ class Project {
}
return this;
}
static useRuffle() {
Runner.register(Platform.FLASH, RuffleRunner);
}
}
Project.BuildSystem = BuildSystem;

75
haxetool/ruffle.js Executable file
View 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;

View File

@@ -123,7 +123,7 @@ class Sdk {
if (this.prepared) {
return Promise.resolve();
} else {
this.log.d('download: *%s*', this.link);
this.log.i('download: *%s*', this.link);
return Downloader.download(this.link, this.path, strip);
}
}

View File

@@ -13,7 +13,14 @@ class TailVinyl extends Vinyl {
super(params);
if (params.path) {
this.tail = new Tail(params.path);
this.tail.on('line', data => this.contents.write(data + '\n'));
this.tail.on('line', line => {
if (params.handler) {
line = params.handler(line);
}
if (line) {
this.contents.write(line + '\n');
}
}),
this.tail.on('error', error => this.contents.write('error: ' + error));
}
}