From e59c3281fd80ce2bad8f0a5c8b264d12afb05c61 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sun, 24 May 2026 20:57:12 +0300 Subject: [PATCH] =?UTF-8?q?feat(skd):=20=D1=80=D0=B0=D0=B7=D0=BB=D0=B8?= =?UTF-8?q?=D1=87=D0=B0=D1=82=D1=8C=203=20namespace=20=D1=86=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=20(style/web/win)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раньше decompile Normalize-Color сворачивал любой dN: префикс в style: независимо от URI. Compile Emit-ColorValue знал только style: → один xmlns (http://v8.1c.ru/8.1/data/ui/style). Цвета web:GhostWhite и win:Highlight терялись/искажались. URI mapping: - http://v8.1c.ru/8.1/data/ui/style → style: - http://v8.1c.ru/8.1/data/ui/colors/web → web: - http://v8.1c.ru/8.1/data/ui/colors/windows → win: decompile: резолвим prefix через GetNamespaceOfPrefix. compile (PS+Py): Emit-ColorValue для template cells — long form с локальным xmlns. Emit-AppearanceValue (внутри settings) — short form, т.к. уже объявляет xmlns:style/web/win/sys на корне. См. upload/erf/ЦветаВМакете — образец с 4 формами цвета. --- .../skd-compile/scripts/skd-compile.ps1 | 23 ++++++++++++++----- .../skills/skd-compile/scripts/skd-compile.py | 21 ++++++++++++----- .../skd-decompile/scripts/skd-decompile.ps1 | 14 +++++++++-- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index 80f01234..fa64cbcb 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.101 — Compile 1C DCS from JSON +# skd-compile v1.102 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -1651,12 +1651,21 @@ foreach ($stylesFile in $searchPaths) { function Emit-ColorValue { param([string]$color, [string]$indent) - if ($color.StartsWith('style:')) { - $styleName = $color.Substring(6) - X "$indentd8p1:$styleName" - } else { - X "$indent$(Esc-Xml $color)" + # Префиксы style:/web:/win: → соответствующий xmlns + dN:Name + $colorPrefixToUri = @{ + 'style:' = 'http://v8.1c.ru/8.1/data/ui/style' + 'web:' = 'http://v8.1c.ru/8.1/data/ui/colors/web' + 'win:' = 'http://v8.1c.ru/8.1/data/ui/colors/windows' } + foreach ($pfx in $colorPrefixToUri.Keys) { + if ($color.StartsWith($pfx)) { + $name = $color.Substring($pfx.Length) + $uri = $colorPrefixToUri[$pfx] + X "$indentd8p1:$name" + return + } + } + X "$indent$(Esc-Xml $color)" } function Emit-CellAppearance { @@ -2438,6 +2447,8 @@ function Emit-AppearanceValue { if ($keyType) { X "$indent`t$(Esc-Xml $actualVal)" } elseif ($actualVal -match '^(style|web|win):') { + # Внутри префиксы style:/web:/win:/sys: уже объявлены на корне, + # локальный xmlns не нужен — эмитим short form. X "$indent`t$(Esc-Xml $actualVal)" } elseif ($actualVal -eq "true" -or $actualVal -eq "false") { X "$indent`t$actualVal" diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index d3e855fe..8f0dbd93 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.101 — Compile 1C DCS from JSON +# skd-compile v1.102 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -1346,11 +1346,18 @@ def load_user_styles(base_dir, output_path=None): def _emit_color_value(lines, color, indent): - if color.startswith('style:'): - style_name = color[6:] - lines.append(f'{indent}d8p1:{style_name}') - else: - lines.append(f'{indent}{esc_xml(color)}') + # Префиксы style:/web:/win: → соответствующий xmlns + dN:Name + color_prefix_to_uri = { + 'style:': 'http://v8.1c.ru/8.1/data/ui/style', + 'web:': 'http://v8.1c.ru/8.1/data/ui/colors/web', + 'win:': 'http://v8.1c.ru/8.1/data/ui/colors/windows', + } + for pfx, uri in color_prefix_to_uri.items(): + if color.startswith(pfx): + name = color[len(pfx):] + lines.append(f'{indent}d8p1:{name}') + return + lines.append(f'{indent}{esc_xml(color)}') def _emit_cell_appearance(lines, style, width=0, v_merge=False, h_merge=False, min_height=0, extra_items=None): @@ -1992,6 +1999,8 @@ def emit_appearance_value(lines, key, val, indent): if key_type: lines.append(f'{indent}\t{esc_xml(actual_val)}') elif re.match(r'^(style|web|win):', actual_val): + # Внутри префиксы style:/web:/win:/sys: уже объявлены на корне, + # локальный xmlns не нужен — эмитим short form. lines.append(f'{indent}\t{esc_xml(actual_val)}') elif actual_val == 'true' or actual_val == 'false': lines.append(f'{indent}\t{actual_val}') diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index 8c3f9625..32dc12d5 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.85 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.86 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -1036,7 +1036,17 @@ function Normalize-Color { param($valNode) if (-not $valNode) { return $null } $txt = $valNode.InnerText - if ($txt -match '^d\d+p\d+:(.+)$') { return 'style:' + $matches[1] } + # Префикс xsi:type или value — резолвим в URI и выбираем DSL-префикс. + if ($txt -match '^([^:]+):(.+)$') { + $pfx = $matches[1] + $name = $matches[2] + $uri = $valNode.GetNamespaceOfPrefix($pfx) + switch ($uri) { + 'http://v8.1c.ru/8.1/data/ui/style' { return 'style:' + $name } + 'http://v8.1c.ru/8.1/data/ui/colors/web' { return 'web:' + $name } + 'http://v8.1c.ru/8.1/data/ui/colors/windows' { return 'win:' + $name } + } + } return $txt }