1
0
forked from BRT/arc
arc/services/scripting/ScriptRuntime.h
slava cae345cf61 Implement JS-based remote scripting framework for dynamic script updates:
- Add Proof of Concept (PoC) for executing JavaScript scripts fetched remotely.
- Integrate `Black::GetProfileInfoScript` logic into a JS version with fallback to C++ on errors.
- Extend `ScreenXmlParser` with additional JS-to-C++ bridge methods.
- Update `config.ini` for scripting configuration.
- Ensure scripts are securely fetched with SHA-256 validation and use an atomic caching mechanism.
- Add developer tools for debugging JS scripts and enable easier script updates without app re-deployment.
2026-05-13 15:42:10 +07:00

35 lines
1.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <QString>
#include <QVariantMap>
namespace Scripting {
class ScriptRuntime {
public:
enum class Result {
// Скрипт выполнился до конца. outResult — пустая строка или бизнес-ошибка
// (то, что вернёт `run()` из JS как строку). EventHandler трактует строку
// как ошибку задачи; пусто — как success.
Completed,
// Не удалось загрузить/распарсить/выполнить скрипт (JS-ошибка, не business).
// В outResult — диагностика. Caller обязан сделать fallback на C++.
EngineError,
// Скрипт не разрешён к запуску (флаг выключен / нет файла / нет SHA).
// outResult — причина. Caller делает fallback.
Disabled
};
// Синхронно запускает скрипт <bank>/<scriptName> в свежем QJSEngine.
// Должен вызываться из того же потока, где будет использоваться (worker-поток
// EventHandler'а — там разрешён блокирующий sleep и DAO).
//
// params видны JS как host.params.<key>.
static Result run(const QString &bank,
const QString &scriptName,
const QVariantMap &params,
QString *outResult);
};
} // namespace Scripting