diff --git a/src/app/exported_functions.cmake b/src/app/exported_functions.cmake index 911dba3..f636d44 100644 --- a/src/app/exported_functions.cmake +++ b/src/app/exported_functions.cmake @@ -1,2 +1,2 @@ -set(EXPORTED_FUNCTIONS "SHELL:-s EXPORTED_FUNCTIONS=[_main,_malloc,_free,_load,_startAudioProcessing,_addSoundFont]") +set(EXPORTED_FUNCTIONS "SHELL:-s EXPORTED_FUNCTIONS=[_main,_malloc,_free,_load,_startAudioProcessing,_addSoundFont,_loadFile,_exportScore,_markUnsaved,_isModified]") diff --git a/src/app/webapi_export.cpp b/src/app/webapi_export.cpp index 3d3d05b..53ccb57 100644 --- a/src/app/webapi_export.cpp +++ b/src/app/webapi_export.cpp @@ -30,6 +30,27 @@ extern "C" { EMSCRIPTEN_KEEPALIVE void load(const void* source, unsigned int len) { WebApi::instance()->load(source, len); } +//! Compose: load with a file name, so the format is known (MusicXML as well as .mscz) +EMSCRIPTEN_KEEPALIVE +void loadFile(const void* source, unsigned int len, const char* fileName) +{ + WebApi::instance()->loadFile(source, len, std::string(fileName ? fileName : "")); +} + +//! Compose: .mscz + MusicXML (.mxl above mxlAbove bytes, 0 = never) of the current score to +//! Module.onScoreExported; 1 on success +EMSCRIPTEN_KEEPALIVE +int exportScore(int markSaved, unsigned int mxlAbove) +{ + return WebApi::instance()->exportScore(markSaved != 0, mxlAbove) ? 1 : 0; +} + +EMSCRIPTEN_KEEPALIVE +void markUnsaved() { WebApi::instance()->markUnsaved(); } + +EMSCRIPTEN_KEEPALIVE +int isModified() { return WebApi::instance()->isModified() ? 1 : 0; } + EMSCRIPTEN_KEEPALIVE void addSoundFont(const char* uri) { diff --git a/src/importexport/midi/internal/midiimport/importmidi.cpp b/src/importexport/midi/internal/midiimport/importmidi.cpp index a8f86ad..096c171 100644 --- a/src/importexport/midi/internal/midiimport/importmidi.cpp +++ b/src/importexport/midi/internal/midiimport/importmidi.cpp @@ -24,6 +24,9 @@ #include #include +#include + +#include "global/io/file.h" #include "engraving/engravingerrors.h" #include "engraving/rw/xmlwriter.h" @@ -1245,14 +1248,31 @@ muse::Ret importMidi(MasterScore* score, const QString& name) opers.addNewMidiFile(name); } +#ifdef Q_OS_WASM + //! NOTE Web: the file lives in MuseScore's in-memory file system (muse::io), which QFile does not see, + //! and it has no modification times: read it through muse::io, every time + qint64 currentModTime = 0; + bool needsReload = true; +#else // Check if file has been modified on disk since last import QFileInfo fileInfo(name); qint64 currentModTime = fileInfo.lastModified().toSecsSinceEpoch(); bool needsReload = (opers.data()->processingsOfOpenedFile == 0) || (opers.data()->fileModificationTime != currentModTime); +#endif if (needsReload) { +#ifdef Q_OS_WASM + muse::ByteArray bytes; + if (!muse::io::File::readFile(muse::io::path_t(name), bytes)) { + LOGD("importMidi: file read error <%s>", qPrintable(name)); + return make_ret(Err::FileOpenError, muse::io::path_t(name)); + } + QByteArray qbytes = bytes.toQByteArray(); + QBuffer fp(&qbytes); +#else QFile fp(name); +#endif if (!fp.open(QIODevice::ReadOnly)) { LOGD("importMidi: file open error <%s>", qPrintable(name)); return make_ret(Err::FileOpenError, muse::io::path_t(name)); diff --git a/src/web/appjs/distr/muapi.js b/src/web/appjs/distr/muapi.js index 16cdb38..44890ea 100644 --- a/src/web/appjs/distr/muapi.js +++ b/src/web/appjs/distr/muapi.js @@ -5,8 +5,13 @@ const DEFAULT_SOUNDFONT = "sound/MS%20Basic.sf3" const MuApi = { // Load score - loadScoreFile: MuImpl.loadScoreFile, - loadScoreData: MuImpl.loadScoreData, + loadScoreFile: MuImpl.loadScoreFile.bind(MuImpl), + loadScoreData: MuImpl.loadScoreData.bind(MuImpl), + + // Compose: get the score out, dirty state + exportScore: MuImpl.exportScore.bind(MuImpl), + markUnsaved: MuImpl.markUnsaved.bind(MuImpl), + isModified: MuImpl.isModified.bind(MuImpl), // Start audio startAudioProcessing: MuImpl.startAudioProcessing.bind(MuImpl), diff --git a/src/web/appjs/distr/muimpl.js b/src/web/appjs/distr/muimpl.js index fb300b5..661e581 100644 --- a/src/web/appjs/distr/muimpl.js +++ b/src/web/appjs/distr/muimpl.js @@ -109,6 +109,9 @@ const MuImpl = { onExit: opt.onExit, entryFunction: window.MuseScoreStudio_entry, // from MuseScoreStudio.js containerElements: [opt.screen], + // Compose: a WebAssembly.Module (or a promise of one) the page has already downloaded + // with its own progress display; otherwise the loader fetches MuseScoreStudio.wasm itself + module: opt.wasmModule, }, soundFont: opt.soundFont, @@ -117,6 +120,27 @@ const MuImpl = { onStartApp: this._onStartApp.bind(this) } + // Compose: optional page callbacks, set before the module starts (the app may call them early); + // all guarded so a page error never unwinds through the wasm side + const guarded = function(name) { + return function(...args) { + try { + if (opt[name]) { + opt[name](...args) + } + } catch (e) { + console.error("[js muapi] " + name + " failed:", e) + } + } + } + this.Module.onAppReady = guarded("onAppReady") + this.Module.onModifiedChanged = guarded("onModifiedChanged") + this.Module.onScoreLoaded = guarded("onScoreLoaded") + // File > Save / Ctrl+S: the page decides where the score goes (no save dialogs on the web) + if (opt.onSaveRequested) { + this.Module.onSaveRequested = guarded("onSaveRequested") + } + setupRpc(this.Module); console.info("STEP 0.1: End setupRpc") setupInternalCallbacks(this.Module); @@ -148,13 +172,46 @@ const MuImpl = { this.loadScoreData(new Uint8Array(buffer)) }, - loadScoreData: function(data) { + // Compose: fileName (optional) gives the format by its suffix: .mscz, .mscx, .musicxml, .xml, .mxl + loadScoreData: function(data, fileName) { const ptr = this.Module._malloc(data.length); this.Module.HEAPU8.set(data, ptr); - this.Module._load(ptr, data.length); + if (fileName) { + this.Module.ccall('loadFile', null, ['number', 'number', 'string'], [ptr, data.length, String(fileName)]); + } else { + this.Module._load(ptr, data.length); + } this.Module._free(ptr); }, + // Compose: the current score as { mscz: Uint8Array, musicxml: Uint8Array, name, format } or null on failure. + // markSaved: clear the "modified" state (call markUnsaved() if the files could not be stored). + // mxlAbove: if the plain MusicXML is larger than this many bytes, musicxml holds the compressed + // .mxl export instead and format is "mxl" (otherwise "musicxml"). 0 or omitted: always plain. + exportScore: function(markSaved, mxlAbove) { + const Module = this.Module; + let result = null; + Module.onScoreExported = function(mscz, musicxml, name, format) { + // copy: the views point into the wasm heap + result = { mscz: mscz.slice(), musicxml: musicxml.slice(), name: name, format: format }; + }; + let ok = 0; + try { + ok = Module._exportScore(markSaved ? 1 : 0, Math.max(0, Math.min(0xffffffff, Math.floor(mxlAbove || 0)))); + } finally { + Module.onScoreExported = undefined; + } + return ok ? result : null; + }, + + markUnsaved: function() { + this.Module._markUnsaved(); + }, + + isModified: function() { + return this.Module._isModified() !== 0; + }, + startAudioProcessing: async function() { if (this.Module.driver.inited) { this.Module._startAudioProcessing() diff --git a/src/web/appjs/webapi.cpp b/src/web/appjs/webapi.cpp index bb00b50..81b5a18 100644 --- a/src/web/appjs/webapi.cpp +++ b/src/web/appjs/webapi.cpp @@ -27,6 +27,18 @@ #endif #include "global/io/file.h" +#include "global/io/buffer.h" + +#include "notation/imasternotation.h" +#include "notation/inotation.h" +#include "notation/inotationundostack.h" +#include "notation/inotationelements.h" + +#include "engraving/dom/masterscore.h" +#include "engraving/dom/text.h" + +#include +#include #include "log.h" @@ -47,6 +59,34 @@ static void callJsWithBytes(const char* fnname, const uint8_t* data, size_t size } } +static bool hasJsCallback(const char* fnname) +{ + emscripten::val fn = emscripten::val::module_property(fnname); + return !fn.isUndefined() && !fn.isNull(); +} + +//! Compose: both files in one call; the page must copy the views right away (they point into the wasm heap) +static void callJsWithTwoBuffers(const char* fnname, const muse::ByteArray& a, const muse::ByteArray& b, const std::string& name, + const std::string& format) +{ + if (!hasJsCallback(fnname)) { + return; + } + + emscripten::val jsA = emscripten::val::global("Uint8Array").new_(emscripten::typed_memory_view(a.size(), a.constData())); + emscripten::val jsB = emscripten::val::global("Uint8Array").new_(emscripten::typed_memory_view(b.size(), b.constData())); + emscripten::val::module_property(fnname)(jsA, jsB, name, format); +} + +static void callJsOptional(const char* fnname, const emscripten::val& a, const emscripten::val& b = emscripten::val::undefined()) +{ + if (!hasJsCallback(fnname)) { + return; + } + + emscripten::val::module_property(fnname)(a, b); +} + #else static void callJsWithBytes(const char*, const uint8_t*, size_t, const std::string& = std::string()) @@ -56,6 +96,44 @@ static void callJsWithBytes(const char*, const uint8_t*, size_t, const std::stri #endif +//! Compose: only a plain base name with a known score suffix is used as the in-memory file name +static std::string sanitizeScoreFileName(const std::string& fileName, std::string& suffix) +{ + static const std::vector SUFFIXES { "mscz", "mscx", "musicxml", "xml", "mxl", "mid", "midi", "kar" }; + + std::string name = fileName; + const size_t slash = name.find_last_of("/\\"); + if (slash != std::string::npos) { + name = name.substr(slash + 1); + } + + std::string base = name; + suffix.clear(); + const size_t dot = name.find_last_of('.'); + if (dot != std::string::npos) { + base = name.substr(0, dot); + suffix = name.substr(dot + 1); + std::transform(suffix.begin(), suffix.end(), suffix.begin(), [](unsigned char c) { return std::tolower(c); }); + } + + if (std::find(SUFFIXES.begin(), SUFFIXES.end(), suffix) == SUFFIXES.end()) { + suffix = "mscz"; + } + + std::string clean; + for (unsigned char c : base) { + clean += (std::isalnum(c) || c == '-' || c == '_' || c == ' ' || c == '(' || c == ')' || c >= 0x80) ? char(c) : '_'; + } + if (clean.size() > 80) { + clean.resize(80); + } + if (clean.empty() || clean.find_first_not_of(" _") == std::string::npos) { + clean = "score"; + } + + return clean; +} + WebApi* WebApi::instance() { static WebApi a; @@ -70,6 +148,7 @@ void WebApi::init(const muse::modularity::ContextPtr& ctx) auto onProjectChanged = [this]() { if (m_currentProject) { m_currentProject->saveComplited().disconnect(this); + m_currentProject->needSaveChanged().disconnect(this); } m_currentProject = projectSession()->project(); @@ -78,7 +157,12 @@ void WebApi::init(const muse::modularity::ContextPtr& ctx) m_currentProject->saveComplited().onReceive(this, [this](const muse::io::path_t& path, project::SaveMode mode) { onProjectSaved(path, mode); }); + m_currentProject->needSaveChanged().onNotify(this, [this]() { + notifyModifiedChanged(); + }); } + + notifyModifiedChanged(); }; projectSession()->projectChanged().onNotify(this, onProjectChanged); @@ -94,6 +178,7 @@ void WebApi::deinit() { if (m_currentProject) { m_currentProject->saveComplited().disconnect(this); + m_currentProject->needSaveChanged().disconnect(this); m_currentProject = nullptr; } @@ -110,24 +195,30 @@ void WebApi::deinit() void WebApi::load(const void* source, unsigned int len) { - LOGI() << source << ", len: " << len; + loadFile(source, len, "score.mscz"); +} + +void WebApi::loadFile(const void* source, unsigned int len, const std::string& fileName) +{ + LOGI() << source << ", len: " << len << ", name: " << fileName; //! NOTE Copy, the source is freed by the caller right after this call, but the project is opened later ByteArray data(reinterpret_cast(source), len); - //! NOTE A new file for each load: the opened project keeps its file, and the open scenario - //! treats the same path as the already opened project - io::path_t filePath = "/mu/temp/score_" + std::to_string(++m_loadCount) + ".mscz"; - Ret ret = io::File::writeFile(filePath, data); - if (!ret) { - LOGE() << "failed write project, path: " << filePath << ", err: " << ret.toString(); - return; - } + //! NOTE Compose: the suffix decides how the file is read (upstream always wrote .mscz, + //! so MusicXML could not be passed in). The base name becomes the score's display name + //! for files without a title. + std::string suffix; + const std::string baseName = sanitizeScoreFileName(fileName, suffix); + + //! NOTE The file is written only after the current project is closed and its file removed, so the + //! plain name can be used (it is what the editor shows in its tab) + const io::path_t filePath = "/mu/temp/" + baseName + "." + suffix; //! NOTE Single window: close the current project first, otherwise the open scenario opens a new window - closeProjectScenario()->closeOpenedProject(false).onResolve(this, [this, filePath](const Ret& closeRet) { + closeProjectScenario()->closeOpenedProject(false).onResolve(this, [this, filePath, data](const Ret& closeRet) { if (!closeRet) { LOGW() << "the current project is not closed, err: " << closeRet.toString(); - io::File::remove(filePath); + notifyLoadResult(false, "the current score was not closed"); return; } @@ -136,18 +227,232 @@ void WebApi::load(const void* source, unsigned int len) m_projectFilePath = io::path_t(); } + Ret ret = io::File::writeFile(filePath, data); + if (!ret) { + LOGE() << "failed write project, path: " << filePath << ", err: " << ret.toString(); + notifyLoadResult(false, ret.toString()); + return; + } + + ++m_loadCount; openProjectScenario()->openProject(filePath).onResolve(this, [this, filePath](const Ret& openRet) { if (!openRet) { LOGE() << "failed open project, path: " << filePath << ", err: " << openRet.toString(); io::File::remove(filePath); + notifyLoadResult(false, openRet.text().empty() ? openRet.toString() : openRet.text()); return; } m_projectFilePath = filePath; + + //! NOTE An imported score (MusicXML, MIDI) counts as "needs saving" from the start (it has no + //! .mscz yet). For the page that is not an unsaved change: ignore it until the first edit. + const project::INotationProjectPtr project = projectSession()->project(); + m_ignoreInitialNeedSave = project && project->isNeedSave(); + if (project && project->masterNotation() && project->masterNotation()->notation()) { + project->masterNotation()->notation()->undoStack()->stackChanged().onNotify(this, [this]() { + if (m_ignoreInitialNeedSave) { + m_ignoreInitialNeedSave = false; + notifyModifiedChanged(); + } + }, muse::async::Asyncable::Mode::SetReplace); + } + rememberTitleText(); + notifyModifiedChanged(); + notifyLoadResult(true, std::string()); }); }); } +bool WebApi::exportScore(bool markSaved, size_t mxlAbove) +{ + const project::INotationProjectPtr project = projectSession() ? projectSession()->project() : nullptr; + if (!project) { + LOGE() << "no project"; + return false; + } + + const notation::IMasterNotationPtr master = project->masterNotation(); + if (!master || !master->notation()) { + LOGE() << "no notation"; + return false; + } + + //! The title people see and edit is the title text on the first page; MusicXML's and + //! come from the score properties (File > Project properties, which this build has no + //! menu for). Rehearsal Room names the score after the MusicXML title: when the user renamed the piece + //! on the page, carry that over. + syncTitleFromTitleText(master); + + //! .mscz first, through the regular project save (in memory), so it is exactly what the desktop app + //! would write; SaveMode::Save also clears the "modified" state. The path keeps the score's file name, + //! which the editor shows in its tab. + std::string stem = io::completeBasename(project->path()).toStdString(); + if (stem.empty()) { + stem = "score"; + } + const io::path_t msczPath = "/mu/temp/" + stem + ".mscz"; + if (markSaved) { + m_ignoreInitialNeedSave = false; + } + m_exporting = true; + Ret ret = project->save(msczPath, markSaved ? project::SaveMode::Save : project::SaveMode::SaveCopy, false); + m_exporting = false; + if (!ret) { + LOGE() << "saving .mscz failed: " << ret.toString(); + return false; + } + + ByteArray msczData; + ret = io::File::readFile(msczPath, msczData); + if (!ret) { + LOGE() << "failed read saved file: " << ret.toString(); + if (markSaved) { + project->markAsUnsaved(); + } + return false; + } + + + //! MusicXML: written straight into memory, does not change the project + project::INotationWriterPtr xmlWriter = writers()->writer("musicxml"); + if (!xmlWriter) { + LOGE() << "no MusicXML writer in this build"; + if (markSaved) { + project->markAsUnsaved(); + } + return false; + } + + ByteArray xmlData; + { + io::Buffer buf(&xmlData); + buf.open(io::IODevice::WriteOnly); + Ret xmlRet = xmlWriter->writeSync(master->notation(), buf); + buf.close(); + if (!xmlRet || xmlData.empty()) { + LOGE() << "MusicXML export failed: " << xmlRet.toString(); + if (markSaved) { + project->markAsUnsaved(); + } + return false; + } + } + + //! Large scores: the compressed MusicXML container (.mxl) instead, if the plain file is above the limit + std::string xmlFormat = "musicxml"; + if (mxlAbove > 0 && xmlData.size() > mxlAbove) { + project::INotationWriterPtr mxlWriter = writers()->writer("mxl"); + ByteArray mxlData; + if (mxlWriter) { + io::Buffer buf(&mxlData); + buf.open(io::IODevice::WriteOnly); + Ret mxlRet = mxlWriter->writeSync(master->notation(), buf); + buf.close(); + if (mxlRet && !mxlData.empty()) { + xmlData = mxlData; + xmlFormat = "mxl"; + } else { + LOGE() << ".mxl export failed, keeping plain MusicXML: " << mxlRet.toString(); + } + } + } + + std::string name = master->notation()->projectWorkTitle().toStdString(); + if (name.empty()) { + name = project->displayName().toStdString(); + } + +#ifdef Q_OS_WASM + callJsWithTwoBuffers("onScoreExported", msczData, xmlData, name, xmlFormat); +#endif + return true; +} + +static muse::String titleTextOf(const mu::engraving::MasterScore* score) +{ + const mu::engraving::Text* t = score ? score->getText(mu::engraving::TextStyleType::TITLE) : nullptr; + return t ? t->plainText() : muse::String(); +} + +void WebApi::rememberTitleText() +{ + const project::INotationProjectPtr project = projectSession() ? projectSession()->project() : nullptr; + m_titleTextAtLoad = project && project->masterNotation() ? titleTextOf(project->masterNotation()->masterScore()) : String(); +} + +void WebApi::syncTitleFromTitleText(const notation::IMasterNotationPtr& master) +{ + engraving::MasterScore* score = master ? master->masterScore() : nullptr; + if (!score) { + return; + } + + //! Only a title the user changed in this session counts: the title text on the page often differs from + //! the file's title (subtitles, numbering such as "28. Terzetto"), and that must not rename the score + const String text = titleTextOf(score); + if (text == m_titleTextAtLoad) { + return; + } + m_titleTextAtLoad = text; + + //! the first non-empty line is the name (the title text may have more lines) + String shown; + for (const String& line : text.split(u'\n')) { + shown = line.simplified(); + if (!shown.isEmpty()) { + break; + } + } + if (shown.isEmpty()) { + return; + } + + const String workTitle = score->metaTag(u"workTitle"); + const String movementTitle = score->metaTag(u"movementTitle"); + const String previous = workTitle.isEmpty() ? movementTitle : workTitle; + if (workTitle != shown) { + score->setMetaTag(u"workTitle", shown); + } + //! the movement title only follows when it was the score's name (not e.g. "II. Allegro") + if (!movementTitle.isEmpty() && movementTitle == previous && movementTitle != shown) { + score->setMetaTag(u"movementTitle", shown); + } +} + +void WebApi::markUnsaved() +{ + const project::INotationProjectPtr project = projectSession() ? projectSession()->project() : nullptr; + m_ignoreInitialNeedSave = false; + if (project) { + project->markAsUnsaved(); + } + notifyModifiedChanged(); +} + +bool WebApi::isModified() const +{ + const project::INotationProjectPtr project = projectSession() ? projectSession()->project() : nullptr; + return project && project->isNeedSave() && !m_ignoreInitialNeedSave; +} + +void WebApi::notifyModifiedChanged() +{ +#ifdef Q_OS_WASM + callJsOptional("onModifiedChanged", emscripten::val(isModified())); +#endif +} + +void WebApi::notifyLoadResult(bool ok, const std::string& error) +{ +#ifdef Q_OS_WASM + callJsOptional("onScoreLoaded", emscripten::val(ok), emscripten::val(error)); +#else + UNUSED(ok); + UNUSED(error); +#endif +} + void WebApi::addSoundFont(const std::string& uri) { soundFontController()->addSoundFont(Uri(uri)); @@ -160,6 +465,11 @@ void WebApi::startAudioProcessing() void WebApi::onProjectSaved(const muse::io::path_t& path, mu::project::SaveMode) { + if (m_exporting) { + //! NOTE Compose: exportScore() hands the bytes over itself + return; + } + IF_ASSERT_FAILED(io::File::exists(path)) { LOGE() << "file does not exist, path: " << path; return; diff --git a/src/web/appjs/webapi.h b/src/web/appjs/webapi.h index fe10f83..07f0625 100644 --- a/src/web/appjs/webapi.h +++ b/src/web/appjs/webapi.h @@ -32,6 +32,8 @@ #include "project/inotationproject.h" #include "audio/main/istartaudiocontroller.h" #include "audio/main/isoundfontcontroller.h" +#include "project/inotationwritersregister.h" +#include "notation/imasternotation.h" namespace mu::appjs { class WebApi : public muse::Contextable, public muse::async::Asyncable @@ -43,6 +45,7 @@ class WebApi : public muse::Contextable, public muse::async::Asyncable muse::ContextInject exportProjectScenario = { this }; inline static muse::GlobalInject startAudioController; inline static muse::GlobalInject soundFontController; + inline static muse::GlobalInject writers; public: @@ -52,6 +55,19 @@ public: void deinit(); void load(const void* source, unsigned int len); + //! Compose: opens a score of any format the build can read; the type is taken from the + //! file name's suffix (mscz, mscx, musicxml, xml, mxl, mid, midi, kar) + void loadFile(const void* source, unsigned int len, const std::string& fileName); + + //! Compose: writes the current score as .mscz and as uncompressed MusicXML (in memory) + //! and hands both to the page via Module.onScoreExported(mscz, musicxml, baseName, format). + //! If the plain MusicXML is larger than mxlAbove bytes (0: never), the compressed .mxl is sent instead + //! (format "mxl"). + //! With markSaved the project is marked as saved (the page calls markUnsaved() if + //! uploading the files fails). Returns false if there is no score or a writer failed. + bool exportScore(bool markSaved, size_t mxlAbove = 0); + void markUnsaved(); + bool isModified() const; void addSoundFont(const std::string& uri); void startAudioProcessing(); @@ -62,11 +78,18 @@ private: void onProjectSaved(const muse::io::path_t& path, mu::project::SaveMode mode); void onFileExported(const muse::io::path_t& path); + void notifyModifiedChanged(); + void syncTitleFromTitleText(const notation::IMasterNotationPtr& master); + void rememberTitleText(); + void notifyLoadResult(bool ok, const std::string& error); project::INotationProjectPtr m_currentProject; //! NOTE The file of the opened project, it's needed while the project is open muse::io::path_t m_projectFilePath; int m_loadCount = 0; + bool m_exporting = false; + bool m_ignoreInitialNeedSave = false; + muse::String m_titleTextAtLoad; }; } diff --git a/src/web/appshell/internal/startupscenario.cpp b/src/web/appshell/internal/startupscenario.cpp index b83d18f..ef63b98 100644 --- a/src/web/appshell/internal/startupscenario.cpp +++ b/src/web/appshell/internal/startupscenario.cpp @@ -21,6 +21,10 @@ */ #include "startupscenario.h" +#ifdef Q_OS_WASM +#include +#endif + #include "log.h" using namespace muse; @@ -56,6 +60,13 @@ muse::async::Promise StartupScenario::runAfterSplashScreen() return async::make_promise([this](auto resolve, auto) { interactive()->open("musescore://notation").onResolve(this, [this, resolve](const Val&) mutable { m_startupCompleted = true; +#ifdef Q_OS_WASM + //! NOTE Compose: tell the page the editor is up, so it can load a score + emscripten::val ready = emscripten::val::module_property("onAppReady"); + if (!ready.isUndefined() && !ready.isNull()) { + ready(); + } +#endif (void)resolve(muse::make_ok()); }); diff --git a/src/web/appshell/qml/MuseScore/AppShell/appmenumodel.cpp b/src/web/appshell/qml/MuseScore/AppShell/appmenumodel.cpp index 8fa494b..4105295 100644 --- a/src/web/appshell/qml/MuseScore/AppShell/appmenumodel.cpp +++ b/src/web/appshell/qml/MuseScore/AppShell/appmenumodel.cpp @@ -367,8 +367,8 @@ MenuItem* AppMenuModel::makeFormatMenu() makeMenuItem(ResetShapesAndPositionsCommand::id), makeMenuItem(ResetToDefaultLayoutCommand::id), makeSeparator(), - makeMenuItem(LoadStyleCommand::id), - makeMenuItem(SaveStyleCommand::id) + makeMenuItem(LoadStyleCommand::id) + //! NOTE Compose: no "Save style...": it writes into the in-memory file system and nothing reaches the user }; return makeMenu(TranslatableString("appshell/menu/format", "F&ormat"), formatItems, "menu-format");