From 0531a6491d089cef1d171ac1c172b38303fbb374 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 16:12:55 +0800
Subject: [PATCH 01/49] refactor: Extract platform-independent scanner into
CodexTpsFloat.Core
---
src/CodexTpsFloat.csproj | 4 ++-
src/Core/CodexTpsFloat.Core.csproj | 11 ++++++
src/{ => Core}/RequestClockReader.cs | 0
src/{ => Core}/UsageScanner.cs | 0
src/Core/packages.lock.json | 53 ++++++++++++++++++++++++++++
src/packages.lock.json | 22 ++++--------
tests/CoreTests.csproj | 2 +-
7 files changed, 75 insertions(+), 17 deletions(-)
create mode 100644 src/Core/CodexTpsFloat.Core.csproj
rename src/{ => Core}/RequestClockReader.cs (100%)
rename src/{ => Core}/UsageScanner.cs (100%)
create mode 100644 src/Core/packages.lock.json
diff --git a/src/CodexTpsFloat.csproj b/src/CodexTpsFloat.csproj
index 223ff90..101aac0 100644
--- a/src/CodexTpsFloat.csproj
+++ b/src/CodexTpsFloat.csproj
@@ -10,6 +10,8 @@
1.1.3
true
app.manifest
+ true
-
+
+
diff --git a/src/Core/CodexTpsFloat.Core.csproj b/src/Core/CodexTpsFloat.Core.csproj
new file mode 100644
index 0000000..6895943
--- /dev/null
+++ b/src/Core/CodexTpsFloat.Core.csproj
@@ -0,0 +1,11 @@
+
+
+ net10.0
+ disable
+ enable
+ CodexTpsFloat
+ CodexTpsFloat.Core
+ true
+
+
+
diff --git a/src/RequestClockReader.cs b/src/Core/RequestClockReader.cs
similarity index 100%
rename from src/RequestClockReader.cs
rename to src/Core/RequestClockReader.cs
diff --git a/src/UsageScanner.cs b/src/Core/UsageScanner.cs
similarity index 100%
rename from src/UsageScanner.cs
rename to src/Core/UsageScanner.cs
diff --git a/src/Core/packages.lock.json b/src/Core/packages.lock.json
new file mode 100644
index 0000000..e11fa5f
--- /dev/null
+++ b/src/Core/packages.lock.json
@@ -0,0 +1,53 @@
+{
+ "version": 1,
+ "dependencies": {
+ "net10.0": {
+ "Microsoft.Data.Sqlite": {
+ "type": "Direct",
+ "requested": "[10.0.13, )",
+ "resolved": "10.0.13",
+ "contentHash": "w37nz3WFmDtRfXxWEwIXX2OgqDRiwhD1JGbFwfpFCF8GkCrV/yO6Y2JF5058J2RGoI2sCcdn02wrk0yEcekWcw==",
+ "dependencies": {
+ "Microsoft.Data.Sqlite.Core": "10.0.13",
+ "SQLitePCLRaw.bundle_e_sqlite3": "2.1.13",
+ "SQLitePCLRaw.core": "2.1.13"
+ }
+ },
+ "Microsoft.Data.Sqlite.Core": {
+ "type": "Transitive",
+ "resolved": "10.0.13",
+ "contentHash": "Gge8XsSCOwcbkbdmt2UDAe6kIv9Q0vA6yb3wsTStjjexaMFLTWfc/1gH4kbhJ+zWiXRTRA4lG2sOQNVfir204w==",
+ "dependencies": {
+ "SQLitePCLRaw.core": "2.1.13"
+ }
+ },
+ "SQLitePCLRaw.bundle_e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "NlDixlC7uHmo+ojXRgkNvN0tQtVGpLDZ3x2OpgNj+G07VHh5cXSszFDrAiC4BpUiPwkcaeuQkMV9WQ123xVtmQ==",
+ "dependencies": {
+ "SQLitePCLRaw.lib.e_sqlite3": "2.1.13",
+ "SQLitePCLRaw.provider.e_sqlite3": "2.1.13"
+ }
+ },
+ "SQLitePCLRaw.core": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "2joofoinuHBFs0nMX3nKuXgxpXryRkCOdM2Ua6HBqQLLy6IW+5f28ZI+HAvMyF8vG7XfNz/lwfBfE6V4juru8Q=="
+ },
+ "SQLitePCLRaw.lib.e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "D2UAuiGxFYBqeRXjjjGgvJ5UQifzn6wefmSqeKU7XcNGKLbJRP6X7kcPZ6opOBJGdCIlgbSxTvDpBbLvsN594A=="
+ },
+ "SQLitePCLRaw.provider.e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "ZU60dSqoSNRe49KcQDUmOVgdRtjITOssVXFtiISs+zJXDI4D2Sndwpn2NOtzDQNPu0ZAvpoLPQ+GLKv6iEZn8Q==",
+ "dependencies": {
+ "SQLitePCLRaw.core": "2.1.13"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/packages.lock.json b/src/packages.lock.json
index 2003c23..b61145f 100644
--- a/src/packages.lock.json
+++ b/src/packages.lock.json
@@ -3,8 +3,7 @@
"dependencies": {
"net10.0-windows7.0": {
"Microsoft.Data.Sqlite": {
- "type": "Direct",
- "requested": "[10.0.13, )",
+ "type": "Transitive",
"resolved": "10.0.13",
"contentHash": "w37nz3WFmDtRfXxWEwIXX2OgqDRiwhD1JGbFwfpFCF8GkCrV/yO6Y2JF5058J2RGoI2sCcdn02wrk0yEcekWcw==",
"dependencies": {
@@ -13,12 +12,6 @@
"SQLitePCLRaw.core": "2.1.13"
}
},
- "Microsoft.NET.ILLink.Tasks": {
- "type": "Direct",
- "requested": "[10.0.11, )",
- "resolved": "10.0.11",
- "contentHash": "IBf7lbovvjGWVWXZX5cJ/cO0WXbId0Zq4BuSeT94mGZuOAP66oMeH9PTBZ9Jpp3Jb6jtK0qm/NyUbPRo1gC/wQ=="
- },
"Microsoft.Data.Sqlite.Core": {
"type": "Transitive",
"resolved": "10.0.13",
@@ -53,13 +46,12 @@
"dependencies": {
"SQLitePCLRaw.core": "2.1.13"
}
- }
- },
- "net10.0-windows7.0/win-x64": {
- "SQLitePCLRaw.lib.e_sqlite3": {
- "type": "Transitive",
- "resolved": "2.1.13",
- "contentHash": "D2UAuiGxFYBqeRXjjjGgvJ5UQifzn6wefmSqeKU7XcNGKLbJRP6X7kcPZ6opOBJGdCIlgbSxTvDpBbLvsN594A=="
+ },
+ "codextpsfloat.core": {
+ "type": "Project",
+ "dependencies": {
+ "Microsoft.Data.Sqlite": "[10.0.13, )"
+ }
}
}
}
diff --git a/tests/CoreTests.csproj b/tests/CoreTests.csproj
index 4c880ff..d86b045 100644
--- a/tests/CoreTests.csproj
+++ b/tests/CoreTests.csproj
@@ -1,4 +1,4 @@
Exenet10.0enableenablefalse
-
+
From 5a6bcf2edad1523dd896ab29db07227a32737d8c Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 16:18:00 +0800
Subject: [PATCH 02/49] fix: Detect rewritten logs without relying on Windows
file creation time
---
src/Core/UsageScanner.cs | 71 +++++++++++++++++++++++++++++++++-------
tests/Program.cs | 15 +++++++++
2 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/src/Core/UsageScanner.cs b/src/Core/UsageScanner.cs
index 55ddba9..4cd6716 100644
--- a/src/Core/UsageScanner.cs
+++ b/src/Core/UsageScanner.cs
@@ -36,14 +36,39 @@ public sealed class UsageScanner
{
sealed class Cursor
{
+ public const int TailCapacity = 256;
public long Offset;
- public long Creation;
+ public byte[]? Tail;
+ public int TailLength;
public string Thread = "";
public string Turn = "";
public bool HasUsage;
public bool HasLegacyUsage;
+
+ // Keep a sliding window of the most recently consumed bytes so a replaced or
+ // rewritten file can be detected without relying on birth time, which Unix
+ // filesystems often do not expose (and ctime changes on every append there).
+ public void AppendTail(ReadOnlySpan data)
+ {
+ Tail ??= new byte[TailCapacity];
+ if (data.Length >= TailCapacity)
+ {
+ data[^TailCapacity..].CopyTo(Tail);
+ TailLength = TailCapacity;
+ return;
+ }
+ int keep = Math.Min(TailLength, TailCapacity - data.Length);
+ int drop = TailLength - keep;
+ if (drop > 0) Tail.AsSpan(drop, keep).CopyTo(Tail);
+ data.CopyTo(Tail.AsSpan(keep));
+ TailLength = keep + data.Length;
+ }
}
- readonly Dictionary cursors = new(StringComparer.OrdinalIgnoreCase);
+ // Windows paths are case-insensitive; Unix paths are not, so two logs that differ only
+ // by case must keep separate cursors there.
+ static readonly StringComparer PathComparer = OperatingSystem.IsWindows()
+ ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal;
+ readonly Dictionary cursors = new(PathComparer);
readonly Dictionary usage = new();
readonly Dictionary turns = new();
readonly string home;
@@ -155,6 +180,7 @@ void ReadCompleteLines(FileStream stream, Cursor cursor)
catch (Exception e) when (e is JsonException or InvalidOperationException or FormatException)
{ invalidLines++; }
}
+ cursor.AppendTail(buffer.AsSpan(consumed, newline + 1));
consumed += newline + 1;
cursor.Offset += newline + 1; // Byte offsets also cover CRLF and multibyte UTF-8.
}
@@ -172,6 +198,24 @@ void ReadCompleteLines(FileStream stream, Cursor cursor)
}
finally { ArrayPool.Shared.Return(buffer, clearArray: true); }
}
+ // Confirms the bytes immediately before the remembered offset are still the ones we
+ // consumed, so a rewritten or replaced file does not get treated as a plain append.
+ static bool TailMatches(FileStream stream, Cursor cursor)
+ {
+ long start = cursor.Offset - cursor.TailLength;
+ if (cursor.Tail == null || start < 0 || stream.Length < cursor.Offset) return false;
+ stream.Seek(start, SeekOrigin.Begin);
+ Span probe = stackalloc byte[Cursor.TailCapacity];
+ var expected = cursor.Tail.AsSpan(0, cursor.TailLength);
+ int read = 0;
+ while (read < expected.Length)
+ {
+ int count = stream.Read(probe[read..expected.Length]);
+ if (count <= 0) return false;
+ read += count;
+ }
+ return probe[..expected.Length].SequenceEqual(expected);
+ }
public UsageSnapshot Refresh(DateTimeOffset now)
{
var watch = System.Diagnostics.Stopwatch.StartNew();
@@ -187,24 +231,27 @@ public UsageSnapshot Refresh(DateTimeOffset now)
{
try
{
- var info = new FileInfo(path);
if (!cursors.TryGetValue(path, out var cursor)) cursors[path] = cursor = new();
- long creation = info.CreationTimeUtc.Ticks;
- if (info.Length < cursor.Offset || (cursor.Creation != 0 && cursor.Creation != creation))
- {
- // Rebuild after replacement/truncation; stale usage must not survive a reset.
- cursors.Clear(); usage.Clear(); turns.Clear(); invalidLines = 0;
- return Refresh(now);
- }
- cursor.Creation = creation;
- if (info.Length == cursor.Offset) continue;
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite | FileShare.Delete);
if (cursor.Offset == 0 && stream.Length >= 3)
{
if (stream.ReadByte() == 0xEF && stream.ReadByte() == 0xBB && stream.ReadByte() == 0xBF)
+ {
cursor.Offset = 3;
+ ReadOnlySpan bom = [0xEF, 0xBB, 0xBF];
+ cursor.AppendTail(bom);
+ }
+ }
+ // Only a cursor that already consumed bytes can be invalidated; an empty
+ // cursor must always fall through to reading so a lone partial line works.
+ if (cursor.Offset > 0 && (stream.Length < cursor.Offset || !TailMatches(stream, cursor)))
+ {
+ // Rebuild after replacement/truncation; stale usage must not survive a reset.
+ cursors.Clear(); usage.Clear(); turns.Clear(); invalidLines = 0;
+ return Refresh(now);
}
+ if (stream.Length == cursor.Offset) continue;
stream.Seek(cursor.Offset, SeekOrigin.Begin);
ReadCompleteLines(stream, cursor);
}
diff --git a/tests/Program.cs b/tests/Program.cs
index 8dde1f3..74a6fa7 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -75,6 +75,21 @@ static void Seed(UsageScanner s, double t = origin)
var partial = inc.Refresh(now);
Check(partial.InvalidLines == 1 && partial.Records.Count == 1, "坏记录不阻断有效记录");
+ // A rewrite that keeps the length identical must still be detected; on Unix systems
+ // birth time is unavailable, so identity has to come from the consumed bytes.
+ string replacedRoot = Path.Combine(directory, "replaced");
+ Directory.CreateDirectory(Path.Combine(replacedRoot, "sessions"));
+ string replacedFile = Path.Combine(replacedRoot, "sessions", "same-length.jsonl");
+ File.WriteAllText(replacedFile, row + "\n", new UTF8Encoding(false));
+ var replaced = new UsageScanner(replacedRoot);
+ Check(replaced.Refresh(now).Records.Count == 1, "重写前计入一条");
+ string other = row.Replace("\"response_id\":\"partial\"", "\"response_id\":\"rewrite\"");
+ Check(other.Length == row.Length, "重写样本保持等长");
+ File.WriteAllText(replacedFile, other + "\n", new UTF8Encoding(false));
+ var afterReplace = replaced.Refresh(now);
+ Check(afterReplace.Records.Count == 1 && afterReplace.Records[0].Usage.Id == "rewrite",
+ "等长重写后重建游标并采用新内容");
+
string streamRoot = Path.Combine(directory, "streaming");
Directory.CreateDirectory(Path.Combine(streamRoot, "sessions"));
string streamFile = Path.Combine(streamRoot, "sessions", "unicode.jsonl");
From 96adc08f30588627b4d13bb23c6fa5ba2c2983ac Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 16:20:28 +0800
Subject: [PATCH 03/49] refactor: Move settings persistence and report export
into the core library
---
src/Core/PanelSettings.cs | 29 ++++++++++++++++++++++
src/Core/ReportExporter.cs | 39 +++++++++++++++++++++++++++++
src/Core/SettingsStore.cs | 50 ++++++++++++++++++++++++++++++++++++++
src/MainWindow.xaml.cs | 45 ++++++----------------------------
tests/Program.cs | 27 +++++++++++++++++++-
5 files changed, 152 insertions(+), 38 deletions(-)
create mode 100644 src/Core/PanelSettings.cs
create mode 100644 src/Core/ReportExporter.cs
create mode 100644 src/Core/SettingsStore.cs
diff --git a/src/Core/PanelSettings.cs b/src/Core/PanelSettings.cs
new file mode 100644
index 0000000..3d5bd57
--- /dev/null
+++ b/src/Core/PanelSettings.cs
@@ -0,0 +1,29 @@
+using System;
+using System.IO;
+using System.Linq;
+
+namespace CodexTpsFloat;
+
+public sealed class PanelSettings
+{
+ public static readonly int[] AllowedWindowSeconds = { 60, 300, 1800, 3600 };
+ public static readonly int[] AllowedRefreshSeconds = { 5, 15, 30, 60 };
+
+ public string CodexHome { get; set; } = DefaultCodexHome();
+ public int WindowSeconds { get; set; } = 300;
+ public int RefreshSeconds { get; set; } = 15;
+ public bool Pinned { get; set; } = true;
+ public double? X { get; set; }
+ public double? Y { get; set; }
+
+ public static string DefaultCodexHome() => Environment.GetEnvironmentVariable("CODEX_HOME")
+ ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".codex");
+
+ /// Replaces values that are out of range or that predate an option set.
+ public void Normalize()
+ {
+ if (!AllowedWindowSeconds.Contains(WindowSeconds)) WindowSeconds = 300;
+ if (!AllowedRefreshSeconds.Contains(RefreshSeconds)) RefreshSeconds = 15;
+ if (string.IsNullOrWhiteSpace(CodexHome)) CodexHome = DefaultCodexHome();
+ }
+}
diff --git a/src/Core/ReportExporter.cs b/src/Core/ReportExporter.cs
new file mode 100644
index 0000000..da8c86d
--- /dev/null
+++ b/src/Core/ReportExporter.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+
+namespace CodexTpsFloat;
+
+/// Renders the hourly TPS report that the panel offers as Markdown or JSON.
+public static class ReportExporter
+{
+ public static string BuildMarkdown(UsageSnapshot snapshot, DateTime date, string? model, IReadOnlyList hours)
+ {
+ var text = new StringBuilder($"# Codex TPS 分时统计\n\n日期:{date:yyyy-MM-dd};北京时间 UTC+8;模型:{model ?? "全部模型"}。\n\n快照:{snapshot.GeneratedAt:yyyy-MM-dd HH:mm:ss zzz}。\n\n| 时段 | 样本 | 中位数 | 加权 TPS |\n|---|---:|---:|---:|\n");
+ foreach (var h in hours)
+ text.AppendLine($"| {h.Hour} | {h.Samples} | {h.Median?.ToString("F2", CultureInfo.InvariantCulture) ?? "—"} | {h.Weighted?.ToString("F2", CultureInfo.InvariantCulture) ?? "—"} |");
+ text.AppendLine("\nTPS 是流式阶段估算:输出词元(包含推理)÷(逐次用量记录时间 − 首个模型输出项开始时间)。输入和缓存输入不计入,不等于精确服务端解码速度。\n\n按首个输出项的北京时间小时分组;零持续时间或缺失计时不作为有效样本。并发响应耗时各自相加。不同任务和上下文不可直接用于认定时段性能差异。\n");
+ return text.ToString();
+ }
+ public static string BuildJson(UsageSnapshot snapshot, DateTime date, string? model, IReadOnlyList hours) =>
+ JsonSerializer.Serialize(new
+ {
+ date = date.ToString("yyyy-MM-dd"),
+ timezone = "UTC+8",
+ snapshot.GeneratedAt,
+ model = model ?? "全部模型",
+ method = "输出词元(含推理)除以输出项计时区间;非精确解码速度",
+ hours
+ }, new JsonSerializerOptions { WriteIndented = true });
+ /// Writes a report; the file extension selects Markdown or JSON.
+ public static void Write(string path, UsageSnapshot snapshot, DateTime date, string? model, IReadOnlyList hours)
+ {
+ bool json = Path.GetExtension(path).Equals(".json", StringComparison.OrdinalIgnoreCase);
+ string content = json ? BuildJson(snapshot, date, model, hours) : BuildMarkdown(snapshot, date, model, hours);
+ File.WriteAllText(path, content, Encoding.UTF8);
+ }
+}
diff --git a/src/Core/SettingsStore.cs b/src/Core/SettingsStore.cs
new file mode 100644
index 0000000..87e4174
--- /dev/null
+++ b/src/Core/SettingsStore.cs
@@ -0,0 +1,50 @@
+using System;
+using System.IO;
+using System.Text.Json;
+
+namespace CodexTpsFloat;
+
+///
+/// Persists panel settings. Portable Windows builds keep the file beside the executable;
+/// other platforms use the conventional per-user application data directory, because a
+/// signed macOS bundle or a /usr install directory is not writable.
+///
+public sealed class SettingsStore
+{
+ readonly string path;
+ public SettingsStore(string path) => this.path = path;
+ public string Path => path;
+ public static SettingsStore ForPortableApp(string baseDirectory) =>
+ new(System.IO.Path.Combine(baseDirectory, "data", "settings.json"));
+ public static SettingsStore ForUserProfile(string appName = "CodexTpsFloat")
+ {
+ string root = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ if (string.IsNullOrEmpty(root))
+ root = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
+ return new(System.IO.Path.Combine(root, appName, "settings.json"));
+ }
+ public PanelSettings Load()
+ {
+ try
+ {
+ var settings = JsonSerializer.Deserialize(File.ReadAllText(path)) ?? new PanelSettings();
+ settings.Normalize();
+ return settings;
+ }
+ catch (Exception e) when (e is IOException or JsonException or UnauthorizedAccessException)
+ { return new PanelSettings(); }
+ }
+ /// Writes atomically; returns an error message when saving fails.
+ public string? Save(PanelSettings settings)
+ {
+ try
+ {
+ Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)!);
+ string temporary = path + ".tmp";
+ File.WriteAllText(temporary, JsonSerializer.Serialize(settings, new JsonSerializerOptions { WriteIndented = true }));
+ File.Move(temporary, path, true);
+ return null;
+ }
+ catch (Exception e) when (e is IOException or UnauthorizedAccessException) { return e.Message; }
+ }
+}
diff --git a/src/MainWindow.xaml.cs b/src/MainWindow.xaml.cs
index 84ed975..64134bd 100644
--- a/src/MainWindow.xaml.cs
+++ b/src/MainWindow.xaml.cs
@@ -4,8 +4,6 @@
using System.Globalization;
using System.IO;
using System.Linq;
-using System.Text;
-using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -18,23 +16,14 @@
namespace CodexTpsFloat;
-public sealed class PanelSettings
-{
- public string CodexHome { get; set; } = Environment.GetEnvironmentVariable("CODEX_HOME")
- ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".codex");
- public int WindowSeconds { get; set; } = 300;
- public int RefreshSeconds { get; set; } = 15;
- public bool Pinned { get; set; } = true;
- public double? X { get; set; }
- public double? Y { get; set; }
-}
-
public partial class MainWindow : Window
{
const string StartupName = "CodexTpsFloat";
readonly DispatcherTimer timer = new();
readonly Forms.NotifyIcon tray;
- readonly string settingsPath = Path.Combine(AppContext.BaseDirectory, "data", "settings.json");
+ readonly SettingsStore settingsStore = OperatingSystem.IsWindows()
+ ? SettingsStore.ForPortableApp(AppContext.BaseDirectory)
+ : SettingsStore.ForUserProfile();
readonly string? capturePath;
PanelSettings settings;
UsageScanner scanner;
@@ -44,11 +33,9 @@ public partial class MainWindow : Window
public MainWindow(string? capturePath = null, string? codexHome = null)
{
this.capturePath = capturePath;
- try { settings = JsonSerializer.Deserialize(File.ReadAllText(settingsPath)) ?? new(); }
- catch (Exception e) when (e is IOException or JsonException or UnauthorizedAccessException) { settings = new(); }
+ settings = settingsStore.Load();
if (codexHome != null) settings.CodexHome = Path.GetFullPath(codexHome);
- if (!new[] { 60, 300, 1800, 3600 }.Contains(settings.WindowSeconds)) settings.WindowSeconds = 300;
- if (!new[] { 5, 15, 30, 60 }.Contains(settings.RefreshSeconds)) settings.RefreshSeconds = 15;
+ settings.Normalize();
scanner = new(settings.CodexHome);
requestClocks = new(settings.CodexHome);
InitializeComponent();
@@ -183,15 +170,8 @@ void RenderHistory()
}
void SaveSettings()
{
- try
- {
- Directory.CreateDirectory(Path.GetDirectoryName(settingsPath)!);
- string temporary = settingsPath + ".tmp";
- File.WriteAllText(temporary, JsonSerializer.Serialize(settings, new JsonSerializerOptions { WriteIndented = true }), Encoding.UTF8);
- File.Move(temporary, settingsPath, true);
- }
- catch (Exception e) when (e is IOException or UnauthorizedAccessException)
- { if (!closing) StatusText.ToolTip = "设置保存失败:" + e.Message; }
+ string? error = settingsStore.Save(settings);
+ if (error != null && !closing) StatusText.ToolTip = "设置保存失败:" + error;
}
void DragHeader(object sender, MouseButtonEventArgs e)
{
@@ -285,16 +265,7 @@ void ExportClick(object sender, RoutedEventArgs e)
try
{
var hours = UsageScanner.Hours(snapshot, date, ModelFilter);
- if (Path.GetExtension(dialog.FileName).Equals(".json", StringComparison.OrdinalIgnoreCase))
- File.WriteAllText(dialog.FileName, JsonSerializer.Serialize(new { date = date.ToString("yyyy-MM-dd"), timezone = "UTC+8", snapshot.GeneratedAt,
- model = ModelFilter ?? "全部模型", method = "输出词元(含推理)除以输出项计时区间;非精确解码速度", hours }, new JsonSerializerOptions { WriteIndented = true }), Encoding.UTF8);
- else
- {
- var text = new StringBuilder($"# Codex TPS 分时统计\n\n日期:{date:yyyy-MM-dd};北京时间 UTC+8;模型:{ModelFilter ?? "全部模型"}。\n\n快照:{snapshot.GeneratedAt:yyyy-MM-dd HH:mm:ss zzz}。\n\n| 时段 | 样本 | 中位数 | 加权 TPS |\n|---|---:|---:|---:|\n");
- foreach (var h in hours) text.AppendLine($"| {h.Hour} | {h.Samples} | {h.Median?.ToString("F2", CultureInfo.InvariantCulture) ?? "—"} | {h.Weighted?.ToString("F2", CultureInfo.InvariantCulture) ?? "—"} |");
- text.AppendLine("\nTPS 是流式阶段估算:输出词元(包含推理)÷(逐次用量记录时间 − 首个模型输出项开始时间)。输入和缓存输入不计入,不等于精确服务端解码速度。\n\n按首个输出项的北京时间小时分组;零持续时间或缺失计时不作为有效样本。并发响应耗时各自相加。不同任务和上下文不可直接用于认定时段性能差异。\n");
- File.WriteAllText(dialog.FileName, text.ToString(), Encoding.UTF8);
- }
+ ReportExporter.Write(dialog.FileName, snapshot, date, ModelFilter, hours);
MessageBox.Show(this, "报告已保存。", "Codex TPS");
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { MessageBox.Show(this, "导出失败:" + ex.Message, "Codex TPS"); }
diff --git a/tests/Program.cs b/tests/Program.cs
index 74a6fa7..e305177 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -148,6 +148,31 @@ static void Seed(UsageScanner s, double t = origin)
var modern = legacy.Refresh(now);
Check(modern.UnsupportedFiles == 1 && modern.Records.Count == 1 && modern.InvalidLines == 0,
"同文件出现逐次 token_usage_record 后恢复可计量状态");
+
+ string settingsDirectory = Path.Combine(directory, "settings");
+ var store = new SettingsStore(Path.Combine(settingsDirectory, "settings.json"));
+ Check(store.Load().WindowSeconds == 300, "缺失设置文件时回退到默认值");
+ var custom = new PanelSettings { CodexHome = directory, WindowSeconds = 999, RefreshSeconds = 42,
+ Pinned = false, X = 12.5, Y = 34.5 };
+ store.Save(custom);
+ var loaded = store.Load();
+ Check(loaded.WindowSeconds == 300 && loaded.RefreshSeconds == 15, "越界选项在读取时归一化");
+ Check(loaded.Pinned == false && loaded.X == 12.5 && loaded.Y == 34.5 && loaded.CodexHome == directory,
+ "有效设置项完整往返");
+ Check(!File.Exists(store.Path + ".tmp"), "原子保存不残留临时文件");
+
+ var exportHours = new[] { new HourStats("09:00–10:00", 2, 21.5, 22.25), new HourStats("10:00–11:00", 0, null, null) };
+ string markdownPath = Path.Combine(directory, "report.md");
+ ReportExporter.Write(markdownPath, snap, now.Date, "model-a", exportHours);
+ string markdown = File.ReadAllText(markdownPath);
+ Check(markdown.Contains("| 09:00–10:00 | 2 | 21.50 | 22.25 |") && markdown.Contains("| 10:00–11:00 | 0 | — | — |"),
+ "Markdown 报告包含有效与空样本行");
+ string jsonPath = Path.Combine(directory, "report.json");
+ ReportExporter.Write(jsonPath, snap, now.Date, null, exportHours);
+ using var reportJson = JsonDocument.Parse(File.ReadAllText(jsonPath));
+ Check(reportJson.RootElement.GetProperty("timezone").GetString() == "UTC+8"
+ && reportJson.RootElement.GetProperty("model").GetString() == "全部模型"
+ && reportJson.RootElement.GetProperty("hours").GetArrayLength() == 2, "JSON 报告字段与导出参数一致");
}
finally { Directory.Delete(directory, true); }
-Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行与旧格式告警。");
+Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、等长重写、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行、旧格式告警、设置往返与报告导出。");
From 7a3a71df2ed4c81318639b3f411a7fe28f43d7e2 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 16:44:58 +0800
Subject: [PATCH 04/49] refactor: Move the headless snapshot command into the
core library
---
src/Core/SnapshotWriter.cs | 40 ++++++++++++++++++++++++++++++++++++++
src/Program.cs | 16 +--------------
2 files changed, 41 insertions(+), 15 deletions(-)
create mode 100644 src/Core/SnapshotWriter.cs
diff --git a/src/Core/SnapshotWriter.cs b/src/Core/SnapshotWriter.cs
new file mode 100644
index 0000000..9f19262
--- /dev/null
+++ b/src/Core/SnapshotWriter.cs
@@ -0,0 +1,40 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Text.Json;
+
+namespace CodexTpsFloat;
+
+///
+/// Renders a machine-readable snapshot of the current usage without starting any UI.
+/// Installed builds use this for smoke tests, and it is the only mode that runs headless.
+///
+public static class SnapshotWriter
+{
+ public static int Write(string snapshotPath, string? codexHome)
+ {
+ string home = codexHome ?? PanelSettings.DefaultCodexHome();
+ var clockReader = new RequestClockReader(home);
+ var scanner = new UsageScanner(home) { RequestStarts = clockReader.Refresh() };
+ var snapshot = scanner.Refresh(DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(8)));
+ string? directory = Path.GetDirectoryName(Path.GetFullPath(snapshotPath));
+ if (directory is { Length: > 0 }) Directory.CreateDirectory(directory);
+ File.WriteAllText(snapshotPath, JsonSerializer.Serialize(new
+ {
+ snapshot.GeneratedAt,
+ snapshot.Files,
+ snapshot.InvalidLines,
+ snapshot.UnsupportedFiles,
+ snapshot.ReadFailures,
+ snapshot.ScanMilliseconds,
+ requestClockWarning = clockReader.Warning,
+ windows = new[]
+ {
+ UsageScanner.Window(snapshot, 60), UsageScanner.Window(snapshot, 300),
+ UsageScanner.Window(snapshot, 1800), UsageScanner.Window(snapshot, 3600)
+ },
+ hours = UsageScanner.Hours(snapshot, snapshot.GeneratedAt.Date)
+ }, new JsonSerializerOptions { WriteIndented = true }), Encoding.UTF8);
+ return snapshot.Files == 0 ? 3 : snapshot.ReadFailures > 0 ? 1 : 0;
+ }
+}
diff --git a/src/Program.cs b/src/Program.cs
index 96ed14f..5659e2e 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -1,7 +1,5 @@
using System;
using System.IO;
-using System.Text;
-using System.Text.Json;
using System.Threading;
using System.Windows;
@@ -27,19 +25,7 @@ public static int Main(string[] args)
try
{
if (snapshotPath != null)
- {
- home ??= Environment.GetEnvironmentVariable("CODEX_HOME")
- ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".codex");
- var clockReader = new RequestClockReader(home);
- var scanner = new UsageScanner(home) { RequestStarts = clockReader.Refresh() };
- var snapshot = scanner.Refresh(DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(8)));
- Directory.CreateDirectory(Path.GetDirectoryName(snapshotPath)!);
- File.WriteAllText(snapshotPath, JsonSerializer.Serialize(new { snapshot.GeneratedAt, snapshot.Files, snapshot.InvalidLines,
- snapshot.UnsupportedFiles, snapshot.ReadFailures, snapshot.ScanMilliseconds, requestClockWarning = clockReader.Warning,
- windows = new[] { UsageScanner.Window(snapshot, 60), UsageScanner.Window(snapshot, 300), UsageScanner.Window(snapshot, 1800), UsageScanner.Window(snapshot, 3600) },
- hours = UsageScanner.Hours(snapshot, snapshot.GeneratedAt.Date) }, new JsonSerializerOptions { WriteIndented = true }), Encoding.UTF8);
- return snapshot.Files == 0 ? 3 : snapshot.ReadFailures > 0 ? 1 : 0;
- }
+ return SnapshotWriter.Write(snapshotPath, home);
using var mutex = new Mutex(true, @"Local\CodexTpsFloat.Panel.v1", out bool first);
using var wake = new EventWaitHandle(false, EventResetMode.AutoReset, @"Local\CodexTpsFloat.Show.v1");
if (!first && capture == null) { wake.Set(); return 0; }
From 5b571ec89701d1a9bde55ff3853a9211231b817f Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 16:48:43 +0800
Subject: [PATCH 05/49] feat: Add cross-platform autostart and platform path
services
---
src/Core/Autostart.cs | 120 ++++++++++++++++++++++++++++++++++++++
src/Core/PlatformPaths.cs | 20 +++++++
src/Core/SettingsStore.cs | 7 +--
src/MainWindow.xaml.cs | 21 ++-----
tests/Program.cs | 17 +++++-
5 files changed, 163 insertions(+), 22 deletions(-)
create mode 100644 src/Core/Autostart.cs
create mode 100644 src/Core/PlatformPaths.cs
diff --git a/src/Core/Autostart.cs b/src/Core/Autostart.cs
new file mode 100644
index 0000000..4eea6a6
--- /dev/null
+++ b/src/Core/Autostart.cs
@@ -0,0 +1,120 @@
+using System;
+using System.IO;
+using System.Runtime.Versioning;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace CodexTpsFloat;
+
+///
+/// Registers the app to start at login. Each platform has its own mechanism:
+/// Windows uses the Run key, macOS a LaunchAgent, Linux a desktop autostart entry.
+///
+public interface IAutostartService
+{
+ bool IsEnabled();
+ /// Enables or disables autostart; returns an error message on failure.
+ string? SetEnabled(bool enabled);
+}
+
+public static class Autostart
+{
+ public static IAutostartService Create(string? executablePath = null, string? configDirectory = null)
+ {
+ string exe = executablePath ?? Environment.ProcessPath ?? "";
+ string config = configDirectory ?? PlatformPaths.UserConfigDirectory();
+ if (OperatingSystem.IsWindows()) return new WindowsAutostart(exe);
+ if (OperatingSystem.IsMacOS()) return new MacAutostart(exe);
+ return new LinuxAutostart(exe, config);
+ }
+}
+
+[SupportedOSPlatform("windows")]
+public sealed class WindowsAutostart : IAutostartService
+{
+ const string StartupName = "CodexTpsFloat";
+ readonly string executable;
+ public WindowsAutostart(string executable) => this.executable = executable;
+ public bool IsEnabled()
+ {
+ using var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
+ @"Software\Microsoft\Windows\CurrentVersion\Run");
+ return key?.GetValue(StartupName) is string value && value == $"\"{executable}\"";
+ }
+ public string? SetEnabled(bool enabled)
+ {
+ try
+ {
+ using var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(
+ @"Software\Microsoft\Windows\CurrentVersion\Run");
+ if (enabled) key.SetValue(StartupName, $"\"{executable}\"");
+ else key.DeleteValue(StartupName, false);
+ return null;
+ }
+ catch (Exception e) when (e is UnauthorizedAccessException or IOException or System.Security.SecurityException)
+ { return e.Message; }
+ }
+}
+
+public sealed class MacAutostart : IAutostartService
+{
+ readonly string executable;
+ readonly string plistPath;
+ public MacAutostart(string executable, string? launchAgentsDirectory = null) =>
+ (this.executable, plistPath) = (executable, Path.Combine(
+ launchAgentsDirectory ?? Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "LaunchAgents"),
+ "com.codextpsfloat.plist"));
+ public bool IsEnabled() => File.Exists(plistPath);
+ public string? SetEnabled(bool enabled)
+ {
+ try
+ {
+ if (!enabled) { if (File.Exists(plistPath)) File.Delete(plistPath); return null; }
+ Directory.CreateDirectory(Path.GetDirectoryName(plistPath)!);
+ string escaped = System.Security.SecurityElement.Escape(executable) ?? executable;
+ string plist = $"""
+
+
+
+
+ Labelcom.codextpsfloat
+ ProgramArguments{escaped}
+ RunAtLoad
+
+
+ """;
+ File.WriteAllText(plistPath, plist, new UTF8Encoding(false));
+ return null;
+ }
+ catch (Exception e) when (e is IOException or UnauthorizedAccessException) { return e.Message; }
+ }
+}
+
+public sealed class LinuxAutostart : IAutostartService
+{
+ readonly string executable;
+ readonly string desktopPath;
+ public LinuxAutostart(string executable, string configDirectory) =>
+ (this.executable, desktopPath) = (executable, Path.Combine(configDirectory, "autostart", "CodexTpsFloat.desktop"));
+ public bool IsEnabled() => File.Exists(desktopPath);
+ public string? SetEnabled(bool enabled)
+ {
+ try
+ {
+ if (!enabled) { if (File.Exists(desktopPath)) File.Delete(desktopPath); return null; }
+ Directory.CreateDirectory(Path.GetDirectoryName(desktopPath)!);
+ string desktop = $"""
+ [Desktop Entry]
+ Type=Application
+ Name=Codex TPS
+ Exec="{executable}"
+ Terminal=false
+ X-GNOME-Autostart-enabled=true
+ """;
+ File.WriteAllText(desktopPath, desktop, new UTF8Encoding(false));
+ return null;
+ }
+ catch (Exception e) when (e is IOException or UnauthorizedAccessException) { return e.Message; }
+ }
+}
diff --git a/src/Core/PlatformPaths.cs b/src/Core/PlatformPaths.cs
new file mode 100644
index 0000000..3f4926f
--- /dev/null
+++ b/src/Core/PlatformPaths.cs
@@ -0,0 +1,20 @@
+using System;
+using System.IO;
+
+namespace CodexTpsFloat;
+
+/// Per-user locations that follow each platform's conventions.
+public static class PlatformPaths
+{
+ ///
+ /// Windows returns %APPDATA%, macOS returns ~/Library/Application Support and Linux
+ /// returns ~/.config, so this is also the right place to keep user settings.
+ ///
+ public static string UserConfigDirectory(string appName = "CodexTpsFloat")
+ {
+ string root = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ if (string.IsNullOrEmpty(root))
+ root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
+ return Path.Combine(root, appName);
+ }
+}
diff --git a/src/Core/SettingsStore.cs b/src/Core/SettingsStore.cs
index 87e4174..6f146ce 100644
--- a/src/Core/SettingsStore.cs
+++ b/src/Core/SettingsStore.cs
@@ -17,12 +17,7 @@ public sealed class SettingsStore
public static SettingsStore ForPortableApp(string baseDirectory) =>
new(System.IO.Path.Combine(baseDirectory, "data", "settings.json"));
public static SettingsStore ForUserProfile(string appName = "CodexTpsFloat")
- {
- string root = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- if (string.IsNullOrEmpty(root))
- root = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
- return new(System.IO.Path.Combine(root, appName, "settings.json"));
- }
+ => new(System.IO.Path.Combine(PlatformPaths.UserConfigDirectory(appName), "settings.json"));
public PanelSettings Load()
{
try
diff --git a/src/MainWindow.xaml.cs b/src/MainWindow.xaml.cs
index 64134bd..c70bd90 100644
--- a/src/MainWindow.xaml.cs
+++ b/src/MainWindow.xaml.cs
@@ -18,9 +18,9 @@ namespace CodexTpsFloat;
public partial class MainWindow : Window
{
- const string StartupName = "CodexTpsFloat";
readonly DispatcherTimer timer = new();
readonly Forms.NotifyIcon tray;
+ readonly IAutostartService autostart = Autostart.Create();
readonly SettingsStore settingsStore = OperatingSystem.IsWindows()
? SettingsStore.ForPortableApp(AppContext.BaseDirectory)
: SettingsStore.ForUserProfile();
@@ -44,7 +44,7 @@ public MainWindow(string? capturePath = null, string? codexHome = null)
TopmostBox.IsChecked = settings.Pinned;
PinButton.Foreground = new SolidColorBrush(settings.Pinned ? Color.FromRgb(0, 122, 255) : Colors.Gray);
DateBox.SelectedDate = BeijingNow.Date;
- StartupBox.IsChecked = StartupEnabled();
+ StartupBox.IsChecked = autostart.IsEnabled();
foreach (var item in CadenceBox.Items.OfType())
item.IsSelected = item.Tag?.ToString() == settings.RefreshSeconds.ToString(CultureInfo.InvariantCulture);
foreach (var radio in new[] { MinuteWindow, FiveMinuteWindow, HalfHourWindow, HourWindow })
@@ -240,21 +240,12 @@ async void ChooseHomeClick(object sender, RoutedEventArgs e)
settings.CodexHome = dialog.SelectedPath; HomeBox.Text = settings.CodexHome;
scanner = new(settings.CodexHome); requestClocks = new(settings.CodexHome); SaveSettings(); await RefreshAsync();
}
- static bool StartupEnabled()
- {
- using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
- return key?.GetValue(StartupName) is string value && value == $"\"{Environment.ProcessPath}\"";
- }
void StartupClick(object sender, RoutedEventArgs e)
{
- try
- {
- using var key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
- if (StartupBox.IsChecked == true) key.SetValue(StartupName, $"\"{Environment.ProcessPath}\"");
- else key.DeleteValue(StartupName, false);
- }
- catch (Exception ex) when (ex is UnauthorizedAccessException or IOException or System.Security.SecurityException)
- { StartupBox.IsChecked = StartupEnabled(); MessageBox.Show(this, "登录启动设置失败:" + ex.Message, "Codex TPS"); }
+ string? error = autostart.SetEnabled(StartupBox.IsChecked == true);
+ if (error == null) return;
+ StartupBox.IsChecked = autostart.IsEnabled();
+ MessageBox.Show(this, "登录启动设置失败:" + error, "Codex TPS");
}
void ExportClick(object sender, RoutedEventArgs e)
{
diff --git a/tests/Program.cs b/tests/Program.cs
index e305177..ddb173f 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -173,6 +173,21 @@ static void Seed(UsageScanner s, double t = origin)
Check(reportJson.RootElement.GetProperty("timezone").GetString() == "UTC+8"
&& reportJson.RootElement.GetProperty("model").GetString() == "全部模型"
&& reportJson.RootElement.GetProperty("hours").GetArrayLength() == 2, "JSON 报告字段与导出参数一致");
+
+ string entry = OperatingSystem.IsMacOS()
+ ? Path.Combine(directory, "LaunchAgents", "com.codextpsfloat.plist")
+ : Path.Combine(directory, "config", "autostart", "CodexTpsFloat.desktop");
+ IAutostartService login = OperatingSystem.IsMacOS()
+ ? new MacAutostart("/Applications/Codex TPS.app", Path.GetDirectoryName(entry))
+ : new LinuxAutostart("/opt/codex tps/CodexTpsFloat", Path.Combine(directory, "config"));
+ Check(!login.IsEnabled(), "未启用时登录启动为关闭状态");
+ Check(login.SetEnabled(true) == null && login.IsEnabled(), "启用登录启动会创建条目");
+ string entryText = File.ReadAllText(entry);
+ Check(OperatingSystem.IsMacOS()
+ ? entryText.Contains("/Applications/Codex TPS.app") && entryText.Contains("RunAtLoad")
+ : entryText.Contains("Exec=\"/opt/codex tps/CodexTpsFloat\"") && entryText.StartsWith("[Desktop Entry]"),
+ "登录启动条目包含可执行路径与自启标记");
+ Check(login.SetEnabled(false) == null && !login.IsEnabled() && !File.Exists(entry), "停用登录启动会移除条目");
}
finally { Directory.Delete(directory, true); }
-Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、等长重写、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行、旧格式告警、设置往返与报告导出。");
+Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、等长重写、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行、旧格式告警、设置往返、报告导出与登录启动。");
From 4c1eb4da1d65187d1a29a514d89f6be6a5d1eeac Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:08:35 +0800
Subject: [PATCH 06/49] feat: Add cross-platform Avalonia application shell
---
src/App/App.axaml | 8 +
src/App/App.axaml.cs | 44 +++
src/App/CodexTpsFloat.App.csproj | 27 ++
src/App/MainWindow.axaml | 232 ++++++++++++++
src/App/MainWindow.axaml.cs | 506 +++++++++++++++++++++++++++++++
src/App/Program.cs | 66 ++++
src/App/app.manifest | 6 +
src/App/packages.lock.json | 273 +++++++++++++++++
src/Core/SingleInstance.cs | 190 ++++++++++++
9 files changed, 1352 insertions(+)
create mode 100644 src/App/App.axaml
create mode 100644 src/App/App.axaml.cs
create mode 100644 src/App/CodexTpsFloat.App.csproj
create mode 100644 src/App/MainWindow.axaml
create mode 100644 src/App/MainWindow.axaml.cs
create mode 100644 src/App/Program.cs
create mode 100644 src/App/app.manifest
create mode 100644 src/App/packages.lock.json
create mode 100644 src/Core/SingleInstance.cs
diff --git a/src/App/App.axaml b/src/App/App.axaml
new file mode 100644
index 0000000..0614db5
--- /dev/null
+++ b/src/App/App.axaml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/src/App/App.axaml.cs b/src/App/App.axaml.cs
new file mode 100644
index 0000000..d5aec84
--- /dev/null
+++ b/src/App/App.axaml.cs
@@ -0,0 +1,44 @@
+using System;
+using System.IO;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+using Avalonia.Threading;
+
+namespace CodexTpsFloat.App;
+
+public partial class App : Application
+{
+ public static CommandLineOptions Options { get; set; } = new(null, null, null);
+ public static SingleInstance? SingleInstance { get; set; }
+ public static Action? ShowExistingPanel { get; set; }
+ MainWindow? window;
+
+ public override void Initialize() => AvaloniaXamlLoader.Load(this);
+
+ public override void OnFrameworkInitializationCompleted()
+ {
+ if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
+ {
+ base.OnFrameworkInitializationCompleted();
+ return;
+ }
+
+ desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
+ window = new MainWindow(Options.CapturePath, Options.CodexHome);
+ desktop.MainWindow = window;
+
+ if (Options.CapturePath == null)
+ ShowExistingPanel = () => Dispatcher.UIThread.Post(window.ShowPanel);
+
+ desktop.Startup += async (_, _) =>
+ {
+ await window.StartAsync();
+ if (Options.CapturePath != null)
+ await window.CaptureAndCloseAsync(Options.CapturePath);
+ };
+
+ base.OnFrameworkInitializationCompleted();
+ }
+}
diff --git a/src/App/CodexTpsFloat.App.csproj b/src/App/CodexTpsFloat.App.csproj
new file mode 100644
index 0000000..599275c
--- /dev/null
+++ b/src/App/CodexTpsFloat.App.csproj
@@ -0,0 +1,27 @@
+
+
+ WinExe
+ net10.0
+ disable
+ enable
+ CodexTpsFloat
+ CodexTpsFloat.App
+ true
+ app.manifest
+ true
+ true
+ true
+ 1.2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/App/MainWindow.axaml b/src/App/MainWindow.axaml
new file mode 100644
index 0000000..6499a6a
--- /dev/null
+++ b/src/App/MainWindow.axaml
@@ -0,0 +1,232 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
new file mode 100644
index 0000000..2cfbee3
--- /dev/null
+++ b/src/App/MainWindow.axaml.cs
@@ -0,0 +1,506 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Media;
+using Avalonia.Media.Imaging;
+using Avalonia.Platform;
+using Avalonia.Platform.Storage;
+using Avalonia.Threading;
+
+namespace CodexTpsFloat.App;
+
+public partial class MainWindow : Window
+{
+ readonly DispatcherTimer timer = new();
+ readonly TrayIcon? tray;
+ readonly IAutostartService autostart = Autostart.Create();
+ readonly SettingsStore settingsStore = OperatingSystem.IsWindows()
+ ? SettingsStore.ForPortableApp(AppContext.BaseDirectory)
+ : SettingsStore.ForUserProfile();
+ readonly string? capturePath;
+ PanelSettings settings;
+ UsageScanner scanner;
+ RequestClockReader requestClocks;
+ UsageSnapshot? snapshot;
+ bool refreshing, initialized, closing;
+ readonly List models = new() { "全部模型" };
+
+ public MainWindow() : this(null, null) { }
+
+ public MainWindow(string? capturePath = null, string? codexHome = null)
+ {
+ this.capturePath = capturePath;
+ settings = settingsStore.Load();
+ if (codexHome != null) settings.CodexHome = Path.GetFullPath(codexHome);
+ settings.Normalize();
+ scanner = new(settings.CodexHome);
+ requestClocks = new(settings.CodexHome);
+
+ InitializeComponent();
+ InitializeState();
+
+ tray = OperatingSystem.IsBrowser() ? null : CreateTrayIcon();
+ if (tray != null && Application.Current != null)
+ TrayIcon.SetIcons(Application.Current, new TrayIcons { tray });
+
+ Opened += (_, _) => PositionPanel();
+ Closing += (_, _) => DisposeWindow();
+ }
+
+ static DateTimeOffset BeijingNow => DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(8));
+
+ void InitializeState()
+ {
+ HomeBox.Text = settings.CodexHome;
+ Topmost = settings.Pinned;
+ TopmostBox.IsChecked = settings.Pinned;
+ SetPinColor(settings.Pinned);
+ DateBox.SelectedDate = BeijingNow.Date;
+ StartupBox.IsChecked = autostart.IsEnabled();
+
+ ModelBox.ItemsSource = models;
+ ModelBox.SelectedIndex = 0;
+
+ foreach (var item in CadenceBox.Items.OfType())
+ item.IsSelected = item.Tag?.ToString() == settings.RefreshSeconds.ToString(CultureInfo.InvariantCulture);
+ foreach (var radio in new[] { MinuteWindow, FiveMinuteWindow, HalfHourWindow, HourWindow })
+ radio.IsChecked = radio.Tag?.ToString() == settings.WindowSeconds.ToString(CultureInfo.InvariantCulture);
+ foreach (var radio in new[] { MinuteWindow, FiveMinuteWindow, HalfHourWindow, HourWindow })
+ radio.IsCheckedChanged += WindowChanged;
+
+ timer.Interval = TimeSpan.FromSeconds(settings.RefreshSeconds);
+ timer.Tick += async (_, _) => await RefreshAsync();
+ }
+
+ TrayIcon? CreateTrayIcon()
+ {
+ try
+ {
+ var menu = new NativeMenu();
+ var open = new NativeMenuItem("打开统计面板");
+ open.Click += (_, _) => ShowPanel();
+ var refresh = new NativeMenuItem("立即刷新");
+ refresh.Click += async (_, _) => await RefreshAsync();
+ var exit = new NativeMenuItem("退出");
+ exit.Click += (_, _) => Close();
+ menu.Items.Add(open);
+ menu.Items.Add(refresh);
+ menu.Items.Add(exit);
+
+ var icon = new TrayIcon
+ {
+ Icon = TrayIconFactory.Create(),
+ ToolTipText = "Codex TPS 悬浮窗",
+ Menu = menu,
+ IsVisible = true
+ };
+ icon.Clicked += (_, _) => TogglePanel();
+ return icon;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ public async Task StartAsync()
+ {
+ if (initialized) return;
+ initialized = true;
+ timer.Start();
+ await RefreshAsync();
+ }
+
+ public async Task CaptureAndCloseAsync(string path)
+ {
+ ShowPanel();
+ await Dispatcher.UIThread.InvokeAsync(() =>
+ {
+ Capture(path);
+ Close();
+ }, DispatcherPriority.ApplicationIdle);
+ }
+
+ void PositionPanel()
+ {
+ var screen = Screens.ScreenFromWindow(this) ?? Screens.Primary;
+ if (screen == null) return;
+ double scale = screen.Scaling;
+ var area = screen.WorkingArea;
+ double areaLeft = area.X / scale, areaTop = area.Y / scale;
+ double areaRight = area.Right / scale, areaBottom = area.Bottom / scale;
+ double x = settings.X ?? areaRight - Width - 24;
+ double y = settings.Y ?? areaBottom - Bounds.Height - 24;
+ Position = new PixelPoint(
+ (int)Math.Round(Math.Clamp(x, areaLeft, Math.Max(areaLeft, areaRight - Width)) * scale),
+ (int)Math.Round(Math.Clamp(y, areaTop, Math.Max(areaTop, areaBottom - Bounds.Height)) * scale));
+ }
+
+ public void ShowPanel()
+ {
+ Show();
+ WindowState = WindowState.Normal;
+ RenderHistory();
+ Activate();
+ }
+
+ void TogglePanel()
+ {
+ if (IsVisible) Hide();
+ else ShowPanel();
+ }
+
+ async Task RefreshAsync()
+ {
+ if (refreshing || closing) return;
+ refreshing = true;
+ RefreshButton.IsEnabled = false;
+ StatusText.Text = "读取中";
+ try
+ {
+ var activeScanner = scanner;
+ var activeClocks = requestClocks;
+ var next = await Task.Run(() =>
+ {
+ activeScanner.RequestStarts = activeClocks.Refresh();
+ return activeScanner.Refresh(BeijingNow);
+ });
+ if (closing) return;
+ bool followToday = snapshot == null || DateBox.SelectedDate == snapshot.GeneratedAt.Date;
+ snapshot = next;
+ if (followToday) DateBox.SelectedDate = next.GeneratedAt.Date;
+
+ string model = ModelBox.SelectedItem as string ?? "全部模型";
+ var nextModels = new[] { "全部模型" }.Concat(next.Records.Select(r => r.Model).Distinct().Order()).ToList();
+ if (!models.SequenceEqual(nextModels))
+ {
+ models.Clear();
+ models.AddRange(nextModels);
+ ModelBox.ItemsSource = null;
+ ModelBox.ItemsSource = models;
+ ModelBox.SelectedItem = models.Contains(model) ? model : "全部模型";
+ }
+
+ RenderMetrics();
+ bool trouble = next.ReadFailures > 0 || next.InvalidLines > 0 || next.UnsupportedFiles > 0;
+ string status = next.Files == 0 ? "未找到会话日志" : trouble ? "部分日志不可计量" : "就绪";
+ StatusText.Text = $"{status} · {next.GeneratedAt:HH:mm:ss}";
+ StatusDot.Fill = new SolidColorBrush(trouble || next.Files == 0
+ ? Color.FromRgb(255, 149, 0)
+ : Color.FromRgb(52, 199, 89));
+ ToolTip.SetTip(StatusText,
+ $"{next.Files} 个文件;{next.InvalidLines} 条异常记录;{next.UnsupportedFiles} 个旧格式文件;{next.ReadFailures} 个读取失败。\nJSONL 扫描 {next.ScanMilliseconds:F0} 毫秒。" +
+ (activeClocks.Warning == null ? "" : "\n" + activeClocks.Warning));
+ }
+ catch (Exception e) when (e is IOException or UnauthorizedAccessException or ArgumentException)
+ {
+ StatusText.Text = "读取失败";
+ StatusDot.Fill = Brushes.OrangeRed;
+ ToolTip.SetTip(StatusText, e.Message);
+ }
+ finally
+ {
+ refreshing = false;
+ RefreshButton.IsEnabled = true;
+ }
+ }
+
+ string? ModelFilter => ModelBox.SelectedItem is string value && value != "全部模型" ? value : null;
+
+ static string Rate(double value) => value >= 1_000_000
+ ? $"{value / 1_000_000:F1}m"
+ : value >= 1000 ? $"{value / 1000:F1}k" : value.ToString("F1", CultureInfo.InvariantCulture);
+
+ void RenderMetrics()
+ {
+ if (snapshot == null) return;
+ var m = UsageScanner.Window(snapshot, settings.WindowSeconds, ModelFilter);
+ HeroValue.Text = m.GenerationTps?.ToString("N1", CultureInfo.InvariantCulture) ?? "—";
+ RequestValue.Text = m.RequestsPerMinute.ToString("F1", CultureInfo.InvariantCulture);
+ InputValue.Text = Rate(m.InputRate);
+ CachedValue.Text = Rate(m.CachedRate);
+ OutputValue.Text = Rate(m.OutputRate);
+ ReasoningValue.Text = Rate(m.ReasoningRate);
+ SessionsValue.Text = $"{m.ActiveSessions} 个活跃会话";
+ CacheRatioValue.Text = $"缓存占比 {m.CacheRatio:P0}";
+ SamplesValue.Text = $"计时样本 {m.GenerationSamples}";
+ TtftValue.Text = m.TurnFirstTokenMs.HasValue
+ ? $"轮次首字 {m.TurnFirstTokenMs.Value / 1000:F1} 秒"
+ : "轮次首字 —";
+ if (tray != null) tray.ToolTipText = $"Codex TPS:{HeroValue.Text} 词元/秒(估算)";
+ RenderHistory();
+ }
+
+ void RenderHistory()
+ {
+ if (snapshot == null || !IsVisible || !HistoryPanel.IsVisible) return;
+ HourGrid.ItemsSource = UsageScanner.Hours(
+ snapshot, (DateBox.SelectedDate ?? BeijingNow).Date, ModelFilter);
+ }
+
+ void SaveSettings()
+ {
+ string? error = settingsStore.Save(settings);
+ if (error != null && !closing) ToolTip.SetTip(StatusText, "设置保存失败:" + error);
+ }
+
+ void DragHeader(object? sender, PointerPressedEventArgs e)
+ {
+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
+ BeginMoveDrag(e);
+ settings.X = Position.X / (Screens.ScreenFromWindow(this)?.Scaling ?? 1);
+ settings.Y = Position.Y / (Screens.ScreenFromWindow(this)?.Scaling ?? 1);
+ SaveSettings();
+ }
+
+ async void RefreshClick(object? sender, RoutedEventArgs e) => await RefreshAsync();
+
+ void FolderClick(object? sender, RoutedEventArgs e)
+ {
+ var path = Path.Combine(settings.CodexHome, "sessions");
+ if (Directory.Exists(path))
+ Process.Start(new ProcessStartInfo(path) { UseShellExecute = true });
+ else
+ _ = ShowMessage("未找到会话目录,请在设置中选择包含 sessions 的 Codex 数据目录。");
+ }
+
+ void PinClick(object? sender, RoutedEventArgs e)
+ {
+ settings.Pinned = !settings.Pinned;
+ ApplyPinned();
+ }
+
+ void ApplyPinned()
+ {
+ Topmost = settings.Pinned;
+ TopmostBox.IsChecked = settings.Pinned;
+ SetPinColor(settings.Pinned);
+ SaveSettings();
+ }
+
+ void SetPinColor(bool pinned) => PinButton.Foreground = new SolidColorBrush(
+ pinned ? Color.FromRgb(0, 122, 255) : Colors.Gray);
+
+ void TopmostClick(object? sender, RoutedEventArgs e)
+ {
+ settings.Pinned = TopmostBox.IsChecked == true;
+ ApplyPinned();
+ }
+
+ void HideClick(object? sender, RoutedEventArgs e) => Hide();
+
+ void ExitClick(object? sender, RoutedEventArgs e) => Close();
+
+ void WindowChanged(object? sender, RoutedEventArgs e)
+ {
+ if (!initialized || sender is not RadioButton radio || radio.IsChecked != true) return;
+ if (!int.TryParse(radio.Tag?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int seconds)) return;
+ settings.WindowSeconds = seconds;
+ RenderMetrics();
+ SaveSettings();
+ }
+
+ void ModelChanged(object? sender, SelectionChangedEventArgs e)
+ {
+ if (initialized) RenderMetrics();
+ }
+
+ void DateChanged(object? sender, DatePickerSelectedValueChangedEventArgs e)
+ {
+ if (initialized) RenderHistory();
+ }
+
+ void CadenceChanged(object? sender, SelectionChangedEventArgs e)
+ {
+ if (!initialized || CadenceBox.SelectedItem is not ComboBoxItem item) return;
+ if (!int.TryParse(item.Tag?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int seconds)) return;
+ settings.RefreshSeconds = seconds;
+ timer.Interval = TimeSpan.FromSeconds(seconds);
+ SaveSettings();
+ }
+
+ void HistoryClick(object? sender, RoutedEventArgs e)
+ {
+ bool show = !HistoryPanel.IsVisible;
+ HistoryPanel.IsVisible = show;
+ HistoryButton.Content = show ? "分时统计 ⌄" : "今日分时 ›";
+ if (show)
+ {
+ RenderHistory();
+ KeepOnScreen();
+ }
+ }
+
+ void SettingsClick(object? sender, RoutedEventArgs e)
+ {
+ SettingsPanel.IsVisible = !SettingsPanel.IsVisible;
+ KeepOnScreen();
+ }
+
+ void KeepOnScreen() => Dispatcher.UIThread.Post(() =>
+ {
+ var screen = Screens.ScreenFromWindow(this) ?? Screens.Primary;
+ if (screen == null) return;
+ double scale = screen.Scaling;
+ double bottom = screen.WorkingArea.Bottom / scale;
+ double top = Position.Y / scale;
+ if (top + Bounds.Height > bottom)
+ Position = new PixelPoint(Position.X, (int)Math.Round(Math.Max(screen.WorkingArea.Y / scale, bottom - Bounds.Height) * scale));
+ }, DispatcherPriority.Loaded);
+
+ async void ChooseHomeClick(object? sender, RoutedEventArgs e)
+ {
+ if (refreshing) return;
+ var folders = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
+ {
+ Title = "选择包含 sessions 的 Codex 数据目录",
+ AllowMultiple = false
+ });
+ string? path = folders.FirstOrDefault()?.TryGetLocalPath();
+ if (path == null) return;
+ if (!Directory.Exists(Path.Combine(path, "sessions")))
+ {
+ _ = ShowMessage("该目录不包含 sessions 文件夹。");
+ return;
+ }
+ settings.CodexHome = path;
+ HomeBox.Text = settings.CodexHome;
+ scanner = new(settings.CodexHome);
+ requestClocks = new(settings.CodexHome);
+ SaveSettings();
+ await RefreshAsync();
+ }
+
+ void StartupClick(object? sender, RoutedEventArgs e)
+ {
+ string? error = autostart.SetEnabled(StartupBox.IsChecked == true);
+ if (error == null) return;
+ StartupBox.IsChecked = autostart.IsEnabled();
+ _ = ShowMessage("登录启动设置失败:" + error);
+ }
+
+ async void ExportClick(object? sender, RoutedEventArgs e)
+ {
+ if (snapshot == null) return;
+ var date = (DateBox.SelectedDate ?? BeijingNow).Date;
+ var file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
+ {
+ Title = "导出报告",
+ SuggestedFileName = $"Codex-TPS-{date:yyyy-MM-dd}.md",
+ DefaultExtension = "md",
+ ShowOverwritePrompt = true,
+ FileTypeChoices = new[]
+ {
+ new FilePickerFileType("中文报告") { Patterns = new[] { "*.md" } },
+ new FilePickerFileType("数据文件") { Patterns = new[] { "*.json" } }
+ }
+ });
+ string? path = file?.TryGetLocalPath();
+ if (path == null) return;
+ try
+ {
+ var hours = UsageScanner.Hours(snapshot, date, ModelFilter);
+ ReportExporter.Write(path, snapshot, date, ModelFilter, hours);
+ _ = ShowMessage("报告已保存。");
+ }
+ catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
+ {
+ _ = ShowMessage("导出失败:" + ex.Message);
+ }
+ }
+
+ async Task ShowMessage(string message)
+ {
+ var dialog = new Window
+ {
+ Title = "Codex TPS",
+ Width = 330,
+ SizeToContent = SizeToContent.Height,
+ CanResize = false,
+ WindowStartupLocation = WindowStartupLocation.CenterOwner,
+ Content = new StackPanel
+ {
+ Margin = new Thickness(18),
+ Spacing = 14,
+ Children =
+ {
+ new TextBlock { Text = message, TextWrapping = TextWrapping.Wrap },
+ new Button { Content = "确定", HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right }
+ }
+ }
+ };
+ if (dialog.Content is StackPanel panel && panel.Children[1] is Button button)
+ button.Click += (_, _) => dialog.Close();
+ await dialog.ShowDialog(this);
+ }
+
+ void Capture(string path)
+ {
+ UpdateLayout();
+ double scale = Screens.ScreenFromWindow(this)?.Scaling ?? 1;
+ var size = new PixelSize(
+ Math.Max(1, (int)Math.Ceiling(Bounds.Width * scale)),
+ Math.Max(1, (int)Math.Ceiling(Bounds.Height * scale)));
+ using var bitmap = new RenderTargetBitmap(size, new Vector(96 * scale, 96 * scale));
+ bitmap.Render(this);
+ string? directory = Path.GetDirectoryName(Path.GetFullPath(path));
+ if (directory is { Length: > 0 }) Directory.CreateDirectory(directory);
+ bitmap.Save(path);
+ }
+
+ void DisposeWindow()
+ {
+ if (closing) return;
+ closing = true;
+ timer.Stop();
+ if (double.IsFinite(Position.X) && double.IsFinite(Position.Y))
+ {
+ double scale = Screens.ScreenFromWindow(this)?.Scaling ?? 1;
+ settings.X = Position.X / scale;
+ settings.Y = Position.Y / scale;
+ }
+ SaveSettings();
+ tray?.Dispose();
+ if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ desktop.Shutdown();
+ }
+}
+
+static class TrayIconFactory
+{
+ public static WindowIcon Create()
+ {
+ const int size = 32;
+ var pixels = new byte[size * size * 4];
+ for (int y = 0; y < size; y++)
+ {
+ for (int x = 0; x < size; x++)
+ {
+ int index = (y * size + x) * 4;
+ pixels[index] = 0x00;
+ pixels[index + 1] = 0x7A;
+ pixels[index + 2] = 0xFF;
+ pixels[index + 3] = 0xFF;
+ }
+ }
+ using var bitmap = new WriteableBitmap(
+ new PixelSize(size, size), new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Unpremul);
+ using (var buffer = bitmap.Lock())
+ {
+ System.Runtime.InteropServices.Marshal.Copy(pixels, 0, buffer.Address, pixels.Length);
+ }
+ using var stream = new MemoryStream();
+ bitmap.Save(stream);
+ stream.Position = 0;
+ return new WindowIcon(stream);
+ }
+}
diff --git a/src/App/Program.cs b/src/App/Program.cs
new file mode 100644
index 0000000..bcb0482
--- /dev/null
+++ b/src/App/Program.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Avalonia;
+
+namespace CodexTpsFloat.App;
+
+public static class Program
+{
+ public static int Main(string[] args)
+ {
+ var options = CommandLineOptions.Parse(args);
+ if (options == null) return 2;
+
+ if (options.SnapshotPath != null)
+ return SnapshotWriter.Write(options.SnapshotPath, options.CodexHome);
+
+ using var singleInstance = SingleInstance.Create(
+ OperatingSystem.IsWindows() ? @"Local\CodexTpsFloat.Panel.v1" : "CodexTpsFloat",
+ () => App.ShowExistingPanel?.Invoke());
+ if (!singleInstance.IsFirstInstance && options.CapturePath == null)
+ {
+ singleInstance.SignalExistingInstance();
+ return 0;
+ }
+
+ try
+ {
+ App.Options = options;
+ App.SingleInstance = singleInstance;
+ BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
+ return 0;
+ }
+ catch (Exception error)
+ {
+ Console.Error.WriteLine("Codex TPS 启动失败:" + error);
+ return 1;
+ }
+ }
+
+ public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure()
+ .UsePlatformDetect()
+ .WithInterFont()
+ .LogToTrace();
+}
+
+public sealed record CommandLineOptions(string? CapturePath, string? CodexHome, string? SnapshotPath)
+{
+ public static CommandLineOptions? Parse(IReadOnlyList args)
+ {
+ string? capture = null, home = null, snapshot = null;
+ for (int i = 0; i < args.Count; i++)
+ {
+ if (i + 1 >= args.Count) return null;
+ switch (args[i])
+ {
+ case "--capture": capture = Path.GetFullPath(args[++i]); break;
+ case "--codex-home": home = Path.GetFullPath(args[++i]); break;
+ case "--snapshot-json": snapshot = Path.GetFullPath(args[++i]); break;
+ default: return null;
+ }
+ }
+ return new(capture, home, snapshot);
+ }
+}
+
diff --git a/src/App/app.manifest b/src/App/app.manifest
new file mode 100644
index 0000000..33e64bf
--- /dev/null
+++ b/src/App/app.manifest
@@ -0,0 +1,6 @@
+
+
+
+
+ PerMonitorV2true
+
diff --git a/src/App/packages.lock.json b/src/App/packages.lock.json
new file mode 100644
index 0000000..194a5bd
--- /dev/null
+++ b/src/App/packages.lock.json
@@ -0,0 +1,273 @@
+{
+ "version": 1,
+ "dependencies": {
+ "net10.0": {
+ "Avalonia": {
+ "type": "Direct",
+ "requested": "[11.3.12, )",
+ "resolved": "11.3.12",
+ "contentHash": "CHB0gXMSba8gTXqTrO9lS1te9ejH52ngHPm+0i/RfXFzqHXHPQ3yciFc/GfGnXUBjqjwH85J1rhYNl4/EujP0w==",
+ "dependencies": {
+ "Avalonia.BuildServices": "11.3.2",
+ "Avalonia.Remote.Protocol": "11.3.12",
+ "MicroCom.Runtime": "0.11.0"
+ }
+ },
+ "Avalonia.Controls.DataGrid": {
+ "type": "Direct",
+ "requested": "[11.3.12, )",
+ "resolved": "11.3.12",
+ "contentHash": "9zlVkd23gaFtJwi4n7JaKnGdCSkD1fuiRdflzfkLoVXxHKQ2pTOcsUB26rAs7uMTCRvvte8OPwbsK8otA1wNPg==",
+ "dependencies": {
+ "Avalonia": "11.3.12"
+ }
+ },
+ "Avalonia.Desktop": {
+ "type": "Direct",
+ "requested": "[11.3.12, )",
+ "resolved": "11.3.12",
+ "contentHash": "zwtEFNvXB60z7rHD92oISkCQq0PcFyttfAW+cgcfALECegtNkd9P9/UXIuE0GvMVBVUPTRUQeSB6/jhwZKqqRQ==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "Avalonia.Native": "11.3.12",
+ "Avalonia.Skia": "11.3.12",
+ "Avalonia.Win32": "11.3.12",
+ "Avalonia.X11": "11.3.12"
+ }
+ },
+ "Avalonia.Diagnostics": {
+ "type": "Direct",
+ "requested": "[11.3.12, )",
+ "resolved": "11.3.12",
+ "contentHash": "fV+CTB/IDsFPqUVu5OQbpFLNeGLv9EmwxEjjuesJkzgT5R7mhkpLdZN3iWNC8gWkb2zfWG6mhu/q9jzDkiNhLA==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "Avalonia.Controls.ColorPicker": "11.3.12",
+ "Avalonia.Themes.Simple": "11.3.12"
+ }
+ },
+ "Avalonia.Fonts.Inter": {
+ "type": "Direct",
+ "requested": "[11.3.12, )",
+ "resolved": "11.3.12",
+ "contentHash": "Q28QGYnGbvrlTwg6md5U0sR8PuP7H77cysnJDR6a/hnCBH71/GPKxi4GGOKh2qFyo15XmvAwNZ+3QetfnOKSXw==",
+ "dependencies": {
+ "Avalonia": "11.3.12"
+ }
+ },
+ "Avalonia.Themes.Fluent": {
+ "type": "Direct",
+ "requested": "[11.3.12, )",
+ "resolved": "11.3.12",
+ "contentHash": "umclBVVjbKdbh6i+dAtbDlVIPS8A83S222fxgC1w0zqWvJrk9NwfFsnIQVBHxN/1hLPVMcUfp5Gxu2FOPWjDaQ==",
+ "dependencies": {
+ "Avalonia": "11.3.12"
+ }
+ },
+ "Avalonia.Angle.Windows.Natives": {
+ "type": "Transitive",
+ "resolved": "2.1.25547.20250602",
+ "contentHash": "ZL0VLc4s9rvNNFt19Pxm5UNAkmKNylugAwJPX9ulXZ6JWs/l6XZihPWWTyezaoNOVyEPU8YbURtW7XMAtqXH5A=="
+ },
+ "Avalonia.BuildServices": {
+ "type": "Transitive",
+ "resolved": "11.3.2",
+ "contentHash": "qHDToxto1e3hci5YqbG9n0Ty8mlp3zBUN5wT66wKqaDVzXyQ0do3EnRILd4Ke9jpvsktaPpgE0YjEk7hornryQ=="
+ },
+ "Avalonia.Controls.ColorPicker": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "NIqh2J3LUYpKvk+eeIc6jXcPWwuL/Dr5DQF6ZL3qRETkOhGdec1G7D9aMFwxltx0cLhXPnuSpYnKPIBp31OrHw==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "Avalonia.Remote.Protocol": "11.3.12"
+ }
+ },
+ "Avalonia.FreeDesktop": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "R1UdslorpUSmAt1SKNmmypkUPj993WpE4iUm5KvPd0mL0NQbIFra2DYYGb8GCtLOsupnA4pyNOU2FXumB2EGKA==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "Tmds.DBus.Protocol": "0.21.2"
+ }
+ },
+ "Avalonia.Native": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "28q2DUSGUBVRpEQWYBo0crokZabPyI7KmA68++nm/qAe/9Zxmxythk/F36swAkI4pIU2ouLIKK0yxiFBy+xvNw==",
+ "dependencies": {
+ "Avalonia": "11.3.12"
+ }
+ },
+ "Avalonia.Remote.Protocol": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "zaWTPaBKxGfHxqQfPh1WP+vWy3iVAwYWW/7FGlz63/wT1b+3b7Wn37H6c9C2E/M3cgllrW5/cirye516QUDZiA=="
+ },
+ "Avalonia.Skia": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "rlVMl2obc5hy4CHfLwA4+Lyu7KU+l5iSmj8leugoWofjgGDyUPa281VCo5FSH4+SkU1+EIXVJZubx2o02gp9nw==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "HarfBuzzSharp": "8.3.1.1",
+ "HarfBuzzSharp.NativeAssets.Linux": "8.3.1.1",
+ "HarfBuzzSharp.NativeAssets.WebAssembly": "8.3.1.1",
+ "SkiaSharp": "2.88.9",
+ "SkiaSharp.NativeAssets.Linux": "2.88.9",
+ "SkiaSharp.NativeAssets.WebAssembly": "2.88.9"
+ }
+ },
+ "Avalonia.Themes.Simple": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "Zubwo5oC2mjLGgHbkhqFIGnOLiPX6I8CfIBMknrhLH1YndKNSpm15o6jn5FASa+rshuBsylKA7iypEIPosXjWw==",
+ "dependencies": {
+ "Avalonia": "11.3.12"
+ }
+ },
+ "Avalonia.Win32": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "3Z8gSpWMU0NWR0fI/m8d9b6d9fms1MJ6eZJ7IU4CdU/zCrPiFTjtPfc2VRaRD/0H4tsR3VgP+iTMGZn5nBWljg==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "Avalonia.Angle.Windows.Natives": "2.1.25547.20250602"
+ }
+ },
+ "Avalonia.X11": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "HR0zf0si52uu/hxPTIOI7gW68kPwz8D/fPYgioxISXAR+Yf6BH/TY/F/zrlu3LbptqU3ySoUmqkA9QJpXz04BQ==",
+ "dependencies": {
+ "Avalonia": "11.3.12",
+ "Avalonia.FreeDesktop": "11.3.12",
+ "Avalonia.Skia": "11.3.12"
+ }
+ },
+ "HarfBuzzSharp": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "tLZN66oe/uiRPTZfrCU4i8ScVGwqHNh5MHrXj0yVf4l7Mz0FhTGnQ71RGySROTmdognAs0JtluHkL41pIabWuQ==",
+ "dependencies": {
+ "HarfBuzzSharp.NativeAssets.Win32": "8.3.1.1",
+ "HarfBuzzSharp.NativeAssets.macOS": "8.3.1.1"
+ }
+ },
+ "HarfBuzzSharp.NativeAssets.Linux": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "3EZ1mpIiKWRLL5hUYA82ZHteeDIVaEA/Z0rA/wU6tjx6crcAkJnBPwDXZugBSfo8+J3EznvRJf49uMsqYfKrHg=="
+ },
+ "HarfBuzzSharp.NativeAssets.macOS": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "jbtCsgftcaFLCA13tVKo5iWdElJScrulLTKJre36O4YQTIlwDtPPqhRZNk+Y0vv4D1gxbscasGRucUDfS44ofQ=="
+ },
+ "HarfBuzzSharp.NativeAssets.WebAssembly": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "loJweK2u/mH/3C2zBa0ggJlITIszOkK64HLAZB7FUT670dTg965whLFYHDQo69NmC4+d9UN0icLC9VHidXaVCA=="
+ },
+ "HarfBuzzSharp.NativeAssets.Win32": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "UsJtQsfAJoFDZrXc4hCUfRPMqccfKZ0iumJ/upcUjz/cmsTgVFGNEL5yaJWmkqsuFYdMWbj/En5/kS4PFl9hBA=="
+ },
+ "MicroCom.Runtime": {
+ "type": "Transitive",
+ "resolved": "0.11.0",
+ "contentHash": "MEnrZ3UIiH40hjzMDsxrTyi8dtqB5ziv3iBeeU4bXsL/7NLSal9F1lZKpK+tfBRnUoDSdtcW3KufE4yhATOMCA=="
+ },
+ "Microsoft.Data.Sqlite": {
+ "type": "Transitive",
+ "resolved": "10.0.13",
+ "contentHash": "w37nz3WFmDtRfXxWEwIXX2OgqDRiwhD1JGbFwfpFCF8GkCrV/yO6Y2JF5058J2RGoI2sCcdn02wrk0yEcekWcw==",
+ "dependencies": {
+ "Microsoft.Data.Sqlite.Core": "10.0.13",
+ "SQLitePCLRaw.bundle_e_sqlite3": "2.1.13",
+ "SQLitePCLRaw.core": "2.1.13"
+ }
+ },
+ "Microsoft.Data.Sqlite.Core": {
+ "type": "Transitive",
+ "resolved": "10.0.13",
+ "contentHash": "Gge8XsSCOwcbkbdmt2UDAe6kIv9Q0vA6yb3wsTStjjexaMFLTWfc/1gH4kbhJ+zWiXRTRA4lG2sOQNVfir204w==",
+ "dependencies": {
+ "SQLitePCLRaw.core": "2.1.13"
+ }
+ },
+ "SkiaSharp": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "3MD5VHjXXieSHCleRLuaTXmL2pD0mB7CcOB1x2kA1I4bhptf4e3R27iM93264ZYuAq6mkUyX5XbcxnZvMJYc1Q==",
+ "dependencies": {
+ "SkiaSharp.NativeAssets.Win32": "2.88.9",
+ "SkiaSharp.NativeAssets.macOS": "2.88.9"
+ }
+ },
+ "SkiaSharp.NativeAssets.Linux": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "cWSaJKVPWAaT/WIn9c8T5uT/l4ETwHxNJTkEOtNKjphNo8AW6TF9O32aRkxqw3l8GUdUo66Bu7EiqtFh/XG0Zg==",
+ "dependencies": {
+ "SkiaSharp": "2.88.9"
+ }
+ },
+ "SkiaSharp.NativeAssets.macOS": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "Nv5spmKc4505Ep7oUoJ5vp3KweFpeNqxpyGDWyeEPTX2uR6S6syXIm3gj75dM0YJz7NPvcix48mR5laqs8dPuA=="
+ },
+ "SkiaSharp.NativeAssets.WebAssembly": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "kt06RccBHSnAs2wDYdBSfsjIDbY3EpsOVqnlDgKdgvyuRA8ZFDaHRdWNx1VHjGgYzmnFCGiTJBnXFl5BqGwGnA=="
+ },
+ "SkiaSharp.NativeAssets.Win32": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "wb2kYgU7iy84nQLYZwMeJXixvK++GoIuECjU4ECaUKNuflyRlJKyiRhN1MAHswvlvzuvkrjRWlK0Za6+kYQK7w=="
+ },
+ "SQLitePCLRaw.bundle_e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "NlDixlC7uHmo+ojXRgkNvN0tQtVGpLDZ3x2OpgNj+G07VHh5cXSszFDrAiC4BpUiPwkcaeuQkMV9WQ123xVtmQ==",
+ "dependencies": {
+ "SQLitePCLRaw.lib.e_sqlite3": "2.1.13",
+ "SQLitePCLRaw.provider.e_sqlite3": "2.1.13"
+ }
+ },
+ "SQLitePCLRaw.core": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "2joofoinuHBFs0nMX3nKuXgxpXryRkCOdM2Ua6HBqQLLy6IW+5f28ZI+HAvMyF8vG7XfNz/lwfBfE6V4juru8Q=="
+ },
+ "SQLitePCLRaw.lib.e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "D2UAuiGxFYBqeRXjjjGgvJ5UQifzn6wefmSqeKU7XcNGKLbJRP6X7kcPZ6opOBJGdCIlgbSxTvDpBbLvsN594A=="
+ },
+ "SQLitePCLRaw.provider.e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "ZU60dSqoSNRe49KcQDUmOVgdRtjITOssVXFtiISs+zJXDI4D2Sndwpn2NOtzDQNPu0ZAvpoLPQ+GLKv6iEZn8Q==",
+ "dependencies": {
+ "SQLitePCLRaw.core": "2.1.13"
+ }
+ },
+ "Tmds.DBus.Protocol": {
+ "type": "Transitive",
+ "resolved": "0.21.2",
+ "contentHash": "ScSMrUrrw8px4kK1Glh0fZv/HQUlg1078bNXNPfRPKQ3WbRzV9HpsydYEOgSoMK5LWICMf2bMwIFH0pGjxjcMA=="
+ },
+ "codextpsfloat.core": {
+ "type": "Project",
+ "dependencies": {
+ "Microsoft.Data.Sqlite": "[10.0.13, )"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Core/SingleInstance.cs b/src/Core/SingleInstance.cs
new file mode 100644
index 0000000..5f00f88
--- /dev/null
+++ b/src/Core/SingleInstance.cs
@@ -0,0 +1,190 @@
+using System;
+using System.IO;
+using System.Net.Sockets;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace CodexTpsFloat;
+
+///
+/// Keeps one panel per user and wakes the running instance on a second launch.
+/// Windows uses named synchronization objects; Unix uses a Unix domain socket
+/// because .NET does not support named event wait handles on those platforms.
+///
+public sealed class SingleInstance : IDisposable
+{
+ readonly Mutex mutex;
+ readonly bool ownsMutex;
+ readonly EventWaitHandle? windowsWake;
+ readonly RegisteredWaitHandle? windowsRegistration;
+ readonly Socket? unixListener;
+ readonly string? unixSocketPath;
+ readonly CancellationTokenSource? unixCancellation;
+ readonly Task? unixAcceptLoop;
+ bool disposed;
+
+ SingleInstance(Mutex mutex, bool ownsMutex,
+ EventWaitHandle? windowsWake = null,
+ RegisteredWaitHandle? windowsRegistration = null,
+ Socket? unixListener = null,
+ string? unixSocketPath = null,
+ CancellationTokenSource? unixCancellation = null,
+ Task? unixAcceptLoop = null)
+ {
+ this.mutex = mutex;
+ this.ownsMutex = ownsMutex;
+ this.windowsWake = windowsWake;
+ this.windowsRegistration = windowsRegistration;
+ this.unixListener = unixListener;
+ this.unixSocketPath = unixSocketPath;
+ this.unixCancellation = unixCancellation;
+ this.unixAcceptLoop = unixAcceptLoop;
+ }
+
+ public bool IsFirstInstance => ownsMutex;
+
+ public static SingleInstance Create(string name, Action? showExisting = null)
+ {
+ string scopedName = OperatingSystem.IsWindows()
+ ? name
+ : $"CodexTpsFloat.{Environment.UserName}.{name}";
+ var mutex = new Mutex(true, scopedName + ".Panel", out bool first);
+ try
+ {
+ return OperatingSystem.IsWindows()
+ ? CreateWindows(mutex, first, scopedName, showExisting)
+ : CreateUnix(mutex, first, scopedName, showExisting);
+ }
+ catch
+ {
+ if (first) mutex.ReleaseMutex();
+ mutex.Dispose();
+ throw;
+ }
+ }
+
+ static SingleInstance CreateWindows(Mutex mutex, bool first, string scopedName,
+ Action? showExisting)
+ {
+ var wake = new EventWaitHandle(false, EventResetMode.AutoReset, scopedName + ".Show");
+ RegisteredWaitHandle? registration = null;
+ if (first && showExisting != null)
+ registration = ThreadPool.RegisterWaitForSingleObject(wake,
+ (_, _) => showExisting(), null, Timeout.Infinite, false);
+ return new(mutex, first, wake, registration);
+ }
+
+ static SingleInstance CreateUnix(Mutex mutex, bool first, string scopedName,
+ Action? showExisting)
+ {
+ string socketPath = Path.Combine(Path.GetTempPath(), scopedName + ".sock");
+ Socket? listener = null;
+ CancellationTokenSource? cancellation = null;
+ Task? acceptLoop = null;
+ if (first)
+ {
+ try
+ {
+ if (File.Exists(socketPath)) File.Delete(socketPath);
+ listener = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
+ listener.Bind(new UnixDomainSocketEndPoint(socketPath));
+ listener.Listen(1);
+ cancellation = new CancellationTokenSource();
+ if (showExisting != null)
+ acceptLoop = AcceptConnectionsAsync(listener, cancellation.Token, showExisting);
+ }
+ catch (Exception e) when (e is SocketException or IOException
+ or UnauthorizedAccessException)
+ {
+ listener?.Dispose();
+ listener = null;
+ cancellation?.Dispose();
+ cancellation = null;
+ }
+ }
+ return new(mutex, first, unixListener: listener, unixSocketPath: socketPath,
+ unixCancellation: cancellation, unixAcceptLoop: acceptLoop);
+ }
+
+ static async Task AcceptConnectionsAsync(Socket listener, CancellationToken cancellation,
+ Action showExisting)
+ {
+ while (!cancellation.IsCancellationRequested)
+ {
+ Socket connection;
+ try
+ {
+ connection = await listener.AcceptAsync(cancellation);
+ }
+ catch (Exception e) when (e is OperationCanceledException or ObjectDisposedException
+ or SocketException)
+ {
+ return;
+ }
+
+ using (connection)
+ {
+ try
+ {
+ var buffer = new byte[1];
+ await connection.ReceiveAsync(buffer, SocketFlags.None, cancellation);
+ showExisting();
+ }
+ catch (Exception e) when (e is OperationCanceledException or ObjectDisposedException
+ or SocketException)
+ {
+ return;
+ }
+ }
+ }
+ }
+
+ public void SignalExistingInstance()
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ windowsWake?.Set();
+ return;
+ }
+
+ if (unixSocketPath == null) return;
+ using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
+ for (int attempt = 0; attempt < 20; attempt++)
+ {
+ try
+ {
+ socket.Connect(new UnixDomainSocketEndPoint(unixSocketPath));
+ socket.Send(new byte[] { 1 });
+ return;
+ }
+ catch (SocketException) when (attempt < 19)
+ {
+ Thread.Sleep(25);
+ }
+ catch (SocketException)
+ {
+ return;
+ }
+ }
+ }
+
+ public void Dispose()
+ {
+ if (disposed) return;
+ disposed = true;
+ windowsRegistration?.Unregister(null);
+ windowsWake?.Dispose();
+ unixCancellation?.Cancel();
+ unixListener?.Dispose();
+ if (unixAcceptLoop != null)
+ {
+ try { unixAcceptLoop.GetAwaiter().GetResult(); }
+ catch (OperationCanceledException) { }
+ }
+ unixCancellation?.Dispose();
+ if (ownsMutex && unixSocketPath != null && File.Exists(unixSocketPath))
+ File.Delete(unixSocketPath);
+ if (ownsMutex) mutex.ReleaseMutex();
+ mutex.Dispose();
+ }
+}
From c66a7bebe8ce09606d2a37065f51359ccb51c237 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:12:40 +0800
Subject: [PATCH 07/49] build: Make the Avalonia app the release entry point
---
Directory.Build.props | 5 +++++
src/App/CodexTpsFloat.App.csproj | 1 -
src/CodexTpsFloat.csproj | 3 ++-
3 files changed, 7 insertions(+), 2 deletions(-)
create mode 100644 Directory.Build.props
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..5a54b72
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ 1.1.3
+
+
diff --git a/src/App/CodexTpsFloat.App.csproj b/src/App/CodexTpsFloat.App.csproj
index 599275c..176fe93 100644
--- a/src/App/CodexTpsFloat.App.csproj
+++ b/src/App/CodexTpsFloat.App.csproj
@@ -11,7 +11,6 @@
true
true
true
- 1.2.0
diff --git a/src/CodexTpsFloat.csproj b/src/CodexTpsFloat.csproj
index 101aac0..6a9e4d9 100644
--- a/src/CodexTpsFloat.csproj
+++ b/src/CodexTpsFloat.csproj
@@ -7,7 +7,8 @@
disable
enable
CodexTpsFloat
- 1.1.3
+ false
+ false
true
app.manifest
true
From 480a093e88d68badfe0765d840ced7e4090588e4 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:14:49 +0800
Subject: [PATCH 08/49] build: Publish the Avalonia app through cross-platform
build scripts
---
build.ps1 | 21 ++++++++++++++++-----
build.sh | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 5 deletions(-)
create mode 100755 build.sh
diff --git a/build.ps1 b/build.ps1
index 1dea532..d189e30 100644
--- a/build.ps1
+++ b/build.ps1
@@ -1,10 +1,21 @@
-param([switch]$Portable)
+param(
+ [string]$Runtime = "win-x64",
+ [switch]$Portable
+)
$ErrorActionPreference = 'Stop'
$taskRoot = $PSScriptRoot
+$arguments = @(
+ 'publish', (Join-Path $taskRoot 'src/App/CodexTpsFloat.App.csproj'),
+ '-c', 'Release', '-r', $Runtime, '--self-contained', 'true',
+ '-o', (Join-Path $taskRoot 'app')
+)
if ($Portable) {
- # The download ZIP provides compression; leave assemblies uncompressed so they do not need private decompression buffers at runtime.
- dotnet publish (Join-Path $taskRoot 'src/CodexTpsFloat.csproj') -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=false -o (Join-Path $taskRoot 'app')
-} else {
- dotnet publish (Join-Path $taskRoot 'src/CodexTpsFloat.csproj') -c Release -o (Join-Path $taskRoot 'app')
+ # The download archive provides compression; leave assemblies uncompressed so they do not need private decompression buffers at runtime.
+ $arguments += @(
+ '-p:PublishSingleFile=true',
+ '-p:IncludeNativeLibrariesForSelfExtract=true',
+ '-p:EnableCompressionInSingleFile=false'
+ )
}
+dotnet @arguments
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..b358b48
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+runtime="${1:-}"
+portable="${PORTABLE:-0}"
+
+if [[ -z "$runtime" ]]; then
+ case "$(uname -s)-$(uname -m)" in
+ Darwin-arm64) runtime="osx-arm64" ;;
+ Darwin-x86_64) runtime="osx-x64" ;;
+ Linux-x86_64) runtime="linux-x64" ;;
+ Linux-aarch64) runtime="linux-arm64" ;;
+ *)
+ echo "Unable to infer a .NET runtime identifier; pass one as the first argument." >&2
+ exit 2
+ ;;
+ esac
+fi
+
+arguments=(
+ publish "$root/src/App/CodexTpsFloat.App.csproj"
+ -c Release
+ -r "$runtime"
+ --self-contained true
+ -o "$root/app"
+)
+
+if [[ "$portable" == "1" ]]; then
+ # The download archive provides compression; leave assemblies uncompressed so they do not need private decompression buffers at runtime.
+ arguments+=(
+ -p:PublishSingleFile=true
+ -p:IncludeNativeLibrariesForSelfExtract=true
+ -p:EnableCompressionInSingleFile=false
+ )
+fi
+
+dotnet "${arguments[@]}"
From 9e7716961f665186e20b042fa97f8d9bc0feafe6 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:17:51 +0800
Subject: [PATCH 09/49] ci: Build tagged releases for Windows, macOS, and Linux
---
.github/workflows/release.yml | 127 +++++++++++++++++++++++++++++-----
1 file changed, 109 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index ef2d491..9727f9e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,4 +1,4 @@
-name: Release portable Windows app
+name: Release cross-platform app
on:
push:
@@ -13,12 +13,9 @@ concurrency:
cancel-in-progress: false
jobs:
- release:
- runs-on: windows-latest
+ validate:
+ runs-on: ubuntu-latest
timeout-minutes: 20
- defaults:
- run:
- shell: pwsh
steps:
- name: Check out tagged source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -30,30 +27,69 @@ jobs:
- name: Check tag matches application version
run: |
- [xml]$project = Get-Content src/CodexTpsFloat.csproj -Raw
- $version = $project.Project.PropertyGroup.Version
- if ($env:GITHUB_REF_NAME -cne "v$version") {
- throw "Tag $env:GITHUB_REF_NAME does not match application version v$version."
- }
+ version="$(dotnet msbuild src/App/CodexTpsFloat.App.csproj -nologo -getProperty:Version)"
+ test "$GITHUB_REF_NAME" = "v$version"
+
+ - name: Run core regression tests
+ run: dotnet run --project tests/CoreTests.csproj -c Release --nologo
+
+ release:
+ needs: validate
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - runner: windows-latest
+ runtime: win-x64
+ shell: pwsh
+ - runner: macos-14
+ runtime: osx-arm64
+ shell: bash
+ - runner: macos-14
+ runtime: osx-x64
+ shell: bash
+ - runner: ubuntu-latest
+ runtime: linux-x64
+ shell: bash
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 30
+ defaults:
+ run:
+ shell: ${{ matrix.shell }}
+ steps:
+ - name: Check out tagged source
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Set up .NET 10
+ uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
+ with:
+ dotnet-version: '10.0.x'
- name: Run core regression tests
run: dotnet run --project tests/CoreTests.csproj -c Release --nologo
- - name: Run hidden tray lifecycle tests
+ - name: Run hidden tray lifecycle tests (Windows only)
+ if: runner.os == 'Windows'
run: dotnet run --project tests/TrayLifecycleTests.csproj -c Release --nologo -- --never-show
- name: Build portable application
- run: ./build.ps1 -Portable
+ if: runner.os == 'Windows'
+ run: ./build.ps1 -Runtime ${{ matrix.runtime }} -Portable
+
+ - name: Build portable application
+ if: runner.os != 'Windows'
+ run: PORTABLE=1 ./build.sh ${{ matrix.runtime }}
- - name: Package portable ZIP and checksum
+ - name: Package portable archive and checksum
id: package
+ if: runner.os == 'Windows'
run: |
$assetDirectory = Join-Path $env:RUNNER_TEMP 'release-assets'
$stagingDirectory = Join-Path $env:RUNNER_TEMP 'portable-package'
New-Item -ItemType Directory -Path $assetDirectory, $stagingDirectory | Out-Null
Copy-Item -LiteralPath 'app/CodexTpsFloat.exe', 'README.md', 'PRIVACY.md', 'THIRD-PARTY-NOTICES.md' -Destination $stagingDirectory
Copy-Item -LiteralPath 'licenses' -Destination $stagingDirectory -Recurse
- $archiveName = "CodexTpsFloat-$env:GITHUB_REF_NAME-win-x64-portable.zip"
+ $archiveName = "CodexTpsFloat-$env:GITHUB_REF_NAME-${{ matrix.runtime }}-portable.zip"
$archivePath = Join-Path $assetDirectory $archiveName
Compress-Archive -Path "$stagingDirectory/*" -DestinationPath $archivePath -CompressionLevel Optimal
$hash = (Get-FileHash -LiteralPath $archivePath -Algorithm SHA256).Hash.ToLowerInvariant()
@@ -61,7 +97,24 @@ jobs:
"directory=$assetDirectory" >> $env:GITHUB_OUTPUT
"archive=$archivePath" >> $env:GITHUB_OUTPUT
+ - name: Package portable archive and checksum
+ id: package_unix
+ if: runner.os != 'Windows'
+ run: |
+ asset_directory="$RUNNER_TEMP/release-assets"
+ staging_directory="$RUNNER_TEMP/portable-package"
+ mkdir -p "$asset_directory" "$staging_directory"
+ cp app/CodexTpsFloat README.md PRIVACY.md THIRD-PARTY-NOTICES.md "$staging_directory/"
+ cp -R licenses "$staging_directory/"
+ archive_name="CodexTpsFloat-$GITHUB_REF_NAME-${{ matrix.runtime }}-portable.tar.gz"
+ archive_path="$asset_directory/$archive_name"
+ tar -czf "$archive_path" -C "$staging_directory" .
+ (cd "$asset_directory" && shasum -a 256 "$archive_name" > "$archive_name.sha256")
+ echo "directory=$asset_directory" >> "$GITHUB_OUTPUT"
+ echo "archive=$archive_path" >> "$GITHUB_OUTPUT"
+
- name: Smoke test extracted portable application
+ if: runner.os == 'Windows'
env:
PORTABLE_ARCHIVE: ${{ steps.package.outputs.archive }}
run: |
@@ -88,11 +141,49 @@ jobs:
throw 'Portable snapshot incorrectly reports an aborted session as unsupported.'
}
+ - name: Smoke test extracted portable application
+ if: runner.os != 'Windows'
+ env:
+ PORTABLE_ARCHIVE: ${{ steps.package_unix.outputs.archive }}
+ run: |
+ smoke_directory="$RUNNER_TEMP/portable-smoke"
+ fixture_directory="$RUNNER_TEMP/fixture-codex-home"
+ session_directory="$fixture_directory/sessions"
+ mkdir -p "$smoke_directory" "$session_directory"
+ tar -xzf "$PORTABLE_ARCHIVE" -C "$smoke_directory"
+ cat > "$session_directory/aborted.jsonl" <<'EOF'
+ {"type":"event_msg","timestamp":"2026-10-14T00:00:00Z","payload":{"type":"task_started","turn_id":"smoke-turn"}}
+ {"type":"event_msg","timestamp":"2026-10-14T00:00:01Z","payload":{"type":"token_count","info":null}}
+ {"type":"event_msg","timestamp":"2026-10-14T00:00:02Z","payload":{"type":"turn_aborted","turn_id":"smoke-turn"}}
+ EOF
+ snapshot_path="$RUNNER_TEMP/portable-snapshot.json"
+ "$smoke_directory/CodexTpsFloat" --codex-home "$fixture_directory" --snapshot-json "$snapshot_path"
+ python3 - "$snapshot_path" <<'PY'
+ import json, sys
+ snapshot = json.load(open(sys.argv[1]))
+ if (snapshot["Files"], snapshot["InvalidLines"], snapshot["UnsupportedFiles"], snapshot["ReadFailures"]) != (1, 0, 0, 0):
+ raise SystemExit("Portable snapshot incorrectly reports an aborted session as unsupported.")
+ PY
+
+ - name: Upload release artifact
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: CodexTpsFloat-${{ github.ref_name }}-${{ matrix.runtime }}
+ path: ${{ runner.os == 'Windows' && steps.package.outputs.directory || steps.package_unix.outputs.directory }}
+
+ publish:
+ needs: release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Download release artifacts
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
+ with:
+ path: release-assets
+ merge-multiple: true
+
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
- RELEASE_ASSET_DIRECTORY: ${{ steps.package.outputs.directory }}
run: |
- $assets = @(Get-ChildItem -LiteralPath $env:RELEASE_ASSET_DIRECTORY -File | Select-Object -ExpandProperty FullName)
- gh release create $env:GITHUB_REF_NAME @assets --verify-tag --title "Codex TPS $env:GITHUB_REF_NAME" --notes-from-tag --latest
+ gh release create "$GITHUB_REF_NAME" release-assets/* --verify-tag --title "Codex TPS $GITHUB_REF_NAME" --notes-from-tag --latest
From cff32fb6c9a3395a0f20c131eb0f901cf34bb238 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:20:16 +0800
Subject: [PATCH 10/49] fix: Cover cross-platform single-instance wakeups
---
src/Core/SingleInstance.cs | 13 ++++++++++++-
tests/Program.cs | 11 ++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/Core/SingleInstance.cs b/src/Core/SingleInstance.cs
index 5f00f88..00b9c50 100644
--- a/src/Core/SingleInstance.cs
+++ b/src/Core/SingleInstance.cs
@@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Net.Sockets;
+using System.Security.Cryptography;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -77,7 +79,7 @@ static SingleInstance CreateWindows(Mutex mutex, bool first, string scopedName,
static SingleInstance CreateUnix(Mutex mutex, bool first, string scopedName,
Action? showExisting)
{
- string socketPath = Path.Combine(Path.GetTempPath(), scopedName + ".sock");
+ string socketPath = UnixSocketPath(scopedName);
Socket? listener = null;
CancellationTokenSource? cancellation = null;
Task? acceptLoop = null;
@@ -106,6 +108,15 @@ static SingleInstance CreateUnix(Mutex mutex, bool first, string scopedName,
unixCancellation: cancellation, unixAcceptLoop: acceptLoop);
}
+ static string UnixSocketPath(string scopedName)
+ {
+ // Unix domain socket paths are limited to roughly 100 bytes. Keep the
+ // temporary path bounded even when the logical instance name is long.
+ string hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(scopedName)))
+ .ToLowerInvariant();
+ return Path.Combine(Path.GetTempPath(), $"CodexTpsFloat-{hash[..16]}.sock");
+ }
+
static async Task AcceptConnectionsAsync(Socket listener, CancellationToken cancellation,
Action showExisting)
{
diff --git a/tests/Program.cs b/tests/Program.cs
index ddb173f..f0d4b64 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -188,6 +188,15 @@ static void Seed(UsageScanner s, double t = origin)
: entryText.Contains("Exec=\"/opt/codex tps/CodexTpsFloat\"") && entryText.StartsWith("[Desktop Entry]"),
"登录启动条目包含可执行路径与自启标记");
Check(login.SetEnabled(false) == null && !login.IsEnabled() && !File.Exists(entry), "停用登录启动会移除条目");
+
+ string instanceName = "codex-tps-test-" + Guid.NewGuid().ToString("N") + new string('x', 80);
+ using var existingInstance = new ManualResetEventSlim(false);
+ using var firstInstance = SingleInstance.Create(instanceName, () => existingInstance.Set());
+ Check(firstInstance.IsFirstInstance, "首个单实例进程获得所有权");
+ using var secondInstance = SingleInstance.Create(instanceName);
+ Check(!secondInstance.IsFirstInstance, "第二个进程不会重复启动界面");
+ secondInstance.SignalExistingInstance();
+ Check(existingInstance.Wait(TimeSpan.FromSeconds(5)), "第二个进程会唤醒已有实例");
}
finally { Directory.Delete(directory, true); }
-Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、等长重写、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行、旧格式告警、设置往返、报告导出与登录启动。");
+Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、等长重写、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行、旧格式告警、设置往返、报告导出、登录启动与单实例唤醒。");
From ca9332aab6aed589a5d9d22a41224ab9e0d5efc6 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:20:49 +0800
Subject: [PATCH 11/49] docs: Document cross-platform installation and builds
---
PRIVACY.md | 2 +-
README.md | 47 +++++++++++++++++++++++++++++++++++------------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/PRIVACY.md b/PRIVACY.md
index 4b25c2d..c439dd6 100644
--- a/PRIVACY.md
+++ b/PRIVACY.md
@@ -2,7 +2,7 @@
应用在本机只读 Codex 日志,不调用网络服务,也不上传提示词、回答正文或凭据。日志解析只保留统计所需的结构字段和用量计数。运行过程会短暂读取日志文本,但不会将正文保存在报告或本工具的持久化数据中。
-本机 `app/data/settings.json` 包含日志目录、窗口位置和界面偏好,可能含用户名或目录信息。程序目录中的真实预览图和实机验收记录可能包含使用时间、用量、文件数量等信息。
+本机设置文件包含日志目录、窗口位置和界面偏好,可能含用户名或目录信息。Windows 便携版的设置位于程序旁的 `data/settings.json`;macOS 和 Linux 使用用户的应用程序数据目录下的 `CodexTpsFloat/settings.json`。源码目录中的真实预览图和实机验收记录可能包含使用时间、用量、文件数量等信息。
这些内容已由 `.gitignore` 排除:运行程序与本机配置、构建缓存、真实预览图、实机验收记录、日志、数据库及导出报告。仓库只保存源码、依赖锁文件、构建脚本、通用测试和文档。
diff --git a/README.md b/README.md
index 1382f2f..1f9b1e0 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,23 @@
# Codex TPS 中文悬浮窗
-Windows 10/11 x64 的本机日志监视工具,默认运行在系统托盘,不显示任务栏窗口按钮。白色圆角面板参考 [codex-tps-panel.png](https://github.com/gaofeng21cn/codex-tps/blob/main/docs/assets/codex-tps-panel.png),代码为独立实现。
+Windows、macOS 和 Linux 的本机日志监视工具,默认运行在系统托盘,不显示任务栏窗口按钮。白色圆角面板参考 [codex-tps-panel.png](https://github.com/gaofeng21cn/codex-tps/blob/main/docs/assets/codex-tps-panel.png),代码为独立实现。
## 使用
-从 [GitHub Releases](https://github.com/jinghero/CodexTpsFloat/releases/latest) 下载 `CodexTpsFloat-v版本号-win-x64-portable.zip`,解压后双击 `CodexTpsFloat.exe`。便携版包含运行时,不需要安装 Python 或 .NET,不需要管理员权限。请下载便携 ZIP;GitHub 自动附带的 `Source code` 压缩包只包含源码。
+从 [GitHub Releases](https://github.com/jinghero/CodexTpsFloat/releases/latest) 选择适合当前系统的附件:
-GitHub 源码仓库不包含可执行文件和本机运行数据。克隆源码后,使用 .NET 10 SDK 运行 `./build.ps1 -Portable` 生成 `app/CodexTpsFloat.exe`。Release 附件同时提供便携 ZIP 的 `.sha256` 校验文件。隐私与提交范围见 [PRIVACY.md](PRIVACY.md)。
+| 系统 | 附件 | 启动文件 |
+|---|---|---|
+| Windows x64 | `CodexTpsFloat-v版本号-win-x64-portable.zip` | `CodexTpsFloat.exe` |
+| macOS Apple 芯片 | `CodexTpsFloat-v版本号-osx-arm64-portable.tar.gz` | `CodexTpsFloat` |
+| macOS Intel | `CodexTpsFloat-v版本号-osx-x64-portable.tar.gz` | `CodexTpsFloat` |
+| Linux x64 | `CodexTpsFloat-v版本号-linux-x64-portable.tar.gz` | `CodexTpsFloat` |
-便携构建使用单文件 EXE,关闭 EXE 内部的程序集压缩,以减少运行时解压所需的内存;下载时由外层 ZIP 压缩。解压后的 EXE 文件较大,其中包含 .NET 和 Windows Desktop 运行时。
+压缩包包含运行时,不需要安装 Python 或 .NET,不需要管理员权限。请下载对应的便携包;GitHub 自动附带的 `Source code` 压缩包只包含源码。Release 附件同时提供压缩包的 `.sha256` 校验文件。隐私与提交范围见 [PRIVACY.md](PRIVACY.md)。
+
+macOS 首次运行时如果被 Gatekeeper 阻止,请在 Finder 中右键 `CodexTpsFloat` 选择「打开」,或前往「系统设置」>「隐私与安全性」允许运行。便携包没有代码签名。
+
+便携构建使用单文件程序,并关闭内部程序集压缩,以减少运行时解压所需的内存;下载时由外层压缩包压缩。解压后的程序较大,其中包含 .NET 运行时及各平台的界面依赖。
- 默认读取 `CODEX_HOME`;未设置时读取当前用户的 `.codex`。同时统计 `sessions` 与 `archived_sessions`。
- 启动后只显示系统托盘图标;悬停显示当前生成速度估算。单击图标打开或收起统计面板,右键可打开面板、立即刷新或退出。面板展开时也不出现任务栏窗口按钮。
@@ -17,7 +26,7 @@ GitHub 源码仓库不包含可执行文件和本机运行数据。克隆源码
- 展开「今日分时」,可以选择其他日期并导出中文 Markdown 或 JSON 报告。时区固定为北京时间 UTC+8。
- 「设置」可以选择数据目录。选择包含 `sessions` 的 `.codex` 目录,而不是 `sessions` 自身。
- 「登录启动」默认关闭,仅在手动勾选后设置当前用户的启动项。取消勾选即可移除。
-- 第二次启动会打开已有统计面板,不重复运行监视进程。关闭面板前尚未打开过它,也可以从托盘菜单正常退出。窗口位置、刷新周期、置顶和时间窗口保存在程序旁的 `data/settings.json`。
+- 第二次启动会打开已有统计面板,不重复运行监视进程。关闭面板前尚未打开过它,也可以从托盘菜单正常退出。Windows 的设置保存在程序旁的 `data/settings.json`;macOS 和 Linux 保存在用户配置目录,避免系统级安装目录不可写。
## 数字的含义
@@ -37,7 +46,7 @@ GitHub 源码仓库不包含可执行文件和本机运行数据。克隆源码
如果当前数据目录存在 `logs_*.sqlite`,以只读方式增量读取请求鉴权边界,用于排除失败尝试遗留的输出项。诊断库缺失、被锁定或格式不兼容时仍可使用 JSONL 输出项计时,状态提示中说明降级。边界日志可能已过期,因此仍是估算值。
-输出不保存提示词或回答正文。配置写入程序旁目录,导出报告的位置由保存对话框选择。若程序目录只读,统计仍可运行,但设置无法保存。
+输出不保存提示词或回答正文。导出报告的位置由保存对话框选择。Windows 配置写入程序旁目录;macOS 和 Linux 写入用户配置目录。
可用于脚本的单次快照:
@@ -46,22 +55,36 @@ GitHub 源码仓库不包含可执行文件和本机运行数据。克隆源码
.\app\CodexTpsFloat.exe --codex-home 'D:\CodexData' --snapshot-json .\snapshot.json
```
+macOS 或 Linux 使用相同参数:
+
+```bash
+./app/CodexTpsFloat --snapshot-json ./snapshot.json
+./app/CodexTpsFloat --codex-home /path/to/.codex --snapshot-json ./snapshot.json
+```
+
退出码:`0` 成功;`1` 读取或写入失败;`2` 参数错误;`3` 未找到会话日志。快照模式独立执行,JSON 包含四个滚动窗口和今日分时汇总,不包含正文。
-从源码构建需要 .NET 10 SDK:
+GitHub 源码仓库不包含可执行文件和本机运行数据。从源码构建需要 .NET 10 SDK。Windows 使用 PowerShell:
```powershell
dotnet run --project .\tests\CoreTests.csproj -c Release
-dotnet run --project .\tests\TrayLifecycleTests.csproj -c Release
dotnet run --project .\tests\TrayLifecycleTests.csproj -c Release -- --never-show
-.\build.ps1 -Portable
+.\build.ps1 -Runtime win-x64 -Portable
+```
+
+macOS 和 Linux 使用 Bash,架构会从当前系统推断,也可以显式传入 RID:
+
+```bash
+dotnet run --project tests/CoreTests.csproj -c Release
+./build.sh osx-arm64
+PORTABLE=1 ./build.sh linux-x64
```
-源码中的 `--capture 文件.png` 用于界面验收,生成真实 WPF 控件渲染图后退出。便携 EXE 未进行 Authenticode 签名。
+源码中的 `--capture 文件.png` 用于界面验收,生成真实 Avalonia 控件渲染图后退出。Windows 便携 EXE 未进行 Authenticode 签名,macOS 便携程序未进行代码签名或公证。
## 发布新版本
-先修改 `src/CodexTpsFloat.csproj` 中的 `Version` 并提交、推送,再创建对应的 `v版本号` 标签。以下示例用于下一个补丁版本;标签说明会成为 Release 说明:
+先修改 `Directory.Build.props` 中的 `Version` 并提交、推送,再创建对应的 `v版本号` 标签。以下示例用于下一个补丁版本;标签说明会成为 Release 说明:
```powershell
git push origin main
@@ -69,4 +92,4 @@ git tag -a v1.1.4 -m "Release v1.1.4"
git push origin v1.1.4
```
-推送标签后,GitHub Actions 会校验标签与项目版本一致,运行核心和隐藏托盘生命周期测试,调用 `build.ps1 -Portable` 构建 Windows x64 便携版,打包并验证解压后的程序,最后创建公开 Release 并上传 ZIP 和 SHA-256 校验文件。打包只包含程序、README、隐私说明和第三方许可证,不包含本机设置、日志或调试符号。
+推送标签后,GitHub Actions 会校验标签与项目版本一致,运行核心测试;Windows 额外运行隐藏托盘生命周期测试。发布矩阵构建 Windows x64、macOS ARM64、macOS x64 和 Linux x64 便携包,解压后执行快照 smoke test,并生成 SHA-256 校验文件。全部平台成功后,工作流创建公开 Release 并上传所有压缩包与校验文件。打包只包含程序、README、隐私说明和第三方许可证,不包含本机设置、日志或调试符号。
From 612397c2cad0cfcf020f0a8b3c1d3e68606f1177 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:24:36 +0800
Subject: [PATCH 12/49] style: Remove trailing blank line from Avalonia entry
point
---
src/App/Program.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/App/Program.cs b/src/App/Program.cs
index bcb0482..e180085 100644
--- a/src/App/Program.cs
+++ b/src/App/Program.cs
@@ -63,4 +63,3 @@ public sealed record CommandLineOptions(string? CapturePath, string? CodexHome,
return new(capture, home, snapshot);
}
}
-
From bc097727b22c5d8e0555b3e2956f8c023b239595 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:31:16 +0800
Subject: [PATCH 13/49] docs: Add cross-platform third-party notices
---
THIRD-PARTY-NOTICES.md | 8 +-
licenses/ANGLE-BSD.txt | 32 +
licenses/Avalonia-MIT.txt | 22 +
licenses/Inter-OFL-1.1.txt | 92 +
licenses/MicroCom.Runtime-MIT.txt | 21 +
licenses/SkiaSharp-HarfBuzzSharp-MIT.txt | 19 +
...harp-HarfBuzzSharp-THIRD-PARTY-NOTICES.txt | 2716 +++++++++++++++++
licenses/Tmds.DBus.Protocol-MIT.txt | 22 +
8 files changed, 2931 insertions(+), 1 deletion(-)
create mode 100644 licenses/ANGLE-BSD.txt
create mode 100644 licenses/Avalonia-MIT.txt
create mode 100644 licenses/Inter-OFL-1.1.txt
create mode 100644 licenses/MicroCom.Runtime-MIT.txt
create mode 100644 licenses/SkiaSharp-HarfBuzzSharp-MIT.txt
create mode 100644 licenses/SkiaSharp-HarfBuzzSharp-THIRD-PARTY-NOTICES.txt
create mode 100644 licenses/Tmds.DBus.Protocol-MIT.txt
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 072d0b8..9908adf 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -4,7 +4,13 @@
便携构建包含以下运行组件:
-- .NET 10 与 Windows Desktop 运行时:Microsoft / .NET Foundation,MIT 及其第三方许可。完整声明见 `licenses/dotnet-MIT.txt` 和 `licenses/dotnet-THIRD-PARTY-NOTICES.txt`。
+- .NET 10 运行时:Microsoft / .NET Foundation,MIT 及其第三方许可。完整声明见 `licenses/dotnet-MIT.txt` 和 `licenses/dotnet-THIRD-PARTY-NOTICES.txt`。
+- Avalonia 11.3.12 桌面 UI 组件:AvaloniaUI OÜ / The AvaloniaUI Project,MIT 许可,项目 https://github.com/AvaloniaUI/Avalonia 。许可全文见 `licenses/Avalonia-MIT.txt`。
+- SkiaSharp 2.88.9 与 HarfBuzzSharp 8.3.1.1:Xamarin / Microsoft,MIT 许可及其第三方许可,项目 https://github.com/mono/SkiaSharp 。许可全文见 `licenses/SkiaSharp-HarfBuzzSharp-MIT.txt`,第三方声明见 `licenses/SkiaSharp-HarfBuzzSharp-THIRD-PARTY-NOTICES.txt`。
+- Tmds.DBus.Protocol 0.21.2:Tom Deseyn 及贡献者,MIT 许可,项目 https://github.com/tmds/Tmds.DBus 。许可全文见 `licenses/Tmds.DBus.Protocol-MIT.txt`。
+- MicroCom.Runtime 0.11.0:Nikita Tsukanov,MIT 许可,项目 https://github.com/kekekeks/MicroCom 。许可全文见 `licenses/MicroCom.Runtime-MIT.txt`。
+- ANGLE(Avalonia Angle Windows Natives 2.1.25547.20250602):The ANGLE Project Authors,BSD 许可,项目 https://github.com/AvaloniaUI/angle 。许可全文见 `licenses/ANGLE-BSD.txt`。
+- Inter 字体(通过 Avalonia.Fonts.Inter 分发):The Inter Project Authors,SIL Open Font License 1.1,项目 https://github.com/rsms/inter 。该 NuGet 包元数据采用 MIT 许可,字体本身按 OFL 1.1 分发;字体许可全文见 `licenses/Inter-OFL-1.1.txt`。
- Microsoft.Data.Sqlite 10.0.13:Microsoft,MIT 许可,项目 https://github.com/dotnet/efcore 。
- SQLitePCLRaw 2.1.13:Eric Sink / SourceGear,Apache-2.0 许可,项目 https://github.com/ericsink/SQLitePCL.raw 。许可全文见 `licenses/Apache-2.0.txt`。
- SQLite 本体:公有领域,声明 https://www.sqlite.org/copyright.html 。
diff --git a/licenses/ANGLE-BSD.txt b/licenses/ANGLE-BSD.txt
new file mode 100644
index 0000000..0f65fd6
--- /dev/null
+++ b/licenses/ANGLE-BSD.txt
@@ -0,0 +1,32 @@
+// Copyright 2018 The ANGLE Project Authors.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of TransGaming Inc., Google Inc., 3DLabs Inc.
+// Ltd., nor the names of their contributors may be used to endorse
+// or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
diff --git a/licenses/Avalonia-MIT.txt b/licenses/Avalonia-MIT.txt
new file mode 100644
index 0000000..4195180
--- /dev/null
+++ b/licenses/Avalonia-MIT.txt
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) AvaloniaUI OÜ
+All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/licenses/Inter-OFL-1.1.txt b/licenses/Inter-OFL-1.1.txt
new file mode 100644
index 0000000..9b2ca37
--- /dev/null
+++ b/licenses/Inter-OFL-1.1.txt
@@ -0,0 +1,92 @@
+Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION AND CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/licenses/MicroCom.Runtime-MIT.txt b/licenses/MicroCom.Runtime-MIT.txt
new file mode 100644
index 0000000..6bcf96f
--- /dev/null
+++ b/licenses/MicroCom.Runtime-MIT.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Nikita Tsukanov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/licenses/SkiaSharp-HarfBuzzSharp-MIT.txt b/licenses/SkiaSharp-HarfBuzzSharp-MIT.txt
new file mode 100644
index 0000000..79ae03e
--- /dev/null
+++ b/licenses/SkiaSharp-HarfBuzzSharp-MIT.txt
@@ -0,0 +1,19 @@
+Copyright (c) 2015-2016 Xamarin, Inc.
+Copyright (c) 2017-2018 Microsoft Corporation.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/licenses/SkiaSharp-HarfBuzzSharp-THIRD-PARTY-NOTICES.txt b/licenses/SkiaSharp-HarfBuzzSharp-THIRD-PARTY-NOTICES.txt
new file mode 100644
index 0000000..28d660b
--- /dev/null
+++ b/licenses/SkiaSharp-HarfBuzzSharp-THIRD-PARTY-NOTICES.txt
@@ -0,0 +1,2716 @@
+THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
+Do not translate or localize
+
+SkiaSharp and HarfBuzzSharp incorporate third party material from the projects
+listed below. The original copyright notice and the license under which
+Microsoft received such third party material are set forth below. Microsoft
+reserves all other rights not expressly granted, whether by implication,
+estoppel or otherwise.
+
+################################################################################
+# ANGLE
+# https://github.com/Microsoft/angle
+################################################################################
+
+// Copyright (C) 2002-2013 The ANGLE Project Authors.
+// Portions Copyright (C) Microsoft Corporation.
+//
+// BSD License
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of TransGaming Inc., Google Inc., 3DLabs Inc.
+// Ltd., Microsoft Corporation, nor the names of their contributors
+// may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+################################################################################
+# END: ANGLE
+################################################################################
+
+################################################################################
+# HarfBuzz
+# https://github.com/harfbuzz/harfbuzz
+################################################################################
+
+HarfBuzz is licensed under the so-called "Old MIT" license. Details follow.
+For parts of HarfBuzz that are licensed under different licenses see individual
+files names COPYING in subdirectories where applicable.
+
+Copyright © 2010,2011,2012 Google, Inc.
+Copyright © 2012 Mozilla Foundation
+Copyright © 2011 Codethink Limited
+Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
+Copyright © 2009 Keith Stribley
+Copyright © 2009 Martin Hosken and SIL International
+Copyright © 2007 Chris Wilson
+Copyright © 2006 Behdad Esfahbod
+Copyright © 2005 David Turner
+Copyright © 2004,2007,2008,2009,2010 Red Hat, Inc.
+Copyright © 1998-2004 David Turner and Werner Lemberg
+
+For full copyright notices consult the individual files in the package.
+
+
+Permission is hereby granted, without written agreement and without
+license or royalty fees, to use, copy, modify, and distribute this
+software and its documentation for any purpose, provided that the
+above copyright notice and the following two paragraphs appear in
+all copies of this software.
+
+IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+################################################################################
+# END: HarfBuzz
+################################################################################
+
+################################################################################
+# skia
+# https://github.com/google/skia
+################################################################################
+
+// Copyright (c) 2011 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------------------
+
+################################################################################
+# END: skia
+################################################################################
+
+################################################################################
+# etc1
+# https://github.com/google/skia
+################################################################################
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the
+copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other
+entities that control, are controlled by, or are under common control with
+that entity. For the purposes of this definition, "control" means (i) the
+power, direct or indirect, to cause the direction or management of such
+entity, whether by contract or otherwise, or (ii) ownership of fifty
+percent (50%) or more of the outstanding shares, or (iii) beneficial
+ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation
+source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation
+or translation of a Source form, including but not limited to compiled
+object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object
+form, made available under the License, as indicated by a copyright
+notice that is included in or attached to the work (an example is
+provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object
+form, that is based on (or derived from) the Work and for which the
+editorial revisions, annotations, elaborations, or other modifications
+represent, as a whole, an original work of authorship. For the purposes
+of this License, Derivative Works shall not include works that remain
+separable from, or merely link (or bind by name) to the interfaces of,
+the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner. For
+the purposes of this definition, "submitted" means any form of electronic,
+verbal, or written communication sent to the Licensor or its
+representatives, including but not limited to communication on electronic
+mailing lists, source code control systems, and issue tracking systems that
+are managed by, or on behalf of, the Licensor for the purpose of discussing
+and improving the Work, but excluding communication that is conspicuously
+marked or otherwise designated in writing by the copyright owner as "Not
+a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on
+behalf of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this
+License, each Contributor hereby grants to You a perpetual, worldwide,
+non-exclusive, no-charge, royalty-free, irrevocable copyright license to
+reproduce, prepare Derivative Works of, publicly display, publicly perform,
+sublicense, and distribute the Work and such Derivative Works in Source or
+Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this
+License, each Contributor hereby grants to You a perpetual, worldwide,
+non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
+this section) patent license to make, have made, use, offer to sell, sell,
+import, and otherwise transfer the Work, where such license applies only to
+those patent claims licensable by such Contributor that are necessarily
+infringed by their Contribution(s) alone or by combination of their
+Contribution(s) with the Work to which such Contribution(s) was submitted.
+If You institute patent litigation against any entity (including a cross-claim
+or counterclaim in a lawsuit) alleging that the Work or a Contribution
+incorporated within the Work constitutes direct or contributory patent
+infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or
+Derivative Works thereof in any medium, with or without modifications, and
+in Source or Object form, provided that You meet the following conditions:
+
+You must give any other recipients of the Work or Derivative Works a copy of
+this License; and
+You must cause any modified files to carry prominent notices stating that
+You changed the files; and
+You must retain, in the Source form of any Derivative Works that You
+distribute, all copyright, patent, trademark, and attribution notices
+from the Source form of the Work, excluding those notices that do not
+pertain to any part of the Derivative Works; and
+If the Work includes a "NOTICE" text file as part of its distribution,
+then any Derivative Works that You distribute must include a readable
+copy of the attribution notices contained within such NOTICE file, excluding
+those notices that do not pertain to any part of the Derivative Works, in
+at least one of the following places: within a NOTICE text file distributed
+as part of the Derivative Works; within the Source form or documentation, if
+provided along with the Derivative Works; or, within a display generated by
+the Derivative Works, if and wherever such third-party notices normally
+appear. The contents of the NOTICE file are for informational purposes
+only and do not modify the License. You may add Your own attribution
+notices within Derivative Works that You distribute, alongside or as
+an addendum to the NOTICE text from the Work, provided that such additional
+attribution notices cannot be construed as modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a
+whole, provided Your use, reproduction, and distribution of the Work otherwise
+complies with the conditions stated in this License.
+5. Submission of Contributions. Unless You explicitly state otherwise, any
+Contribution intentionally submitted for inclusion in the Work by You to the
+Licensor shall be under the terms and conditions of this License, without any
+additional terms or conditions. Notwithstanding the above, nothing herein
+shall supersede or modify the terms of any separate license agreement you
+may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names,
+trademarks, service marks, or product names of the Licensor, except as
+required for reasonable and customary use in describing the origin of the
+Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to
+in writing, Licensor provides the Work (and each Contributor provides its
+Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ANY KIND, either express or implied, including, without limitation, any
+warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
+FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining
+the appropriateness of using or redistributing the Work and assume any risks
+associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in
+tort (including negligence), contract, or otherwise, unless required by
+applicable law (such as deliberate and grossly negligent acts) or agreed to
+in writing, shall any Contributor be liable to You for damages, including
+any direct, indirect, special, incidental, or consequential damages of any
+character arising as a result of this License or out of the use or inability
+to use the Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all other
+commercial damages or losses), even if such Contributor has been advised
+of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the
+Work or Derivative Works thereof, You may choose to offer, and charge a
+fee for, acceptance of support, warranty, indemnity, or other liability
+obligations and/or rights consistent with this License. However, in accepting
+such obligations, You may act only on Your own behalf and on Your sole
+responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any
+liability incurred by, or claims asserted against, such Contributor by
+reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+################################################################################
+# END: etc1
+################################################################################
+
+################################################################################
+# gif
+################################################################################
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Chris Saari
+ * Apple Computer
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+################################################################################
+# END: gif
+################################################################################
+
+################################################################################
+# libpng
+################################################################################
+
+This copy of the libpng notices is provided for your convenience. In case of
+any discrepancy between this copy and the notices in the file png.h that is
+included in the libpng distribution, the latter shall prevail.
+
+COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+
+If you modify libpng you may insert additional notices immediately following
+this sentence.
+
+This code is released under the libpng license.
+
+libpng versions 1.0.7, July 1, 2000 through 1.6.22rc01, May 14, 2016 are
+Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
+derived from libpng-1.0.6, and are distributed according to the same
+disclaimer and license as libpng-1.0.6 with the following individuals
+added to the list of Contributing Authors:
+
+ Simon-Pierre Cadieux
+ Eric S. Raymond
+ Mans Rullgard
+ Cosmin Truta
+ Gilles Vollant
+ James Yu
+
+and with the following additions to the disclaimer:
+
+ There is no warranty against interference with your enjoyment of the
+ library or against infringement. There is no warranty that our
+ efforts or the library will fulfill any of your particular purposes
+ or needs. This library is provided with all faults, and the entire
+ risk of satisfactory quality, performance, accuracy, and effort is with
+ the user.
+
+Some files in the "contrib" directory and some configure-generated
+files that are distributed with libpng have other copyright owners and
+are released under other open source licenses.
+
+libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
+Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
+libpng-0.96, and are distributed according to the same disclaimer and
+license as libpng-0.96, with the following individuals added to the list
+of Contributing Authors:
+
+ Tom Lane
+ Glenn Randers-Pehrson
+ Willem van Schaik
+
+libpng versions 0.89, June 1996, through 0.96, May 1997, are
+Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
+and are distributed according to the same disclaimer and license as
+libpng-0.88, with the following individuals added to the list of
+Contributing Authors:
+
+ John Bowler
+ Kevin Bracey
+ Sam Bushell
+ Magnus Holmgren
+ Greg Roelofs
+ Tom Tanner
+
+Some files in the "scripts" directory have other copyright owners
+but are released under this license.
+
+libpng versions 0.5, May 1995, through 0.88, January 1996, are
+Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+
+For the purposes of this copyright and license, "Contributing Authors"
+is defined as the following set of individuals:
+
+ Andreas Dilger
+ Dave Martindale
+ Guy Eric Schalnat
+ Paul Schmidt
+ Tim Wegner
+
+The PNG Reference Library is supplied "AS IS". The Contributing Authors
+and Group 42, Inc. disclaim all warranties, expressed or implied,
+including, without limitation, the warranties of merchantability and of
+fitness for any purpose. The Contributing Authors and Group 42, Inc.
+assume no liability for direct, indirect, incidental, special, exemplary,
+or consequential damages, which may result from the use of the PNG
+Reference Library, even if advised of the possibility of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute this
+source code, or portions hereof, for any purpose, without fee, subject
+to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented.
+
+ 2. Altered versions must be plainly marked as such and must not
+ be misrepresented as being the original source.
+
+ 3. This Copyright notice may not be removed or altered from any
+ source or altered source distribution.
+
+The Contributing Authors and Group 42, Inc. specifically permit, without
+fee, and encourage the use of this source code as a component to
+supporting the PNG file format in commercial products. If you use this
+source code in a product, acknowledgment is not required but would be
+appreciated.
+
+END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
+
+TRADEMARK:
+
+The name "libpng" has not been registered by the Copyright owner
+as a trademark in any jurisdiction. However, because libpng has
+been distributed and maintained world-wide, continually since 1995,
+the Copyright owner claims "common-law trademark protection" in any
+jurisdiction where common-law trademark is recognized.
+
+OSI CERTIFICATION:
+
+Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
+a certification mark of the Open Source Initiative. OSI has not addressed
+the additional disclaimers inserted at version 1.0.7.
+
+EXPORT CONTROL:
+
+The Copyright owner believes that the Export Control Classification
+Number (ECCN) for libpng is EAR99, which means not subject to export
+controls or International Traffic in Arms Regulations (ITAR) because
+it is open source, publicly available software, that does not contain
+any encryption software. See the EAR, paragraphs 734.3(b)(3) and
+734.7(b).
+
+Glenn Randers-Pehrson
+glennrp at users.sourceforge.net
+May 14, 2016
+
+################################################################################
+# END: libpng
+################################################################################
+
+################################################################################
+# DNG SDK
+################################################################################
+
+This product includes DNG technology under license by Adobe Systems
+Incorporated.
+
+DNG SDK License Agreement
+NOTICE TO USER:
+Adobe Systems Incorporated provides the Software and Documentation for use under
+the terms of this Agreement. Any download, installation, use, reproduction,
+modification or distribution of the Software or Documentation, or any
+derivatives or portions thereof, constitutes your acceptance of this Agreement.
+
+As used in this Agreement, "Adobe" means Adobe Systems Incorporated. "Software"
+means the software code, in any format, including sample code and source code,
+accompanying this Agreement. "Documentation" means the documents, specifications
+and all other items accompanying this Agreement other than the Software.
+
+1. LICENSE GRANT
+Software License. Subject to the restrictions below and other terms of this
+Agreement, Adobe hereby grants you a non-exclusive, worldwide, royalty free
+license to use, reproduce, prepare derivative works from, publicly display,
+publicly perform, distribute and sublicense the Software for any purpose.
+
+Document License. Subject to the terms of this Agreement, Adobe hereby grants
+you a non-exclusive, worldwide, royalty free license to make a limited number of
+copies of the Documentation for your development purposes and to publicly
+display, publicly perform and distribute such copies. You may not modify the
+Documentation.
+
+2. RESTRICTIONS AND OWNERSHIP
+You will not remove any copyright or other notice included in the Software or
+Documentation and you will include such notices in any copies of the Software
+that you distribute in human-readable format.
+
+You will not copy, use, display, modify or distribute the Software or
+Documentation in any manner not permitted by this Agreement. No title to the
+intellectual property in the Software or Documentation is transferred to you
+under the terms of this Agreement. You do not acquire any rights to the Software
+or the Documentation except as expressly set forth in this Agreement. All rights
+not granted are reserved by Adobe.
+
+3. DISCLAIMER OF WARRANTY
+ADOBE PROVIDES THE SOFTWARE AND DOCUMENTATION ONLY ON AN "AS IS" BASIS WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. ADOBE MAKES NO WARRANTY
+THAT THE SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. To the extent
+permissible, any warranties that are not and cannot be excluded by the foregoing
+are limited to ninety (90) days.
+
+4. LIMITATION OF LIABILITY
+ADOBE AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF
+THIS AGREEMENT OR FROM THE USE OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT
+WILL ADOBE BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT,
+CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST
+SAVINGS, COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF
+THIS AGREEMENT OR THE USE OR THE INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES. ADOBE'S AGGREGATE LIABILITY AND THAT OF ITS
+SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE
+AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION.
+
+5. INDEMNIFICATION
+If you choose to distribute the Software in a commercial product, you do so with
+the understanding that you agree to defend, indemnify and hold harmless Adobe
+against any losses, damages and costs arising from the claims, lawsuits or other
+legal actions arising out of such distribution.
+
+6. TRADEMARK USAGE
+Adobe and the DNG logo are the trademarks or registered trademarks of Adobe
+Systems Incorporated in the United States and other countries. Such trademarks
+may not be used to endorse or promote any product unless expressly permitted
+under separate agreement with Adobe. For information on how to license the DNG
+logo please go to www.adobe.com.
+
+7. TERM
+Your rights under this Agreement shall terminate if you fail to comply with any
+of the material terms or conditions of this Agreement. If all your rights under
+this Agreement terminate, you will immediately cease use and distribution of the
+Software and Documentation.
+
+8. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes
+and laws of the State of California, without regard to the conflicts of law
+principles thereof. The federal and state courts located in Santa Clara County,
+California, USA, will have non-exclusive jurisdiction over any dispute arising
+out of this Agreement.
+
+9. GENERAL
+This Agreement supersedes any prior agreement, oral or written, between Adobe
+and you with respect to the licensing to you of the Software and Documentation.
+No variation of the terms of this Agreement will be enforceable against Adobe
+unless Adobe gives its express consent in writing signed by an authorized
+signatory of Adobe. If any part of this Agreement is found void and
+unenforceable, it will not affect the validity of the balance of the Agreement,
+which shall remain valid and enforceable according to its terms.
+
+################################################################################
+# END: DNG SDK
+################################################################################
+
+################################################################################
+# expat
+################################################################################
+
+Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+ and Clark Cooper
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+################################################################################
+# END: expat
+################################################################################
+
+################################################################################
+# freetype
+################################################################################
+
+--- LICENSE.TXT ---
+
+The FreeType 2 font engine is copyrighted work and cannot be used
+legally without a software license. In order to make this project
+usable to a vast majority of developers, we distribute it under two
+mutually exclusive open-source licenses.
+
+This means that *you* must choose *one* of the two licenses described
+below, then obey all its terms and conditions when using FreeType 2 in
+any of your projects or products.
+
+ - The FreeType License, found in the file `FTL.TXT', which is similar
+ to the original BSD license *with* an advertising clause that forces
+ you to explicitly cite the FreeType project in your product's
+ documentation. All details are in the license file. This license
+ is suited to products which don't use the GNU General Public
+ License.
+
+ Note that this license is compatible to the GNU General Public
+ License version 3, but not version 2.
+
+ - The GNU General Public License version 2, found in `GPLv2.TXT' (any
+ later version can be used also), for programs which already use the
+ GPL. Note that the FTL is incompatible with GPLv2 due to its
+ advertisement clause.
+
+The contributed BDF and PCF drivers come with a license similar to that
+of the X Window System. It is compatible to the above two licenses (see
+file src/bdf/README and src/pcf/README). The same holds for the files
+`fthash.c' and `fthash.h'; their code was part of the BDF driver in
+earlier FreeType versions.
+
+The gzip module uses the zlib license (see src/gzip/zlib.h) which too is
+compatible to the above two licenses.
+
+The MD5 checksum support (only used for debugging in development builds)
+is in the public domain.
+
+
+--- end of LICENSE.TXT ---
+
+--- FTL.TXT ---
+
+ The FreeType Project LICENSE
+ ----------------------------
+
+ 2006-Jan-27
+
+ Copyright 1996-2002, 2006 by
+ David Turner, Robert Wilhelm, and Werner Lemberg
+
+
+
+Introduction
+============
+
+ The FreeType Project is distributed in several archive packages;
+ some of them may contain, in addition to the FreeType font engine,
+ various tools and contributions which rely on, or relate to, the
+ FreeType Project.
+
+ This license applies to all files found in such packages, and
+ which do not fall under their own explicit license. The license
+ affects thus the FreeType font engine, the test programs,
+ documentation and makefiles, at the very least.
+
+ This license was inspired by the BSD, Artistic, and IJG
+ (Independent JPEG Group) licenses, which all encourage inclusion
+ and use of free software in commercial and freeware products
+ alike. As a consequence, its main points are that:
+
+ o We don't promise that this software works. However, we will be
+ interested in any kind of bug reports. (`as is' distribution)
+
+ o You can use this software for whatever you want, in parts or
+ full form, without having to pay us. (`royalty-free' usage)
+
+ o You may not pretend that you wrote this software. If you use
+ it, or only parts of it, in a program, you must acknowledge
+ somewhere in your documentation that you have used the
+ FreeType code. (`credits')
+
+ We specifically permit and encourage the inclusion of this
+ software, with or without modifications, in commercial products.
+ We disclaim all warranties covering The FreeType Project and
+ assume no liability related to The FreeType Project.
+
+
+ Finally, many people asked us for a preferred form for a
+ credit/disclaimer to use in compliance with this license. We thus
+ encourage you to use the following text:
+
+ """
+ Portions of this software are copyright © The FreeType
+ Project (www.freetype.org). All rights reserved.
+ """
+
+ Please replace with the value from the FreeType version you
+ actually use.
+
+
+Legal Terms
+===========
+
+0. Definitions
+--------------
+
+ Throughout this license, the terms `package', `FreeType Project',
+ and `FreeType archive' refer to the set of files originally
+ distributed by the authors (David Turner, Robert Wilhelm, and
+ Werner Lemberg) as the `FreeType Project', be they named as alpha,
+ beta or final release.
+
+ `You' refers to the licensee, or person using the project, where
+ `using' is a generic term including compiling the project's source
+ code as well as linking it to form a `program' or `executable'.
+ This program is referred to as `a program using the FreeType
+ engine'.
+
+ This license applies to all files distributed in the original
+ FreeType Project, including all source code, binaries and
+ documentation, unless otherwise stated in the file in its
+ original, unmodified form as distributed in the original archive.
+ If you are unsure whether or not a particular file is covered by
+ this license, you must contact us to verify this.
+
+ The FreeType Project is copyright (C) 1996-2000 by David Turner,
+ Robert Wilhelm, and Werner Lemberg. All rights reserved except as
+ specified below.
+
+1. No Warranty
+--------------
+
+ THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
+ USE, OF THE FREETYPE PROJECT.
+
+2. Redistribution
+-----------------
+
+ This license grants a worldwide, royalty-free, perpetual and
+ irrevocable right and license to use, execute, perform, compile,
+ display, copy, create derivative works of, distribute and
+ sublicense the FreeType Project (in both source and object code
+ forms) and derivative works thereof for any purpose; and to
+ authorize others to exercise some or all of the rights granted
+ herein, subject to the following conditions:
+
+ o Redistribution of source code must retain this license file
+ (`FTL.TXT') unaltered; any additions, deletions or changes to
+ the original files must be clearly indicated in accompanying
+ documentation. The copyright notices of the unaltered,
+ original files must be preserved in all copies of source
+ files.
+
+ o Redistribution in binary form must provide a disclaimer that
+ states that the software is based in part of the work of the
+ FreeType Team, in the distribution documentation. We also
+ encourage you to put an URL to the FreeType web page in your
+ documentation, though this isn't mandatory.
+
+ These conditions apply to any software derived from or based on
+ the FreeType Project, not just the unmodified files. If you use
+ our work, you must acknowledge us. However, no fee need be paid
+ to us.
+
+3. Advertising
+--------------
+
+ Neither the FreeType authors and contributors nor you shall use
+ the name of the other for commercial, advertising, or promotional
+ purposes without specific prior written permission.
+
+ We suggest, but do not require, that you use one or more of the
+ following phrases to refer to this software in your documentation
+ or advertising materials: `FreeType Project', `FreeType Engine',
+ `FreeType library', or `FreeType Distribution'.
+
+ As you have not signed this license, you are not required to
+ accept it. However, as the FreeType Project is copyrighted
+ material, only this license, or another one contracted with the
+ authors, grants you the right to use, distribute, and modify it.
+ Therefore, by using, distributing, or modifying the FreeType
+ Project, you indicate that you understand and accept all the terms
+ of this license.
+
+4. Contacts
+-----------
+
+ There are two mailing lists related to FreeType:
+
+ o freetype@nongnu.org
+
+ Discusses general use and applications of FreeType, as well as
+ future and wanted additions to the library and distribution.
+ If you are looking for support, start in this list if you
+ haven't found anything to help you in the documentation.
+
+ o freetype-devel@nongnu.org
+
+ Discusses bugs, as well as engine internals, design issues,
+ specific licenses, porting, etc.
+
+ Our home page can be found at
+
+ http://www.freetype.org
+
+
+--- end of FTL.TXT ---
+
+################################################################################
+# END: freetype
+################################################################################
+
+################################################################################
+# ICU
+################################################################################
+
+ICU License - ICU 1.8.1 and later
+
+ COPYRIGHT AND PERMISSION NOTICE
+
+ Copyright (c) 1995-2015 International Business Machines Corporation and
+ others
+
+ All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, and/or sell copies of the Software, and to permit persons to
+ whom the Software is furnished to do so, provided that the above
+ copyright notice(s) and this permission notice appear in all copies of
+ the Software and that both the above copyright notice(s) and this
+ permission notice appear in supporting documentation.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+ THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
+
+ Except as contained in this notice, the name of a copyright holder shall
+ not be used in advertising or otherwise to promote the sale, use or
+ other dealings in this Software without prior written authorization of
+ the copyright holder.
+ ___________________________________________________________________
+
+ All trademarks and registered trademarks mentioned herein are the
+ property of their respective owners.
+ ___________________________________________________________________
+
+Third-Party Software Licenses
+
+ This section contains third-party software notices and/or additional
+ terms for licensed third-party software components included within ICU
+ libraries.
+
+ 1. Unicode Data Files and Software
+
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright © 1991-2015 Unicode, Inc. All rights reserved.
+Distributed under the Terms of Use in
+http://www.unicode.org/copyright.html.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Unicode data files and any associated documentation
+(the "Data Files") or Unicode software and any associated documentation
+(the "Software") to deal in the Data Files or Software
+without restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, and/or sell copies of
+the Data Files or Software, and to permit persons to whom the Data Files
+or Software are furnished to do so, provided that
+(a) this copyright and permission notice appear with all copies
+of the Data Files or Software,
+(b) this copyright and permission notice appear in associated
+documentation, and
+(c) there is clear notice in each modified Data File or in the Software
+as well as in the documentation associated with the Data File(s) or
+Software that the data or software has been modified.
+
+THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale,
+use or other dealings in these Data Files or Software without prior
+written authorization of the copyright holder.
+
+ 2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt)
+
+ # The Google Chrome software developed by Google is licensed under
+ # the BSD license. Other software included in this distribution is
+ # provided under other licenses, as set forth below.
+ #
+ # The BSD License
+ # http://opensource.org/licenses/bsd-license.php
+ # Copyright (C) 2006-2008, Google Inc.
+ #
+ # All rights reserved.
+ #
+ # Redistribution and use in source and binary forms, with or
+ # without modification, are permitted provided that the
+ # following conditions are met:
+ #
+ # Redistributions of source code must retain the above copyright
+ # notice, this list of conditions and the following disclaimer.
+ # Redistributions in binary form must reproduce the above
+ # copyright notice, this list of conditions and the following
+ # disclaimer in the documentation and/or other materials
+ # provided with the distribution.
+ # Neither the name of Google Inc. nor the names of its
+ # contributors may be used to endorse or promote products
+ # derived from this software without specific prior written
+ # permission.
+ #
+ #
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ #
+ #
+ # The word list in cjdict.txt are generated by combining three
+ # word lists listed below with further processing for compound
+ # word breaking. The frequency is generated with an iterative
+ # training against Google web corpora.
+ #
+ # * Libtabe (Chinese)
+ # - https://sourceforge.net/project/?group_id=1519
+ # - Its license terms and conditions are shown below.
+ #
+ # * IPADIC (Japanese)
+ # - http://chasen.aist-nara.ac.jp/chasen/distribution.html
+ # - Its license terms and conditions are shown below.
+ #
+ # ---------COPYING.libtabe ---- BEGIN--------------------
+ #
+ # /*
+ # * Copyrighy (c) 1999 TaBE Project.
+ # * Copyright (c) 1999 Pai-Hsiang Hsiao.
+ # * All rights reserved.
+ # *
+ # * Redistribution and use in source and binary forms, with or without
+ # * modification, are permitted provided that the following conditions
+ # * are met:
+ # *
+ # * . Redistributions of source code must retain the above copyright
+ # * notice, this list of conditions and the following disclaimer.
+ # * . Redistributions in binary form must reproduce the above copyright
+ # * notice, this list of conditions and the following disclaimer in
+ # * the documentation and/or other materials provided with the
+ # * distribution.
+ # * . Neither the name of the TaBE Project nor the names of its
+ # * contributors may be used to endorse or promote products derived
+ # * from this software without specific prior written permission.
+ # *
+ # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ # * OF THE POSSIBILITY OF SUCH DAMAGE.
+ # */
+ #
+ # /*
+ # * Copyright (c) 1999 Computer Systems and Communication Lab,
+ # * Institute of Information Science, Academia Sinica.
+ # * All rights reserved.
+ # *
+ # * Redistribution and use in source and binary forms, with or without
+ # * modification, are permitted provided that the following conditions
+ # * are met:
+ # *
+ # * . Redistributions of source code must retain the above copyright
+ # * notice, this list of conditions and the following disclaimer.
+ # * . Redistributions in binary form must reproduce the above copyright
+ # * notice, this list of conditions and the following disclaimer in
+ # * the documentation and/or other materials provided with the
+ # * distribution.
+ # * . Neither the name of the Computer Systems and Communication Lab
+ # * nor the names of its contributors may be used to endorse or
+ # * promote products derived from this software without specific
+ # * prior written permission.
+ # *
+ # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ # * OF THE POSSIBILITY OF SUCH DAMAGE.
+ # */
+ #
+ # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, University of Illinois
+ # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4
+ #
+ # ---------------COPYING.libtabe-----END------------------------------------
+ #
+ #
+ # ---------------COPYING.ipadic-----BEGIN------------------------------------
+ #
+ # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science
+ # and Technology. All Rights Reserved.
+ #
+ # Use, reproduction, and distribution of this software is permitted.
+ # Any copy of this software, whether in its original form or modified,
+ # must include both the above copyright notice and the following
+ # paragraphs.
+ #
+ # Nara Institute of Science and Technology (NAIST),
+ # the copyright holders, disclaims all warranties with regard to this
+ # software, including all implied warranties of merchantability and
+ # fitness, in no event shall NAIST be liable for
+ # any special, indirect or consequential damages or any damages
+ # whatsoever resulting from loss of use, data or profits, whether in an
+ # action of contract, negligence or other tortuous action, arising out
+ # of or in connection with the use or performance of this software.
+ #
+ # A large portion of the dictionary entries
+ # originate from ICOT Free Software. The following conditions for ICOT
+ # Free Software applies to the current dictionary as well.
+ #
+ # Each User may also freely distribute the Program, whether in its
+ # original form or modified, to any third party or parties, PROVIDED
+ # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear
+ # on, or be attached to, the Program, which is distributed substantially
+ # in the same form as set out herein and that such intended
+ # distribution, if actually made, will neither violate or otherwise
+ # contravene any of the laws and regulations of the countries having
+ # jurisdiction over the User or the intended distribution itself.
+ #
+ # NO WARRANTY
+ #
+ # The program was produced on an experimental basis in the course of the
+ # research and development conducted during the project and is provided
+ # to users as so produced on an experimental basis. Accordingly, the
+ # program is provided without any warranty whatsoever, whether express,
+ # implied, statutory or otherwise. The term "warranty" used herein
+ # includes, but is not limited to, any warranty of the quality,
+ # performance, merchantability and fitness for a particular purpose of
+ # the program and the nonexistence of any infringement or violation of
+ # any right of any third party.
+ #
+ # Each user of the program will agree and understand, and be deemed to
+ # have agreed and understood, that there is no warranty whatsoever for
+ # the program and, accordingly, the entire risk arising from or
+ # otherwise connected with the program is assumed by the user.
+ #
+ # Therefore, neither ICOT, the copyright holder, or any other
+ # organization that participated in or was otherwise related to the
+ # development of the program and their respective officials, directors,
+ # officers and other employees shall be held liable for any and all
+ # damages, including, without limitation, general, special, incidental
+ # and consequential damages, arising out of or otherwise in connection
+ # with the use or inability to use the program or any product, material
+ # or result produced or otherwise obtained by using the program,
+ # regardless of whether they have been advised of, or otherwise had
+ # knowledge of, the possibility of such damages at any time during the
+ # project or thereafter. Each user will be deemed to have agreed to the
+ # foregoing by his or her commencement of use of the program. The term
+ # "use" as used herein includes, but is not limited to, the use,
+ # modification, copying and distribution of the program and the
+ # production of secondary products from the program.
+ #
+ # In the case where the program, whether in its original form or
+ # modified, was distributed or delivered to or received by a user from
+ # any person, organization or entity other than ICOT, unless it makes or
+ # grants independently of ICOT any specific warranty to the user in
+ # writing, such person, organization or entity, will also be exempted
+ # from and not be held liable to the user for any such damages as noted
+ # above as far as the program is concerned.
+ #
+ # ---------------COPYING.ipadic-----END------------------------------------
+
+ 3. Lao Word Break Dictionary Data (laodict.txt)
+
+ # Copyright (c) 2013 International Business Machines Corporation
+ # and others. All Rights Reserved.
+ #
+ # Project: http://code.google.com/p/lao-dictionary/
+ # Dictionary: http://lao-dictionary.googlecode.com/git/Lao-Dictionary.txt
+ # License: http://lao-dictionary.googlecode.com/git/Lao-Dictionary-LICENSE.txt
+ # (copied below)
+ #
+ # This file is derived from the above dictionary, with slight modifications.
+ # --------------------------------------------------------------------------------
+ # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell.
+ # All rights reserved.
+ #
+ # Redistribution and use in source and binary forms, with or without modification,
+ # are permitted provided that the following conditions are met:
+ #
+ # Redistributions of source code must retain the above copyright notice, this
+ # list of conditions and the following disclaimer. Redistributions in binary
+ # form must reproduce the above copyright notice, this list of conditions and
+ # the following disclaimer in the documentation and/or other materials
+ # provided with the distribution.
+ #
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ # --------------------------------------------------------------------------------
+
+ 4. Burmese Word Break Dictionary Data (burmesedict.txt)
+
+ # Copyright (c) 2014 International Business Machines Corporation
+ # and others. All Rights Reserved.
+ #
+ # This list is part of a project hosted at:
+ # github.com/kanyawtech/myanmar-karen-word-lists
+ #
+ # --------------------------------------------------------------------------------
+ # Copyright (c) 2013, LeRoy Benjamin Sharon
+ # All rights reserved.
+ #
+ # Redistribution and use in source and binary forms, with or without modification,
+ # are permitted provided that the following conditions are met:
+ #
+ # Redistributions of source code must retain the above copyright notice, this
+ # list of conditions and the following disclaimer.
+ #
+ # Redistributions in binary form must reproduce the above copyright notice, this
+ # list of conditions and the following disclaimer in the documentation an d/or
+ # other materials provided with the distribution.
+ #
+ # Neither the name Myanmar Karen Word Lists, nor the names of its
+ # contributors may be used to endorse or promote products derived from
+ # this software without specific prior written permission.
+ #
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ # --------------------------------------------------------------------------------
+
+ 5. Time Zone Database
+
+ ICU uses the public domain data and code derived from Time Zone Database
+ for its time zone support. The ownership of the TZ database is explained
+ in BCP 175: Procedure for Maintaining the Time Zone Database section 7.
+
+7. Database Ownership
+
+ The TZ database itself is not an IETF Contribution or an IETF
+ document. Rather it is a pre-existing and regularly updated work
+ that is in the public domain, and is intended to remain in the public
+ domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do not apply
+ to the TZ Database or contributions that individuals make to it.
+ Should any claims be made and substantiated against the TZ Database,
+ the organization that is providing the IANA Considerations defined in
+ this RFC, under the memorandum of understanding with the IETF,
+ currently ICANN, may act in accordance with all competent court
+ orders. No ownership claims will be made by ICANN or the IETF Trust
+ on the database or the code. Any person making a contribution to the
+ database or code waives all rights to future claims in that
+ contribution or in the TZ Database.
+
+################################################################################
+# END: ICU
+################################################################################
+
+################################################################################
+# imgui
+################################################################################
+
+The MIT License (MIT)
+
+Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+################################################################################
+# END: imgui
+################################################################################
+
+################################################################################
+# jsoncpp
+################################################################################
+
+The JsonCpp library's source code, including accompanying documentation,
+tests and demonstration applications, are licensed under the following
+conditions...
+
+The author (Baptiste Lepilleur) explicitly disclaims copyright in all
+jurisdictions which recognize such a disclaimer. In such jurisdictions,
+this software is released into the Public Domain.
+
+In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
+2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
+released under the terms of the MIT License (see below).
+
+In jurisdictions which recognize Public Domain property, the user of this
+software may choose to accept it either as 1) Public Domain, 2) under the
+conditions of the MIT License (see below), or 3) under the terms of dual
+Public Domain/MIT License conditions described here, as they choose.
+
+The MIT License is about as close to Public Domain as a license can get, and is
+described in clear, concise terms at:
+
+ http://en.wikipedia.org/wiki/MIT_License
+
+The full text of the MIT License follows:
+
+========================================================================
+Copyright (c) 2007-2010 Baptiste Lepilleur
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use, copy,
+modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+========================================================================
+(END LICENSE TEXT)
+
+The MIT license is compatible with both the GPL and commercial
+software, affording one all of the rights of Public Domain with the
+minor nuisance of being required to keep the above copyright notice
+and license text in the source code. Note also that by accepting the
+Public Domain "license" you can re-license your copy using whatever
+license you like.
+
+################################################################################
+# END: jsoncpp
+################################################################################
+
+################################################################################
+# libjpeg-turbo
+################################################################################
+
+libjpeg-turbo Licenses
+======================
+
+libjpeg-turbo is covered by three compatible BSD-style open source licenses:
+
+- The IJG (Independent JPEG Group) License, which is listed in
+ [README.ijg](README.ijg)
+
+ This license applies to the libjpeg API library and associated programs
+ (any code inherited from libjpeg, and any modifications to that code.)
+
+- The Modified (3-clause) BSD License, which is listed in
+ [turbojpeg.c](turbojpeg.c)
+
+ This license covers the TurboJPEG API library and associated programs.
+
+- The zlib License, which is listed in [simd/jsimdext.inc](simd/jsimdext.inc)
+
+ This license is a subset of the other two, and it covers the libjpeg-turbo
+ SIMD extensions.
+
+
+Complying with the libjpeg-turbo Licenses
+=========================================
+
+This section provides a roll-up of the libjpeg-turbo licensing terms, to the
+best of our understanding.
+
+1. If you are distributing a modified version of the libjpeg-turbo source,
+ then:
+
+ 1. You cannot alter or remove any existing copyright or license notices
+ from the source.
+
+ **Origin**
+ - Clause 1 of the IJG License
+ - Clause 1 of the Modified BSD License
+ - Clauses 1 and 3 of the zlib License
+
+ 2. You must add your own copyright notice to the header of each source
+ file you modified, so others can tell that you modified that file (if
+ there is not an existing copyright header in that file, then you can
+ simply add a notice stating that you modified the file.)
+
+ **Origin**
+ - Clause 1 of the IJG License
+ - Clause 2 of the zlib License
+
+ 3. You must include the IJG README file, and you must not alter any of the
+ copyright or license text in that file.
+
+ **Origin**
+ - Clause 1 of the IJG License
+
+2. If you are distributing only libjpeg-turbo binaries without the source, or
+ if you are distributing an application that statically links with
+ libjpeg-turbo, then:
+
+ 1. Your product documentation must include a message stating:
+
+ This software is based in part on the work of the Independent JPEG
+ Group.
+
+ **Origin**
+ - Clause 2 of the IJG license
+
+ 2. If your binary distribution includes or uses the TurboJPEG API, then
+ your product documentation must include the text of the Modified BSD
+ License.
+
+ **Origin**
+ - Clause 2 of the Modified BSD License
+
+3. You cannot use the name of the IJG or The libjpeg-turbo Project or the
+ contributors thereof in advertising, publicity, etc.
+
+ **Origin**
+ - IJG License
+ - Clause 3 of the Modified BSD License
+
+4. The IJG and The libjpeg-turbo Project do not warrant libjpeg-turbo to be
+ free of defects, nor do we accept any liability for undesirable
+ consequences resulting from your use of the software.
+
+ **Origin**
+ - IJG License
+ - Modified BSD License
+ - zlib License
+
+################################################################################
+# END: libjpeg-turbo
+################################################################################
+
+################################################################################
+# libwebp
+################################################################################
+
+Copyright (c) 2010, Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ * Neither the name of Google nor the names of its contributors may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+################################################################################
+# END: libwebp
+################################################################################
+
+################################################################################
+# libmicrohttpd
+################################################################################
+
+Some of this code is DUAL-LICENSED. If you use MHD without HTTPS/SSL
+support, you are free to choose between the LGPL and the eCos License
+(http://ecos.sourceware.org/license-overview.html). If you compile
+MHD with HTTPS support, you must obey the terms of the GNU LGPL.
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+################################################################################
+# END: libmicrohttpd
+################################################################################
+
+################################################################################
+# piex
+################################################################################
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+################################################################################
+# END: piex
+################################################################################
+
+################################################################################
+# sdl
+################################################################################
+
+Simple DirectMedia Layer
+Copyright (C) 1997-2015 Sam Lantinga
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+################################################################################
+# END: sdl
+################################################################################
+
+################################################################################
+# sfntly
+################################################################################
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2011 Google Inc. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+################################################################################
+# END: sfntly
+################################################################################
+
+################################################################################
+# SPIR-V Headers
+################################################################################
+
+Copyright (c) 2015-2016 The Khronos Group Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and/or associated documentation files (the
+"Materials"), to deal in the Materials without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Materials, and to
+permit persons to whom the Materials are furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Materials.
+
+MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
+KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
+SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
+ https://www.khronos.org/registry/
+
+THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+
+################################################################################
+# END: SPIR-V Headers
+################################################################################
+
+################################################################################
+# SPIR-V Tools
+################################################################################
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+################################################################################
+# END: SPIR-V Tools
+################################################################################
+
+################################################################################
+# zlib
+################################################################################
+
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+ version 1.2.4, March 14th, 2010
+
+ Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly
+ Mark Adler
+
+*/
+
+mozzconf.h is distributed under the MPL 1.1/GPL 2.0/LGPL 2.1 tri-license.
+
+################################################################################
+# END: zlib
+################################################################################
diff --git a/licenses/Tmds.DBus.Protocol-MIT.txt b/licenses/Tmds.DBus.Protocol-MIT.txt
new file mode 100644
index 0000000..c9bff9d
--- /dev/null
+++ b/licenses/Tmds.DBus.Protocol-MIT.txt
@@ -0,0 +1,22 @@
+Copyright 2006 Alp Toker
+Copyright 2010 Other Contributors
+Copyright 2016 Tom Deseyn
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
From 07a974b2726fb1257d0b126dd3477db882260c76 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:36:50 +0800
Subject: [PATCH 14/49] ci: Match release runners to target architectures
---
.github/workflows/release.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9727f9e..e90e6ab 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -42,10 +42,10 @@ jobs:
- runner: windows-latest
runtime: win-x64
shell: pwsh
- - runner: macos-14
+ - runner: macos-15
runtime: osx-arm64
shell: bash
- - runner: macos-14
+ - runner: macos-15-intel
runtime: osx-x64
shell: bash
- runner: ubuntu-latest
From f1fc8376e12fbdcba5893ca6d83bec3b2b15d569 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:40:43 +0800
Subject: [PATCH 15/49] fix: Keep the tray app hidden on startup
---
src/App/App.axaml.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/App/App.axaml.cs b/src/App/App.axaml.cs
index d5aec84..ffa00f7 100644
--- a/src/App/App.axaml.cs
+++ b/src/App/App.axaml.cs
@@ -27,7 +27,6 @@ public override void OnFrameworkInitializationCompleted()
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
window = new MainWindow(Options.CapturePath, Options.CodexHome);
- desktop.MainWindow = window;
if (Options.CapturePath == null)
ShowExistingPanel = () => Dispatcher.UIThread.Post(window.ShowPanel);
From ce51eb3f92fd33db01c7c56a83a151d3b1d23a54 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:49:03 +0800
Subject: [PATCH 16/49] fix: Use process-safe single-instance locking on Unix
---
src/App/Program.cs | 3 +-
src/Core/PlatformPaths.cs | 23 +++++
src/Core/SingleInstance.cs | 207 ++++++++++++++++++-------------------
tests/Program.cs | 60 +++++++++--
4 files changed, 180 insertions(+), 113 deletions(-)
diff --git a/src/App/Program.cs b/src/App/Program.cs
index e180085..c250c8b 100644
--- a/src/App/Program.cs
+++ b/src/App/Program.cs
@@ -16,8 +16,7 @@ public static int Main(string[] args)
return SnapshotWriter.Write(options.SnapshotPath, options.CodexHome);
using var singleInstance = SingleInstance.Create(
- OperatingSystem.IsWindows() ? @"Local\CodexTpsFloat.Panel.v1" : "CodexTpsFloat",
- () => App.ShowExistingPanel?.Invoke());
+ "CodexTpsFloat", () => App.ShowExistingPanel?.Invoke());
if (!singleInstance.IsFirstInstance && options.CapturePath == null)
{
singleInstance.SignalExistingInstance();
diff --git a/src/Core/PlatformPaths.cs b/src/Core/PlatformPaths.cs
index 3f4926f..7602011 100644
--- a/src/Core/PlatformPaths.cs
+++ b/src/Core/PlatformPaths.cs
@@ -17,4 +17,27 @@ public static string UserConfigDirectory(string appName = "CodexTpsFloat")
root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
return Path.Combine(root, appName);
}
+
+ public static string UserCacheDirectory(string appName = "CodexTpsFloat")
+ {
+ string root;
+ if (OperatingSystem.IsMacOS())
+ {
+ root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ "Library", "Caches");
+ }
+ else if (OperatingSystem.IsWindows())
+ {
+ root = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+ }
+ else
+ {
+ root = Environment.GetEnvironmentVariable("XDG_CACHE_HOME") ?? "";
+ if (!Path.IsPathRooted(root))
+ root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cache");
+ }
+ if (string.IsNullOrEmpty(root))
+ root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cache");
+ return Path.Combine(root, appName);
+ }
}
diff --git a/src/Core/SingleInstance.cs b/src/Core/SingleInstance.cs
index 00b9c50..9dad6a8 100644
--- a/src/Core/SingleInstance.cs
+++ b/src/Core/SingleInstance.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
@@ -10,52 +9,62 @@ namespace CodexTpsFloat;
///
/// Keeps one panel per user and wakes the running instance on a second launch.
-/// Windows uses named synchronization objects; Unix uses a Unix domain socket
-/// because .NET does not support named event wait handles on those platforms.
+/// Windows uses named synchronization objects; Unix uses an exclusive lock file
+/// plus an atomically replaced wake request because .NET does not provide named
+/// event wait handles on those platforms.
///
public sealed class SingleInstance : IDisposable
{
- readonly Mutex mutex;
- readonly bool ownsMutex;
+ readonly Mutex? mutex;
readonly EventWaitHandle? windowsWake;
readonly RegisteredWaitHandle? windowsRegistration;
- readonly Socket? unixListener;
- readonly string? unixSocketPath;
+ readonly FileStream? unixLock;
+ readonly string? unixWakePath;
readonly CancellationTokenSource? unixCancellation;
- readonly Task? unixAcceptLoop;
+ readonly Task? unixWakeLoop;
+ readonly bool ownsInstance;
bool disposed;
- SingleInstance(Mutex mutex, bool ownsMutex,
+ SingleInstance(bool ownsInstance, Mutex? mutex = null,
EventWaitHandle? windowsWake = null,
RegisteredWaitHandle? windowsRegistration = null,
- Socket? unixListener = null,
- string? unixSocketPath = null,
+ FileStream? unixLock = null,
+ string? unixWakePath = null,
CancellationTokenSource? unixCancellation = null,
- Task? unixAcceptLoop = null)
+ Task? unixWakeLoop = null)
{
+ this.ownsInstance = ownsInstance;
this.mutex = mutex;
- this.ownsMutex = ownsMutex;
this.windowsWake = windowsWake;
this.windowsRegistration = windowsRegistration;
- this.unixListener = unixListener;
- this.unixSocketPath = unixSocketPath;
+ this.unixLock = unixLock;
+ this.unixWakePath = unixWakePath;
this.unixCancellation = unixCancellation;
- this.unixAcceptLoop = unixAcceptLoop;
+ this.unixWakeLoop = unixWakeLoop;
}
- public bool IsFirstInstance => ownsMutex;
+ public bool IsFirstInstance => ownsInstance;
- public static SingleInstance Create(string name, Action? showExisting = null)
+ public static SingleInstance Create(string name, Action? showExisting = null,
+ string? stateDirectory = null)
{
- string scopedName = OperatingSystem.IsWindows()
- ? name
- : $"CodexTpsFloat.{Environment.UserName}.{name}";
- var mutex = new Mutex(true, scopedName + ".Panel", out bool first);
+ if (OperatingSystem.IsWindows())
+ return CreateWindows(name, showExisting);
+ return CreateUnix(name, showExisting, stateDirectory);
+ }
+
+ static SingleInstance CreateWindows(string name, Action? showExisting)
+ {
+ string scopedName = $"Local\\{name}.Panel.v1";
+ var mutex = new Mutex(true, scopedName, out bool first);
try
{
- return OperatingSystem.IsWindows()
- ? CreateWindows(mutex, first, scopedName, showExisting)
- : CreateUnix(mutex, first, scopedName, showExisting);
+ var wake = new EventWaitHandle(false, EventResetMode.AutoReset, scopedName + ".Show");
+ RegisteredWaitHandle? registration = null;
+ if (first && showExisting != null)
+ registration = ThreadPool.RegisterWaitForSingleObject(wake,
+ (_, _) => showExisting(), null, Timeout.Infinite, false);
+ return new(first, mutex, wake, registration);
}
catch
{
@@ -65,88 +74,81 @@ public static SingleInstance Create(string name, Action? showExisting = null)
}
}
- static SingleInstance CreateWindows(Mutex mutex, bool first, string scopedName,
- Action? showExisting)
+ static SingleInstance CreateUnix(string name, Action? showExisting, string? stateDirectory)
{
- var wake = new EventWaitHandle(false, EventResetMode.AutoReset, scopedName + ".Show");
- RegisteredWaitHandle? registration = null;
- if (first && showExisting != null)
- registration = ThreadPool.RegisterWaitForSingleObject(wake,
- (_, _) => showExisting(), null, Timeout.Infinite, false);
- return new(mutex, first, wake, registration);
- }
+ string scopedName = $"{Environment.UserName}.{name}";
+ string directory = stateDirectory ?? PlatformPaths.UserCacheDirectory();
+ Directory.CreateDirectory(directory);
+ string key = InstanceKey(scopedName);
+ string lockPath = Path.Combine(directory, $"instance-{key}.lock");
+ string wakePath = Path.Combine(directory, $"instance-{key}.wake");
- static SingleInstance CreateUnix(Mutex mutex, bool first, string scopedName,
- Action? showExisting)
- {
- string socketPath = UnixSocketPath(scopedName);
- Socket? listener = null;
- CancellationTokenSource? cancellation = null;
- Task? acceptLoop = null;
- if (first)
+ FileStream? lockFile = null;
+ bool owns = false;
+ try
{
try
{
- if (File.Exists(socketPath)) File.Delete(socketPath);
- listener = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
- listener.Bind(new UnixDomainSocketEndPoint(socketPath));
- listener.Listen(1);
+ lockFile = new FileStream(lockPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
+ FileShare.None);
+ owns = true;
+ }
+ catch (IOException)
+ {
+ }
+
+ if (!owns)
+ return new(false, unixWakePath: wakePath);
+
+ CancellationTokenSource? cancellation = null;
+ try
+ {
+ if (File.Exists(wakePath)) File.Delete(wakePath);
cancellation = new CancellationTokenSource();
- if (showExisting != null)
- acceptLoop = AcceptConnectionsAsync(listener, cancellation.Token, showExisting);
+ Task? wakeLoop = showExisting == null
+ ? null
+ : WatchWakeRequestsAsync(wakePath, cancellation.Token, showExisting);
+ return new(true, unixLock: lockFile, unixWakePath: wakePath,
+ unixCancellation: cancellation, unixWakeLoop: wakeLoop);
}
- catch (Exception e) when (e is SocketException or IOException
- or UnauthorizedAccessException)
+ catch
{
- listener?.Dispose();
- listener = null;
cancellation?.Dispose();
- cancellation = null;
+ throw;
}
}
- return new(mutex, first, unixListener: listener, unixSocketPath: socketPath,
- unixCancellation: cancellation, unixAcceptLoop: acceptLoop);
+ catch
+ {
+ lockFile?.Dispose();
+ throw;
+ }
}
- static string UnixSocketPath(string scopedName)
- {
- // Unix domain socket paths are limited to roughly 100 bytes. Keep the
- // temporary path bounded even when the logical instance name is long.
- string hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(scopedName)))
- .ToLowerInvariant();
- return Path.Combine(Path.GetTempPath(), $"CodexTpsFloat-{hash[..16]}.sock");
- }
+ static string InstanceKey(string scopedName) => Convert.ToHexString(
+ SHA256.HashData(Encoding.UTF8.GetBytes(scopedName))).ToLowerInvariant()[..16];
- static async Task AcceptConnectionsAsync(Socket listener, CancellationToken cancellation,
+ static async Task WatchWakeRequestsAsync(string wakePath, CancellationToken cancellation,
Action showExisting)
{
while (!cancellation.IsCancellationRequested)
{
- Socket connection;
try
{
- connection = await listener.AcceptAsync(cancellation);
+ await Task.Delay(200, cancellation);
}
- catch (Exception e) when (e is OperationCanceledException or ObjectDisposedException
- or SocketException)
+ catch (OperationCanceledException)
{
return;
}
- using (connection)
+ if (!File.Exists(wakePath)) continue;
+ try
{
- try
- {
- var buffer = new byte[1];
- await connection.ReceiveAsync(buffer, SocketFlags.None, cancellation);
- showExisting();
- }
- catch (Exception e) when (e is OperationCanceledException or ObjectDisposedException
- or SocketException)
- {
- return;
- }
+ File.Delete(wakePath);
}
+ catch (IOException) { continue; }
+ catch (UnauthorizedAccessException) { continue; }
+ showExisting();
}
}
@@ -158,24 +160,18 @@ public void SignalExistingInstance()
return;
}
- if (unixSocketPath == null) return;
- using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
- for (int attempt = 0; attempt < 20; attempt++)
+ if (unixWakePath == null) return;
+ string temporary = unixWakePath + "." + Guid.NewGuid().ToString("N");
+ try
{
- try
- {
- socket.Connect(new UnixDomainSocketEndPoint(unixSocketPath));
- socket.Send(new byte[] { 1 });
- return;
- }
- catch (SocketException) when (attempt < 19)
- {
- Thread.Sleep(25);
- }
- catch (SocketException)
- {
- return;
- }
+ Directory.CreateDirectory(Path.GetDirectoryName(unixWakePath)!);
+ File.WriteAllText(temporary, "show");
+ File.Move(temporary, unixWakePath, true);
+ }
+ catch (Exception e) when (e is IOException or UnauthorizedAccessException)
+ {
+ try { File.Delete(temporary); }
+ catch (Exception cleanup) when (cleanup is IOException or UnauthorizedAccessException) { }
}
}
@@ -186,16 +182,19 @@ public void Dispose()
windowsRegistration?.Unregister(null);
windowsWake?.Dispose();
unixCancellation?.Cancel();
- unixListener?.Dispose();
- if (unixAcceptLoop != null)
+ if (unixWakeLoop != null)
{
- try { unixAcceptLoop.GetAwaiter().GetResult(); }
+ try { unixWakeLoop.GetAwaiter().GetResult(); }
catch (OperationCanceledException) { }
}
unixCancellation?.Dispose();
- if (ownsMutex && unixSocketPath != null && File.Exists(unixSocketPath))
- File.Delete(unixSocketPath);
- if (ownsMutex) mutex.ReleaseMutex();
- mutex.Dispose();
+ if (ownsInstance)
+ {
+ if (unixWakePath != null && File.Exists(unixWakePath))
+ File.Delete(unixWakePath);
+ mutex?.ReleaseMutex();
+ }
+ unixLock?.Dispose();
+ mutex?.Dispose();
}
}
diff --git a/tests/Program.cs b/tests/Program.cs
index f0d4b64..40367fe 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -2,6 +2,22 @@
using System.Text.Json;
using CodexTpsFloat;
+if (args.Length == 6 && args[0] == "--single-instance-child")
+{
+ string instanceName = args[1], stateDirectory = args[2], readyPath = args[3];
+ string wakePath = args[4], observedPath = args[5];
+ using var instance = SingleInstance.Create(instanceName,
+ () => File.WriteAllText(observedPath, "observed"), stateDirectory);
+ if (!instance.IsFirstInstance) return 3;
+ File.WriteAllText(readyPath, "ready");
+ for (int attempt = 0; attempt < 100; attempt++)
+ {
+ if (File.Exists(observedPath)) return 0;
+ Thread.Sleep(50);
+ }
+ return 4;
+}
+
static string Event(string type, object payload, double second) => JsonSerializer.Serialize(new
{
type, timestamp = DateTimeOffset.FromUnixTimeMilliseconds((long)(second * 1000)).ToString("O"), payload
@@ -190,13 +206,43 @@ static void Seed(UsageScanner s, double t = origin)
Check(login.SetEnabled(false) == null && !login.IsEnabled() && !File.Exists(entry), "停用登录启动会移除条目");
string instanceName = "codex-tps-test-" + Guid.NewGuid().ToString("N") + new string('x', 80);
- using var existingInstance = new ManualResetEventSlim(false);
- using var firstInstance = SingleInstance.Create(instanceName, () => existingInstance.Set());
- Check(firstInstance.IsFirstInstance, "首个单实例进程获得所有权");
- using var secondInstance = SingleInstance.Create(instanceName);
- Check(!secondInstance.IsFirstInstance, "第二个进程不会重复启动界面");
- secondInstance.SignalExistingInstance();
- Check(existingInstance.Wait(TimeSpan.FromSeconds(5)), "第二个进程会唤醒已有实例");
+ string instanceDirectory = Path.Combine(directory, "instance");
+ string readyPath = Path.Combine(directory, "instance-ready");
+ string wakePath = Path.Combine(directory, "instance-wake");
+ string observedPath = Path.Combine(directory, "instance-observed");
+ using var child = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
+ {
+ FileName = Environment.ProcessPath!,
+ UseShellExecute = false,
+ ArgumentList =
+ {
+ "--single-instance-child", instanceName, instanceDirectory,
+ readyPath, wakePath, observedPath
+ }
+ }) ?? throw new Exception("无法启动单实例测试子进程");
+ try
+ {
+ for (int attempt = 0; attempt < 100 && !File.Exists(readyPath); attempt++)
+ Thread.Sleep(50);
+ Check(File.Exists(readyPath) && !child.HasExited, "子进程获得首个单实例所有权");
+ using var secondInstance = SingleInstance.Create(instanceName, stateDirectory: instanceDirectory);
+ Check(!secondInstance.IsFirstInstance, "第二个进程不会重复启动界面");
+ secondInstance.SignalExistingInstance();
+ for (int attempt = 0; attempt < 100 && !File.Exists(observedPath); attempt++)
+ Thread.Sleep(50);
+ Check(File.Exists(observedPath), "第二个进程会唤醒已有实例");
+ Check(child.WaitForExit(5000), "已有实例收到唤醒后正常退出");
+ Check(child.ExitCode == 0, "已有实例退出码正确");
+ }
+ finally
+ {
+ if (!child.HasExited)
+ {
+ child.Kill(true);
+ child.WaitForExit();
+ }
+ }
}
finally { Directory.Delete(directory, true); }
Console.WriteLine("通过:统计口径、去重、重试区间、时区、增量刷新、归档、截断、等长重写、坏记录、BOM、跨缓冲区长行、CRLF、中文字符中间补全尾行、旧格式告警、设置往返、报告导出、登录启动与单实例唤醒。");
+return 0;
From 4190f678acec652967472ce99114d5ca99b8e1ed Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:56:22 +0800
Subject: [PATCH 17/49] fix: Use the XDG autostart directory on Linux
---
src/Core/Autostart.cs | 9 ++++-----
src/Core/PlatformPaths.cs | 24 ++++++++++++++++++++----
tests/Program.cs | 4 ++--
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/src/Core/Autostart.cs b/src/Core/Autostart.cs
index 4eea6a6..88015ab 100644
--- a/src/Core/Autostart.cs
+++ b/src/Core/Autostart.cs
@@ -19,13 +19,12 @@ public interface IAutostartService
public static class Autostart
{
- public static IAutostartService Create(string? executablePath = null, string? configDirectory = null)
+ public static IAutostartService Create(string? executablePath = null, string? autostartDirectory = null)
{
string exe = executablePath ?? Environment.ProcessPath ?? "";
- string config = configDirectory ?? PlatformPaths.UserConfigDirectory();
if (OperatingSystem.IsWindows()) return new WindowsAutostart(exe);
if (OperatingSystem.IsMacOS()) return new MacAutostart(exe);
- return new LinuxAutostart(exe, config);
+ return new LinuxAutostart(exe, autostartDirectory ?? PlatformPaths.UserAutostartDirectory());
}
}
@@ -95,8 +94,8 @@ public sealed class LinuxAutostart : IAutostartService
{
readonly string executable;
readonly string desktopPath;
- public LinuxAutostart(string executable, string configDirectory) =>
- (this.executable, desktopPath) = (executable, Path.Combine(configDirectory, "autostart", "CodexTpsFloat.desktop"));
+ public LinuxAutostart(string executable, string autostartDirectory) =>
+ (this.executable, desktopPath) = (executable, Path.Combine(autostartDirectory, "CodexTpsFloat.desktop"));
public bool IsEnabled() => File.Exists(desktopPath);
public string? SetEnabled(bool enabled)
{
diff --git a/src/Core/PlatformPaths.cs b/src/Core/PlatformPaths.cs
index 7602011..7b5523c 100644
--- a/src/Core/PlatformPaths.cs
+++ b/src/Core/PlatformPaths.cs
@@ -12,12 +12,13 @@ public static class PlatformPaths
///
public static string UserConfigDirectory(string appName = "CodexTpsFloat")
{
- string root = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- if (string.IsNullOrEmpty(root))
- root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
- return Path.Combine(root, appName);
+ return Path.Combine(UserConfigRoot(), appName);
}
+ /// Returns the XDG autostart directory used by desktop environments.
+ public static string UserAutostartDirectory() =>
+ Path.Combine(UserConfigRoot(), "autostart");
+
public static string UserCacheDirectory(string appName = "CodexTpsFloat")
{
string root;
@@ -40,4 +41,19 @@ public static string UserCacheDirectory(string appName = "CodexTpsFloat")
root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cache");
return Path.Combine(root, appName);
}
+
+ static string UserConfigRoot()
+ {
+ if (OperatingSystem.IsLinux())
+ {
+ string? configHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
+ if (Path.IsPathRooted(configHome)) return configHome!;
+ return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
+ }
+
+ string root = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ if (string.IsNullOrEmpty(root))
+ root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
+ return root;
+ }
}
diff --git a/tests/Program.cs b/tests/Program.cs
index 40367fe..b428126 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -192,10 +192,10 @@ static void Seed(UsageScanner s, double t = origin)
string entry = OperatingSystem.IsMacOS()
? Path.Combine(directory, "LaunchAgents", "com.codextpsfloat.plist")
- : Path.Combine(directory, "config", "autostart", "CodexTpsFloat.desktop");
+ : Path.Combine(directory, "autostart", "CodexTpsFloat.desktop");
IAutostartService login = OperatingSystem.IsMacOS()
? new MacAutostart("/Applications/Codex TPS.app", Path.GetDirectoryName(entry))
- : new LinuxAutostart("/opt/codex tps/CodexTpsFloat", Path.Combine(directory, "config"));
+ : new LinuxAutostart("/opt/codex tps/CodexTpsFloat", Path.GetDirectoryName(entry)!);
Check(!login.IsEnabled(), "未启用时登录启动为关闭状态");
Check(login.SetEnabled(true) == null && login.IsEnabled(), "启用登录启动会创建条目");
string entryText = File.ReadAllText(entry);
From ce451e41b4f071afcbee615d0a201d7cb5fdeca5 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 17:57:43 +0800
Subject: [PATCH 18/49] fix: Show the panel when no tray is available
---
src/App/App.axaml.cs | 2 ++
src/App/MainWindow.axaml | 2 +-
src/App/MainWindow.axaml.cs | 8 +++++++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/App/App.axaml.cs b/src/App/App.axaml.cs
index ffa00f7..0c09523 100644
--- a/src/App/App.axaml.cs
+++ b/src/App/App.axaml.cs
@@ -36,6 +36,8 @@ public override void OnFrameworkInitializationCompleted()
await window.StartAsync();
if (Options.CapturePath != null)
await window.CaptureAndCloseAsync(Options.CapturePath);
+ else if (!window.HasTray)
+ window.ShowPanel();
};
base.OnFrameworkInitializationCompleted();
diff --git a/src/App/MainWindow.axaml b/src/App/MainWindow.axaml
index 6499a6a..2ad3ba9 100644
--- a/src/App/MainWindow.axaml
+++ b/src/App/MainWindow.axaml
@@ -77,7 +77,7 @@
-
+
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index 2cfbee3..bcb33ba 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -49,6 +49,7 @@ public MainWindow(string? capturePath = null, string? codexHome = null)
InitializeState();
tray = OperatingSystem.IsBrowser() ? null : CreateTrayIcon();
+ HideButton.IsVisible = tray != null;
if (tray != null && Application.Current != null)
TrayIcon.SetIcons(Application.Current, new TrayIcons { tray });
@@ -58,6 +59,8 @@ public MainWindow(string? capturePath = null, string? codexHome = null)
static DateTimeOffset BeijingNow => DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(8));
+ public bool HasTray => tray != null;
+
void InitializeState()
{
HomeBox.Text = settings.CodexHome;
@@ -296,7 +299,10 @@ void TopmostClick(object? sender, RoutedEventArgs e)
ApplyPinned();
}
- void HideClick(object? sender, RoutedEventArgs e) => Hide();
+ void HideClick(object? sender, RoutedEventArgs e)
+ {
+ if (tray != null) Hide();
+ }
void ExitClick(object? sender, RoutedEventArgs e) => Close();
From d689ae4a15194407199de04c52b50648d3ddad3b Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:01:51 +0800
Subject: [PATCH 19/49] fix: Use platform-native config directories on macOS
---
src/Core/PlatformPaths.cs | 6 +++++-
tests/Program.cs | 13 +++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/Core/PlatformPaths.cs b/src/Core/PlatformPaths.cs
index 7b5523c..d7e04cd 100644
--- a/src/Core/PlatformPaths.cs
+++ b/src/Core/PlatformPaths.cs
@@ -8,7 +8,7 @@ public static class PlatformPaths
{
///
/// Windows returns %APPDATA%, macOS returns ~/Library/Application Support and Linux
- /// returns ~/.config, so this is also the right place to keep user settings.
+ /// returns $XDG_CONFIG_HOME (or ~/.config), so this is also the right place for user settings.
///
public static string UserConfigDirectory(string appName = "CodexTpsFloat")
{
@@ -44,6 +44,10 @@ public static string UserCacheDirectory(string appName = "CodexTpsFloat")
static string UserConfigRoot()
{
+ if (OperatingSystem.IsMacOS())
+ return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ "Library", "Application Support");
+
if (OperatingSystem.IsLinux())
{
string? configHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
diff --git a/tests/Program.cs b/tests/Program.cs
index b428126..602d49d 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -166,6 +166,19 @@ static void Seed(UsageScanner s, double t = origin)
"同文件出现逐次 token_usage_record 后恢复可计量状态");
string settingsDirectory = Path.Combine(directory, "settings");
+ string expectedConfigRoot = OperatingSystem.IsMacOS()
+ ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ "Library", "Application Support")
+ : OperatingSystem.IsLinux()
+ ? Path.IsPathRooted(Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"))
+ ? Environment.GetEnvironmentVariable("XDG_CONFIG_HOME")!
+ : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config")
+ : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ Check(PlatformPaths.UserConfigDirectory() == Path.Combine(expectedConfigRoot, "CodexTpsFloat"),
+ "用户配置目录遵循各平台约定");
+ Check(PlatformPaths.UserAutostartDirectory() == Path.Combine(expectedConfigRoot, "autostart"),
+ "自动启动目录使用平台配置根目录");
+
var store = new SettingsStore(Path.Combine(settingsDirectory, "settings.json"));
Check(store.Load().WindowSeconds == 300, "缺失设置文件时回退到默认值");
var custom = new PanelSettings { CodexHome = directory, WindowSeconds = 999, RefreshSeconds = 42,
From 196f0f9df5dbe46c38be75d060f15fae7e565a0d Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:07:58 +0800
Subject: [PATCH 20/49] fix: Hide the macOS Dock icon for the tray app
---
README.md | 2 +-
src/App/Program.cs | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1f9b1e0..ea12f28 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ macOS 首次运行时如果被 Gatekeeper 阻止,请在 Finder 中右键 `Code
便携构建使用单文件程序,并关闭内部程序集压缩,以减少运行时解压所需的内存;下载时由外层压缩包压缩。解压后的程序较大,其中包含 .NET 运行时及各平台的界面依赖。
- 默认读取 `CODEX_HOME`;未设置时读取当前用户的 `.codex`。同时统计 `sessions` 与 `archived_sessions`。
-- 启动后只显示系统托盘图标;悬停显示当前生成速度估算。单击图标打开或收起统计面板,右键可打开面板、立即刷新或退出。面板展开时也不出现任务栏窗口按钮。
+- 启动后只显示系统托盘图标;悬停显示当前生成速度估算。单击图标打开或收起统计面板,右键可打开面板、立即刷新或退出。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。
- 面板可拖动,蓝色菱形切换置顶,减号收起到托盘。电源按钮退出整个工具。
- 切换 1 分钟、5 分钟、30 分钟、1 小时窗口,或筛选模型。自动刷新支持 5、15、30、60 秒。
- 展开「今日分时」,可以选择其他日期并导出中文 Markdown 或 JSON 报告。时区固定为北京时间 UTC+8。
diff --git a/src/App/Program.cs b/src/App/Program.cs
index c250c8b..92a9b7a 100644
--- a/src/App/Program.cs
+++ b/src/App/Program.cs
@@ -39,6 +39,7 @@ public static int Main(string[] args)
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure()
.UsePlatformDetect()
+ .With(new MacOSPlatformOptions { ShowInDock = false })
.WithInterFont()
.LogToTrace();
}
From 59ae60d0de3ae244f220f22876a6670e4d22005a Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:45:42 +0800
Subject: [PATCH 21/49] fix: Show the panel on macOS startup
---
README.md | 2 +-
src/App/App.axaml.cs | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index ea12f28..ccdc1d4 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ macOS 首次运行时如果被 Gatekeeper 阻止,请在 Finder 中右键 `Code
便携构建使用单文件程序,并关闭内部程序集压缩,以减少运行时解压所需的内存;下载时由外层压缩包压缩。解压后的程序较大,其中包含 .NET 运行时及各平台的界面依赖。
- 默认读取 `CODEX_HOME`;未设置时读取当前用户的 `.codex`。同时统计 `sessions` 与 `archived_sessions`。
-- 启动后只显示系统托盘图标;悬停显示当前生成速度估算。单击图标打开或收起统计面板,右键可打开面板、立即刷新或退出。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。
+- 启动后只显示系统托盘图标;悬停显示当前生成速度估算。单击图标打开或收起统计面板,右键可打开面板、立即刷新或退出。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。macOS 上菜单栏图标可能受系统或第三方工具影响而不可见,因此首次启动会直接显示面板,之后可用减号收起到菜单栏。
- 面板可拖动,蓝色菱形切换置顶,减号收起到托盘。电源按钮退出整个工具。
- 切换 1 分钟、5 分钟、30 分钟、1 小时窗口,或筛选模型。自动刷新支持 5、15、30、60 秒。
- 展开「今日分时」,可以选择其他日期并导出中文 Markdown 或 JSON 报告。时区固定为北京时间 UTC+8。
diff --git a/src/App/App.axaml.cs b/src/App/App.axaml.cs
index 0c09523..3d0fcd9 100644
--- a/src/App/App.axaml.cs
+++ b/src/App/App.axaml.cs
@@ -36,7 +36,9 @@ public override void OnFrameworkInitializationCompleted()
await window.StartAsync();
if (Options.CapturePath != null)
await window.CaptureAndCloseAsync(Options.CapturePath);
- else if (!window.HasTray)
+ // Avalonia can create a tray icon on macOS without macOS displaying it,
+ // so there is no reliable way to detect an unusable menu bar item.
+ else if (OperatingSystem.IsMacOS() || !window.HasTray)
window.ShowPanel();
};
From 1d3a198b867ae7d59bb3d7fc89b3654109ed969d Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:45:45 +0800
Subject: [PATCH 22/49] feat: Make the whole macOS panel draggable
---
src/App/MainWindow.axaml | 3 ++-
src/App/MainWindow.axaml.cs | 12 +++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/App/MainWindow.axaml b/src/App/MainWindow.axaml
index 2ad3ba9..be7d893 100644
--- a/src/App/MainWindow.axaml
+++ b/src/App/MainWindow.axaml
@@ -11,6 +11,7 @@
Background="Transparent"
ShowInTaskbar="False"
Topmost="True"
+ PointerPressed="DragPanel"
FontFamily="{DynamicResource InterFont}"
FontSize="12"
Foreground="#262629">
@@ -56,7 +57,7 @@
-
+
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index bcb33ba..c9cd9aa 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -15,6 +15,7 @@
using Avalonia.Platform;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
+using Avalonia.VisualTree;
namespace CodexTpsFloat.App;
@@ -256,15 +257,24 @@ void SaveSettings()
if (error != null && !closing) ToolTip.SetTip(StatusText, "设置保存失败:" + error);
}
- void DragHeader(object? sender, PointerPressedEventArgs e)
+ void DragPanel(object? sender, PointerPressedEventArgs e)
{
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
+ if (e.Source is Visual source && HasInteractiveAncestor(source)) return;
BeginMoveDrag(e);
settings.X = Position.X / (Screens.ScreenFromWindow(this)?.Scaling ?? 1);
settings.Y = Position.Y / (Screens.ScreenFromWindow(this)?.Scaling ?? 1);
SaveSettings();
}
+ // macOS three-finger drag and ordinary mouse drag both end up here, so the whole
+ // panel is a drag surface except for controls that need the press themselves.
+ static bool HasInteractiveAncestor(Visual source) =>
+ source.FindAncestorOfType
-
-
-
-
+
+
+
+
diff --git a/src/App/packages.lock.json b/src/App/packages.lock.json
index 194a5bd..8cccd0a 100644
--- a/src/App/packages.lock.json
+++ b/src/App/packages.lock.json
@@ -35,17 +35,6 @@
"Avalonia.X11": "11.3.12"
}
},
- "Avalonia.Diagnostics": {
- "type": "Direct",
- "requested": "[11.3.12, )",
- "resolved": "11.3.12",
- "contentHash": "fV+CTB/IDsFPqUVu5OQbpFLNeGLv9EmwxEjjuesJkzgT5R7mhkpLdZN3iWNC8gWkb2zfWG6mhu/q9jzDkiNhLA==",
- "dependencies": {
- "Avalonia": "11.3.12",
- "Avalonia.Controls.ColorPicker": "11.3.12",
- "Avalonia.Themes.Simple": "11.3.12"
- }
- },
"Avalonia.Fonts.Inter": {
"type": "Direct",
"requested": "[11.3.12, )",
@@ -64,6 +53,12 @@
"Avalonia": "11.3.12"
}
},
+ "Microsoft.NET.ILLink.Tasks": {
+ "type": "Direct",
+ "requested": "[10.0.11, )",
+ "resolved": "10.0.11",
+ "contentHash": "IBf7lbovvjGWVWXZX5cJ/cO0WXbId0Zq4BuSeT94mGZuOAP66oMeH9PTBZ9Jpp3Jb6jtK0qm/NyUbPRo1gC/wQ=="
+ },
"Avalonia.Angle.Windows.Natives": {
"type": "Transitive",
"resolved": "2.1.25547.20250602",
@@ -74,15 +69,6 @@
"resolved": "11.3.2",
"contentHash": "qHDToxto1e3hci5YqbG9n0Ty8mlp3zBUN5wT66wKqaDVzXyQ0do3EnRILd4Ke9jpvsktaPpgE0YjEk7hornryQ=="
},
- "Avalonia.Controls.ColorPicker": {
- "type": "Transitive",
- "resolved": "11.3.12",
- "contentHash": "NIqh2J3LUYpKvk+eeIc6jXcPWwuL/Dr5DQF6ZL3qRETkOhGdec1G7D9aMFwxltx0cLhXPnuSpYnKPIBp31OrHw==",
- "dependencies": {
- "Avalonia": "11.3.12",
- "Avalonia.Remote.Protocol": "11.3.12"
- }
- },
"Avalonia.FreeDesktop": {
"type": "Transitive",
"resolved": "11.3.12",
@@ -119,14 +105,6 @@
"SkiaSharp.NativeAssets.WebAssembly": "2.88.9"
}
},
- "Avalonia.Themes.Simple": {
- "type": "Transitive",
- "resolved": "11.3.12",
- "contentHash": "Zubwo5oC2mjLGgHbkhqFIGnOLiPX6I8CfIBMknrhLH1YndKNSpm15o6jn5FASa+rshuBsylKA7iypEIPosXjWw==",
- "dependencies": {
- "Avalonia": "11.3.12"
- }
- },
"Avalonia.Win32": {
"type": "Transitive",
"resolved": "11.3.12",
@@ -268,6 +246,59 @@
"Microsoft.Data.Sqlite": "[10.0.13, )"
}
}
+ },
+ "net10.0/osx-arm64": {
+ "Avalonia.Angle.Windows.Natives": {
+ "type": "Transitive",
+ "resolved": "2.1.25547.20250602",
+ "contentHash": "ZL0VLc4s9rvNNFt19Pxm5UNAkmKNylugAwJPX9ulXZ6JWs/l6XZihPWWTyezaoNOVyEPU8YbURtW7XMAtqXH5A=="
+ },
+ "Avalonia.Native": {
+ "type": "Transitive",
+ "resolved": "11.3.12",
+ "contentHash": "28q2DUSGUBVRpEQWYBo0crokZabPyI7KmA68++nm/qAe/9Zxmxythk/F36swAkI4pIU2ouLIKK0yxiFBy+xvNw==",
+ "dependencies": {
+ "Avalonia": "11.3.12"
+ }
+ },
+ "HarfBuzzSharp.NativeAssets.Linux": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "3EZ1mpIiKWRLL5hUYA82ZHteeDIVaEA/Z0rA/wU6tjx6crcAkJnBPwDXZugBSfo8+J3EznvRJf49uMsqYfKrHg=="
+ },
+ "HarfBuzzSharp.NativeAssets.macOS": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "jbtCsgftcaFLCA13tVKo5iWdElJScrulLTKJre36O4YQTIlwDtPPqhRZNk+Y0vv4D1gxbscasGRucUDfS44ofQ=="
+ },
+ "HarfBuzzSharp.NativeAssets.Win32": {
+ "type": "Transitive",
+ "resolved": "8.3.1.1",
+ "contentHash": "UsJtQsfAJoFDZrXc4hCUfRPMqccfKZ0iumJ/upcUjz/cmsTgVFGNEL5yaJWmkqsuFYdMWbj/En5/kS4PFl9hBA=="
+ },
+ "SkiaSharp.NativeAssets.Linux": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "cWSaJKVPWAaT/WIn9c8T5uT/l4ETwHxNJTkEOtNKjphNo8AW6TF9O32aRkxqw3l8GUdUo66Bu7EiqtFh/XG0Zg==",
+ "dependencies": {
+ "SkiaSharp": "2.88.9"
+ }
+ },
+ "SkiaSharp.NativeAssets.macOS": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "Nv5spmKc4505Ep7oUoJ5vp3KweFpeNqxpyGDWyeEPTX2uR6S6syXIm3gj75dM0YJz7NPvcix48mR5laqs8dPuA=="
+ },
+ "SkiaSharp.NativeAssets.Win32": {
+ "type": "Transitive",
+ "resolved": "2.88.9",
+ "contentHash": "wb2kYgU7iy84nQLYZwMeJXixvK++GoIuECjU4ECaUKNuflyRlJKyiRhN1MAHswvlvzuvkrjRWlK0Za6+kYQK7w=="
+ },
+ "SQLitePCLRaw.lib.e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "D2UAuiGxFYBqeRXjjjGgvJ5UQifzn6wefmSqeKU7XcNGKLbJRP6X7kcPZ6opOBJGdCIlgbSxTvDpBbLvsN594A=="
+ }
}
}
}
\ No newline at end of file
diff --git a/src/Core/packages.lock.json b/src/Core/packages.lock.json
index e11fa5f..1a00a78 100644
--- a/src/Core/packages.lock.json
+++ b/src/Core/packages.lock.json
@@ -13,6 +13,12 @@
"SQLitePCLRaw.core": "2.1.13"
}
},
+ "Microsoft.NET.ILLink.Tasks": {
+ "type": "Direct",
+ "requested": "[10.0.11, )",
+ "resolved": "10.0.11",
+ "contentHash": "IBf7lbovvjGWVWXZX5cJ/cO0WXbId0Zq4BuSeT94mGZuOAP66oMeH9PTBZ9Jpp3Jb6jtK0qm/NyUbPRo1gC/wQ=="
+ },
"Microsoft.Data.Sqlite.Core": {
"type": "Transitive",
"resolved": "10.0.13",
@@ -48,6 +54,13 @@
"SQLitePCLRaw.core": "2.1.13"
}
}
+ },
+ "net10.0/osx-arm64": {
+ "SQLitePCLRaw.lib.e_sqlite3": {
+ "type": "Transitive",
+ "resolved": "2.1.13",
+ "contentHash": "D2UAuiGxFYBqeRXjjjGgvJ5UQifzn6wefmSqeKU7XcNGKLbJRP6X7kcPZ6opOBJGdCIlgbSxTvDpBbLvsN594A=="
+ }
}
}
}
\ No newline at end of file
From 0bb1a785414a21e63149c6465bb54f7875e16714 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:50:06 +0800
Subject: [PATCH 24/49] Replace panel symbols with vector icons
---
src/App/MainWindow.axaml | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/App/MainWindow.axaml b/src/App/MainWindow.axaml
index 53fc3b4..b7c8c0c 100644
--- a/src/App/MainWindow.axaml
+++ b/src/App/MainWindow.axaml
@@ -76,21 +76,29 @@
From a009f2aa2b2dba14a46a618b9fd2e5128f43b8eb Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:54:31 +0800
Subject: [PATCH 25/49] fix: Upgrade Tmds.DBus.Protocol to patched version
Reference version 0.21.3 explicitly and update the lock file to resolve GHSA-xrw6-gwf8-vvr9 and eliminate NU1903.
---
src/App/CodexTpsFloat.App.csproj | 2 ++
src/App/packages.lock.json | 11 ++++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/App/CodexTpsFloat.App.csproj b/src/App/CodexTpsFloat.App.csproj
index 176fe93..8101cf8 100644
--- a/src/App/CodexTpsFloat.App.csproj
+++ b/src/App/CodexTpsFloat.App.csproj
@@ -19,6 +19,8 @@
+
+
diff --git a/src/App/packages.lock.json b/src/App/packages.lock.json
index 8cccd0a..4d01eaa 100644
--- a/src/App/packages.lock.json
+++ b/src/App/packages.lock.json
@@ -59,6 +59,12 @@
"resolved": "10.0.11",
"contentHash": "IBf7lbovvjGWVWXZX5cJ/cO0WXbId0Zq4BuSeT94mGZuOAP66oMeH9PTBZ9Jpp3Jb6jtK0qm/NyUbPRo1gC/wQ=="
},
+ "Tmds.DBus.Protocol": {
+ "type": "Direct",
+ "requested": "[0.21.3, )",
+ "resolved": "0.21.3",
+ "contentHash": "hDwB8WsQoyALQKqIbwzS68UKdlnafDm4T/DkO/JrA/YIneP/rKv96SxYPVXeh3FP4i/SXfShrYftKLtciJAIlw=="
+ },
"Avalonia.Angle.Windows.Natives": {
"type": "Transitive",
"resolved": "2.1.25547.20250602",
@@ -235,11 +241,6 @@
"SQLitePCLRaw.core": "2.1.13"
}
},
- "Tmds.DBus.Protocol": {
- "type": "Transitive",
- "resolved": "0.21.2",
- "contentHash": "ScSMrUrrw8px4kK1Glh0fZv/HQUlg1078bNXNPfRPKQ3WbRzV9HpsydYEOgSoMK5LWICMf2bMwIFH0pGjxjcMA=="
- },
"codextpsfloat.core": {
"type": "Project",
"dependencies": {
From 15a2f773d63c802d856ef9604813a2cc289dc48c Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 18:54:54 +0800
Subject: [PATCH 26/49] fix: Render a transparent macOS tray icon
---
README.md | 2 +-
src/App/MainWindow.axaml.cs | 28 ++++++++++------------------
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index ccdc1d4..844d957 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ macOS 首次运行时如果被 Gatekeeper 阻止,请在 Finder 中右键 `Code
便携构建使用单文件程序,并关闭内部程序集压缩,以减少运行时解压所需的内存;下载时由外层压缩包压缩。解压后的程序较大,其中包含 .NET 运行时及各平台的界面依赖。
- 默认读取 `CODEX_HOME`;未设置时读取当前用户的 `.codex`。同时统计 `sessions` 与 `archived_sessions`。
-- 启动后只显示系统托盘图标;悬停显示当前生成速度估算。单击图标打开或收起统计面板,右键可打开面板、立即刷新或退出。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。macOS 上菜单栏图标可能受系统或第三方工具影响而不可见,因此首次启动会直接显示面板,之后可用减号收起到菜单栏。
+- 托盘图标使用透明底的统计条形图;macOS 菜单栏图标随系统自动适配深浅色。悬停显示当前生成速度估算。Windows 和 Linux 启动后只显示系统托盘图标,单击打开或收起统计面板,右键可打开面板、立即刷新或退出;macOS 点击图标弹出菜单,可选择「打开统计面板」。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。macOS 上菜单栏图标可能受系统或第三方工具影响而不可见,因此启动会直接显示面板,之后可用减号收起到菜单栏。
- 面板可拖动,蓝色菱形切换置顶,减号收起到托盘。电源按钮退出整个工具。
- 切换 1 分钟、5 分钟、30 分钟、1 小时窗口,或筛选模型。自动刷新支持 5、15、30、60 秒。
- 展开「今日分时」,可以选择其他日期并导出中文 Markdown 或 JSON 报告。时区固定为北京时间 UTC+8。
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index c9cd9aa..7a6868c 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -12,7 +12,6 @@
using Avalonia.Interactivity;
using Avalonia.Media;
using Avalonia.Media.Imaging;
-using Avalonia.Platform;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using Avalonia.VisualTree;
@@ -107,6 +106,8 @@ void InitializeState()
Menu = menu,
IsVisible = true
};
+ // Let AppKit tint the transparent glyph for light/dark menu bars.
+ MacOSProperties.SetIsTemplateIcon(icon, OperatingSystem.IsMacOS());
icon.Clicked += (_, _) => TogglePanel();
return icon;
}
@@ -495,24 +496,15 @@ static class TrayIconFactory
{
public static WindowIcon Create()
{
- const int size = 32;
- var pixels = new byte[size * size * 4];
- for (int y = 0; y < size; y++)
+ // An 18-point glyph rendered at 2x stays sharp on Retina displays.
+ // Leave transparent padding so the menu bar shows bars, not a solid square.
+ using var bitmap = new RenderTargetBitmap(new PixelSize(36, 36), new Vector(192, 192));
+ using (var drawing = bitmap.CreateDrawingContext())
{
- for (int x = 0; x < size; x++)
- {
- int index = (y * size + x) * 4;
- pixels[index] = 0x00;
- pixels[index + 1] = 0x7A;
- pixels[index + 2] = 0xFF;
- pixels[index + 3] = 0xFF;
- }
- }
- using var bitmap = new WriteableBitmap(
- new PixelSize(size, size), new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Unpremul);
- using (var buffer = bitmap.Lock())
- {
- System.Runtime.InteropServices.Marshal.Copy(pixels, 0, buffer.Address, pixels.Length);
+ IBrush brush = OperatingSystem.IsMacOS() ? Brushes.Black : new SolidColorBrush(Color.Parse("#007AFF"));
+ drawing.DrawRectangle(brush, null, new Rect(2, 10, 3, 6), 0.75, 0.75);
+ drawing.DrawRectangle(brush, null, new Rect(7.5, 6, 3, 10), 0.75, 0.75);
+ drawing.DrawRectangle(brush, null, new Rect(13, 2, 3, 14), 0.75, 0.75);
}
using var stream = new MemoryStream();
bitmap.Save(stream);
From 8ed1cb85054248db5bd7c5af42003accb88dfca3 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 19:20:56 +0800
Subject: [PATCH 27/49] ci: Add cross-platform build workflow
---
.github/workflows/ci.yml | 82 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
create mode 100644 .github/workflows/ci.yml
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..2c72a3a
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,82 @@
+name: CI
+
+on:
+ pull_request:
+ push:
+ branches:
+ - '**'
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ci-${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ steps:
+ - name: Check out source
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Set up .NET 10
+ uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
+ with:
+ dotnet-version: '10.0.x'
+
+ - name: Run core regression tests
+ run: dotnet run --project tests/CoreTests.csproj -c Release --nologo
+
+ build:
+ needs: test
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - runner: windows-latest
+ runtime: win-x64
+ shell: pwsh
+ - runner: macos-15
+ runtime: osx-arm64
+ shell: bash
+ - runner: macos-15-intel
+ runtime: osx-x64
+ shell: bash
+ - runner: ubuntu-latest
+ runtime: linux-x64
+ shell: bash
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 30
+ defaults:
+ run:
+ shell: ${{ matrix.shell }}
+ steps:
+ - name: Check out source
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Set up .NET 10
+ uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
+ with:
+ dotnet-version: '10.0.x'
+
+ - name: Run hidden tray lifecycle tests (Windows only)
+ if: runner.os == 'Windows'
+ run: dotnet run --project tests/TrayLifecycleTests.csproj -c Release --nologo -- --never-show
+
+ - name: Build portable application
+ if: runner.os == 'Windows'
+ run: ./build.ps1 -Runtime ${{ matrix.runtime }} -Portable
+
+ - name: Build portable application
+ if: runner.os != 'Windows'
+ run: PORTABLE=1 ./build.sh ${{ matrix.runtime }}
+
+ - name: Upload build artifact
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: CodexTpsFloat-ci-${{ matrix.runtime }}-${{ github.sha }}
+ path: app
+ if-no-files-found: error
+ retention-days: 14
From e0d3debaa35392bc995d320453b63bbda8ec9a27 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 20:41:36 +0800
Subject: [PATCH 28/49] fix: Restore refresh cadence selection and refine
window segments
---
src/App/MainWindow.axaml | 53 ++++++++++++++++++++++++++++---------
src/App/MainWindow.axaml.cs | 5 +++-
src/Core/packages.lock.json | 13 ---------
src/MainWindow.xaml | 4 +--
src/MainWindow.xaml.cs | 5 +++-
5 files changed, 51 insertions(+), 29 deletions(-)
diff --git a/src/App/MainWindow.axaml b/src/App/MainWindow.axaml
index b7c8c0c..0ee629b 100644
--- a/src/App/MainWindow.axaml
+++ b/src/App/MainWindow.axaml
@@ -15,6 +15,45 @@
FontFamily="{DynamicResource InterFont}"
FontSize="12"
Foreground="#262629">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -18,7 +18,7 @@
-
+
diff --git a/src/MainWindow.xaml.cs b/src/MainWindow.xaml.cs
index c70bd90..c3d9b2f 100644
--- a/src/MainWindow.xaml.cs
+++ b/src/MainWindow.xaml.cs
@@ -45,8 +45,11 @@ public MainWindow(string? capturePath = null, string? codexHome = null)
PinButton.Foreground = new SolidColorBrush(settings.Pinned ? Color.FromRgb(0, 122, 255) : Colors.Gray);
DateBox.SelectedDate = BeijingNow.Date;
StartupBox.IsChecked = autostart.IsEnabled();
+ // Assign the selection instead of toggling IsSelected on every item: clearing a later
+ // item's IsSelected would also clear the selection just set on an earlier one.
foreach (var item in CadenceBox.Items.OfType())
- item.IsSelected = item.Tag?.ToString() == settings.RefreshSeconds.ToString(CultureInfo.InvariantCulture);
+ if (item.Tag?.ToString() == settings.RefreshSeconds.ToString(CultureInfo.InvariantCulture))
+ CadenceBox.SelectedItem = item;
foreach (var radio in new[] { MinuteWindow, FiveMinuteWindow, HalfHourWindow, HourWindow })
if (radio.Tag?.ToString() == settings.WindowSeconds.ToString(CultureInfo.InvariantCulture)) radio.IsChecked = true;
timer.Interval = TimeSpan.FromSeconds(settings.RefreshSeconds);
From 64a606ebeee854389adbb1ebcf8dc150702f7d94 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Thu, 15 Oct 2026 23:45:45 +0800
Subject: [PATCH 29/49] fix: Exclude Avalonia sources from the legacy WPF
project
---
src/CodexTpsFloat.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CodexTpsFloat.csproj b/src/CodexTpsFloat.csproj
index 6a9e4d9..2faed30 100644
--- a/src/CodexTpsFloat.csproj
+++ b/src/CodexTpsFloat.csproj
@@ -14,5 +14,5 @@
true
-
+
From d2830e1ca7a14b5e02e24e72707a636cad4f2e46 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:10:58 +0800
Subject: [PATCH 30/49] fix: Start the Avalonia UI on an STA thread
---
src/App/Program.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/App/Program.cs b/src/App/Program.cs
index 92a9b7a..9653879 100644
--- a/src/App/Program.cs
+++ b/src/App/Program.cs
@@ -7,6 +7,7 @@ namespace CodexTpsFloat.App;
public static class Program
{
+ [STAThread]
public static int Main(string[] args)
{
var options = CommandLineOptions.Parse(args);
From fcf2071402e2c1d8d73f0ac0158df15e314741ed Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:10:58 +0800
Subject: [PATCH 31/49] fix: Preserve the legacy Windows wake event name
---
src/Core/SingleInstance.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Core/SingleInstance.cs b/src/Core/SingleInstance.cs
index 9dad6a8..4f1bd08 100644
--- a/src/Core/SingleInstance.cs
+++ b/src/Core/SingleInstance.cs
@@ -59,7 +59,7 @@ static SingleInstance CreateWindows(string name, Action? showExisting)
var mutex = new Mutex(true, scopedName, out bool first);
try
{
- var wake = new EventWaitHandle(false, EventResetMode.AutoReset, scopedName + ".Show");
+ var wake = new EventWaitHandle(false, EventResetMode.AutoReset, $"Local\\{name}.Show.v1");
RegisteredWaitHandle? registration = null;
if (first && showExisting != null)
registration = ThreadPool.RegisterWaitForSingleObject(wake,
From bbd40caa94c4c1a3479e397392403d8573f6bc07 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:11:11 +0800
Subject: [PATCH 32/49] fix: Keep capture sessions from persisting settings
---
src/App/MainWindow.axaml.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index a214265..f73104e 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -257,6 +257,7 @@ void RenderHistory()
void SaveSettings()
{
+ if (capturePath != null) return;
string? error = settingsStore.Save(settings);
if (error != null && !closing) ToolTip.SetTip(StatusText, "设置保存失败:" + error);
}
From 8c3fac2f6f697a1cf81381d0ca3f46171706ae27 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:11:11 +0800
Subject: [PATCH 33/49] fix: Preserve saved coordinates when exiting an
unopened panel
---
src/App/MainWindow.axaml.cs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index f73104e..c7b9f24 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
UsageScanner scanner;
RequestClockReader requestClocks;
UsageSnapshot? snapshot;
- bool refreshing, initialized, closing;
+ bool refreshing, initialized, closing, positioned;
readonly List models = new() { "全部模型" };
public MainWindow() : this(null, null) { }
@@ -151,6 +151,7 @@ void PositionPanel()
Position = new PixelPoint(
(int)Math.Round(Math.Clamp(x, areaLeft, Math.Max(areaLeft, areaRight - Width)) * scale),
(int)Math.Round(Math.Clamp(y, areaTop, Math.Max(areaTop, areaBottom - Bounds.Height)) * scale));
+ positioned = true;
}
public void ShowPanel()
@@ -483,7 +484,7 @@ void DisposeWindow()
if (closing) return;
closing = true;
timer.Stop();
- if (double.IsFinite(Position.X) && double.IsFinite(Position.Y))
+ if (positioned && double.IsFinite(Position.X) && double.IsFinite(Position.Y))
{
double scale = Screens.ScreenFromWindow(this)?.Scaling ?? 1;
settings.X = Position.X / scale;
From a84e6dbc1d87c3f6e815a3af4102e3afd75db50b Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:11:18 +0800
Subject: [PATCH 34/49] fix: Handle snapshot and single-instance startup errors
---
src/App/Program.cs | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/App/Program.cs b/src/App/Program.cs
index 9653879..a35eaf8 100644
--- a/src/App/Program.cs
+++ b/src/App/Program.cs
@@ -10,22 +10,22 @@ public static class Program
[STAThread]
public static int Main(string[] args)
{
- var options = CommandLineOptions.Parse(args);
- if (options == null) return 2;
+ try
+ {
+ var options = CommandLineOptions.Parse(args);
+ if (options == null) return 2;
- if (options.SnapshotPath != null)
- return SnapshotWriter.Write(options.SnapshotPath, options.CodexHome);
+ if (options.SnapshotPath != null)
+ return SnapshotWriter.Write(options.SnapshotPath, options.CodexHome);
- using var singleInstance = SingleInstance.Create(
- "CodexTpsFloat", () => App.ShowExistingPanel?.Invoke());
- if (!singleInstance.IsFirstInstance && options.CapturePath == null)
- {
- singleInstance.SignalExistingInstance();
- return 0;
- }
+ using var singleInstance = SingleInstance.Create(
+ "CodexTpsFloat", () => App.ShowExistingPanel?.Invoke());
+ if (!singleInstance.IsFirstInstance && options.CapturePath == null)
+ {
+ singleInstance.SignalExistingInstance();
+ return 0;
+ }
- try
- {
App.Options = options;
App.SingleInstance = singleInstance;
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
From c0242720f9abf20a694eeeac617c28cd76c4a673 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:11:41 +0800
Subject: [PATCH 35/49] fix: Keep the Linux panel accessible without a tray
host
---
README.md | 2 +-
src/App/MainWindow.axaml.cs | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 844d957..4c91fa0 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ macOS 首次运行时如果被 Gatekeeper 阻止,请在 Finder 中右键 `Code
便携构建使用单文件程序,并关闭内部程序集压缩,以减少运行时解压所需的内存;下载时由外层压缩包压缩。解压后的程序较大,其中包含 .NET 运行时及各平台的界面依赖。
- 默认读取 `CODEX_HOME`;未设置时读取当前用户的 `.codex`。同时统计 `sessions` 与 `archived_sessions`。
-- 托盘图标使用透明底的统计条形图;macOS 菜单栏图标随系统自动适配深浅色。悬停显示当前生成速度估算。Windows 和 Linux 启动后只显示系统托盘图标,单击打开或收起统计面板,右键可打开面板、立即刷新或退出;macOS 点击图标弹出菜单,可选择「打开统计面板」。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。macOS 上菜单栏图标可能受系统或第三方工具影响而不可见,因此启动会直接显示面板,之后可用减号收起到菜单栏。
+- 托盘图标使用透明底的统计条形图;macOS 菜单栏图标随系统自动适配深浅色。悬停显示当前生成速度估算。Windows 启动后只显示系统托盘图标,单击打开或收起统计面板,右键可打开面板、立即刷新或退出;macOS 点击图标弹出菜单,可选择「打开统计面板」。面板展开时也不出现任务栏窗口按钮或 macOS Dock 图标。macOS 上菜单栏图标可能受系统或第三方工具影响而不可见,因此启动会直接显示面板,之后可用减号收起到菜单栏。Linux 无法可靠检测托盘宿主,启动时直接显示面板并禁用收起,确保没有托盘的桌面也能操作和退出。
- 面板可拖动,蓝色菱形切换置顶,减号收起到托盘。电源按钮退出整个工具。
- 切换 1 分钟、5 分钟、30 分钟、1 小时窗口,或筛选模型。自动刷新支持 5、15、30、60 秒。
- 展开「今日分时」,可以选择其他日期并导出中文 Markdown 或 JSON 报告。时区固定为北京时间 UTC+8。
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index c7b9f24..bb77393 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -49,7 +49,7 @@ public MainWindow(string? capturePath = null, string? codexHome = null)
InitializeState();
tray = OperatingSystem.IsBrowser() ? null : CreateTrayIcon();
- HideButton.IsVisible = tray != null;
+ HideButton.IsVisible = HasTray;
if (tray != null && Application.Current != null)
TrayIcon.SetIcons(Application.Current, new TrayIcons { tray });
@@ -59,7 +59,9 @@ public MainWindow(string? capturePath = null, string? codexHome = null)
static DateTimeOffset BeijingNow => DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(8));
- public bool HasTray => tray != null;
+ // Linux can create the object without a status-notifier host. Keep the panel
+ // accessible until Avalonia exposes whether the host actually displays it.
+ public bool HasTray => tray != null && !OperatingSystem.IsLinux();
void InitializeState()
{
@@ -164,7 +166,7 @@ public void ShowPanel()
void TogglePanel()
{
- if (IsVisible) Hide();
+ if (IsVisible && HasTray) Hide();
else ShowPanel();
}
@@ -317,7 +319,7 @@ void TopmostClick(object? sender, RoutedEventArgs e)
void HideClick(object? sender, RoutedEventArgs e)
{
- if (tray != null) Hide();
+ if (HasTray) Hide();
}
void ExitClick(object? sender, RoutedEventArgs e) => Close();
From 702fe6462f2dc0853fb9d0cc64004d9d6863de7e Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:11:41 +0800
Subject: [PATCH 36/49] fix: Refresh the selected directory after in-flight
scans
---
src/App/MainWindow.axaml.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index bb77393..fdb6f36 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
UsageScanner scanner;
RequestClockReader requestClocks;
UsageSnapshot? snapshot;
- bool refreshing, initialized, closing, positioned;
+ bool refreshing, initialized, closing, positioned, refreshPending;
readonly List models = new() { "全部模型" };
public MainWindow() : this(null, null) { }
@@ -172,7 +172,8 @@ void TogglePanel()
async Task RefreshAsync()
{
- if (refreshing || closing) return;
+ if (closing) return;
+ if (refreshing) { refreshPending = true; return; }
refreshing = true;
RefreshButton.IsEnabled = false;
StatusText.Text = "读取中";
@@ -185,7 +186,7 @@ async Task RefreshAsync()
activeScanner.RequestStarts = activeClocks.Refresh();
return activeScanner.Refresh(BeijingNow);
});
- if (closing) return;
+ if (closing || !ReferenceEquals(activeScanner, scanner)) return;
bool followToday = snapshot == null || DateBox.SelectedDate == snapshot.GeneratedAt.Date;
snapshot = next;
if (followToday) DateBox.SelectedDate = next.GeneratedAt.Date;
@@ -222,6 +223,11 @@ async Task RefreshAsync()
{
refreshing = false;
RefreshButton.IsEnabled = true;
+ if (refreshPending && !closing)
+ {
+ refreshPending = false;
+ await RefreshAsync();
+ }
}
}
From 5e2ba799e10bfc2c2b1891deae8f2c26a9409fe3 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:12:00 +0800
Subject: [PATCH 37/49] ci: Label tray lifecycle checks as legacy WPF coverage
---
.github/workflows/ci.yml | 2 +-
.github/workflows/release.yml | 2 +-
README.md | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2c72a3a..ef5f42b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -61,7 +61,7 @@ jobs:
with:
dotnet-version: '10.0.x'
- - name: Run hidden tray lifecycle tests (Windows only)
+ - name: Run legacy WPF hidden tray lifecycle tests (Windows only)
if: runner.os == 'Windows'
run: dotnet run --project tests/TrayLifecycleTests.csproj -c Release --nologo -- --never-show
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e90e6ab..60aa524 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -68,7 +68,7 @@ jobs:
- name: Run core regression tests
run: dotnet run --project tests/CoreTests.csproj -c Release --nologo
- - name: Run hidden tray lifecycle tests (Windows only)
+ - name: Run legacy WPF hidden tray lifecycle tests (Windows only)
if: runner.os == 'Windows'
run: dotnet run --project tests/TrayLifecycleTests.csproj -c Release --nologo -- --never-show
diff --git a/README.md b/README.md
index 4c91fa0..dfa513f 100644
--- a/README.md
+++ b/README.md
@@ -92,4 +92,4 @@ git tag -a v1.1.4 -m "Release v1.1.4"
git push origin v1.1.4
```
-推送标签后,GitHub Actions 会校验标签与项目版本一致,运行核心测试;Windows 额外运行隐藏托盘生命周期测试。发布矩阵构建 Windows x64、macOS ARM64、macOS x64 和 Linux x64 便携包,解压后执行快照 smoke test,并生成 SHA-256 校验文件。全部平台成功后,工作流创建公开 Release 并上传所有压缩包与校验文件。打包只包含程序、README、隐私说明和第三方许可证,不包含本机设置、日志或调试符号。
+推送标签后,GitHub Actions 会校验标签与项目版本一致,运行核心测试;Windows 额外运行旧版 WPF 隐藏托盘生命周期回归测试;该测试不覆盖 Avalonia 发布入口的托盘行为,后者仍需在各桌面环境进行手动验收。发布矩阵构建 Windows x64、macOS ARM64、macOS x64 和 Linux x64 便携包,解压后执行快照 smoke test,并生成 SHA-256 校验文件。全部平台成功后,工作流创建公开 Release 并上传所有压缩包与校验文件。打包只包含程序、README、隐私说明和第三方许可证,不包含本机设置、日志或调试符号。
From 9de23d57e6a1dc334d656d518b89c537f0ab00be Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:12:41 +0800
Subject: [PATCH 38/49] fix: Escape Linux desktop autostart executable paths
---
src/Core/Autostart.cs | 18 ++++++++++++++++--
tests/Program.cs | 18 ++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/Core/Autostart.cs b/src/Core/Autostart.cs
index 88015ab..70198ac 100644
--- a/src/Core/Autostart.cs
+++ b/src/Core/Autostart.cs
@@ -92,6 +92,20 @@ public MacAutostart(string executable, string? launchAgentsDirectory = null) =>
public sealed class LinuxAutostart : IAutostartService
{
+ // Exec quoting is decoded after desktop-entry string escapes.
+ static string EncodeExecutable(string path)
+ {
+ if (path.Contains('=') || path.Contains('\0'))
+ throw new ArgumentException("登录启动路径不能包含等号或空字符。");
+ var quoted = new StringBuilder();
+ foreach (char c in path)
+ {
+ if (c is '\\' or '"' or '`' or '$') quoted.Append('\\');
+ quoted.Append(c == '%' ? "%%" : c.ToString());
+ }
+ return quoted.ToString().Replace("\\", "\\\\").Replace("\n", "\\n")
+ .Replace("\r", "\\r").Replace("\t", "\\t");
+ }
readonly string executable;
readonly string desktopPath;
public LinuxAutostart(string executable, string autostartDirectory) =>
@@ -107,13 +121,13 @@ public LinuxAutostart(string executable, string autostartDirectory) =>
[Desktop Entry]
Type=Application
Name=Codex TPS
- Exec="{executable}"
+ Exec="{EncodeExecutable(executable)}"
Terminal=false
X-GNOME-Autostart-enabled=true
""";
File.WriteAllText(desktopPath, desktop, new UTF8Encoding(false));
return null;
}
- catch (Exception e) when (e is IOException or UnauthorizedAccessException) { return e.Message; }
+ catch (Exception e) when (e is IOException or UnauthorizedAccessException or ArgumentException) { return e.Message; }
}
}
diff --git a/tests/Program.cs b/tests/Program.cs
index 602d49d..a769136 100644
--- a/tests/Program.cs
+++ b/tests/Program.cs
@@ -218,6 +218,24 @@ static void Seed(UsageScanner s, double t = origin)
"登录启动条目包含可执行路径与自启标记");
Check(login.SetEnabled(false) == null && !login.IsEnabled() && !File.Exists(entry), "停用登录启动会移除条目");
+ string linuxEntryDirectory = Path.Combine(directory, "linux-escaping");
+ var escapedLogin = new LinuxAutostart("/opt/a\"b\\c%d$e`f\napp", linuxEntryDirectory);
+ Check(escapedLogin.SetEnabled(true) == null, "Linux 特殊字符路径可写入自启动条目");
+ string execLine = File.ReadAllLines(Path.Combine(linuxEntryDirectory, "CodexTpsFloat.desktop"))
+ .Single(line => line.StartsWith("Exec="));
+ // Decode desktop-entry escapes, then Exec quoting and literal percent codes.
+ string decodedExec = execLine[6..^1].Replace("\\n", "\n").Replace("\\\\", "\\");
+ var decodedPath = new StringBuilder();
+ for (int i = 0; i < decodedExec.Length; i++)
+ {
+ if (decodedExec[i] == '\\') i++;
+ else if (decodedExec[i] == '%' && decodedExec[i + 1] == '%') i++;
+ decodedPath.Append(decodedExec[i]);
+ }
+ Check(decodedPath.ToString() == "/opt/a\"b\\c%d$e`f\napp", "Exec 两层转义后保留原始路径且不插入新条目");
+ Check(new LinuxAutostart("/opt/a=b/app", linuxEntryDirectory).SetEnabled(true) != null,
+ "拒绝 Desktop Entry 规范禁止的可执行路径");
+
string instanceName = "codex-tps-test-" + Guid.NewGuid().ToString("N") + new string('x', 80);
string instanceDirectory = Path.Combine(directory, "instance");
string readyPath = Path.Combine(directory, "instance-ready");
From 7f1740fa50e88c42560b1a3268baf3658fbd3c77 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:12:41 +0800
Subject: [PATCH 39/49] fix: Propagate Unix lock failures unrelated to
contention
---
src/Core/SingleInstance.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Core/SingleInstance.cs b/src/Core/SingleInstance.cs
index 4f1bd08..2ba00a1 100644
--- a/src/Core/SingleInstance.cs
+++ b/src/Core/SingleInstance.cs
@@ -93,7 +93,7 @@ static SingleInstance CreateUnix(string name, Action? showExisting, string? stat
FileShare.None);
owns = true;
}
- catch (IOException)
+ catch (IOException error) when ((error.HResult & 0xffff) is 11 or 32 or 33 or 35)
{
}
From 714a409df55855c5287659af88cd9609e3b2aba4 Mon Sep 17 00:00:00 2001
From: Craun718 <3653544699@qq.com>
Date: Fri, 16 Oct 2026 01:12:41 +0800
Subject: [PATCH 40/49] fix: Exclude interactive event sources from panel
dragging
---
src/App/MainWindow.axaml.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/App/MainWindow.axaml.cs b/src/App/MainWindow.axaml.cs
index fdb6f36..2926ff7 100644
--- a/src/App/MainWindow.axaml.cs
+++ b/src/App/MainWindow.axaml.cs
@@ -284,10 +284,10 @@ void DragPanel(object? sender, PointerPressedEventArgs e)
// macOS three-finger drag and ordinary mouse drag both end up here, so the whole
// panel is a drag surface except for controls that need the press themselves.
static bool HasInteractiveAncestor(Visual source) =>
- source.FindAncestorOfType