diff --git a/.claude/skills/meta-compile/scripts/meta-compile.ps1 b/.claude/skills/meta-compile/scripts/meta-compile.ps1 index 0ae4cd34..8967f97f 100644 --- a/.claude/skills/meta-compile/scripts/meta-compile.ps1 +++ b/.claude/skills/meta-compile/scripts/meta-compile.ps1 @@ -1,4 +1,4 @@ -# meta-compile v1.28 — Compile 1C metadata object from JSON +# meta-compile v1.29 — Compile 1C metadata object from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -1580,6 +1580,29 @@ function Emit-Attribute { X "$indent" } +# команды — структурный блок (зеркало form-compile). Дефолт LoadTransparent=true (конвенция +# кнопки/команды): фиксируем только false. Значение: строка-ref + sibling `loadTransparent` ЛИБО объект +# {src, loadTransparent?, transparentPixel?}. src с префиксом "abs:" → , иначе . Нет → . +function Emit-CommandPicture { + param([string]$indent, $cmd) + $pic = $cmd.picture + if (-not $pic) { X "$indent"; return } + $src = $null; $lt = $true; $tpx = $null + if ($pic -is [string]) { $src = "$pic"; if ($cmd.loadTransparent -eq $false) { $lt = $false } } + else { + $src = if ($pic.src) { "$($pic.src)" } elseif ($pic.ref) { "$($pic.ref)" } else { "" } + if ($pic.loadTransparent -eq $false) { $lt = $false } + $tpx = $pic.transparentPixel + } + if (-not $src) { X "$indent"; return } + X "$indent" + if ($src -match '^abs:(.*)$') { X "$indent`t$(Esc-Xml $matches[1])" } + else { X "$indent`t$(Esc-Xml $src)" } + X "$indent`t$(if ($lt) { 'true' } else { 'false' })" + if ($tpx) { X "$indent`t" } + X "$indent" +} + # --- 8b. Command emitter --- # $cmd — объект свойств команды. Поля (omit-on-default): synonym/tooltip (ML), comment, group, # commandParameterType (тип), parameterUseMode (Single), modifiesData (false), representation (Auto), @@ -1608,7 +1631,7 @@ function Emit-Command { $rep = if ($cmd.representation) { "$($cmd.representation)" } else { "Auto" } X "$indent`t`t$rep" Emit-MLText "$indent`t`t" "ToolTip" $cmd.tooltip - if ($cmd.picture) { X "$indent`t`t$(Esc-Xml "$($cmd.picture)")" } else { X "$indent`t`t" } + Emit-CommandPicture "$indent`t`t" $cmd if ($cmd.shortcut) { X "$indent`t`t$(Esc-Xml "$($cmd.shortcut)")" } else { X "$indent`t`t" } $osu = if ($cmd.onMainServerUnavalableBehavior) { "$($cmd.onMainServerUnavalableBehavior)" } else { "Auto" } X "$indent`t`t$osu" diff --git a/.claude/skills/meta-compile/scripts/meta-compile.py b/.claude/skills/meta-compile/scripts/meta-compile.py index b3b594de..b97a3fb7 100644 --- a/.claude/skills/meta-compile/scripts/meta-compile.py +++ b/.claude/skills/meta-compile/scripts/meta-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# meta-compile v1.28 — Compile 1C metadata object from JSON +# meta-compile v1.29 — Compile 1C metadata object from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse @@ -832,7 +832,8 @@ def parse_attribute_shorthand(val): 'synonym': val['synonym'] if val.get('synonym') is not None else split_camel_case(name), 'tooltip': val.get('tooltip'), 'comment': str(val['comment']) if val.get('comment') else '', - 'flags': list(val.get('flags', [])), + # Лоуэркейз как в строковом пути (стр.809): проверки флагов регистронезависимы (зеркало PS -contains). + 'flags': [str(f).strip().lower() for f in val.get('flags', [])], 'fillChecking': fc, 'indexing': str(val['indexing']) if val.get('indexing') else '', 'multiLine': True if val.get('multiLine') is True else False, @@ -1630,6 +1631,39 @@ def emit_attribute(indent, parsed, context): # 9. TabularSection emitter # --------------------------------------------------------------------------- +def emit_command_picture(indent, cmd): + """ команды — структурный блок (зеркало form-compile). Дефолт LoadTransparent=true (конвенция + кнопки/команды): фиксируем только false. Значение: строка-ref + sibling loadTransparent ЛИБО объект + {src, loadTransparent?, transparentPixel?}. src с префиксом "abs:" → , иначе . Нет → .""" + pic = cmd.get('picture') + if not pic: + X(f'{indent}') + return + lt = True + tpx = None + if isinstance(pic, str): + src = pic + if cmd.get('loadTransparent') is False: + lt = False + else: + src = str(pic.get('src') or pic.get('ref') or '') + if pic.get('loadTransparent') is False: + lt = False + tpx = pic.get('transparentPixel') + if not src: + X(f'{indent}') + return + X(f'{indent}') + m = re.match(r'^abs:(.*)$', src) + if m: + X(f'{indent}\t{esc_xml(m.group(1))}') + else: + X(f'{indent}\t{esc_xml(src)}') + X(f'{indent}\t{"true" if lt else "false"}') + if tpx: + X(f'{indent}\t') + X(f'{indent}') + def emit_command(indent, cmd_name, cmd): X(f'{indent}') X(f'{indent}\t') @@ -1651,10 +1685,7 @@ def emit_command(indent, cmd_name, cmd): X(f'{indent}\t\t{"true" if cmd.get("modifiesData") is True else "false"}') X(f'{indent}\t\t{cmd.get("representation") or "Auto"}') emit_mltext(f'{indent}\t\t', 'ToolTip', cmd.get('tooltip')) - if cmd.get('picture'): - X(f'{indent}\t\t{esc_xml(str(cmd["picture"]))}') - else: - X(f'{indent}\t\t') + emit_command_picture(f'{indent}\t\t', cmd) if cmd.get('shortcut'): X(f'{indent}\t\t{esc_xml(str(cmd["shortcut"]))}') else: diff --git a/.claude/skills/meta-decompile/scripts/meta-decompile.ps1 b/.claude/skills/meta-decompile/scripts/meta-decompile.ps1 index f0bbdf4d..767be0e2 100644 --- a/.claude/skills/meta-decompile/scripts/meta-decompile.ps1 +++ b/.claude/skills/meta-decompile/scripts/meta-decompile.ps1 @@ -1,4 +1,4 @@ -# meta-decompile v0.19 — XML объекта метаданных 1С → JSON-черновик формата meta-compile +# meta-decompile v0.20 — XML объекта метаданных 1С → JSON-черновик формата meta-compile # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # # Пилот: только Catalog. Инверс meta-compile (omit-on-default: ключ эмитим только @@ -589,7 +589,25 @@ if ($childObjs) { $mdN = $cp.SelectSingleNode('md:ModifiesData', $nsm); if ($mdN -and $mdN.InnerText -eq 'true') { $o['modifiesData'] = $true } $repN = $cp.SelectSingleNode('md:Representation', $nsm); if ($repN -and $repN.InnerText -ne 'Auto') { $o['representation'] = $repN.InnerText } $ctt = Get-MLValue ($cp.SelectSingleNode('md:ToolTip', $nsm)); if ($null -ne $ctt) { $o['tooltip'] = $ctt } - $picN = $cp.SelectSingleNode('md:Picture', $nsm); if ($picN -and $picN.InnerText) { $o['picture'] = $picN.InnerText } + # — структурный блок (зеркало form-decompile Set-CommandPicture). Дефолт LoadTransparent=true: + # скаляр `picture` + sibling `loadTransparent:false` при отклонении; объект {src,loadTransparent?,transparentPixel} при TransparentPixel. + $refN = $cp.SelectSingleNode('md:Picture/xr:Ref', $nsm) + $absN = $cp.SelectSingleNode('md:Picture/xr:Abs', $nsm) + if ($refN -or $absN) { + $psrc = if ($refN) { $refN.InnerText } else { "abs:$($absN.InnerText)" } + $ltN = $cp.SelectSingleNode('md:Picture/xr:LoadTransparent', $nsm) + $ltFalse = ($ltN -and $ltN.InnerText -eq 'false') + $tpxN = $cp.SelectSingleNode('md:Picture/xr:TransparentPixel', $nsm) + if ($tpxN) { + $po = [ordered]@{ src = $psrc } + if ($ltFalse) { $po['loadTransparent'] = $false } + $po['transparentPixel'] = [ordered]@{ x = [int]$tpxN.GetAttribute('x'); y = [int]$tpxN.GetAttribute('y') } + $o['picture'] = $po + } else { + $o['picture'] = $psrc + if ($ltFalse) { $o['loadTransparent'] = $false } + } + } $scN = $cp.SelectSingleNode('md:Shortcut', $nsm); if ($scN -and $scN.InnerText) { $o['shortcut'] = $scN.InnerText } $osuN = $cp.SelectSingleNode('md:OnMainServerUnavalableBehavior', $nsm); if ($osuN -and $osuN.InnerText -ne 'Auto') { $o['onMainServerUnavalableBehavior'] = $osuN.InnerText } $cmdMap[$cn] = $o diff --git a/docs/meta-dsl-spec.md b/docs/meta-dsl-spec.md index 04344bda..1818f211 100644 --- a/docs/meta-dsl-spec.md +++ b/docs/meta-dsl-spec.md @@ -444,15 +444,26 @@ JSON DSL для описания объектов метаданных конф | `parameterUseMode` | ParameterUseMode | `Single` (`Single`/`Multiple`) | | `modifiesData` | ModifiesData | `false` (bool) | | `representation` | Representation | `Auto` | -| `picture` / `shortcut` | Picture / Shortcut | пусто | +| `picture` | Picture | пусто (структурный блок, см. ниже) | +| `loadTransparent` | Picture/LoadTransparent | `true` (bool, sibling `picture`) | +| `shortcut` | Shortcut | пусто | | `onMainServerUnavalableBehavior` | OnMainServerUnavalableBehavior | `Auto` | +**`picture`** — картинка команды `` (структурный блок ``+``, зеркало form-compile). +Значение: строка-ref (`StdPicture.X` / `CommonPicture.X`; встроенная — префикс `abs:` → ``) ЛИБО объект +`{src, loadTransparent?, transparentPixel?}`. LoadTransparent платформа пишет всегда, **дефолт `true`** (конвенция +кнопки/команды) — фиксируем только `false`: строкой-ref + sibling-ключ `loadTransparent: false`, либо внутри объекта. +`transparentPixel: {x, y}` → ``. Декомпилятор: скаляр при LoadTransparent=true без пикселя, +иначе объект. + ```json "commands": { "ПечатьЭтикеток": { "synonym": "Печать этикеток", "group": "FormCommandBarImportant", - "commandParameterType": "CatalogRef.Номенклатура", "modifiesData": true - } + "commandParameterType": "CatalogRef.Номенклатура", "modifiesData": true, + "picture": "StdPicture.Print" + }, + "ЗагрузитьИзФайла": { "picture": "CommonPicture.Загрузка", "loadTransparent": false } } ``` diff --git a/tests/skills/cases/meta-compile/catalog-command.json b/tests/skills/cases/meta-compile/catalog-command.json index 30477d8d..5fe3abac 100644 --- a/tests/skills/cases/meta-compile/catalog-command.json +++ b/tests/skills/cases/meta-compile/catalog-command.json @@ -9,7 +9,16 @@ "commandParameterType": "CatalogRef.Номенклатура", "parameterUseMode": "Multiple", "modifiesData": true, - "tooltip": "Печать этикеток для выбранных товаров" + "tooltip": "Печать этикеток для выбранных товаров", + "picture": "StdPicture.Print" + }, + "ЗагрузитьИзФайла": { + "synonym": "Загрузить из файла", + "picture": "CommonPicture.Загрузка", + "loadTransparent": false + }, + "ОбновитьСписок": { + "picture": { "src": "StdPicture.Refresh", "transparentPixel": { "x": 0, "y": 0 } } } } }, diff --git a/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура.xml b/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура.xml index 52547a0f..2a808659 100644 --- a/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура.xml +++ b/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура.xml @@ -114,7 +114,59 @@ Печать этикеток для выбранных товаров - + + StdPicture.Print + true + + + Auto + + + + + ЗагрузитьИзФайла + + + ru + Загрузить из файла + + + + + + Single + false + Auto + + + CommonPicture.Загрузка + false + + + Auto + + + + + ОбновитьСписок + + + ru + Обновить список + + + + + + Single + false + Auto + + + StdPicture.Refresh + true + + Auto diff --git a/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура/Commands/ЗагрузитьИзФайла/Ext/CommandModule.bsl b/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура/Commands/ЗагрузитьИзФайла/Ext/CommandModule.bsl new file mode 100644 index 00000000..d7ec0aeb --- /dev/null +++ b/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура/Commands/ЗагрузитьИзФайла/Ext/CommandModule.bsl @@ -0,0 +1,6 @@ +&НаКлиенте +Процедура ОбработкаКоманды(ПараметрКоманды, ПараметрыВыполненияКоманды) + + // Вставьте обработчик команды. + +КонецПроцедуры diff --git a/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура/Commands/ОбновитьСписок/Ext/CommandModule.bsl b/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура/Commands/ОбновитьСписок/Ext/CommandModule.bsl new file mode 100644 index 00000000..d7ec0aeb --- /dev/null +++ b/tests/skills/cases/meta-compile/snapshots/catalog-command/Catalogs/Номенклатура/Commands/ОбновитьСписок/Ext/CommandModule.bsl @@ -0,0 +1,6 @@ +&НаКлиенте +Процедура ОбработкаКоманды(ПараметрКоманды, ПараметрыВыполненияКоманды) + + // Вставьте обработчик команды. + +КонецПроцедуры