mirror of
https://github.com/illuminus5/skiff.git
synced 2026-12-05 12:24:45 +01:00
- #72: KBD HOLD: ARP 2 › HOLD ON with the ARP's MODE OFF holds the notes you play; a key pressed with none down starts a new chord, keys pressed while others are down join it; HOLD off, the ARP on or another track ends them. - A chord on a MONO, LEGATO or UNISON sound goes whole into the arpeggiator when the ARP is on. - Learn: the eleven chapters whose videos showed 1.3 have new ones, made on 2.0. - #69: FX let go with an effect key still held: KNOB 1 to 4 stay while the key is held. - #71: the same pattern on two neighbouring SONG entries: the second plays every edit at once, on its own sound. - #70: the header's octave no longer covers the BPM (#73, by fengqiaoqu). - SONG: a change to the next entry after it was lined up is heard that round. - SAMPLE: a note struck again while it still sounds starts without a click. - #64: on an SMK-37 whose start-up part isn't V016's, the installer says why the way back stops, not to replug.
358 lines
29 KiB
HTML
358 lines
29 KiB
HTML
<!doctype html>
|
||
<!-- SPDX-License-Identifier: GPL-3.0-only
|
||
Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments -->
|
||
<html lang="ja">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Skiff</title>
|
||
<style>
|
||
:root { --bg: #fff; --fg: #000; --dim: #777; }
|
||
@media (prefers-color-scheme: dark) {
|
||
:root:not([data-theme="light"]) { --bg: #000; --fg: #fff; --dim: #888; }
|
||
}
|
||
:root[data-theme="dark"] { --bg: #000; --fg: #fff; --dim: #888; }
|
||
body { margin: 0; background: var(--bg); color: var(--fg);
|
||
font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; }
|
||
main { max-width: 520px; margin: 0 auto; padding: 48px 16px; }
|
||
h1 { font-size: 24px; font-weight: 600; margin: 0 0 24px; }
|
||
.lang { float: right; font-size: 13px; color: var(--dim); cursor: pointer; text-decoration: underline; background: none; padding: 0; color: var(--dim); }
|
||
p { margin: 0 0 16px; }
|
||
button { font: inherit; background: var(--fg); color: var(--bg); border: 0; padding: 8px 20px; cursor: pointer; }
|
||
button:disabled { opacity: .3; cursor: default; }
|
||
#status { margin-top: 16px; min-height: 1.6em; }
|
||
.small { color: var(--dim); font-size: 13px; }
|
||
progress { width: 100%; height: 4px; margin-top: 16px; }
|
||
pre { color: var(--dim); font-size: 12px; white-space: pre-wrap; margin-top: 16px; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<main>
|
||
<button class="lang" id="lang"></button>
|
||
<h1>Skiff</h1>
|
||
<p data-t="intro"></p>
|
||
<p data-t="warn"></p>
|
||
<p class="small" data-t="direct"></p>
|
||
<p class="small" data-t="beta"></p>
|
||
<p class="small"><span data-t="brick"></span>
|
||
<a href="https://github.com/kurogedelic/FM-1-transporter" target="_blank" rel="noopener" style="color:inherit">FM-1-transporter</a></p>
|
||
<p class="small"><span data-t="smk"></span>
|
||
<a href="https://github.com/illuminus5/skiff/blob/main/SMK37.md" target="_blank" rel="noopener" style="color:inherit">SMK37.md</a></p>
|
||
<p><button id="go" disabled data-t="install"></button></p>
|
||
<details style="margin-top:24px">
|
||
<summary data-t="stockTitle"></summary>
|
||
<p class="small" data-t="back"></p>
|
||
<p class="small"><a href="https://www.m-vave.com/download" target="_blank" rel="noopener" style="color:inherit">M-VAVE Downloads</a></p>
|
||
<p><label><span data-t="stockFile"></span><br><input id="stock-file" type="file" accept=".fwsc"></label></p>
|
||
<p><button id="stock-go" disabled data-t="stockGo"></button></p>
|
||
<p class="small" data-t="stockBackup"></p>
|
||
<p class="small"><label><input id="stock-recovery" type="checkbox"> <span data-t="stockRecovery"></span></label></p>
|
||
</details>
|
||
<progress id="bar" max="100" value="0"></progress>
|
||
<p id="status"></p>
|
||
<pre id="log"></pre>
|
||
<p><a href="../editor/" style="color:inherit" data-t="editor"></a></p>
|
||
<p><a href="../../learn/" style="color:inherit" data-t="learn"></a></p>
|
||
<p class="small">Skiff by illuminus5, built on Felucca by Leo Kuroshita (@kurogedelic), <a href="https://hugelton.com" target="_blank" rel="noopener" style="color:inherit">Hügelton Instruments</a>, with its CrispyZebra waveforms, drum voices, Sample Pack and Fukiai icons (MIT).<br>
|
||
SMK-37 support after genkigenki's SMK-37 layer (GPL-3.0). Font: Barlow Condensed (The Barlow Project Authors, SIL OFL 1.1). DRUM-X: JIANT FM by juanjiant-bit (GPL-3.0). Samples: Versilian Studios VSCO-2 Community Edition and VCSL (CC0 1.0).<br>
|
||
FM6 engine: msfa from Dexed (Google Inc., Pascal Gauthier, Apache-2.0). The package also holds three JieLi AC79 SDK files, uboot.boot, cfg_tool.bin and eq_cfg_hw.bin (JieLi Technology, Apache-2.0). <a href="../../firmware/LICENSING.md" style="color:inherit">Licences</a>: <a href="../../firmware/LICENSE" style="color:inherit">GPL-3.0</a>, <a href="../../firmware/LICENSES/Apache-2.0.txt" style="color:inherit">Apache-2.0</a>, <a href="../../firmware/LICENSES/" style="color:inherit">all</a>.<br>
|
||
M-VAVE, FM-1 and SMK-37 are trademarks of their respective owners.<br>
|
||
<span data-t="license"></span> <a href="https://github.com/illuminus5/skiff" target="_blank" rel="noopener" style="color:inherit">github.com/illuminus5/skiff</a></p>
|
||
</main>
|
||
<script type="module">
|
||
/*LIB*/
|
||
const $ = (id) => document.getElementById(id);
|
||
const TEXT = {
|
||
ja: {
|
||
intro: "FM-1 または SMK-37 を USB で接続してください。(Chrome か Edge で使えます)",
|
||
warn: "書き込み中は USB を抜かず、電源も切らないでください。途中で切れても書き込みモードのまま残るので、挿し直す(電源を入れる)と続きから再開します。",
|
||
install: "インストール", other: "English",
|
||
editor: "エディタ(インストール後、パソコンから音色やシーケンスを編集)",
|
||
learn: "Learn Skiff(使い方ガイド。章ごとに解説動画つき・英語のみ)",
|
||
direct: "USB ケーブルはパソコンに直接つないでください。Probe や Transporter などの機材は不要です。",
|
||
brick: "FM-1 で万一インストールに失敗して起動しなくなった場合は、復旧に Transporter が必要です:",
|
||
smk: "SMK-37 Pro は Skiff に新しく対応した機種です。インストール前にバックアップと公式への戻し方をお読みください:",
|
||
beta: "Skiff はカスタムファームウェアです。不具合は GitHub で知らせてください。このカスタムファームウェアを使ったことで機器が壊れたり不具合が起きたりしても、作者は一切の責任を負いません。自己責任でお使いください。",
|
||
back: "M-VAVE から公式ファームウェア(FM-1 は Skiff の前に入っていた版で V15 か V16、SMK-37 Pro は V016)を取得し、未変更の FM-1.fwsc または SMK-37_Pro_016.fwsc を選んでください。M-VAVE のダウンロードページは現在 V16 です。V15 は M-VAVE の fm1_open リポジトリ(sdk/firmware/FM-1_015.fwsc)にあります。ファイルはこのブラウザ内で検証し、サーバーへ送りません。",
|
||
stockTitle: "公式ファームウェアに戻す", stockFile: "公式 FM-1.fwsc(V15 または V16)または SMK-37_Pro_016.fwsc", stockGo: "バックアップして公式ファームウェアへ戻す",
|
||
stockBackup: "現在の曲・保存曲・音色バンク・サンプル・設定を先に保存します。全体バックアップ非対応版は、Skiff を更新してから行ってください。復元は Skiff を再インストールしてエディタから行います。",
|
||
stockRecovery: "更新中断の再開:全体バックアップはすでにパソコンへ保存済み",
|
||
stockValid: "公式ファームウェアを確認しました: ", stockConfirm: "全体バックアップファイルをパソコンに保存できましたか? 続けると公式ファームウェアへ戻します。Skiff の曲は公式ファームウェアでは開けません。",
|
||
stockNeedBackup: "書き込みモードからはバックアップできません。保存済みバックアップがある場合だけ、更新中断の再開にチェックしてください。",
|
||
stockUnsupported: "このファームウェアは Skiff の全体バックアップを作れません。古い Skiff なら先に最新版をインストールしてください。他のファームウェアから戻すには M-VAVE のアップデーターを使ってください。",
|
||
stockIsStock: "この機器はすでにその公式ファームウェアです。",
|
||
stockNotSkiff: "この機器は Skiff ではないため、バックアップする Skiff の曲はありません。他のファームウェアから戻すには M-VAVE のアップデーターを使ってください。機器の報告: ",
|
||
saved20: "Skiff 2.0 は、それより前のファームウェアで保存したデータをそのままでは開けません。先にこの機器の全体バックアップをこのパソコンに保存しました(Skiff-backup-....json)。これが元に戻す方法です: 今のファームウェアを入れ直し、エディタで復元します。Skiff 2.0 をインストールしますか?",
|
||
converting: "前のファームウェアで保存したデータを 2.0 用に変換中 ",
|
||
converted: "完了。前のファームウェアで保存したデータを 2.0 用に変換しました(下に一覧)。",
|
||
asIs: "完了。この機器のデータはそのまま 2.0 で開けます。",
|
||
convertedPart: "完了しましたが、前のファームウェアで保存したデータの一部はそのままです(下に一覧)。本体では OLD FORMAT と表示されます。空きパターンが足りなかったプロジェクトは、SAVE > PATTERNS で空けてからエディタでバックアップし、それを復元すると変換されます。",
|
||
convertFailed: "インストールは完了しましたが、前のデータの変換に失敗しました。保存したバックアップをエディタで復元してください(復元時に変換されます)。",
|
||
stockWrongModel: "選んだファイルは、接続している機器とは別の機種用です。",
|
||
stockSkiffOld: "書き込みはしていません。この Skiff はその公式版にまだ対応していません。最新の Skiff をインストールしてから、公式ファームウェアに戻してください。",
|
||
stockNeedsV16: "書き込みはしていません。この FM-1 の起動部は V16 のものです(Skiff の前は V16 でした)。戻せるのは V16 です。M-VAVE の現在の FM-1.fwsc(V16)を選んでください。",
|
||
stockNeedsV15: "書き込みはしていません。この FM-1 の起動部は V15 のものです(Skiff の前は V15 でした)。戻せるのは V15 です。M-VAVE の fm1_open リポジトリ(sdk/firmware)の FM-1_015.fwsc を選んでください。その後 M-VAVE の M-UPGRADE で V16 にできます。",
|
||
stockSmkHead: "書き込みはしていません。Skiff はそのまま使えます。このキーボードの起動部は V016 のものではありません(別の版で出荷されたか、Skiff の前のファームウェアが書き換えました)。そのため V016 には戻せません。Skiff が動いている間は、M-VAVE のアップデーターでも同じ確認で止まります。Skiff の前に何が入っていたかを、Skiff の GitHub で教えてください。",
|
||
backup: "全体バックアップ保存中 ", stockError: "公式ファイルを確認できません: ",
|
||
nomidi: "このブラウザでは使えません。Chrome か Edge で開いてください。", loadfail: "読み込めませんでした: ",
|
||
start: "開始します", verify: "確認中", loader: "書き込みモードに切り替え中", write: "書き込み中",
|
||
reboot: "再起動中", done: "完了しました", stopped: "途中で止まりました。USB を挿し直してもう一度押してください。",
|
||
dropped: "接続が切れました。書き込みモードのまま残っています。USB を挿し直す(または電源を入れる)と続きから再開します。待機中…",
|
||
resume: "書き込みを再開しています。試行 ",
|
||
error: "エラー: ",
|
||
denied: "MIDI(SysEx)の使用が許可されませんでした。アドレスバーのサイト設定で MIDI を許可して、もう一度押してください。",
|
||
notfound: "FM-1 / SMK-37 が見つかりません。USB ケーブル(データ通信用か)を確かめ、MIDI を使う他のアプリを閉じてから、もう一度押してください。",
|
||
model: "接続されている機器は、このファイルの機種ではありません。",
|
||
nopkg: "この機器向けの Skiff はありません。機器の報告: ",
|
||
needV016: "この SMK-37 は V016 より古い M-VAVE 公式ファームウェアです。先に M-VAVE のアップデーター(M-UPGRADE)で V016 に更新してから、Skiff をインストールしてください。機器の報告: ",
|
||
lost: "USB の接続が切れました。挿し直してもう一度押してください。",
|
||
noloader: "書き込みモードの機器が見つかりません。USB をハブや USB 共有ソフトを通さずパソコンに直接挿し直して、もう一度押してください(終わるまで書き込みモードのままです)。",
|
||
noreturn: "機器が戻ってきません。電源を入れ直してください。",
|
||
mismatch: "書き込みは終わりましたが、機器が別のバージョンを報告しています: ",
|
||
badpkg: "インストールするファイルが壊れています。ページを再読み込みしてください。",
|
||
leave: "書き込み中です。ページを閉じないでください。",
|
||
license: "GPL-3.0、無保証。ソース:",
|
||
},
|
||
en: {
|
||
intro: "Connect the FM-1 or SMK-37 by USB. (Works in Chrome or Edge.)",
|
||
warn: "Keep it plugged in and switched on while it writes. If the cable or the power is cut, it stays in update mode: plug it back in (or switch it on) and the install carries on.",
|
||
install: "Install", other: "日本語",
|
||
editor: "Editor (after installing: edit sounds and sequences from the computer)",
|
||
learn: "Learn Skiff (the manual, with a video for every chapter)",
|
||
direct: "Connect the USB cable directly to the computer. No probe or Transporter is needed.",
|
||
brick: "If an install fails on an FM-1 and it no longer starts, recovering it needs a Transporter:",
|
||
smk: "The SMK-37 Pro is new to Skiff. Before installing, read about the backup and the way back to stock:",
|
||
beta: "Skiff is custom firmware; please report problems on GitHub. The author accepts no responsibility if your keyboard is damaged or misbehaves because of this custom firmware. Use it at your own risk.",
|
||
back: "Get the official firmware from M-VAVE (FM-1: the version it had before Skiff, V15 or V16; SMK-37 Pro: V016) and select the unmodified FM-1.fwsc or SMK-37_Pro_016.fwsc. M-VAVE's download page now has V16; V15 is in M-VAVE's fm1_open repository (sdk/firmware/FM-1_015.fwsc). The browser validates it locally; it is not sent to a server.",
|
||
stockTitle: "Return to the official firmware", stockFile: "Official FM-1.fwsc (V15 or V16) or SMK-37_Pro_016.fwsc", stockGo: "Back up and return to the official firmware",
|
||
stockBackup: "Current music, saved music, sound banks, samples and settings are saved first. Older firmware needs a Skiff update for complete backups. To restore an archive later, reinstall Skiff and use the editor.",
|
||
stockRecovery: "Resume an interrupted update: I already saved a complete backup to this computer",
|
||
stockValid: "Official firmware verified: ", stockConfirm: "Has the complete backup file been saved to this computer? Continue to return to the official firmware. The official firmware cannot open Skiff music.",
|
||
stockNeedBackup: "An update loader cannot export a backup. Only select resume if you already saved a complete backup.",
|
||
stockUnsupported: "This firmware cannot make a complete Skiff backup. An older Skiff: install the current Skiff first. Another firmware: return with M-VAVE's updater.",
|
||
stockIsStock: "This keyboard already runs that official firmware.",
|
||
stockNotSkiff: "This keyboard is not running Skiff, so there is no Skiff music to back up. To return from another firmware, use M-VAVE's updater. It reports: ",
|
||
saved20: "Skiff 2.0 opens nothing that firmware before it saves: a complete backup of this unit was saved to this computer first (Skiff-backup-....json). It is the way back: install your firmware of now, then restore it in the editor. Install Skiff 2.0?",
|
||
converting: "Converting what the firmware before saved, for 2.0 ",
|
||
converted: "Done. What the firmware before saved was converted for 2.0 (the list below).",
|
||
asIs: "Done. Everything this unit had opens in 2.0 as it is.",
|
||
convertedPart: "Done, but some of what the firmware before saved stays as it was (the list below): the unit shows it as OLD FORMAT. A project no free pattern could take converts once you free some (SAVE > PATTERNS), take a backup in the editor and restore it.",
|
||
convertFailed: "Installed, but converting what the firmware before saved failed: restore the saved backup in the editor, which converts it. ",
|
||
stockWrongModel: "The selected file is for another model than the connected keyboard.",
|
||
stockSkiffOld: "Nothing was written. This Skiff can't take that official version yet: install the current Skiff first, then return to the official firmware.",
|
||
stockNeedsV16: "Nothing was written. This FM-1's start-up part is V16's (it ran V16 before Skiff), so its way back is V16: select M-VAVE's current FM-1.fwsc (V16).",
|
||
stockNeedsV15: "Nothing was written. This FM-1's start-up part is V15's (it ran V15 before Skiff), so its way back is V15: select FM-1_015.fwsc from M-VAVE's fm1_open repository (sdk/firmware). M-VAVE's M-UPGRADE can take it to V16 afterwards.",
|
||
stockSmkHead: "Nothing was written, and Skiff runs as before. This keyboard's start-up part is not V016's (it came with another, or a firmware before Skiff rewrote it), so V016 can't go back on it; while Skiff runs, M-VAVE's own updaters stop at the same check. Please tell us on Skiff's GitHub what the keyboard ran before Skiff.",
|
||
backup: "Saving complete backup ", stockError: "Cannot validate official firmware: ",
|
||
nomidi: "This browser cannot do it. Open the page in Chrome or Edge.", loadfail: "Could not load: ",
|
||
start: "Starting", verify: "Verifying", loader: "Switching to update mode", write: "Writing",
|
||
reboot: "Restarting", done: "Done", stopped: "Stopped. Replug the USB cable and press Install again.",
|
||
dropped: "The connection dropped. The keyboard stays in update mode: plug the cable back in (or switch it back on) and the install carries on. Waiting…",
|
||
resume: "Resuming the write, try ",
|
||
error: "Error: ",
|
||
denied: "MIDI (SysEx) access was not allowed. Allow MIDI in the site settings (address bar) and press Install again.",
|
||
notfound: "No FM-1 or SMK-37 found. Check the USB cable (a data cable), close other apps that use MIDI, and press Install again.",
|
||
model: "The connected keyboard is not the model this file is for.",
|
||
nopkg: "There is no Skiff for this keyboard. It reports: ",
|
||
needV016: "This SMK-37 runs M-VAVE's firmware older than V016. Update it to V016 with M-VAVE's own updater (M-UPGRADE) first, then install Skiff. It reports: ",
|
||
lost: "The USB connection was lost. Replug it and press Install again.",
|
||
noloader: "The keyboard in update mode was not found. Replug the USB cable straight into the computer (not through a hub or USB-sharing software) and press Install again (it stays in update mode until it is finished).",
|
||
noreturn: "The keyboard did not come back. Power-cycle it.",
|
||
mismatch: "Written, but the keyboard reports another version: ",
|
||
badpkg: "The file to install is damaged. Reload the page.",
|
||
leave: "Writing. Do not close the page.",
|
||
license: "GPL-3.0, no warranty. Source:",
|
||
},
|
||
};
|
||
let lang = (navigator.language || "en").toLowerCase().startsWith("ja") ? "ja" : "en";
|
||
const t = (k) => TEXT[lang][k];
|
||
let lastKey = null, lastArg = "";
|
||
function applyLang() {
|
||
document.documentElement.lang = lang;
|
||
document.querySelectorAll("[data-t]").forEach((e) => { e.textContent = t(e.dataset.t); });
|
||
$("lang").textContent = t("other");
|
||
if (lastKey) $("status").textContent = t(lastKey) + lastArg;
|
||
}
|
||
$("lang").addEventListener("click", () => { lang = lang === "ja" ? "en" : "ja"; applyLang(); });
|
||
applyLang();
|
||
const sayK = (k, arg = "") => { lastKey = k; lastArg = arg; $("status").textContent = t(k) + arg; };
|
||
const say = (txt) => { lastKey = null; $("status").textContent = txt; };
|
||
const log = (t) => { $("log").textContent += t + "\n"; };
|
||
const meta = /*META*/;
|
||
// one package per model ({ product, pkg }); a site made before the SMK builds carries only product + pkg
|
||
const packages = meta.packages || [{ product: meta.product, pkg: meta.pkg }];
|
||
const images = new Map(); // product -> logical image, loaded on first use
|
||
|
||
let writing = false, stock = null, stockFileEpoch = 0;
|
||
const lockInstaller = (on) => { writing = on; $("go").disabled = on || !navigator.requestMIDIAccess; $("stock-go").disabled = on || !stock; $("stock-file").disabled = on; $("stock-recovery").disabled = on; };
|
||
window.addEventListener("beforeunload", (e) => { if (writing) { e.preventDefault(); e.returnValue = t("leave"); } });
|
||
|
||
if (!navigator.requestMIDIAccess) sayK("nomidi");
|
||
else { say(`Skiff ${meta.version}`); $("go").disabled = false; }
|
||
|
||
async function imageFor(entry) {
|
||
if (images.has(entry.product)) return images.get(entry.product);
|
||
const r = await fetch(entry.pkg);
|
||
if (!r.ok) throw Object.assign(new Error(`${entry.pkg}: HTTP ${r.status}`), { code: "loadfail" });
|
||
const pkg = new Uint8Array(await r.arrayBuffer());
|
||
if (productOf(pkg) !== entry.product) throw Object.assign(new Error(entry.product), { code: "badpkg" });
|
||
const image = logicalImage(pkg);
|
||
images.set(entry.product, image);
|
||
return image;
|
||
}
|
||
|
||
// the bar: the running firmware's check takes the first 5 %, the loader's write (forward only) the rest
|
||
const stepper = () => (k, a) => {
|
||
log(`${k} ${a ?? ""}`);
|
||
if (k === "start") sayK("start");
|
||
if (k === "verify") { sayK("verify"); $("bar").value = Math.min(5, a * 5 / 80); }
|
||
if (k === "loader") sayK("loader");
|
||
if (k === "write") { if (lastKey !== "write") sayK("write"); $("bar").value = 5 + a * 0.95; }
|
||
if (k === "dropped") sayK("dropped");
|
||
if (k === "resume") sayK("resume", `${a}`);
|
||
if (k === "reboot") sayK("reboot");
|
||
if (k === "done") { $("bar").value = 100; sayK("done"); }
|
||
};
|
||
|
||
$("go").addEventListener("click", async () => {
|
||
if (writing) return;
|
||
lockInstaller(true);
|
||
let midi;
|
||
try { midi = await navigator.requestMIDIAccess({ sysex: true }); }
|
||
catch (e) { sayK("denied"); lockInstaller(false); return; }
|
||
try {
|
||
const up = new Updater(midi, log);
|
||
const dev = await up.find();
|
||
if (!dev) { sayK("notfound"); return; }
|
||
dev.link.close();
|
||
const entry = packageFor(packages, dev.id.model);
|
||
if (!entry) { sayK("nopkg", dev.id.text); return; }
|
||
if (!IS_OTA(dev.id) && needsStockUpdate(dev.id)) { sayK("needV016", dev.id.text); return; }
|
||
const image = await imageFor(entry);
|
||
const step = stepper();
|
||
if (IS_OTA(dev.id)) { sayK((await up.resume(image, step, entry.product)) ? "done" : "stopped"); return; }
|
||
const model = entry.product.split("_")[0];
|
||
const archive = await backupBefore(up, model); // ((2.0) over firmware before it: the backup first, the way back)
|
||
if (archive && !confirm(t("saved20"))) return;
|
||
await up.install(image, entry.product, step);
|
||
if (archive) await convertAfter(up, model, archive);
|
||
} catch (e) {
|
||
if (e && e.code && TEXT[lang][e.code]) sayK(e.code, e.detail || (e.code === "loadfail" ? e.message : ""));
|
||
else sayK("error", e && e.message);
|
||
log(String(e && e.stack || e));
|
||
} finally { lockInstaller(false); }
|
||
});
|
||
|
||
$("stock-file").addEventListener("change", async () => {
|
||
const epoch = ++stockFileEpoch, file = $("stock-file").files[0]; stock = null; lockInstaller(false);
|
||
if (!file) return;
|
||
try {
|
||
if (![STOCK_V15_SIZE, STOCK_V16_SIZE, STOCK_SMK016_SIZE].includes(file.size)) throw new Error("FM-1.fwsc / SMK-37_Pro_016.fwsc");
|
||
const verified = await validateStockPackage(new Uint8Array(await file.arrayBuffer()));
|
||
if (epoch !== stockFileEpoch) return;
|
||
stock = verified; sayK("stockValid", verified.product); lockInstaller(false);
|
||
} catch (e) { if (epoch === stockFileEpoch) sayK("stockError", e.message); }
|
||
});
|
||
function saveArchive(archive) {
|
||
const url = URL.createObjectURL(new Blob([JSON.stringify(archive)], {type:"application/json"}));
|
||
const a = document.createElement("a"); a.href = url; a.download = `Skiff-backup-${new Date().toISOString().slice(0,10)}.json`;
|
||
document.body.append(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||
}
|
||
// ((Skiff 2.0, Tier B: design/TIER_B.md 10) installing 2.0 over firmware before it that answers complete backups (Skiff,
|
||
// Felucca 1.0.3 on): its backup taken and saved to this computer first (the way back; a failure stops before anything is
|
||
// written); after the install, what 2.0 can't read converted (web/conv/conv.js) and only that written back. Other
|
||
// firmware (stock, JIANT: nothing of Skiff's to convert) installs as before
|
||
const major = (v) => +(/(\d+)\.\d/.exec(v || "") || [0, 0])[1];
|
||
async function backupBefore(up, model) {
|
||
if (major(meta.version) < 2) return null;
|
||
const device = await up.find((id) => !IS_OTA(id) && sameModel(id.model, model));
|
||
if (!device) return null;
|
||
const input = device.link.input, output = device.link.output; device.link.close();
|
||
const link = new BackupConnection(input, output);
|
||
try {
|
||
let reply;
|
||
try { reply = await link.request([1, []]); }
|
||
catch (e) { if (e.code === "timeout") return null; throw e; }
|
||
const info = archiveInfo(reply);
|
||
if (!info.supported || major(info.version) >= 2) return null;
|
||
const archive = await captureBackup((r, o) => link.request(r, o), info.version,
|
||
(done, total) => sayK("backup", `${Math.round(done / Math.max(1, total) * 100)}%`));
|
||
saveArchive(archive);
|
||
return archive;
|
||
} finally { link.close(); }
|
||
}
|
||
async function convertAfter(up, model, archive) {
|
||
let link = null;
|
||
sayK("converting");
|
||
try {
|
||
const device = await up.waitFor((id) => !IS_OTA(id) && sameModel(id.model, model), 20000);
|
||
if (!device) throw new Error("the unit does not answer");
|
||
const input = device.link.input, output = device.link.output; device.link.close();
|
||
link = new BackupConnection(input, output);
|
||
const r = (await loadConverter("../editor/conv/conv.wasm")).convert(readBackup(archive));
|
||
if (r.writeBack.length)
|
||
await restoreBackup((q, o) => link.request(q, o), r.archive,
|
||
(done, total) => sayK("converting", `${Math.round(done / Math.max(1, total) * 100)}%`), r.writeBack);
|
||
for (const x of r.report)
|
||
if (x.what !== "kept" || x.note) log(`${x.id}: ${x.was} -> ${x.now} (${x.what})${x.note ? `: ${x.note}` : ""}`);
|
||
sayK(r.report.some((x) => /^(refused|kept as)/.test(x.what)) ? "convertedPart" : r.writeBack.length ? "converted" : "asIs");
|
||
} catch (e) { sayK("convertFailed", e.message); log(String(e.stack || e)); }
|
||
finally { if (link) link.close(); }
|
||
}
|
||
function archiveInfo(a) {
|
||
let pos = a.indexOf(0); if (pos < 0) throw new Error("Invalid INFO");
|
||
const version = String.fromCharCode(...a.slice(0,pos)); pos++;
|
||
const engines = a[pos]; pos += 5;
|
||
for (let i = 0; i < engines; i++) { const end = a.indexOf(0,pos); if (end < 0) throw new Error("Invalid INFO"); pos = end + 1; }
|
||
const ext = a.slice(pos + 1);
|
||
const supported = /^FELUCCA /i.test(version) && ext[0] === 16 && ext[1] === 0x55 && ext[2] === 1 &&
|
||
ext[4] === 0x4d && ext[5] === 1 && ext[8] === 0x42 && ext[9] === 1 && (ext[10] & 1);
|
||
return {version,supported};
|
||
}
|
||
$("stock-go").addEventListener("click", async () => {
|
||
if (!stock || writing) return;
|
||
const selected = stock, model = selected.product.split("_")[0]; lockInstaller(true);
|
||
let link = null;
|
||
try {
|
||
let midi;
|
||
try { midi = await navigator.requestMIDIAccess({sysex:true}); } catch (e) { sayK("denied"); return; }
|
||
const up = new Updater(midi, log);
|
||
const step = stepper();
|
||
const loader = await up.find(id => IS_OTA(id) && sameModel(id.model, model));
|
||
if (loader) {
|
||
loader.link.close();
|
||
if (!$("stock-recovery").checked) { sayK("stockNeedBackup"); return; }
|
||
if (!confirm(t("stockConfirm"))) return;
|
||
sayK(await up.resume(selected.image, step, selected.product) ? "done" : "stopped");
|
||
} else {
|
||
const device = await up.find(id => !IS_OTA(id) && sameModel(id.model, model)) || await up.find(id => !IS_OTA(id));
|
||
if (!device) { sayK("notfound"); return; }
|
||
const input = device.link.input, output = device.link.output; device.link.close();
|
||
if (!sameModel(device.id.model, model)) { sayK("stockWrongModel"); return; }
|
||
if (device.id.text === selected.product) { sayK("stockIsStock"); return; } // (#23: it is official already)
|
||
link = new BackupConnection(input, output);
|
||
let reply; // every Skiff answers INFO: no answer, no Skiff (#23 read "Backup timed out")
|
||
try { reply = await link.request([1,[]]); }
|
||
catch (e) { if (e.code !== "timeout") throw e; sayK("stockNotSkiff", device.id.text); return; }
|
||
const info = archiveInfo(reply);
|
||
if (!info.supported) { sayK("stockUnsupported"); return; }
|
||
const archive = await captureBackup((r,o) => link.request(r,o), info.version,
|
||
(done,total) => sayK("backup", `${Math.round(done / Math.max(1,total) * 100)}%`));
|
||
saveArchive(archive); link.close(); link = null;
|
||
if (!confirm(t("stockConfirm"))) return;
|
||
try { await up.install(selected.image, selected.product, step); }
|
||
catch (e) { // ((2.0.2, #64) the version this unit needs, or Skiff too old)
|
||
const k = stockRefusal(selected.product, e);
|
||
if (!k) throw e;
|
||
log(String(e.stack || e)); sayK(k);
|
||
}
|
||
}
|
||
} catch (e) {
|
||
if (e.code && TEXT[lang][e.code]) sayK(e.code,e.detail || ""); else sayK("error",e.message);
|
||
log(String(e.stack || e));
|
||
} finally { if (link) link.close(); lockInstaller(false); }
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|