1
0
forked from BRT/arc
arc/services/scripting/ScriptCache.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

30 lines
1.4 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 <QByteArray>
#include <QString>
namespace Scripting {
// Локальное хранилище JS-скриптов. Источник истины — cacheDir() из ScriptingConfig.
// Если в кэше скрипта нет — fallback на bundledDir() (рядом с бинарником).
class ScriptCache {
public:
// Резолвит абсолютный путь к файлу для <bank>/<scriptName>.
// 1. <cacheDir>/<bank>/<scriptName>.js
// 2. <bundledDir>/<bank>/<scriptName>.js
// Возвращает true только если файл существует.
static bool resolve(const QString &bank, const QString &scriptName,
QString *outPath, QString *outError);
// Сохраняет скрипт в кэш атомарно (через .tmp + rename).
// body — содержимое .js-файла. version — для диагностики, пишется в *.version.
static bool installFromBytes(const QString &bank, const QString &scriptName,
const QString &version, const QByteArray &body,
QString *outError);
// Текущая установленная версия (содержимое sidecar *.version). Пусто если не установлено.
static QString installedVersion(const QString &bank, const QString &scriptName);
};
} // namespace Scripting