cdpm-mcp 0.1.8 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -89
- package/README.ko.md +326 -277
- package/README.md +249 -200
- package/dist/agent-setup.js +23 -23
- package/dist/cdp/client.js +13 -9
- package/dist/cdp/downloads.js +4 -1
- package/dist/cdp/sessions.js +45 -24
- package/dist/cdp/targets.js +12 -1
- package/dist/chrome/bubbles.js +14 -14
- package/dist/chrome/launcher.js +3 -0
- package/dist/claude-md-setup.js +22 -22
- package/dist/cli.js +6 -4
- package/dist/page/actions.js +248 -143
- package/dist/page/keys.js +1 -1
- package/dist/page/snapshot.js +11 -5
- package/dist/proxy-forwarder.js +17 -11
- package/dist/registry/lock.js +47 -4
- package/dist/registry/messages.js +28 -13
- package/dist/registry/store.js +19 -7
- package/dist/service.js +5 -5
- package/dist/taskbar/dock.js +31 -31
- package/dist/taskbar/icon-gdi.js +158 -158
- package/dist/taskbar/watcher.js +4 -0
- package/dist/tools/register.js +105 -73
- package/package.json +65 -64
package/dist/taskbar/icon-gdi.js
CHANGED
|
@@ -7,164 +7,164 @@ import { execFileSync } from 'node:child_process';
|
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import os from 'node:os';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
const SCRIPT = String.raw `
|
|
11
|
-
param([string]$OutDir, [int]$Slot, [string]$Hex, [string]$Sizes)
|
|
12
|
-
# 오류가 나면 바로 멈춰 실패로 알린다 (조용히 넘어가 망가진 아이콘이 저장되지 않게)
|
|
13
|
-
$ErrorActionPreference = 'Stop'
|
|
14
|
-
Add-Type -AssemblyName System.Drawing
|
|
15
|
-
$base = [System.Drawing.ColorTranslator]::FromHtml($Hex)
|
|
16
|
-
function C([int]$a) { [System.Drawing.Color]::FromArgb($a, $base.R, $base.G, $base.B) }
|
|
17
|
-
function W([int]$a) { [System.Drawing.Color]::FromArgb($a, 255, 255, 255) }
|
|
18
|
-
# 주의: PowerShell에는 'r' 별칭(Invoke-History)이 있어 함수 이름으로 R을 쓰면 별칭이 먼저 불린다
|
|
19
|
-
function SnapPx([double]$v) { [double][Math]::Round($v) }
|
|
20
|
-
function RoundRect([double]$x, [double]$y, [double]$w, [double]$h, [double]$r) {
|
|
21
|
-
$p = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
22
|
-
$d = [single]($r * 2)
|
|
23
|
-
$p.AddArc([single]$x, [single]$y, $d, $d, 180, 90); $p.AddArc([single]($x + $w - 2 * $r), [single]$y, $d, $d, 270, 90)
|
|
24
|
-
$p.AddArc([single]($x + $w - 2 * $r), [single]($y + $h - 2 * $r), $d, $d, 0, 90); $p.AddArc([single]$x, [single]($y + $h - 2 * $r), $d, $d, 90, 90)
|
|
25
|
-
$p.CloseFigure(); return $p
|
|
26
|
-
}
|
|
27
|
-
# 실제 아이콘(숫자 그리기 직전 상태 $pre)의 복사본에 숫자를 그려, 잉크가 있는 줄(배경보다 50% 이상 밝아진 줄)의 위·아래를 잰다.
|
|
28
|
-
# (따로 투명한 판에 그리면 글자 가장자리가 실제와 다르게 나와서, 실제와 똑같이 그려 본다)
|
|
29
|
-
function InkRows($pre, [string]$str, [single]$em, [single]$x, [single]$y) {
|
|
30
|
-
$w = $pre.Width; $h = $pre.Height
|
|
31
|
-
$rect = New-Object System.Drawing.Rectangle(0, 0, $w, $h)
|
|
32
|
-
$lb = $pre.Clone($rect, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
33
|
-
$lg = [System.Drawing.Graphics]::FromImage($lb)
|
|
34
|
-
$lg.SmoothingMode = 'AntiAlias'; $lg.PixelOffsetMode = 'Half'; $lg.CompositingQuality = 'HighQuality'; $lg.TextRenderingHint = 'AntiAliasGridFit'
|
|
35
|
-
$lf = New-Object System.Drawing.Font($family, $em, ([System.Drawing.FontStyle]::Bold), ([System.Drawing.GraphicsUnit]::Pixel))
|
|
36
|
-
$lg.DrawString($str, $lf, [System.Drawing.Brushes]::White, (New-Object System.Drawing.PointF($x, $y)), $fmt); $lg.Dispose()
|
|
37
|
-
$fmtA = [System.Drawing.Imaging.PixelFormat]::Format32bppArgb
|
|
38
|
-
$d1 = $pre.LockBits($rect, 'ReadOnly', $fmtA); $d2 = $lb.LockBits($rect, 'ReadOnly', $fmtA)
|
|
39
|
-
$b1 = New-Object byte[] ($d1.Stride * $h); $b2 = New-Object byte[] ($d2.Stride * $h)
|
|
40
|
-
[System.Runtime.InteropServices.Marshal]::Copy($d1.Scan0, $b1, 0, $b1.Length); [System.Runtime.InteropServices.Marshal]::Copy($d2.Scan0, $b2, 0, $b2.Length)
|
|
41
|
-
$ls = $d1.Stride; $pre.UnlockBits($d1); $lb.UnlockBits($d2); $lb.Dispose()
|
|
42
|
-
$first = -1; $last = -1
|
|
43
|
-
for ($yy = 0; $yy -lt $h; $yy++) {
|
|
44
|
-
for ($xx = 0; $xx -lt $w; $xx++) {
|
|
45
|
-
$o = $yy * $ls + $xx * 4
|
|
46
|
-
$s1 = [int]$b1[$o] + $b1[$o + 1] + $b1[$o + 2]; $s2 = [int]$b2[$o] + $b2[$o + 1] + $b2[$o + 2]
|
|
47
|
-
if ($s1 -lt 765 -and ($s2 - $s1) -ge (765 - $s1) / 2.0) { if ($first -lt 0) { $first = $yy }; $last = $yy; break }
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return @($first, $last)
|
|
51
|
-
}
|
|
52
|
-
$text = [string]$Slot
|
|
53
|
-
$family = $null
|
|
54
|
-
foreach ($name in @('Segoe UI Variable Display', 'Segoe UI', 'Arial')) {
|
|
55
|
-
try { $family = New-Object System.Drawing.FontFamily($name); break } catch {}
|
|
56
|
-
}
|
|
57
|
-
$fmt = [System.Drawing.StringFormat]::GenericTypographic
|
|
58
|
-
|
|
59
|
-
foreach ($s in ($Sizes -split ',')) {
|
|
60
|
-
$size = [int]$s
|
|
61
|
-
$k = $size / 64.0
|
|
62
|
-
$small = $size -le 48
|
|
63
|
-
$bmp = New-Object System.Drawing.Bitmap $size, $size, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
|
64
|
-
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
|
65
|
-
$g.SmoothingMode = 'AntiAlias'; $g.PixelOffsetMode = 'Half'; $g.CompositingQuality = 'HighQuality'
|
|
66
|
-
$g.Clear([System.Drawing.Color]::Transparent)
|
|
67
|
-
|
|
68
|
-
# 창 모양: 칸을 꽉 채운다. 경계가 정수 픽셀에 오도록 (0,0)~(size,size)
|
|
69
|
-
$radius = [Math]::Max(2.0, (SnapPx (11 * $k)))
|
|
70
|
-
$win = RoundRect 0 0 $size $size $radius
|
|
71
|
-
$grad = New-Object System.Drawing.Drawing2D.LinearGradientBrush((New-Object System.Drawing.PointF(0, -1)), (New-Object System.Drawing.PointF(0, ($size + 1))), (C 255), (C 205))
|
|
72
|
-
$grad.WrapMode = 'TileFlipXY'
|
|
73
|
-
$g.FillPath($grad, $win)
|
|
74
|
-
|
|
75
|
-
# 위 막대 (높이 16/64, 정수 픽셀): 몸통보다 진하게 + 아래 경계 1px 밝은 선
|
|
76
|
-
$barH = [Math]::Max(3.0, (SnapPx (16 * $k)))
|
|
77
|
-
$g.SetClip($win)
|
|
78
|
-
$g.SmoothingMode = 'None'
|
|
79
|
-
$g.FillRectangle((New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(85, 0, 0, 0))), [single]0, [single]0, [single]$size, [single]$barH)
|
|
80
|
-
$g.FillRectangle((New-Object System.Drawing.SolidBrush((W 70))), [single]0, [single]$barH, [single]$size, [single]1)
|
|
81
|
-
|
|
82
|
-
$g.ResetClip()
|
|
83
|
-
$g.SmoothingMode = 'AntiAlias'
|
|
84
|
-
|
|
85
|
-
# 점 3개: 지름·간격·위치를 정수 픽셀로 (작은 크기에서도 또렷하게 떨어져 보이게)
|
|
86
|
-
$dotD = [Math]::Max(2.0, (SnapPx (6.4 * $k)))
|
|
87
|
-
$gap = [Math]::Max(1.0, (SnapPx (2.6 * $k)))
|
|
88
|
-
$dotY = [Math]::Floor(($barH - $dotD) / 2)
|
|
89
|
-
$dotX = [Math]::Max(1.0, (SnapPx (6.5 * $k)))
|
|
90
|
-
$dot = New-Object System.Drawing.SolidBrush((W 245))
|
|
91
|
-
foreach ($i in 0, 1, 2) { $g.FillEllipse($dot, [single]($dotX + $i * ($dotD + $gap)), [single]$dotY, [single]$dotD, [single]$dotD) }
|
|
92
|
-
|
|
93
|
-
# 흰 테두리: 작은 크기는 정확히 1px 안쪽 선, 큰 크기는 비례 두께
|
|
94
|
-
$pw = if ($small) { 1.0 } else { [Math]::Max(1.0, $k) }
|
|
95
|
-
$border = RoundRect ($pw / 2) ($pw / 2) ($size - $pw) ($size - $pw) ([Math]::Max(1.0, $radius - $pw / 2))
|
|
96
|
-
$g.DrawPath((New-Object System.Drawing.Pen((W 128), [single]$pw)), $border)
|
|
97
|
-
|
|
98
|
-
# 숫자 크기: 한 자리든 두 자리든 같은 크기 (64칸 기준 33, 작업표시줄 크기에서는 조금 키움)
|
|
99
|
-
$emU = 33
|
|
100
|
-
if ($size -le 32) { $emU = $emU * 1.12 }
|
|
101
|
-
$em = [single]($emU * $k)
|
|
102
|
-
# 작은 크기: 숫자 위·아래 빈칸을 정확히 같게 하려면 (본문 높이 - 숫자 높이)가 짝수여야 한다.
|
|
103
|
-
# 숫자 높이가 맞지 않으면 글자 크기를 가장 적게(2% 단위, 최대 ±8%) 바꿔 맞춘다.
|
|
104
|
-
# (둥근 숫자 0·8 등은 평평한 1·4·7보다 1px 더 튀어나와서, 높이는 그 슬롯의 번호로 잰다)
|
|
105
|
-
$spaceTop = $barH + 1; $spaceBottom = $size - 2
|
|
106
|
-
if ($small) {
|
|
107
|
-
$g.Flush()
|
|
108
|
-
$pre = $bmp.Clone((New-Object System.Drawing.Rectangle(0, 0, $size, $size)), ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
109
|
-
foreach ($d in 0, -0.02, 0.02, -0.04, 0.04, -0.06, 0.06, -0.08, 0.08) {
|
|
110
|
-
$try = [single]($emU * $k * (1 + $d))
|
|
111
|
-
$rows = InkRows $pre $text $try ([single]($size * 0.1)) ([single]($spaceTop))
|
|
112
|
-
if ((($spaceBottom - $spaceTop + 1) - ($rows[1] - $rows[0] + 1)) % 2 -eq 0) { $em = $try; break }
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
$tp = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
116
|
-
$tp.AddString($text, $family, [int][System.Drawing.FontStyle]::Bold, $em, (New-Object System.Drawing.PointF(0, 0)), $fmt)
|
|
117
|
-
$b = $tp.GetBounds()
|
|
118
|
-
|
|
119
|
-
# 잉크 무게중심: 숫자를 마스크에 그려 평균 x를 잰다 ("1"처럼 한쪽에 꺾임이 있으면 상자 중심과 다르다)
|
|
120
|
-
$mk = [Math]::Max(1.0, 96.0 / [Math]::Max(1.0, $b.Height))
|
|
121
|
-
$mw = [int][Math]::Ceiling($b.Width * $mk) + 4; $mh = [int][Math]::Ceiling($b.Height * $mk) + 4
|
|
122
|
-
$mask = New-Object System.Drawing.Bitmap $mw, $mh, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
|
123
|
-
$mg = [System.Drawing.Graphics]::FromImage($mask); $mg.SmoothingMode = 'AntiAlias'
|
|
124
|
-
$mg.ScaleTransform([single]$mk, [single]$mk); $mg.TranslateTransform([single](2 / $mk - $b.X), [single](2 / $mk - $b.Y))
|
|
125
|
-
$mg.FillPath([System.Drawing.Brushes]::White, $tp); $mg.Dispose()
|
|
126
|
-
$data = $mask.LockBits((New-Object System.Drawing.Rectangle(0, 0, $mw, $mh)), 'ReadOnly', ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
127
|
-
$bytes = New-Object byte[] ($data.Stride * $mh)
|
|
128
|
-
[System.Runtime.InteropServices.Marshal]::Copy($data.Scan0, $bytes, 0, $bytes.Length)
|
|
129
|
-
$stride = $data.Stride; $mask.UnlockBits($data); $mask.Dispose()
|
|
130
|
-
$sum = 0.0; $wsum = 0.0
|
|
131
|
-
for ($yy = 0; $yy -lt $mh; $yy++) { $rowStart = $yy * $stride; for ($xx = 0; $xx -lt $mw; $xx++) { $al = $bytes[$rowStart + $xx * 4 + 3]; if ($al) { $sum += $al * $xx; $wsum += $al } } }
|
|
132
|
-
$centroidX = $b.X + (($sum / [Math]::Max(1.0, $wsum)) + 0.5 - 2) / $mk
|
|
133
|
-
$opticalX = (($b.X + $b.Width / 2) + $centroidX) / 2
|
|
134
|
-
|
|
135
|
-
# 창 본문(막대 아래) 정중앙으로. 작은 크기는 정수 픽셀 위치에 놓는다.
|
|
136
|
-
# 본문: 막대 아래 경계선 다음 줄부터 아래 테두리 바로 위까지
|
|
137
|
-
$cx = $size / 2.0; $cy = ($barH + 1 + $size - $pw) / 2.0
|
|
138
|
-
$dx = $cx - $opticalX; $dy = $cy - ($b.Y + $b.Height / 2)
|
|
139
|
-
if ($small) {
|
|
140
|
-
$dx = SnapPx $dx; $dy = SnapPx $dy
|
|
141
|
-
# 실제로 그려지는 잉크를 재서 위·아래 빈칸이 같아지도록 정수 픽셀만큼 옮긴다
|
|
142
|
-
$rows = InkRows $pre $text $em ([single]$dx) ([single]$dy)
|
|
143
|
-
if ($rows[0] -ge 0) { $dy += [Math]::Floor((($spaceBottom - $rows[1]) - ($rows[0] - $spaceTop)) / 2.0) }
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if ($small) {
|
|
147
|
-
# 작은 크기: 힌팅(글자를 픽셀 격자에 맞춤)을 켠 글자 그리기로 줄기를 또렷하게
|
|
148
|
-
$g.TextRenderingHint = 'AntiAliasGridFit'
|
|
149
|
-
$font = New-Object System.Drawing.Font($family, $em, ([System.Drawing.FontStyle]::Bold), ([System.Drawing.GraphicsUnit]::Pixel))
|
|
150
|
-
$g.DrawString($text, $font, [System.Drawing.Brushes]::White, (New-Object System.Drawing.PointF([single]$dx, [single]$dy)), $fmt)
|
|
151
|
-
} else {
|
|
152
|
-
$t = New-Object System.Drawing.Drawing2D.Matrix
|
|
153
|
-
$t.Translate([single]$dx, [single]$dy)
|
|
154
|
-
$tp.Transform($t)
|
|
155
|
-
$g.FillPath([System.Drawing.Brushes]::White, $tp)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
$g.Dispose()
|
|
159
|
-
$bmp.Save((Join-Path $OutDir "$size.png"), [System.Drawing.Imaging.ImageFormat]::Png)
|
|
160
|
-
# 작은 크기용 BMP(DIB) 항목을 만들 수 있게 픽셀 원본(BGRA, 위에서 아래로)도 저장
|
|
161
|
-
$bd = $bmp.LockBits((New-Object System.Drawing.Rectangle(0, 0, $size, $size)), 'ReadOnly', ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
162
|
-
$raw = New-Object byte[] ($size * $size * 4)
|
|
163
|
-
for ($ry = 0; $ry -lt $size; $ry++) { [System.Runtime.InteropServices.Marshal]::Copy([IntPtr]($bd.Scan0.ToInt64() + $ry * $bd.Stride), $raw, $ry * $size * 4, $size * 4) }
|
|
164
|
-
$bmp.UnlockBits($bd)
|
|
165
|
-
[System.IO.File]::WriteAllBytes((Join-Path $OutDir "$size.raw"), $raw)
|
|
166
|
-
$bmp.Dispose()
|
|
167
|
-
}
|
|
10
|
+
const SCRIPT = String.raw `
|
|
11
|
+
param([string]$OutDir, [int]$Slot, [string]$Hex, [string]$Sizes)
|
|
12
|
+
# 오류가 나면 바로 멈춰 실패로 알린다 (조용히 넘어가 망가진 아이콘이 저장되지 않게)
|
|
13
|
+
$ErrorActionPreference = 'Stop'
|
|
14
|
+
Add-Type -AssemblyName System.Drawing
|
|
15
|
+
$base = [System.Drawing.ColorTranslator]::FromHtml($Hex)
|
|
16
|
+
function C([int]$a) { [System.Drawing.Color]::FromArgb($a, $base.R, $base.G, $base.B) }
|
|
17
|
+
function W([int]$a) { [System.Drawing.Color]::FromArgb($a, 255, 255, 255) }
|
|
18
|
+
# 주의: PowerShell에는 'r' 별칭(Invoke-History)이 있어 함수 이름으로 R을 쓰면 별칭이 먼저 불린다
|
|
19
|
+
function SnapPx([double]$v) { [double][Math]::Round($v) }
|
|
20
|
+
function RoundRect([double]$x, [double]$y, [double]$w, [double]$h, [double]$r) {
|
|
21
|
+
$p = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
22
|
+
$d = [single]($r * 2)
|
|
23
|
+
$p.AddArc([single]$x, [single]$y, $d, $d, 180, 90); $p.AddArc([single]($x + $w - 2 * $r), [single]$y, $d, $d, 270, 90)
|
|
24
|
+
$p.AddArc([single]($x + $w - 2 * $r), [single]($y + $h - 2 * $r), $d, $d, 0, 90); $p.AddArc([single]$x, [single]($y + $h - 2 * $r), $d, $d, 90, 90)
|
|
25
|
+
$p.CloseFigure(); return $p
|
|
26
|
+
}
|
|
27
|
+
# 실제 아이콘(숫자 그리기 직전 상태 $pre)의 복사본에 숫자를 그려, 잉크가 있는 줄(배경보다 50% 이상 밝아진 줄)의 위·아래를 잰다.
|
|
28
|
+
# (따로 투명한 판에 그리면 글자 가장자리가 실제와 다르게 나와서, 실제와 똑같이 그려 본다)
|
|
29
|
+
function InkRows($pre, [string]$str, [single]$em, [single]$x, [single]$y) {
|
|
30
|
+
$w = $pre.Width; $h = $pre.Height
|
|
31
|
+
$rect = New-Object System.Drawing.Rectangle(0, 0, $w, $h)
|
|
32
|
+
$lb = $pre.Clone($rect, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
33
|
+
$lg = [System.Drawing.Graphics]::FromImage($lb)
|
|
34
|
+
$lg.SmoothingMode = 'AntiAlias'; $lg.PixelOffsetMode = 'Half'; $lg.CompositingQuality = 'HighQuality'; $lg.TextRenderingHint = 'AntiAliasGridFit'
|
|
35
|
+
$lf = New-Object System.Drawing.Font($family, $em, ([System.Drawing.FontStyle]::Bold), ([System.Drawing.GraphicsUnit]::Pixel))
|
|
36
|
+
$lg.DrawString($str, $lf, [System.Drawing.Brushes]::White, (New-Object System.Drawing.PointF($x, $y)), $fmt); $lg.Dispose()
|
|
37
|
+
$fmtA = [System.Drawing.Imaging.PixelFormat]::Format32bppArgb
|
|
38
|
+
$d1 = $pre.LockBits($rect, 'ReadOnly', $fmtA); $d2 = $lb.LockBits($rect, 'ReadOnly', $fmtA)
|
|
39
|
+
$b1 = New-Object byte[] ($d1.Stride * $h); $b2 = New-Object byte[] ($d2.Stride * $h)
|
|
40
|
+
[System.Runtime.InteropServices.Marshal]::Copy($d1.Scan0, $b1, 0, $b1.Length); [System.Runtime.InteropServices.Marshal]::Copy($d2.Scan0, $b2, 0, $b2.Length)
|
|
41
|
+
$ls = $d1.Stride; $pre.UnlockBits($d1); $lb.UnlockBits($d2); $lb.Dispose()
|
|
42
|
+
$first = -1; $last = -1
|
|
43
|
+
for ($yy = 0; $yy -lt $h; $yy++) {
|
|
44
|
+
for ($xx = 0; $xx -lt $w; $xx++) {
|
|
45
|
+
$o = $yy * $ls + $xx * 4
|
|
46
|
+
$s1 = [int]$b1[$o] + $b1[$o + 1] + $b1[$o + 2]; $s2 = [int]$b2[$o] + $b2[$o + 1] + $b2[$o + 2]
|
|
47
|
+
if ($s1 -lt 765 -and ($s2 - $s1) -ge (765 - $s1) / 2.0) { if ($first -lt 0) { $first = $yy }; $last = $yy; break }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return @($first, $last)
|
|
51
|
+
}
|
|
52
|
+
$text = [string]$Slot
|
|
53
|
+
$family = $null
|
|
54
|
+
foreach ($name in @('Segoe UI Variable Display', 'Segoe UI', 'Arial')) {
|
|
55
|
+
try { $family = New-Object System.Drawing.FontFamily($name); break } catch {}
|
|
56
|
+
}
|
|
57
|
+
$fmt = [System.Drawing.StringFormat]::GenericTypographic
|
|
58
|
+
|
|
59
|
+
foreach ($s in ($Sizes -split ',')) {
|
|
60
|
+
$size = [int]$s
|
|
61
|
+
$k = $size / 64.0
|
|
62
|
+
$small = $size -le 48
|
|
63
|
+
$bmp = New-Object System.Drawing.Bitmap $size, $size, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
|
64
|
+
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
|
65
|
+
$g.SmoothingMode = 'AntiAlias'; $g.PixelOffsetMode = 'Half'; $g.CompositingQuality = 'HighQuality'
|
|
66
|
+
$g.Clear([System.Drawing.Color]::Transparent)
|
|
67
|
+
|
|
68
|
+
# 창 모양: 칸을 꽉 채운다. 경계가 정수 픽셀에 오도록 (0,0)~(size,size)
|
|
69
|
+
$radius = [Math]::Max(2.0, (SnapPx (11 * $k)))
|
|
70
|
+
$win = RoundRect 0 0 $size $size $radius
|
|
71
|
+
$grad = New-Object System.Drawing.Drawing2D.LinearGradientBrush((New-Object System.Drawing.PointF(0, -1)), (New-Object System.Drawing.PointF(0, ($size + 1))), (C 255), (C 205))
|
|
72
|
+
$grad.WrapMode = 'TileFlipXY'
|
|
73
|
+
$g.FillPath($grad, $win)
|
|
74
|
+
|
|
75
|
+
# 위 막대 (높이 16/64, 정수 픽셀): 몸통보다 진하게 + 아래 경계 1px 밝은 선
|
|
76
|
+
$barH = [Math]::Max(3.0, (SnapPx (16 * $k)))
|
|
77
|
+
$g.SetClip($win)
|
|
78
|
+
$g.SmoothingMode = 'None'
|
|
79
|
+
$g.FillRectangle((New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(85, 0, 0, 0))), [single]0, [single]0, [single]$size, [single]$barH)
|
|
80
|
+
$g.FillRectangle((New-Object System.Drawing.SolidBrush((W 70))), [single]0, [single]$barH, [single]$size, [single]1)
|
|
81
|
+
|
|
82
|
+
$g.ResetClip()
|
|
83
|
+
$g.SmoothingMode = 'AntiAlias'
|
|
84
|
+
|
|
85
|
+
# 점 3개: 지름·간격·위치를 정수 픽셀로 (작은 크기에서도 또렷하게 떨어져 보이게)
|
|
86
|
+
$dotD = [Math]::Max(2.0, (SnapPx (6.4 * $k)))
|
|
87
|
+
$gap = [Math]::Max(1.0, (SnapPx (2.6 * $k)))
|
|
88
|
+
$dotY = [Math]::Floor(($barH - $dotD) / 2)
|
|
89
|
+
$dotX = [Math]::Max(1.0, (SnapPx (6.5 * $k)))
|
|
90
|
+
$dot = New-Object System.Drawing.SolidBrush((W 245))
|
|
91
|
+
foreach ($i in 0, 1, 2) { $g.FillEllipse($dot, [single]($dotX + $i * ($dotD + $gap)), [single]$dotY, [single]$dotD, [single]$dotD) }
|
|
92
|
+
|
|
93
|
+
# 흰 테두리: 작은 크기는 정확히 1px 안쪽 선, 큰 크기는 비례 두께
|
|
94
|
+
$pw = if ($small) { 1.0 } else { [Math]::Max(1.0, $k) }
|
|
95
|
+
$border = RoundRect ($pw / 2) ($pw / 2) ($size - $pw) ($size - $pw) ([Math]::Max(1.0, $radius - $pw / 2))
|
|
96
|
+
$g.DrawPath((New-Object System.Drawing.Pen((W 128), [single]$pw)), $border)
|
|
97
|
+
|
|
98
|
+
# 숫자 크기: 한 자리든 두 자리든 같은 크기 (64칸 기준 33, 작업표시줄 크기에서는 조금 키움)
|
|
99
|
+
$emU = 33
|
|
100
|
+
if ($size -le 32) { $emU = $emU * 1.12 }
|
|
101
|
+
$em = [single]($emU * $k)
|
|
102
|
+
# 작은 크기: 숫자 위·아래 빈칸을 정확히 같게 하려면 (본문 높이 - 숫자 높이)가 짝수여야 한다.
|
|
103
|
+
# 숫자 높이가 맞지 않으면 글자 크기를 가장 적게(2% 단위, 최대 ±8%) 바꿔 맞춘다.
|
|
104
|
+
# (둥근 숫자 0·8 등은 평평한 1·4·7보다 1px 더 튀어나와서, 높이는 그 슬롯의 번호로 잰다)
|
|
105
|
+
$spaceTop = $barH + 1; $spaceBottom = $size - 2
|
|
106
|
+
if ($small) {
|
|
107
|
+
$g.Flush()
|
|
108
|
+
$pre = $bmp.Clone((New-Object System.Drawing.Rectangle(0, 0, $size, $size)), ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
109
|
+
foreach ($d in 0, -0.02, 0.02, -0.04, 0.04, -0.06, 0.06, -0.08, 0.08) {
|
|
110
|
+
$try = [single]($emU * $k * (1 + $d))
|
|
111
|
+
$rows = InkRows $pre $text $try ([single]($size * 0.1)) ([single]($spaceTop))
|
|
112
|
+
if ((($spaceBottom - $spaceTop + 1) - ($rows[1] - $rows[0] + 1)) % 2 -eq 0) { $em = $try; break }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
$tp = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
116
|
+
$tp.AddString($text, $family, [int][System.Drawing.FontStyle]::Bold, $em, (New-Object System.Drawing.PointF(0, 0)), $fmt)
|
|
117
|
+
$b = $tp.GetBounds()
|
|
118
|
+
|
|
119
|
+
# 잉크 무게중심: 숫자를 마스크에 그려 평균 x를 잰다 ("1"처럼 한쪽에 꺾임이 있으면 상자 중심과 다르다)
|
|
120
|
+
$mk = [Math]::Max(1.0, 96.0 / [Math]::Max(1.0, $b.Height))
|
|
121
|
+
$mw = [int][Math]::Ceiling($b.Width * $mk) + 4; $mh = [int][Math]::Ceiling($b.Height * $mk) + 4
|
|
122
|
+
$mask = New-Object System.Drawing.Bitmap $mw, $mh, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
|
123
|
+
$mg = [System.Drawing.Graphics]::FromImage($mask); $mg.SmoothingMode = 'AntiAlias'
|
|
124
|
+
$mg.ScaleTransform([single]$mk, [single]$mk); $mg.TranslateTransform([single](2 / $mk - $b.X), [single](2 / $mk - $b.Y))
|
|
125
|
+
$mg.FillPath([System.Drawing.Brushes]::White, $tp); $mg.Dispose()
|
|
126
|
+
$data = $mask.LockBits((New-Object System.Drawing.Rectangle(0, 0, $mw, $mh)), 'ReadOnly', ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
127
|
+
$bytes = New-Object byte[] ($data.Stride * $mh)
|
|
128
|
+
[System.Runtime.InteropServices.Marshal]::Copy($data.Scan0, $bytes, 0, $bytes.Length)
|
|
129
|
+
$stride = $data.Stride; $mask.UnlockBits($data); $mask.Dispose()
|
|
130
|
+
$sum = 0.0; $wsum = 0.0
|
|
131
|
+
for ($yy = 0; $yy -lt $mh; $yy++) { $rowStart = $yy * $stride; for ($xx = 0; $xx -lt $mw; $xx++) { $al = $bytes[$rowStart + $xx * 4 + 3]; if ($al) { $sum += $al * $xx; $wsum += $al } } }
|
|
132
|
+
$centroidX = $b.X + (($sum / [Math]::Max(1.0, $wsum)) + 0.5 - 2) / $mk
|
|
133
|
+
$opticalX = (($b.X + $b.Width / 2) + $centroidX) / 2
|
|
134
|
+
|
|
135
|
+
# 창 본문(막대 아래) 정중앙으로. 작은 크기는 정수 픽셀 위치에 놓는다.
|
|
136
|
+
# 본문: 막대 아래 경계선 다음 줄부터 아래 테두리 바로 위까지
|
|
137
|
+
$cx = $size / 2.0; $cy = ($barH + 1 + $size - $pw) / 2.0
|
|
138
|
+
$dx = $cx - $opticalX; $dy = $cy - ($b.Y + $b.Height / 2)
|
|
139
|
+
if ($small) {
|
|
140
|
+
$dx = SnapPx $dx; $dy = SnapPx $dy
|
|
141
|
+
# 실제로 그려지는 잉크를 재서 위·아래 빈칸이 같아지도록 정수 픽셀만큼 옮긴다
|
|
142
|
+
$rows = InkRows $pre $text $em ([single]$dx) ([single]$dy)
|
|
143
|
+
if ($rows[0] -ge 0) { $dy += [Math]::Floor((($spaceBottom - $rows[1]) - ($rows[0] - $spaceTop)) / 2.0) }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if ($small) {
|
|
147
|
+
# 작은 크기: 힌팅(글자를 픽셀 격자에 맞춤)을 켠 글자 그리기로 줄기를 또렷하게
|
|
148
|
+
$g.TextRenderingHint = 'AntiAliasGridFit'
|
|
149
|
+
$font = New-Object System.Drawing.Font($family, $em, ([System.Drawing.FontStyle]::Bold), ([System.Drawing.GraphicsUnit]::Pixel))
|
|
150
|
+
$g.DrawString($text, $font, [System.Drawing.Brushes]::White, (New-Object System.Drawing.PointF([single]$dx, [single]$dy)), $fmt)
|
|
151
|
+
} else {
|
|
152
|
+
$t = New-Object System.Drawing.Drawing2D.Matrix
|
|
153
|
+
$t.Translate([single]$dx, [single]$dy)
|
|
154
|
+
$tp.Transform($t)
|
|
155
|
+
$g.FillPath([System.Drawing.Brushes]::White, $tp)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
$g.Dispose()
|
|
159
|
+
$bmp.Save((Join-Path $OutDir "$size.png"), [System.Drawing.Imaging.ImageFormat]::Png)
|
|
160
|
+
# 작은 크기용 BMP(DIB) 항목을 만들 수 있게 픽셀 원본(BGRA, 위에서 아래로)도 저장
|
|
161
|
+
$bd = $bmp.LockBits((New-Object System.Drawing.Rectangle(0, 0, $size, $size)), 'ReadOnly', ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb))
|
|
162
|
+
$raw = New-Object byte[] ($size * $size * 4)
|
|
163
|
+
for ($ry = 0; $ry -lt $size; $ry++) { [System.Runtime.InteropServices.Marshal]::Copy([IntPtr]($bd.Scan0.ToInt64() + $ry * $bd.Stride), $raw, $ry * $size * 4, $size * 4) }
|
|
164
|
+
$bmp.UnlockBits($bd)
|
|
165
|
+
[System.IO.File]::WriteAllBytes((Join-Path $OutDir "$size.raw"), $raw)
|
|
166
|
+
$bmp.Dispose()
|
|
167
|
+
}
|
|
168
168
|
`;
|
|
169
169
|
/** 크기별 PNG와 픽셀 원본. 실패하면 undefined (그때는 기본 그리기로 대체). */
|
|
170
170
|
export function renderPngsWithGdi(slot, color, sizes) {
|
package/dist/taskbar/watcher.js
CHANGED
|
@@ -14,6 +14,10 @@ const INTERVAL_MS = 2000;
|
|
|
14
14
|
export const appIdOf = (slot) => `cdpm.slot.${slot}.v${ICON_VERSION}`;
|
|
15
15
|
/** 창마다 이 프로세스가 지정한 아이콘 경로 */
|
|
16
16
|
const appliedIcon = new Map();
|
|
17
|
+
/** 작업표시줄 아이콘을 붙일 수 있는지 (Windows이고 koffi가 있고 Chrome 번호를 앎). 아니면 창을 기다릴 이유가 없다. */
|
|
18
|
+
export function canApplyTaskbar(pid) {
|
|
19
|
+
return !!pid && !!win32();
|
|
20
|
+
}
|
|
17
21
|
/** 한 슬롯의 창들에 적용. 이미 같은 ID면 속성은 건너뛰고 창 아이콘만 다시 지정한다. */
|
|
18
22
|
export function applyTaskbar(slot, pid) {
|
|
19
23
|
const w = win32();
|