dsh-snowbreak-heimdall 3.0.0

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.
Files changed (68) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +175 -0
  3. package/SHA256SUMS.txt +61 -0
  4. package/TEST-REPORT.md +96 -0
  5. package/assets/icons/app-512.png +0 -0
  6. package/assets/icons/app-light-512.png +0 -0
  7. package/assets/icons/app.ico +0 -0
  8. package/assets/icons/apple-touch-icon.png +0 -0
  9. package/assets/icons/favicon-dark.svg +5 -0
  10. package/assets/icons/favicon.svg +5 -0
  11. package/assets/icons/icon-192.png +0 -0
  12. package/assets/icons/icon-512.png +0 -0
  13. package/assets/icons/icon-maskable-512.png +0 -0
  14. package/assets/icons/icon.svg +5 -0
  15. package/assets/icons/res-icon.png +0 -0
  16. package/assets/icons/tray.ico +0 -0
  17. package/assets/previews/assets/hm-mark-blue.png +0 -0
  18. package/assets/previews/brand-fix.png +0 -0
  19. package/assets/previews/exe-icon-test.png +0 -0
  20. package/assets/previews/loading-dark.html +443 -0
  21. package/assets/previews/loading-dark.png +0 -0
  22. package/assets/previews/loading-fallback.html +443 -0
  23. package/assets/previews/loading-fallback.png +0 -0
  24. package/assets/previews/loading-handoff.html +457 -0
  25. package/assets/previews/loading-light.html +443 -0
  26. package/assets/previews/loading-light.png +0 -0
  27. package/assets/previews/mask-test.png +0 -0
  28. package/assets/previews/progress-winforms-complete.png +0 -0
  29. package/assets/previews/progress-winforms.png +0 -0
  30. package/assets/previews/ui-chrome.html +24 -0
  31. package/assets/previews/ui-chrome.png +0 -0
  32. package/assets/source/brand-client.js +95 -0
  33. package/assets/source/client-template.js +217 -0
  34. package/assets/source/hm-mark-blue.png +0 -0
  35. package/assets/source/hm-mark-ink.png +0 -0
  36. package/assets/source/hm-mark-light.png +0 -0
  37. package/assets/source/loading.css +373 -0
  38. package/assets/source/loading.html +58 -0
  39. package/assets/source/logo.webp +0 -0
  40. package/assets/source/mark-alpha.png +0 -0
  41. package/assets/source/mark-color.png +0 -0
  42. package/assets/source/progress.ps1 +312 -0
  43. package/assets/source/shell.css +475 -0
  44. package/assets/source/shell.js +293 -0
  45. package/assets/source/update.css +47 -0
  46. package/assets/source/watermark-soft.png +0 -0
  47. package/assets/source/welcome-brand.svg +18 -0
  48. package/assets/source/welcome-mark-ink.png +0 -0
  49. package/assets/source/welcome-mark-light.png +0 -0
  50. package/assets/source/welcome.css +121 -0
  51. package/cordis.patch.yml +4 -0
  52. package/icon.svg +5 -0
  53. package/lib/client.js +217 -0
  54. package/lib/index.js +239 -0
  55. package/locale/en.json +6 -0
  56. package/locale/zh.json +6 -0
  57. package/package.json +47 -0
  58. package/patch/asar.py +237 -0
  59. package/patch/patcher.py +1307 -0
  60. package/tools/build_assets.py +206 -0
  61. package/tools/build_client.py +21 -0
  62. package/tools/test_lock.py +28 -0
  63. package/tools/test_progress_launch.py +44 -0
  64. package/tools/test_progress_ps1.py +38 -0
  65. package/tools/test_progress_ps1_complete.py +38 -0
  66. package/vendor/rcedit/LICENSE +20 -0
  67. package/vendor/rcedit/README.md +51 -0
  68. package/vendor/rcedit/rcedit-x64.exe +0 -0
@@ -0,0 +1,312 @@
1
+ param()
2
+
3
+ $ErrorActionPreference = 'Stop'
4
+ $ProgressPath = '__PROGRESS_PATH__'
5
+ $LogoPath = '__LOGO_PATH__'
6
+ $AppExe = '__APP_EXE__'
7
+ $LogPath = Join-Path (Split-Path -Parent $ProgressPath) 'ui.log'
8
+
9
+ function Write-UiLog($text) {
10
+ try { Add-Content -LiteralPath $LogPath -Value ("[" + (Get-Date -Format 'HH:mm:ss') + "] " + $text) -Encoding UTF8 } catch {}
11
+ }
12
+
13
+ try {
14
+ Add-Type -TypeDefinition @"
15
+ using System;
16
+ using System.Runtime.InteropServices;
17
+ public class HeimdallDpi {
18
+ [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
19
+ [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
20
+ [DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
21
+ }
22
+ "@
23
+ [HeimdallDpi]::SetProcessDPIAware() | Out-Null
24
+ Add-Type -AssemblyName PresentationFramework, PresentationCore, WindowsBase
25
+
26
+ $xaml = @'
27
+ <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
28
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
29
+ Title="海姆达尔终端 · 源码层覆盖"
30
+ Width="760" Height="520"
31
+ WindowStyle="None" ResizeMode="NoResize"
32
+ WindowStartupLocation="CenterScreen"
33
+ Topmost="True" ShowInTaskbar="True"
34
+ Background="#05080C" Foreground="#E6EEF5"
35
+ FontFamily="Microsoft YaHei UI" UseLayoutRounding="True" SnapsToDevicePixels="True">
36
+ <Grid>
37
+ <Grid.RowDefinitions>
38
+ <RowDefinition Height="Auto"/>
39
+ <RowDefinition Height="Auto"/>
40
+ <RowDefinition Height="Auto"/>
41
+ <RowDefinition Height="*"/>
42
+ <RowDefinition Height="Auto"/>
43
+ </Grid.RowDefinitions>
44
+
45
+ <Image x:Name="Watermark" Grid.RowSpan="5" Width="340" Height="212" HorizontalAlignment="Right" VerticalAlignment="Bottom"
46
+ Opacity="0.07" Margin="0,0,18,18" Stretch="Uniform" IsHitTestVisible="False"/>
47
+
48
+ <Grid Grid.Row="0" Margin="30,24,30,0">
49
+ <Grid.ColumnDefinitions>
50
+ <ColumnDefinition Width="68"/>
51
+ <ColumnDefinition Width="*"/>
52
+ <ColumnDefinition Width="150"/>
53
+ </Grid.ColumnDefinitions>
54
+ <Image x:Name="Logo" Width="56" Height="36" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform"/>
55
+ <StackPanel Grid.Column="1" Margin="12,0,0,0">
56
+ <TextBlock x:Name="Org" Text="YGGDRASIL CORPORATION // HEIMDALL FORCE" FontSize="10" Foreground="#7FB2D0"/>
57
+ <TextBlock x:Name="HeroTitle" Text="海姆达尔终端" FontSize="30" FontWeight="Bold" Foreground="#E6EEF5" Margin="0,2,0,0"/>
58
+ <TextBlock x:Name="Mode" Text="SOURCE LAYER // 源码层覆盖" FontSize="11" Foreground="#7E8E9E" Margin="0,2,0,0"/>
59
+ </StackPanel>
60
+ <StackPanel Grid.Column="2" HorizontalAlignment="Right">
61
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
62
+ <TextBlock x:Name="Pct" Text="0" FontSize="52" FontWeight="Light" Foreground="#E6EEF5"/>
63
+ <TextBlock Text="%" FontSize="16" Foreground="#7FB2D0" VerticalAlignment="Top" Margin="2,8,0,0"/>
64
+ </StackPanel>
65
+ <TextBlock Text="LINK INTEGRITY" FontSize="9" Foreground="#7E8E9E" HorizontalAlignment="Right" Margin="0,2,0,0"/>
66
+ </StackPanel>
67
+ </Grid>
68
+
69
+ <Grid x:Name="Rail" Grid.Row="1" Margin="30,18,30,0" Height="2">
70
+ <Rectangle Fill="#263440"/>
71
+ <Rectangle x:Name="Bar" Fill="#D97745" HorizontalAlignment="Left" Width="0"/>
72
+ </Grid>
73
+
74
+ <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="30,14,30,0">
75
+ <Rectangle x:Name="Dot" Width="6" Height="6" Fill="#D97745" Margin="0,6,10,0"/>
76
+ <TextBlock x:Name="Stage" Text="WAIT" Width="90" FontSize="10" Foreground="#D97745"/>
77
+ <TextBlock x:Name="Status" Text="正在等待 DSH 完全退出…" FontSize="14" Foreground="#B7C4CF" TextTrimming="CharacterEllipsis"/>
78
+ </StackPanel>
79
+
80
+ <StackPanel x:Name="Steps" Grid.Row="3" Margin="30,18,30,0"/>
81
+
82
+ <Grid Grid.Row="4" Margin="30,0,30,18">
83
+ <TextBlock Text="HM-04 // ANALYST-04" FontSize="9" Foreground="#7E8E9E" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
84
+ <TextBlock x:Name="Note" Text="请勿关闭此窗口" FontSize="9" Foreground="#7FB2D0" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
85
+ </Grid>
86
+
87
+ <Grid x:Name="Complete" Grid.RowSpan="5" Background="#05080C" Visibility="Collapsed">
88
+ <Image x:Name="CompleteWatermark" Width="340" Height="212" HorizontalAlignment="Right" VerticalAlignment="Bottom"
89
+ Opacity="0.06" Margin="0,0,18,18" Stretch="Uniform" IsHitTestVisible="False"/>
90
+ <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
91
+ <Border Width="130" Height="130" CornerRadius="65" BorderBrush="#7FB2D0" BorderThickness="1" Background="#05080C" HorizontalAlignment="Center">
92
+ <Image x:Name="CompleteLogo" Width="64" Height="40" Stretch="Uniform"/>
93
+ </Border>
94
+ <TextBlock Text="LINK CLOSED // 覆盖完成" FontSize="10" Foreground="#7FB2D0" HorizontalAlignment="Center" Margin="0,18,0,0"/>
95
+ <TextBlock Text="接入链路已闭合" FontSize="34" FontWeight="Bold" Foreground="#E6EEF5" HorizontalAlignment="Center" Margin="0,8,0,0"/>
96
+ <TextBlock Text="HM-04 · ANALYST-04 · CLEARANCE A · ZERO ZONE" FontSize="10" Foreground="#7E8E9E" HorizontalAlignment="Center" Margin="0,8,0,0"/>
97
+ <Button x:Name="Launch" Width="300" Height="58" Margin="0,26,0,0" HorizontalAlignment="Center"
98
+ Background="#D97745" Foreground="#0A0F14" BorderThickness="0" Cursor="Hand">
99
+ <StackPanel>
100
+ <TextBlock Text="启动终端" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center"/>
101
+ <TextBlock Text="LAUNCH DSH" FontSize="9" HorizontalAlignment="Center" Margin="0,2,0,0"/>
102
+ </StackPanel>
103
+ </Button>
104
+ <TextBlock Text="点击后启动 DeepSeek Harness,当前窗口会自动关闭" FontSize="9" Foreground="#7E8E9E" HorizontalAlignment="Center" Margin="0,12,0,0"/>
105
+ </StackPanel>
106
+ </Grid>
107
+
108
+ <Grid x:Name="Failure" Grid.RowSpan="5" Background="#05080C" Visibility="Collapsed">
109
+ <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="640">
110
+ <TextBlock Text="接入链路中断" FontSize="28" FontWeight="Bold" Foreground="#E39797" HorizontalAlignment="Center"/>
111
+ <TextBlock x:Name="ErrorText" Text="" FontSize="14" Foreground="#B7C4CF" TextWrapping="Wrap" TextAlignment="Center" Margin="0,18,0,0"/>
112
+ <Button x:Name="CloseError" Width="120" Height="38" Margin="0,24,0,0" HorizontalAlignment="Center"
113
+ Background="#141C24" Foreground="#E6EEF5" BorderBrush="#263440" BorderThickness="1" Content="关闭"/>
114
+ </StackPanel>
115
+ </Grid>
116
+
117
+ <Border Grid.RowSpan="5" BorderBrush="#263440" BorderThickness="1" Margin="7" IsHitTestVisible="False"/>
118
+ </Grid>
119
+ </Window>
120
+ '@
121
+
122
+ $window = [Windows.Markup.XamlReader]::Parse($xaml)
123
+ $window.Add_SourceInitialized({
124
+ $helper = New-Object Windows.Interop.WindowInteropHelper($window)
125
+ $handle = $helper.Handle
126
+ $style = [HeimdallDpi]::GetWindowLong($handle, -16)
127
+ $style = ($style -band (-bnot 0x00C00000)) -band (-bnot 0x00040000)
128
+ $style = $style -bor 0x80000000
129
+ [void][HeimdallDpi]::SetWindowLong($handle, -16, $style)
130
+ })
131
+
132
+ $logo = $window.FindName('Logo')
133
+ $completeLogo = $window.FindName('CompleteLogo')
134
+ $bmp = New-Object Windows.Media.Imaging.BitmapImage
135
+ $bmp.BeginInit()
136
+ $bmp.CacheOption = [Windows.Media.Imaging.BitmapCacheOption]::OnLoad
137
+ $bmp.UriSource = New-Object Uri($LogoPath)
138
+ $bmp.EndInit()
139
+ $logo.Source = $bmp
140
+ $completeLogo.Source = $bmp
141
+ $watermark = $window.FindName('Watermark')
142
+ $completeWatermark = $window.FindName('CompleteWatermark')
143
+ $watermark.Source = $bmp
144
+ $completeWatermark.Source = $bmp
145
+
146
+ $pctText = $window.FindName('Pct')
147
+ $bar = $window.FindName('Bar')
148
+ $rail = $window.FindName('Rail')
149
+ $stageText = $window.FindName('Stage')
150
+ $statusText = $window.FindName('Status')
151
+ $noteText = $window.FindName('Note')
152
+ $dot = $window.FindName('Dot')
153
+ $complete = $window.FindName('Complete')
154
+ $failure = $window.FindName('Failure')
155
+ $errorText = $window.FindName('ErrorText')
156
+ $launch = $window.FindName('Launch')
157
+ $closeError = $window.FindName('CloseError')
158
+
159
+ $stepNames = @('等待主进程退出', '备份官方归档与图标', '重打包源码层', '逐条目哈希校验', '写入图标并闭合链路')
160
+ $stepCodes = @('WAIT', 'BACKUP', 'PACK', 'VERIFY', 'WRITE')
161
+ $stepRows = @()
162
+ $steps = $window.FindName('Steps')
163
+ for ($i = 0; $i -lt 5; $i++) {
164
+ $row = New-Object Windows.Controls.Grid
165
+ $row.Height = 34
166
+ foreach ($w in @(40, 540, 90)) {
167
+ $col = New-Object Windows.Controls.ColumnDefinition
168
+ $col.Width = New-Object Windows.GridLength($w)
169
+ $row.ColumnDefinitions.Add($col)
170
+ }
171
+ $line = New-Object Windows.Shapes.Rectangle
172
+ $line.Height = 1
173
+ $line.Fill = New-Object Windows.Media.SolidColorBrush([Windows.Media.Color]::FromRgb(24, 35, 45))
174
+ $line.VerticalAlignment = 'Top'
175
+ [Windows.Controls.Grid]::SetColumnSpan($line, 3)
176
+ $row.Children.Add($line) | Out-Null
177
+
178
+ $num = New-Object Windows.Controls.TextBlock
179
+ $num.Text = '0' + ($i + 1)
180
+ $num.FontSize = 9
181
+ $num.Foreground = New-Object Windows.Media.SolidColorBrush([Windows.Media.Color]::FromRgb(126, 142, 158))
182
+ $num.Margin = New-Object Windows.Thickness(4, 9, 0, 0)
183
+ [Windows.Controls.Grid]::SetColumn($num, 0)
184
+ $row.Children.Add($num) | Out-Null
185
+
186
+ $title = New-Object Windows.Controls.TextBlock
187
+ $title.Text = $stepNames[$i]
188
+ $title.FontSize = 13
189
+ $title.Foreground = New-Object Windows.Media.SolidColorBrush([Windows.Media.Color]::FromRgb(126, 142, 158))
190
+ $title.Margin = New-Object Windows.Thickness(6, 7, 0, 0)
191
+ [Windows.Controls.Grid]::SetColumn($title, 1)
192
+ $row.Children.Add($title) | Out-Null
193
+
194
+ $code = New-Object Windows.Controls.TextBlock
195
+ $code.Text = $stepCodes[$i]
196
+ $code.FontSize = 9
197
+ $code.HorizontalAlignment = 'Right'
198
+ $code.Foreground = New-Object Windows.Media.SolidColorBrush([Windows.Media.Color]::FromRgb(126, 142, 158))
199
+ $code.Margin = New-Object Windows.Thickness(0, 9, 4, 0)
200
+ [Windows.Controls.Grid]::SetColumn($code, 2)
201
+ $row.Children.Add($code) | Out-Null
202
+
203
+ $steps.Children.Add($row) | Out-Null
204
+ $stepRows += [pscustomobject]@{ Title = $title; Code = $code }
205
+ }
206
+
207
+ $script:lastPct = 0
208
+ $timer = New-Object Windows.Threading.DispatcherTimer
209
+ $timer.Interval = [TimeSpan]::FromMilliseconds(350)
210
+ $timer.Add_Tick({
211
+ if (-not (Test-Path -LiteralPath $ProgressPath)) { return }
212
+ try { $raw = Get-Content -LiteralPath $ProgressPath -Encoding Unicode -Raw } catch { return }
213
+ $map = @{}
214
+ foreach ($line in ($raw -split "`r?`n")) {
215
+ $at = $line.IndexOf('=')
216
+ if ($at -gt 0) { $map[$line.Substring(0, $at)] = $line.Substring($at + 1) }
217
+ }
218
+ $pct = 0
219
+ [void][int]::TryParse($map['pct'], [ref]$pct)
220
+ if ($pct -lt 0) { $pct = 0 }
221
+ if ($pct -gt 100) { $pct = 100 }
222
+ if (-not $map['error'] -and $pct -lt $script:lastPct) { $pct = $script:lastPct }
223
+ $script:lastPct = $pct
224
+
225
+ $stage = if ($map['stage']) { $map['stage'] } else { 'WAIT' }
226
+ $status = if ($map['text']) { $map['text'] } else { '' }
227
+ $pctText.Text = [string]$pct
228
+ $bar.Width = [double]($rail.ActualWidth * $pct / 100.0)
229
+ $stageText.Text = $stage
230
+ $statusText.Text = $status
231
+ $order = @('WAIT', 'BACKUP', 'PACK', 'VERIFY', 'WRITE', 'READY')
232
+ $cur = 0
233
+ for ($i = 0; $i -lt $order.Length; $i++) { if ($order[$i] -eq $stage) { $cur = $i } }
234
+ for ($i = 0; $i -lt 5; $i++) {
235
+ $on = $i -le $cur
236
+ $stepRows[$i].Title.Foreground = New-Object Windows.Media.SolidColorBrush(
237
+ [Windows.Media.Color]::FromRgb($(if ($on) { 230 } else { 126 }), $(if ($on) { 238 } else { 142 }), $(if ($on) { 245 } else { 158 })))
238
+ $stepRows[$i].Code.Foreground = New-Object Windows.Media.SolidColorBrush(
239
+ [Windows.Media.Color]::FromRgb($(if ($on) { 127 } else { 126 }), $(if ($on) { 178 } else { 142 }), $(if ($on) { 208 } else { 158 })))
240
+ $stepRows[$i].Title.FontWeight = if ($on) { [Windows.FontWeights]::SemiBold } else { [Windows.FontWeights]::Normal }
241
+ }
242
+
243
+ if ($map['error']) {
244
+ $timer.Stop()
245
+ $errorText.Text = '覆盖失败:' + $map['error']
246
+ $failure.Visibility = 'Visible'
247
+ $failure.BringIntoView()
248
+ return
249
+ }
250
+ if ($map['done'] -eq '1') {
251
+ $timer.Stop()
252
+ $complete.Visibility = 'Visible'
253
+ $complete.BringIntoView()
254
+ $launch.Focus()
255
+ return
256
+ }
257
+ $noteText.Text = '请勿关闭此窗口'
258
+ })
259
+
260
+ $launch.Add_Click({
261
+ try {
262
+ Start-Process -FilePath $AppExe -WorkingDirectory (Split-Path -Parent $AppExe)
263
+ $window.Close()
264
+ } catch {
265
+ $errorText.Text = '启动终端失败:' + $_.Exception.Message
266
+ $failure.Visibility = 'Visible'
267
+ $complete.Visibility = 'Collapsed'
268
+ }
269
+ })
270
+ $closeError.Add_Click({ $window.Close() })
271
+
272
+ if ($env:HEIMDALL_TEST_UI_OFFSCREEN -eq '1') {
273
+ $window.WindowStartupLocation = 'Manual'
274
+ $window.Left = -10000
275
+ $window.Top = -10000
276
+ $window.ShowInTaskbar = $false
277
+ }
278
+
279
+ $window.Add_ContentRendered({
280
+ $window.Activate() | Out-Null
281
+ $timer.Start()
282
+ })
283
+
284
+ if ($env:HEIMDALL_TEST_UI_SNAPSHOT) {
285
+ $snap = New-Object Windows.Threading.DispatcherTimer
286
+ $snap.Interval = [TimeSpan]::FromMilliseconds(1500)
287
+ $snap.Add_Tick({
288
+ $snap.Stop()
289
+ try {
290
+ $w = [int]$window.ActualWidth
291
+ $h = [int]$window.ActualHeight
292
+ $bmp2 = New-Object Windows.Media.Imaging.RenderTargetBitmap($w, $h, 96, 96,
293
+ [Windows.Media.PixelFormats]::Pbgra32)
294
+ $bmp2.Render($window)
295
+ $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
296
+ $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($bmp2)) | Out-Null
297
+ $stream = [IO.File]::Create($env:HEIMDALL_TEST_UI_SNAPSHOT)
298
+ $encoder.Save($stream)
299
+ $stream.Close()
300
+ } catch {
301
+ Write-UiLog ("snapshot: " + $_.Exception.Message)
302
+ }
303
+ $window.Close()
304
+ })
305
+ $window.Add_ContentRendered({ $snap.Start() })
306
+ }
307
+
308
+ [void]$window.ShowDialog()
309
+ } catch {
310
+ Write-UiLog ("fatal: " + $_.Exception.Message)
311
+ exit 1
312
+ }