sql
This commit is contained in:
37
README_BUILD178.txt
Normal file
37
README_BUILD178.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
BUILD178 · 2026.09.30.1
|
||||
|
||||
Установка поверх BUILD177:
|
||||
1. Остановите веб-сервер.
|
||||
2. Замените четыре файла из архива, сохранив вложенные каталоги.
|
||||
3. Запустите сервер и обновите страницу браузера через Ctrl+F5.
|
||||
|
||||
Изменённые файлы:
|
||||
app.py
|
||||
hockey_data/agent_bridge.py
|
||||
hockey_data/mapping_context.py
|
||||
ui_builder/static/app.js
|
||||
|
||||
Исправления:
|
||||
- Кнопки титров под профилями и сценарии нижней панели разово обновляют SQL/Mapping перед заполнением и показом выбранного Input.
|
||||
- Автообновление SQL для этого не требуется. Сам источник SQL должен оставаться включённым.
|
||||
- Для каждого Input в одном запуске сценария используется одно обновление: необходимые SQL-источники выполняются по одному разу, их результат заполняет все связанные поля. Preview и последующий Overlay не вызывают повторный запрос.
|
||||
- Обновление ограничено выбранным Input и SQL-источниками его связей, включая оба поля условий видимости. Остальные титры не обновляются этой кнопкой.
|
||||
- Перед показом заново отправляются связанные значения и условия видимости, даже если локальный кеш считает их неизменившимися.
|
||||
- Явные команды SetText сценария выполняются после SQL/Mapping и сохраняют свои значения.
|
||||
- При ошибке SQL, отсутствии необходимых параметров или полей показ выбранного титра блокируется с сообщением. Новый запуск кнопки повторяет чтение.
|
||||
- Пустая надпись кнопки считается допустимым SQL-параметром и очищает предыдущий текст. Пустой успешный результат SELECT также очищает связанные поля.
|
||||
- Новые назначения Input сохраняются по названию. Старые ключи и номера существующих кнопок преобразуются в название по структуре выбранного Agent. Для сохранения старого назначения по названию откройте настройки кнопок и нажмите «Сохранить».
|
||||
- Обновление списка Inputs доступно оператору в окне настройки кнопок.
|
||||
- Команды основного времени и удалений отправляются своим независимым путём.
|
||||
|
||||
Проверено на временной SQLite и в изолированном Chromium:
|
||||
- разовое выполнение SQL при выключенном автообновлении;
|
||||
- последовательность сохранение выбора → SQL/Mapping → SetText/Preview/Overlay;
|
||||
- один запрос источника для нескольких полей выбранного Input;
|
||||
- отсутствие обновлений чужого Input и чужого Agent;
|
||||
- переходы видимости Off → On → Off;
|
||||
- пустой текст, пустой результат запроса, ошибки SQL и отсутствующие параметры;
|
||||
- старые ссылки по ключу/номеру, новые назначения по названию и сохранение конфигурации;
|
||||
- права управления матчем и независимая отправка команд таймеров.
|
||||
|
||||
Настройки, SQL-запросы, базы данных и пользовательские конфигурационные файлы не включены в архив. Проверка с подключением к вашему рабочему vMix не выполнялась.
|
||||
329079
agent/agent.log.1
329079
agent/agent.log.1
File diff suppressed because it is too large
Load Diff
2
app.py
2
app.py
@@ -35,7 +35,7 @@ from khl_site.khl_data_center import APP as khl_site_app, configure_storage, syn
|
||||
from hockey_data.khl_career import KhlCareerService
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
BUILD_VERSION = "2026.09.29.14"
|
||||
BUILD_VERSION = "2026.09.30.1"
|
||||
# compatibility: BUILD_VERSION = "2026.09.24.2"
|
||||
# compatibility: BUILD_VERSION = "2026.09.23.8"
|
||||
# compatibility: BUILD_VERSION = "2026.09.23.7"
|
||||
|
||||
@@ -1567,6 +1567,7 @@ class VmixAgentHub:
|
||||
source_codes: set[str] | None = None,
|
||||
only_changed: bool = False,
|
||||
extra_context: dict[str, Any] | None = None,
|
||||
input_title: str = "",
|
||||
) -> Any:
|
||||
"""Resolve the active mapping against the device's current match and push values to vMix.
|
||||
|
||||
@@ -1622,6 +1623,9 @@ class VmixAgentHub:
|
||||
mapping_language = preferred_display
|
||||
profile = self._active_mapping_profile_for_device(session, device)
|
||||
if profile is None:
|
||||
if input_title:
|
||||
return {"ok": True, "reason": "title_unmapped", "device_id": device_id,
|
||||
"input_title": input_title, "total": 0, "applied": 0, "errors": []}
|
||||
return {"ok": False, "reason": "mapping_missing", "device_id": device_id}
|
||||
fields = list(
|
||||
session.scalars(
|
||||
@@ -1630,6 +1634,8 @@ class VmixAgentHub:
|
||||
.order_by(VmixMappingField.sort_order, VmixMappingField.id)
|
||||
)
|
||||
)
|
||||
if input_title:
|
||||
fields = [field for field in fields if field.vmix_input_title == input_title]
|
||||
if source_codes is not None:
|
||||
wanted_sources = {str(code) for code in source_codes}
|
||||
fields = [field for field in fields if any(
|
||||
@@ -1655,17 +1661,19 @@ class VmixAgentHub:
|
||||
supplied_context[key] = str(raw_value)[:8000]
|
||||
if mapping_language:
|
||||
supplied_context["ui_language"] = mapping_language
|
||||
catalog_source_codes = None if source_codes is None else {str(code) for code in source_codes}
|
||||
# A button refresh reads only the selected Input's sources, including
|
||||
# both operands of visibility rules. Each source is queried once by the catalog.
|
||||
catalog_source_codes = (set() if input_title else None) if source_codes is None else {str(code) for code in source_codes}
|
||||
if catalog_source_codes is not None:
|
||||
for field in fields:
|
||||
catalog_source_codes.update(self._mapping_source_code(key) for key in
|
||||
_mapping_dependency_keys(field.data_key, _mapping_rule_payload(field.rule_json)))
|
||||
score_home_key, score_away_key = self._score_source_settings()
|
||||
if catalog_source_codes is not None and "score" in catalog_source_codes:
|
||||
for score_key in (score_home_key, score_away_key):
|
||||
dependency_code = self._mapping_source_code(score_key)
|
||||
if dependency_code and dependency_code not in {"score", "context"}:
|
||||
catalog_source_codes.add(dependency_code)
|
||||
if catalog_source_codes is not None:
|
||||
for field in fields:
|
||||
catalog_source_codes.update(self._mapping_source_code(key) for key in
|
||||
_mapping_dependency_keys(field.data_key, _mapping_rule_payload(field.rule_json)))
|
||||
catalog = (
|
||||
self.mapping_data.data_catalog(user, supplied_context, source_codes=catalog_source_codes)
|
||||
if catalog_source_codes is not None
|
||||
@@ -1691,7 +1699,8 @@ class VmixAgentHub:
|
||||
return candidates[-1] if candidates else (by_key.get(key) if not key.startswith("score.") else None)
|
||||
|
||||
score_snapshot = None
|
||||
if source_codes is None or "score" in {str(code) for code in source_codes}:
|
||||
refresh_score = ("score" in (catalog_source_codes or set())) if input_title else (source_codes is None or "score" in source_codes)
|
||||
if refresh_score:
|
||||
fallback_home = self._score_int((by_key.get("score.external_home") or {}).get("value"), 0)
|
||||
fallback_away = self._score_int((by_key.get("score.external_away") or {}).get("value"), 0)
|
||||
home_item = external_score_item(score_home_key)
|
||||
@@ -1733,11 +1742,18 @@ class VmixAgentHub:
|
||||
"unchanged": 0,
|
||||
"rules_unchanged": 0,
|
||||
"rule_missing": [],
|
||||
"source_codes": sorted(source_codes) if source_codes is not None else [],
|
||||
"source_codes": sorted(catalog_source_codes or []) if input_title else sorted(source_codes or []),
|
||||
"input_title": input_title,
|
||||
"missing": [],
|
||||
"errors": [],
|
||||
"transport": "batch" if self._agent_supports_batch(agent_version) else "legacy",
|
||||
}
|
||||
if input_title:
|
||||
for source in catalog.get("sources") or []:
|
||||
if source.get("ok") is False or source.get("skipped"):
|
||||
result["errors"].append({"source_code": source.get("code"),
|
||||
"reason": "sql_source_failed", "error": source.get("error") or
|
||||
f"Не заданы параметры SQL: {', '.join(source.get('missing') or [])}"})
|
||||
pending_entries: list[dict[str, Any]] = []
|
||||
for field in fields:
|
||||
data_key = str(field.data_key or "")
|
||||
@@ -1805,6 +1821,12 @@ class VmixAgentHub:
|
||||
})
|
||||
|
||||
result["total_commands"] = len(pending_entries)
|
||||
# Do not preview stale or partially updated data after a failed SQL read.
|
||||
# An empty successful query still supplies columns with empty values,
|
||||
# which deliberately clears text left by the previous player/button.
|
||||
if input_title and (result["missing"] or result["rule_missing"] or result["errors"]):
|
||||
result["ok"] = False
|
||||
return result
|
||||
if not pending_entries:
|
||||
result["ok"] = not result["errors"]
|
||||
return result
|
||||
@@ -1819,6 +1841,7 @@ class VmixAgentHub:
|
||||
source_codes: set[str] | None = None,
|
||||
only_changed: bool = False,
|
||||
extra_context: dict[str, Any] | None = None,
|
||||
input_title: str = "",
|
||||
) -> dict[str, Any]:
|
||||
"""Resolve the active mapping against the device's current match and push values to vMix.
|
||||
|
||||
@@ -1826,7 +1849,8 @@ class VmixAgentHub:
|
||||
so it never needs database access or knowledge of SQL/context keys.
|
||||
"""
|
||||
prepared = await run_db(self._prepare_mapping_to_device, device_id, reason=reason,
|
||||
source_codes=source_codes, only_changed=only_changed, extra_context=extra_context)
|
||||
source_codes=source_codes, only_changed=only_changed, extra_context=extra_context,
|
||||
input_title=input_title)
|
||||
if isinstance(prepared, dict):
|
||||
return prepared
|
||||
result, pending_entries, assignment_id, match_id, agent_version = prepared
|
||||
@@ -3760,7 +3784,7 @@ class VmixAgentHub:
|
||||
"""Return vMix inventory for one device owned by the current operator.
|
||||
|
||||
This endpoint is intentionally read-only and available to regular hockey
|
||||
operators so settings pages can store stable Input keys without requiring
|
||||
operators so settings pages can store Input titles without requiring
|
||||
the UI Builder editor PIN.
|
||||
"""
|
||||
requested = self.normalise_device_id(device_id) if str(device_id or "").strip() else ""
|
||||
@@ -5223,6 +5247,7 @@ def create_hockey_agent_router(
|
||||
only_changed: bool = False,
|
||||
active_tab: str = "",
|
||||
source_code: str = "",
|
||||
input_title: str = Query(default="", max_length=512),
|
||||
user: HockeyUser = Depends(auth_dependency),
|
||||
) -> dict[str, Any]:
|
||||
device_id = hub.normalise_device_id(device_id)
|
||||
@@ -5239,9 +5264,10 @@ def create_hockey_agent_router(
|
||||
source_codes = {wanted_source} if wanted_source else None
|
||||
result = await hub.apply_mapping_to_device(
|
||||
device_id,
|
||||
reason=("runtime_score_changed" if wanted_source == "score" else "runtime_strength_changed") if only_changed else "manual_apply",
|
||||
reason="runtime_title_button" if input_title else (("runtime_score_changed" if wanted_source == "score" else "runtime_strength_changed") if only_changed else "manual_apply"),
|
||||
source_codes=source_codes,
|
||||
only_changed=only_changed,
|
||||
input_title=input_title,
|
||||
extra_context={"active_tab": str(active_tab or "").strip()} if str(active_tab or "").strip() else None,
|
||||
)
|
||||
# BUILD97: field-level vMix errors are returned as diagnostics instead of
|
||||
|
||||
@@ -909,7 +909,12 @@ class MappingDataService:
|
||||
def _run_source(self, source: MappingSqlDataSource, context: dict[str, str], *, max_rows: int = 25) -> dict[str, Any]:
|
||||
params = self.validate_sql(source.sql_text)
|
||||
sql_text = self._normalise_sql(source.sql_text)
|
||||
missing = sorted(name for name in params if not context.get(name))
|
||||
# An intentionally blank button caption is valid SQL input: it clears
|
||||
# the previous title's text. Identifiers still require a selected entity.
|
||||
def blank_caption(name: str) -> bool:
|
||||
return name == "title_button_text" or (name.startswith("player_select_") and name.endswith("_preview_button_text"))
|
||||
missing = sorted(name for name in params if name not in context or
|
||||
(not context.get(name) and not blank_caption(name)))
|
||||
if missing:
|
||||
return {"ok": True, "skipped": True, "missing": missing, "columns": [], "rows": [], "row_count": 0}
|
||||
bound = {name: context.get(name, "") for name in params}
|
||||
|
||||
@@ -4850,6 +4850,33 @@ function startCustomTooltips() {
|
||||
const rawCommands = typeof commands === "function" ? commands() : commands;
|
||||
const clean = (rawCommands || []).map(compactVmixCommand).filter((command) => command.Function);
|
||||
if (!clean.length) return { ok: true, applied: 0, results: [] };
|
||||
// A click must resolve SQL even when the source's periodic refresh is off.
|
||||
// Refresh before the first title command, so explicit SetText steps can
|
||||
// still override Mapping. Preview + Overlay in one run reuse this read.
|
||||
if (execution && hockeyTimerSelectedGameId()) {
|
||||
execution.titleMappingRefreshes ||= new Map();
|
||||
const gameId = hockeyTimerSelectedGameId();
|
||||
const deviceId = currentRuntimeVmixDeviceId();
|
||||
execution.titleMappingContext ||= { gameId, deviceId };
|
||||
if (execution.titleMappingContext.gameId !== gameId || execution.titleMappingContext.deviceId !== deviceId) {
|
||||
throw new Error("Выбранный матч или Agent изменился");
|
||||
}
|
||||
for (const command of clean) {
|
||||
if (!command.Input || !/^(PreviewInput|ActiveInput|OverlayInput[1-8](In)?|SetText.*|SetImage.*|SetColor)$/i.test(command.Function)) continue;
|
||||
const inputTitle = await hockeyRuntimeVmixInputTitle(command.Input);
|
||||
if (gameId !== hockeyTimerSelectedGameId() || deviceId !== currentRuntimeVmixDeviceId()) {
|
||||
throw new Error("Выбранный матч или Agent изменился");
|
||||
}
|
||||
command.Input = inputTitle;
|
||||
if (!execution.titleMappingRefreshes.has(inputTitle)) {
|
||||
execution.titleMappingRefreshes.set(inputTitle, hockeyRefreshQuickPanelMapping({ inputTitle, onlyChanged: false, throwOnError: true }));
|
||||
}
|
||||
await execution.titleMappingRefreshes.get(inputTitle);
|
||||
if (!hockeyCanControl() || gameId !== hockeyTimerSelectedGameId() || deviceId !== currentRuntimeVmixDeviceId()) {
|
||||
throw new Error("Выбранный матч, Agent или права управления изменились");
|
||||
}
|
||||
}
|
||||
}
|
||||
state.vmixCommandQueueDepth += 1;
|
||||
const controller = new AbortController();
|
||||
// BUILD100: runtime vMix delivery is ACKed command-by-command on the server.
|
||||
@@ -9310,11 +9337,14 @@ async function openHockeyPrematchButtonsEditor({ section = "buttons", panelId =
|
||||
toast("Не удалось загрузить настройки кнопок титров. Попробуйте открыть настройки ещё раз.", true);
|
||||
return;
|
||||
}
|
||||
await loadShortcutInventory({ silent: true });
|
||||
let draftGroups = normalizePrematchGroups(state.config.prematch_groups);
|
||||
let draft = normalizePrematchButtons(state.config.prematch_buttons);
|
||||
let draftSelectors = normalizeQuickPanelSelectors(state.config.quick_panel_selectors);
|
||||
let draftPlayerPanels = normalizePlayerSelectionPanels(state.config.player_selection_panels);
|
||||
let draftPanelTitleButtons = normalisePlayerPanelTitleButtons(state.playerPanelTitleButtons);
|
||||
let draftPanelTitleButtons = normalisePlayerPanelTitleButtons(state.playerPanelTitleButtons).map((button) => ({
|
||||
...button, input: String(vmixInputByRef(button.input)?.title || button.input),
|
||||
}));
|
||||
let dragButtonId = "";
|
||||
let dragSelectorId = "";
|
||||
let activeEditorGroupId = String(state.quickPanelActiveTab || "");
|
||||
@@ -9895,15 +9925,23 @@ function quickPanelSelectorValue(selector) {
|
||||
return options[0]?.value || "";
|
||||
}
|
||||
|
||||
async function hockeyRefreshQuickPanelMapping() {
|
||||
async function hockeyRefreshQuickPanelMapping({ inputTitle = "", onlyChanged = true, throwOnError = false } = {}) {
|
||||
const deviceId = currentRuntimeVmixDeviceId();
|
||||
if (!deviceId) return false;
|
||||
try {
|
||||
const response = await fetch(`/api/hockey/agents/devices/${encodeURIComponent(deviceId)}/apply-mapping?only_changed=true`, { method: "POST", cache: "no-store", credentials: "same-origin" });
|
||||
if (!response.ok) return false;
|
||||
if (!deviceId) throw new Error("Сначала выберите Hockey Agent");
|
||||
const target = inputTitle ? `&input_title=${encodeURIComponent(inputTitle)}` : "";
|
||||
const response = await fetch(`/api/hockey/agents/devices/${encodeURIComponent(deviceId)}/apply-mapping?only_changed=${onlyChanged ? "true" : "false"}${target}`, { method: "POST", cache: "no-store", credentials: "same-origin" });
|
||||
const payload = await response.json();
|
||||
return payload?.ok !== false && !(payload?.errors?.length);
|
||||
} catch (_) { return false; }
|
||||
if (!response.ok || payload?.ok === false || payload?.errors?.length || (inputTitle && (payload?.missing?.length || payload?.rule_missing?.length))) {
|
||||
const first = payload?.errors?.[0] || payload?.rule_missing?.[0];
|
||||
const detail = payload?.detail?.message || payload?.detail || first?.error || first?.reason || payload?.missing?.[0] || payload?.reason || `HTTP ${response.status}`;
|
||||
throw new Error(`Не удалось обновить данные${inputTitle ? ` титра «${inputTitle}»` : ""}: ${typeof detail === "string" ? detail : JSON.stringify(detail)}`);
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (throwOnError) throw error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function hockeyRefreshScoreMapping() {
|
||||
@@ -10165,9 +10203,8 @@ function renderHockeyQuickCommandDock({ force = false } = {}) {
|
||||
control.classList.add("is-sending");
|
||||
try {
|
||||
const attachedSelectors = selectors.filter((selector) => selector.button_id === button.id);
|
||||
// BUILD102: save the button context without a full Mapping ACK round-trip.
|
||||
// Selector changes already refresh Mapping; the operator click itself must not
|
||||
// wait behind Mapping before its Shortcut Sequence is dispatched.
|
||||
// Save context first; the sequence resolves only its target title's SQL
|
||||
// before dispatching title commands, independently of periodic refresh.
|
||||
await hockeyCommitQuickPanelButtonContext(button, attachedSelectors, { refreshMapping: false });
|
||||
if (button.mode === "toggle") {
|
||||
const flagResult = await hockeyToggleMatchFlag(hockeyPrematchFlagKey(button.id));
|
||||
@@ -10481,7 +10518,10 @@ async function hockeyPreviewPlayerPanelTitle(panel, button) {
|
||||
state.playerPanelTitleBusy.add(panel.id);
|
||||
hockeyRefreshPlayerPanelTitleButtonState();
|
||||
const gameId = hockeyTimerSelectedGameId();
|
||||
const deviceId = currentRuntimeVmixDeviceId();
|
||||
try {
|
||||
const inputTitle = await hockeyRuntimeVmixInputTitle(button.input);
|
||||
if (gameId !== hockeyTimerSelectedGameId() || deviceId !== currentRuntimeVmixDeviceId() || !hockeyCanControl()) throw new Error("Выбранный матч, Agent или права управления изменились");
|
||||
// Publish which panel button is being used before PreviewInput. SQL/Mapping
|
||||
// can therefore distinguish several graphics that use the same selected
|
||||
// player block while the player identifiers themselves stay unchanged.
|
||||
@@ -10490,16 +10530,14 @@ async function hockeyPreviewPlayerPanelTitle(panel, button) {
|
||||
"title_button.label": button.label,
|
||||
"title_button.text": button.title_text || "",
|
||||
"title_button.panel_id": panel.id,
|
||||
"title_button.input": button.input,
|
||||
"title_button.input": inputTitle,
|
||||
[`player_select.${panel.id}._preview_button_id`]: button.id,
|
||||
[`player_select.${panel.id}._preview_button_label`]: button.label,
|
||||
[`player_select.${panel.id}._preview_button_text`]: button.title_text || "",
|
||||
[`player_select.${panel.id}._preview_input`]: button.input,
|
||||
[`player_select.${panel.id}._preview_input`]: inputTitle,
|
||||
}, { refreshMapping: false });
|
||||
if (!saved || gameId !== hockeyTimerSelectedGameId() || !hockeyCanControl()) throw new Error("Выбранный матч или права управления изменились");
|
||||
if (!(await hockeyRefreshQuickPanelMapping())) throw new Error("Не удалось обновить данные титра в vMix");
|
||||
if (gameId !== hockeyTimerSelectedGameId() || !hockeyCanControl()) throw new Error("Выбранный матч изменился");
|
||||
const result = await sendRuntimeVmixSequence([{ Function: "PreviewInput", Input: button.input }]);
|
||||
if (!saved || gameId !== hockeyTimerSelectedGameId() || deviceId !== currentRuntimeVmixDeviceId() || !hockeyCanControl()) throw new Error("Выбранный матч, Agent или права управления изменились");
|
||||
const result = await sendRuntimeVmixSequence([{ Function: "PreviewInput", Input: inputTitle }], { titleMappingRefreshes: new Map() });
|
||||
if (!result || result.ok === false) throw new Error("Титр не отправлен в Preview");
|
||||
toast(`${panel.label} · ${button.label} → Preview`);
|
||||
return true;
|
||||
@@ -15806,16 +15844,35 @@ function renderHockeyPenaltyDashboard(node, component, runtime) {
|
||||
}
|
||||
|
||||
function vmixInputRef(item) {
|
||||
// Stable vMix identity: key is immutable when an Input is moved/reordered.
|
||||
// Title is the fallback for old/third-party inventories without key. Number
|
||||
// is used only as a last-resort legacy reference.
|
||||
return String(item?.key || item?.title || item?.number || "").trim();
|
||||
return String(item?.title || "").trim();
|
||||
}
|
||||
|
||||
function vmixInputByRef(ref) {
|
||||
const wanted = String(ref || "").trim();
|
||||
if (!wanted) return null;
|
||||
return vmixInventoryInputs().find((item) => [item.number, item.key, item.title].some((value) => String(value || "").trim() === wanted)) || null;
|
||||
const inputs = vmixInventoryInputs();
|
||||
return inputs.find((item) => String(item.title || "").trim() === wanted)
|
||||
|| inputs.find((item) => [item.number, item.key].some((value) => String(value || "").trim() === wanted)) || null;
|
||||
}
|
||||
|
||||
async function hockeyRuntimeVmixInputTitle(ref) {
|
||||
const wanted = String(ref || "").trim();
|
||||
// vMix's special selectors are commands, not saved graphic identities.
|
||||
if (["-1", "0", "Dynamic1", "Dynamic2", "Dynamic3", "Dynamic4"].includes(wanted)) return wanted;
|
||||
const deviceId = currentRuntimeVmixDeviceId();
|
||||
if (deviceId && (state.shortcutInventory.device_id !== deviceId || !vmixInventoryInputs().length)) {
|
||||
await loadShortcutInventory({ silent: true });
|
||||
}
|
||||
const inputs = state.shortcutInventory.device_id === deviceId ? vmixInventoryInputs() : [];
|
||||
if (inputs.some((item) => String(item.title || "") === wanted)) return wanted;
|
||||
// Compatibility with buttons saved before titles became the identity.
|
||||
// Resolve their old selector in this Agent's inventory and send the name.
|
||||
const legacy = inputs.filter((item) => [item.key, item.number].some((value) => String(value || "") === wanted));
|
||||
if (legacy.length === 1 && legacy[0].title) return String(legacy[0].title);
|
||||
if (legacy.length > 1 || /^\d+$/.test(wanted) || /^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(wanted)) {
|
||||
throw new Error("Не удалось определить название vMix Input. Обновите список Inputs и выберите титр по названию");
|
||||
}
|
||||
return wanted;
|
||||
}
|
||||
|
||||
function vmixFunctionOptions(selected = "") {
|
||||
@@ -15825,8 +15882,8 @@ function renderHockeyPenaltyDashboard(node, component, runtime) {
|
||||
}
|
||||
|
||||
function vmixInputOptions(selected = "") {
|
||||
const current = String(selected || "").trim();
|
||||
const inputs = vmixInventoryInputs();
|
||||
const current = String(vmixInputByRef(selected)?.title || selected || "").trim();
|
||||
const inputs = vmixInventoryInputs().filter((item) => vmixInputRef(item));
|
||||
const values = new Set(inputs.map(vmixInputRef));
|
||||
const fixed = [
|
||||
["", "— Input не требуется —"],
|
||||
@@ -15886,10 +15943,19 @@ function renderHockeyPenaltyDashboard(node, component, runtime) {
|
||||
}
|
||||
|
||||
async function loadShortcutInventory({ silent = false } = {}) {
|
||||
if (boot.mode !== "editor") return state.shortcutInventory;
|
||||
const deviceId = currentRuntimeVmixDeviceId();
|
||||
if (boot.mode !== "editor" && !deviceId) return state.shortcutInventory;
|
||||
state.shortcutInventoryLoading = true;
|
||||
try {
|
||||
const payload = await api("/vmix-inventory");
|
||||
let payload;
|
||||
if (boot.mode === "editor") {
|
||||
payload = await api("/vmix-inventory");
|
||||
} else {
|
||||
const response = await fetch(`/api/hockey/agents/vmix-inventory?device_id=${encodeURIComponent(deviceId)}`, { cache: "no-store", credentials: "same-origin" });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
payload = await response.json();
|
||||
if (deviceId !== currentRuntimeVmixDeviceId()) return state.shortcutInventory;
|
||||
}
|
||||
state.shortcutInventory = payload && typeof payload === "object" ? payload : state.shortcutInventory;
|
||||
if (!silent && !vmixInventoryInputs().length) toast("Agent пока не передал структуру текущего vMix-проекта", true);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user