5ad2c681e7
Drop Carla integration across frontend and backend: - plugins.py: remove /carla-midi, /carla-status, /carla-stop, /open-in-carla, /carla-play-notes endpoints and Carla process management - runtime.py: remove find_carla / _carla_* helpers, detect and capabilities - app.jsx: remove Carla bridge UI, SonicCarlaMidi routing, shouldRouteCarla guards, VST row Carla button and preset fallback - system.py: remove /carla-path - Keep audio path unchanged (tracks -> masterBus -> output -> analyser), directOut only for offline render Build frontend, tests pass (124 passed).
61 lines
2.8 KiB
JavaScript
61 lines
2.8 KiB
JavaScript
// SonicForge Runtime service — phát hiện môi trường chạy (desktop Windows /
|
|
// docker headless) qua /api/v1/system/capabilities, bật/tắt tính năng theo đó.
|
|
// - data-runtime trên <html>: "desktop" | "headless"
|
|
// - Thư viện preset (.vstpreset) cache trong SonicRuntime.presets — dùng cho
|
|
// dropdown gán preset vào track (preset → pedalboard bridge).
|
|
window.SonicRuntime = window.SonicRuntime || { loaded: false, capabilities: null, presets: null };
|
|
|
|
(function () {
|
|
function getHeaders() {
|
|
const token = localStorage.getItem('sonic_token') || '';
|
|
return token ? { 'Authorization': 'Bearer ' + token } : {};
|
|
}
|
|
|
|
function load() {
|
|
return fetch(window.API_BASE_URL + '/api/v1/system/capabilities')
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (data) {
|
|
var c = data && data.success ? data : { features: {} };
|
|
window.SonicRuntime.capabilities = c;
|
|
window.SonicRuntime.loaded = true;
|
|
// environment: "docker" | "standalone" — quyết định luồng âm
|
|
// instrument: docker → FluidSynthWASM (client), standalone →
|
|
// native (backend pyfluidsynth / native_bridge). Không phải
|
|
// docker = standalone (Windows/Linux/macOS chạy trực tiếp trên OS).
|
|
window.SonicRuntime.environment = c.environment || (c.docker ? 'docker' : 'standalone');
|
|
var html = document.documentElement;
|
|
html.dataset.runtime = c.runtime || 'unknown';
|
|
html.dataset.platform = c.platform || '';
|
|
html.dataset.environment = window.SonicRuntime.environment;
|
|
// Cache sẵn danh sách preset (static, ít thay đổi)
|
|
listPresets().catch(function () {});
|
|
return c;
|
|
})
|
|
.catch(function () { return null; });
|
|
}
|
|
|
|
function listPresets() {
|
|
if (window.SonicRuntime.presets) return Promise.resolve(window.SonicRuntime.presets);
|
|
return fetch(window.API_BASE_URL + '/api/v1/presets', { headers: getHeaders() })
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (d) {
|
|
window.SonicRuntime.presets = (d && d.presets) || [];
|
|
return window.SonicRuntime.presets;
|
|
})
|
|
.catch(function () { return []; });
|
|
}
|
|
|
|
window.SonicRuntime.load = load;
|
|
window.SonicRuntime.listPresets = listPresets;
|
|
window.SonicRuntime.refreshPresets = function () {
|
|
window.SonicRuntime.presets = null;
|
|
return window.SonicRuntime.listPresets();
|
|
};
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', load);
|
|
} else {
|
|
load();
|
|
}
|
|
})();
|