mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-31 16:57:46 +03:00
feat(form-decompile,form-compile): CommandInterface — командный интерфейс формы из ring-3
Снят fast-fail на CommandInterface (4388 форм, 13.5% корпуса — крупнейший
оставшийся триггер ring-3).
Форменный ключ commandInterface = панели commandBar + navigationPanel, списки
переопределений авто-расстановки (платформа эмитит только отклонения). Элемент:
command (verbatim; "0"=пустой), type (Auto опускаем/Added), defaultVisible,
visible (тот же xr-flag, что userVisible/use — bool или {common,roles}),
group (CommandGroup verbatim), index, attribute. Порядок тегов Item:
Command,Type,Attribute,CommandGroup,Index,DefaultVisible,Visible.
Две формы записи панели: плоский массив (декомпилятор эмитит её) + древовидная
{группа:[команды]} как входной сахар (алиасы important/goTo/seeAlso→
FormNavigationPanel*, important/createBasedOn→FormCommandBar*; иной ключ verbatim;
group из ключа, элементы не дублируют). Голый элемент → строка-shorthand.
Переиспользует Decompile-XrFlag/Emit-XrFlag.
Выборка 2.17: ring3 37→7, match 181→197; сам CommandInterface роундтрипится
бит-в-бит (0 CI-diff, остаток TOTAL — несвязанный хвост раскрытых форм). Зеркало
py байт-в-байт, кейс commands (+commandInterface tree-форма) сертифицирован
загрузкой в 1С. Регресс 40/40 (ps1+py).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ef036c7cf1
commit
d7dedd4843
@@ -1,4 +1,4 @@
|
||||
# form-decompile v0.73 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# form-decompile v0.74 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||
param(
|
||||
@@ -145,7 +145,6 @@ function Fail-Ring3 {
|
||||
[Console]::Error.WriteLine("Для точечной работы с этой формой используй /form-edit.")
|
||||
exit 3
|
||||
}
|
||||
foreach ($el in $xmlDoc.SelectNodes("//*[local-name()='CommandInterface']")) { Fail-Ring3 -kind "CommandInterface" -loc "form/CommandInterface" }
|
||||
foreach ($el in $xmlDoc.SelectNodes("//*[local-name()='ConditionalAppearance']")) { Fail-Ring3 -kind "ConditionalAppearance" -loc "form/ConditionalAppearance" }
|
||||
|
||||
# --- 1c. Compact JSON serializer (созвучно skd-decompile: 2-проб. indent, inline в пределах lineLimit) ---
|
||||
@@ -864,6 +863,38 @@ function Decompile-XrFlag {
|
||||
return $o
|
||||
}
|
||||
|
||||
# Командный интерфейс формы (<CommandInterface>): панели CommandBar + NavigationPanel,
|
||||
# каждая — список переопределений команд (платформа эмитит ТОЛЬКО отклонения от авто-расстановки).
|
||||
# Элемент: command (verbatim, "0"=пустой) + type (Auto опускаем) + attribute/group(CommandGroup)/index +
|
||||
# defaultVisible(bool) + visible(xr-flag bool/{common,roles} — тот же механизм, что userVisible).
|
||||
# Голый элемент (только команда, Type=Auto) → строковый shorthand.
|
||||
function Decompile-CommandInterface {
|
||||
$ciNode = $root.SelectSingleNode("lf:CommandInterface", $ns)
|
||||
if (-not $ciNode) { return $null }
|
||||
$ci = [ordered]@{}
|
||||
foreach ($panel in @(@('CommandBar','commandBar'), @('NavigationPanel','navigationPanel'))) {
|
||||
$pn = $ciNode.SelectSingleNode("lf:$($panel[0])", $ns)
|
||||
if (-not $pn) { continue }
|
||||
$items = New-Object System.Collections.ArrayList
|
||||
foreach ($it in @($pn.SelectNodes("lf:Item", $ns))) {
|
||||
$o = [ordered]@{}
|
||||
$cmd = Get-Child $it 'Command'
|
||||
$o['command'] = "$cmd"
|
||||
$ty = Get-Child $it 'Type'; if ($ty -and $ty -ne 'Auto') { $o['type'] = $ty }
|
||||
$at = Get-Child $it 'Attribute'; if ($at) { $o['attribute'] = $at }
|
||||
$cg = Get-Child $it 'CommandGroup'; if ($cg) { $o['group'] = $cg }
|
||||
$idx = Get-Child $it 'Index'; if ($null -ne $idx) { $o['index'] = [int]$idx }
|
||||
$dv = Get-Child $it 'DefaultVisible'; if ($null -ne $dv) { $o['defaultVisible'] = ($dv -eq 'true') }
|
||||
$vis = Decompile-XrFlag $it 'Visible'; if ($null -ne $vis) { $o['visible'] = $vis }
|
||||
# Голый элемент (только command) → строка-shorthand; иначе объект
|
||||
if ($o.Count -eq 1) { [void]$items.Add("$cmd") } else { [void]$items.Add($o) }
|
||||
}
|
||||
if ($items.Count -gt 0) { $ci[$panel[1]] = @($items) }
|
||||
}
|
||||
if ($ci.Count -gt 0) { return $ci }
|
||||
return $null
|
||||
}
|
||||
|
||||
# <FunctionalOptions><Item>FunctionalOption.X</Item>…> → массив строк (префикс FunctionalOption. снят; GUID — как есть).
|
||||
function Decompile-FunctionalOptions {
|
||||
param($node)
|
||||
@@ -2092,6 +2123,10 @@ if ($cmdsNode) {
|
||||
if ($cmds.Count -gt 0) { $dsl['commands'] = @($cmds) }
|
||||
}
|
||||
|
||||
# commandInterface (форменный <CommandInterface> — последний дочерний Form)
|
||||
$ci = Decompile-CommandInterface
|
||||
if ($null -ne $ci) { $dsl['commandInterface'] = $ci }
|
||||
|
||||
# --- 6. Output ---
|
||||
$json = ConvertTo-CompactJson -obj $dsl
|
||||
if ($OutputPath) {
|
||||
|
||||
Reference in New Issue
Block a user