From f271a6f6bae5f3e14e3bf4280e87dd996b6b73a1 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 23 May 2026 16:19:48 +0300 Subject: [PATCH] =?UTF-8?q?feat(skd):=20viewMode/userSettingID/userSetting?= =?UTF-8?q?Presentation=20=D0=BD=D0=B0=20outputParameters=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrapper {value, ...} расширен: помимо use=false поддерживает viewMode, userSettingID, userSettingPresentation на каждом item внутри . Также value=Font dict теперь работает в wrapper. sample30: −92 строки (3322 → 3230). --- .../skd-compile/scripts/skd-compile.ps1 | 64 +++++++++++++++---- .../skills/skd-compile/scripts/skd-compile.py | 38 ++++++++--- .../skd-decompile/scripts/skd-decompile.ps1 | 18 ++++-- 3 files changed, 96 insertions(+), 24 deletions(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index adea798f..863af634 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.ps1 +++ b/.claude/skills/skd-compile/scripts/skd-compile.ps1 @@ -1,4 +1,4 @@ -# skd-compile v1.66 — Compile 1C DCS from JSON +# skd-compile v1.67 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -2356,30 +2356,72 @@ function Emit-OutputParameters { foreach ($prop in $params.PSObject.Properties) { $key = $prop.Name $rawVal = $prop.Value - # Распознаём wrapper {use: false, value: ...} (отличаем от multilang dict) - $useWrapper = $false - if ($rawVal -is [PSCustomObject] -and $rawVal.PSObject.Properties['use'] -and $rawVal.use -eq $false -and $rawVal.PSObject.Properties['value']) { - $useWrapper = $true + # Распознаём wrapper {value, use?, viewMode?, userSettingID?, userSettingPresentation?} + # отличая от multilang dict ({ru, en, ...}). Wrapper всегда имеет ключ 'value'. + $useFalse = $false + $wrapVM = $null + $wrapUSID = $null + $wrapUSP = $null + $hasValueKey = $false + if ($rawVal -is [PSCustomObject] -and $rawVal.PSObject.Properties['value']) { + $hasValueKey = $true + if ($rawVal.PSObject.Properties['use'] -and $rawVal.use -eq $false) { $useFalse = $true } + if ($rawVal.PSObject.Properties['viewMode']) { $wrapVM = "$($rawVal.viewMode)" } + if ($rawVal.PSObject.Properties['userSettingID']) { $wrapUSID = "$($rawVal.userSettingID)" } + if ($rawVal.PSObject.Properties['userSettingPresentation']) { $wrapUSP = $rawVal.userSettingPresentation } $rawVal = $rawVal.value - } elseif (($rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) -and $rawVal.Contains('use') -and $rawVal['use'] -eq $false -and $rawVal.Contains('value')) { - $useWrapper = $true + } elseif (($rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) -and $rawVal.Contains('value')) { + $hasValueKey = $true + if ($rawVal.Contains('use') -and $rawVal['use'] -eq $false) { $useFalse = $true } + if ($rawVal.Contains('viewMode')) { $wrapVM = "$($rawVal['viewMode'])" } + if ($rawVal.Contains('userSettingID')) { $wrapUSID = "$($rawVal['userSettingID'])" } + if ($rawVal.Contains('userSettingPresentation')) { $wrapUSP = $rawVal['userSettingPresentation'] } $rawVal = $rawVal['value'] } + # Font dict внутри значения + $isFontDict = $false + if ($rawVal -is [PSCustomObject]) { + $tProp = $rawVal.PSObject.Properties['@type'] + if ($tProp -and "$($tProp.Value)" -eq 'Font') { $isFontDict = $true } + } elseif ($rawVal -is [System.Collections.IDictionary]) { + if ($rawVal.Contains('@type') -and "$($rawVal['@type'])" -eq 'Font') { $isFontDict = $true } + } $ptype = $script:outputParamTypes[$key] if (-not $ptype) { $ptype = "xs:string" } - # Auto-promote to mltext if value is a multilang dict ({ru, en, ...}) - if ($rawVal -is [System.Management.Automation.PSCustomObject] -or $rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) { + # Auto-promote to mltext if value is a multilang dict (но не Font/wrapper) + if (-not $isFontDict -and ($rawVal -is [System.Management.Automation.PSCustomObject] -or $rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary])) { $ptype = "mltext" } X "$indent`t" - if ($useWrapper) { X "$indent`t`tfalse" } + if ($useFalse) { X "$indent`t`tfalse" } X "$indent`t`t$(Esc-Xml $key)" - if ($ptype -eq "mltext") { + if ($isFontDict) { + $attrParts = @() + foreach ($attrName in @('ref','faceName','height','bold','italic','underline','strikeout','kind','scale')) { + $av = $null + if ($rawVal -is [PSCustomObject]) { + $ap = $rawVal.PSObject.Properties[$attrName] + if ($ap) { $av = $ap.Value } + } else { + if ($rawVal.Contains($attrName)) { $av = $rawVal[$attrName] } + } + if ($null -ne $av) { $attrParts += "$attrName=`"$(Esc-Xml "$av")`"" } + } + X "$indent`t`t" + } elseif ($ptype -eq "mltext") { Emit-MLText -tag "dcscor:value" -text $rawVal -indent "$indent`t`t" } else { X "$indent`t`t$(Esc-Xml "$rawVal")" } + if ($wrapVM) { X "$indent`t`t$(Esc-Xml $wrapVM)" } + if ($wrapUSID) { + $uid = if ("$wrapUSID" -eq 'auto') { New-Guid-String } else { "$wrapUSID" } + X "$indent`t`t$(Esc-Xml $uid)" + } + if ($wrapUSP) { + Emit-MLText -tag "dcsset:userSettingPresentation" -text $wrapUSP -indent "$indent`t`t" + } X "$indent`t" } if ($null -ne $blockViewMode) { diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index f4f28f11..21c5e3e1 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.py +++ b/.claude/skills/skd-compile/scripts/skd-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# skd-compile v1.66 — Compile 1C DCS from JSON +# skd-compile v1.67 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -1948,24 +1948,44 @@ def emit_output_parameters(lines, params, indent): lines.append(f'{indent}') for key, val in params.items(): - # Распознаём wrapper {use: false, value: ...} — отличаем от multilang dict - use_wrapper = False - if isinstance(val, dict) and val.get('use') is False and 'value' in val: - use_wrapper = True + # wrapper {value, use?, viewMode?, userSettingID?, userSettingPresentation?} + use_false = False + wrap_vm = None + wrap_usid = None + wrap_usp = None + if isinstance(val, dict) and 'value' in val: + if val.get('use') is False: use_false = True + wrap_vm = val.get('viewMode') + wrap_usid = val.get('userSettingID') + wrap_usp = val.get('userSettingPresentation') val = val['value'] + is_font_dict = isinstance(val, dict) and val.get('@type') == 'Font' ptype = OUTPUT_PARAM_TYPES.get(key, 'xs:string') - # Auto-promote to mltext if value is a multilang dict ({ru, en, ...}) - if isinstance(val, dict): + # Auto-promote to mltext if value is a multilang dict (but not Font) + if not is_font_dict and isinstance(val, dict): ptype = 'mltext' lines.append(f'{indent}\t') - if use_wrapper: + if use_false: lines.append(f'{indent}\t\tfalse') lines.append(f'{indent}\t\t{esc_xml(key)}') - if ptype == 'mltext': + if is_font_dict: + attr_parts = [] + for attr_name in ('ref', 'faceName', 'height', 'bold', 'italic', 'underline', 'strikeout', 'kind', 'scale'): + if attr_name in val: + attr_parts.append(f'{attr_name}="{esc_xml(str(val[attr_name]))}"') + lines.append(f'{indent}\t\t') + elif ptype == 'mltext': emit_mltext(lines, f'{indent}\t\t', 'dcscor:value', val) else: lines.append(f'{indent}\t\t{esc_xml(str(val))}') + if wrap_vm: + lines.append(f'{indent}\t\t{esc_xml(str(wrap_vm))}') + if wrap_usid: + uid = new_uuid() if str(wrap_usid) == 'auto' else str(wrap_usid) + lines.append(f'{indent}\t\t{esc_xml(uid)}') + if wrap_usp: + emit_mltext(lines, f'{indent}\t\t', 'dcsset:userSettingPresentation', wrap_usp) lines.append(f'{indent}\t') lines.append(f'{indent}') diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index bbb1d48e..55e79701 100644 --- a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 +++ b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 @@ -1,4 +1,4 @@ -# skd-decompile v0.50 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.51 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -1672,11 +1672,21 @@ function Build-OutputParameters { if (-not $pName -or -not $val) { continue } $vType = Get-LocalXsiType $val if ($vType -eq 'LocalStringType') { $rawVal = Get-MLText $val } + elseif ($vType -eq 'Font') { $rawVal = Get-FontValue $val } else { $rawVal = $val.InnerText } - # false → wrapper {value, use: false} + # Extras (use=false / viewMode / userSettingID / userSettingPresentation) → wrapper. $useV = Get-Text $it "dcscor:use" - if ($useV -eq 'false') { - $d[$pName] = [ordered]@{ value = $rawVal; use = $false } + $vmN = $it.SelectSingleNode("dcsset:viewMode", $ns) + $usidV = Get-Text $it "dcsset:userSettingID" + $uspN = $it.SelectSingleNode("dcsset:userSettingPresentation", $ns) + $hasExtras = ($useV -eq 'false') -or $vmN -or $usidV -or $uspN + if ($hasExtras) { + $wrap = [ordered]@{ value = $rawVal } + if ($useV -eq 'false') { $wrap['use'] = $false } + if ($vmN) { $wrap['viewMode'] = $vmN.InnerText } + if ($usidV) { $wrap['userSettingID'] = 'auto' } + if ($uspN) { $wrap['userSettingPresentation'] = Get-MLText $uspN } + $d[$pName] = $wrap } else { $d[$pName] = $rawVal }