agentgui 1.0.274 → 1.0.275
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +280 -280
- package/IPFS_DOWNLOADER.md +277 -277
- package/TASK_2C_COMPLETION.md +334 -334
- package/bin/gmgui.cjs +54 -54
- package/build-portable.js +3 -42
- package/database.js +1422 -1406
- package/lib/claude-runner.js +1130 -1130
- package/lib/ipfs-downloader.js +459 -459
- package/lib/speech.js +152 -152
- package/package.json +1 -1
- package/readme.md +76 -76
- package/server.js +3787 -3794
- package/setup-npm-token.sh +68 -68
- package/static/app.js +773 -773
- package/static/event-rendering-showcase.html +708 -708
- package/static/index.html +3178 -3180
- package/static/js/agent-auth.js +298 -298
- package/static/js/audio-recorder-processor.js +18 -18
- package/static/js/client.js +2656 -2656
- package/static/js/conversations.js +583 -583
- package/static/js/dialogs.js +267 -267
- package/static/js/event-consolidator.js +101 -101
- package/static/js/event-filter.js +311 -311
- package/static/js/event-processor.js +452 -452
- package/static/js/features.js +413 -413
- package/static/js/kalman-filter.js +67 -67
- package/static/js/progress-dialog.js +130 -130
- package/static/js/script-runner.js +219 -219
- package/static/js/streaming-renderer.js +2123 -2120
- package/static/js/syntax-highlighter.js +269 -269
- package/static/js/tts-websocket-handler.js +152 -152
- package/static/js/ui-components.js +431 -431
- package/static/js/voice.js +849 -849
- package/static/js/websocket-manager.js +596 -596
- package/static/templates/INDEX.html +465 -465
- package/static/templates/README.md +190 -190
- package/static/templates/agent-capabilities.html +56 -56
- package/static/templates/agent-metadata-panel.html +44 -44
- package/static/templates/agent-status-badge.html +30 -30
- package/static/templates/code-annotation-panel.html +155 -155
- package/static/templates/code-suggestion-panel.html +184 -184
- package/static/templates/command-header.html +77 -77
- package/static/templates/command-output-scrollable.html +118 -118
- package/static/templates/elapsed-time.html +54 -54
- package/static/templates/error-alert.html +106 -106
- package/static/templates/error-history-timeline.html +160 -160
- package/static/templates/error-recovery-options.html +109 -109
- package/static/templates/error-stack-trace.html +95 -95
- package/static/templates/error-summary.html +80 -80
- package/static/templates/event-counter.html +48 -48
- package/static/templates/execution-actions.html +97 -97
- package/static/templates/execution-progress-bar.html +80 -80
- package/static/templates/execution-stepper.html +120 -120
- package/static/templates/file-breadcrumb.html +118 -118
- package/static/templates/file-diff-viewer.html +121 -121
- package/static/templates/file-metadata.html +133 -133
- package/static/templates/file-read-panel.html +66 -66
- package/static/templates/file-write-panel.html +120 -120
- package/static/templates/git-branch-remote.html +107 -107
- package/static/templates/git-diff-list.html +101 -101
- package/static/templates/git-log-visualization.html +153 -153
- package/static/templates/git-status-panel.html +115 -115
- package/static/templates/quality-metrics-display.html +170 -170
- package/static/templates/terminal-output-panel.html +87 -87
- package/static/templates/test-results-display.html +144 -144
- package/static/theme.js +72 -72
- package/test-download-progress.js +223 -223
- package/test-websocket-broadcast.js +147 -147
- package/tests/ipfs-downloader.test.js +370 -370
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
<!-- Test Results Display -->
|
|
2
|
-
<div class="test-results-display card" role="region" aria-label="Test execution results">
|
|
3
|
-
<div class="card-header flex items-center justify-between mb-3 pb-3 border-b">
|
|
4
|
-
<h4 class="font-semibold">Test Results</h4>
|
|
5
|
-
<div class="test-summary flex gap-2">
|
|
6
|
-
<span class="badge-result passed" aria-label="Passed tests">{{ passedCount }}</span>
|
|
7
|
-
<span class="badge-result failed" aria-label="Failed tests">{{ failedCount }}</span>
|
|
8
|
-
<span class="badge-result skipped" aria-label="Skipped tests">{{ skippedCount }}</span>
|
|
9
|
-
</div>
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<!-- Summary Stats -->
|
|
13
|
-
<div class="summary-stats grid grid-cols-4 gap-3 mb-4 pb-4 border-b text-center">
|
|
14
|
-
<div>
|
|
15
|
-
<p class="text-2xl font-bold text-green-600">{{ passedCount }}</p>
|
|
16
|
-
<p class="text-xs text-secondary">Passed</p>
|
|
17
|
-
</div>
|
|
18
|
-
<div>
|
|
19
|
-
<p class="text-2xl font-bold text-red-600">{{ failedCount }}</p>
|
|
20
|
-
<p class="text-xs text-secondary">Failed</p>
|
|
21
|
-
</div>
|
|
22
|
-
<div>
|
|
23
|
-
<p class="text-2xl font-bold text-yellow-600">{{ skippedCount }}</p>
|
|
24
|
-
<p class="text-xs text-secondary">Skipped</p>
|
|
25
|
-
</div>
|
|
26
|
-
<div>
|
|
27
|
-
<p class="text-2xl font-bold font-mono">{{ passPercentage }}%</p>
|
|
28
|
-
<p class="text-xs text-secondary">Pass Rate</p>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
<!-- Test Tree/List -->
|
|
33
|
-
<div class="test-list space-y-1">
|
|
34
|
-
{{ for suite in testSuites }}
|
|
35
|
-
<details class="test-suite">
|
|
36
|
-
<summary class="cursor-pointer py-2 px-3 rounded hover:bg-hover-bg flex items-center gap-2">
|
|
37
|
-
<svg class="w-4 h-4 chevron" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
38
|
-
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"/>
|
|
39
|
-
</svg>
|
|
40
|
-
<span class="font-semibold text-sm">{{ suite.name }}</span>
|
|
41
|
-
<span class="ml-auto text-xs space-x-1">
|
|
42
|
-
<span class="text-green-600">{{ suite.passed }}</span>
|
|
43
|
-
<span class="text-red-600">{{ suite.failed }}</span>
|
|
44
|
-
</span>
|
|
45
|
-
</summary>
|
|
46
|
-
|
|
47
|
-
<div class="test-cases mt-2 ml-4 space-y-1 border-l pl-3">
|
|
48
|
-
{{ for test in suite.tests }}
|
|
49
|
-
<div class="test-case flex items-center gap-2 py-1 text-sm">
|
|
50
|
-
{{ if test.status == 'passed' }}
|
|
51
|
-
<svg class="w-4 h-4 text-green-600" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
52
|
-
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"/>
|
|
53
|
-
</svg>
|
|
54
|
-
{{ else if test.status == 'failed' }}
|
|
55
|
-
<svg class="w-4 h-4 text-red-600" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
56
|
-
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"/>
|
|
57
|
-
</svg>
|
|
58
|
-
{{ else }}
|
|
59
|
-
<svg class="w-4 h-4 text-yellow-600" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
60
|
-
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm0-2a6 6 0 100-12 6 6 0 000 12z"/>
|
|
61
|
-
</svg>
|
|
62
|
-
{{ end }}
|
|
63
|
-
<span class="flex-1">{{ test.name }}</span>
|
|
64
|
-
<span class="text-secondary text-xs">{{ test.duration }}ms</span>
|
|
65
|
-
</div>
|
|
66
|
-
{{ end }}
|
|
67
|
-
</div>
|
|
68
|
-
</details>
|
|
69
|
-
{{ end }}
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<!-- Execution Metadata -->
|
|
73
|
-
<div class="mt-4 pt-4 border-t text-xs text-secondary space-y-1">
|
|
74
|
-
<p>Total Duration: <code class="font-mono">{{ totalDuration }}</code></p>
|
|
75
|
-
<p>Framework: <code class="font-mono">{{ framework }}</code></p>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<style scoped>
|
|
80
|
-
.test-results-display {
|
|
81
|
-
padding: 16px;
|
|
82
|
-
max-height: 600px;
|
|
83
|
-
overflow-y: auto;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.badge-result {
|
|
87
|
-
padding: 4px 8px;
|
|
88
|
-
border-radius: 3px;
|
|
89
|
-
font-size: 12px;
|
|
90
|
-
font-weight: 600;
|
|
91
|
-
color: white;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.badge-result.passed {
|
|
95
|
-
background-color: #10b981;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.badge-result.failed {
|
|
99
|
-
background-color: #ef4444;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.badge-result.skipped {
|
|
103
|
-
background-color: #6b7280;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.test-suite {
|
|
107
|
-
background-color: var(--color-bg-secondary);
|
|
108
|
-
border: 1px solid var(--color-border);
|
|
109
|
-
border-radius: 4px;
|
|
110
|
-
overflow: hidden;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.test-suite[open] summary {
|
|
114
|
-
background-color: var(--color-bg-hover);
|
|
115
|
-
border-bottom: 1px solid var(--color-border);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
summary {
|
|
119
|
-
list-style: none;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
summary::-webkit-details-marker {
|
|
123
|
-
display: none;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.chevron {
|
|
127
|
-
transition: transform 0.2s;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
details[open] .chevron {
|
|
131
|
-
transform: rotate(180deg);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.test-case {
|
|
135
|
-
padding: 4px 0;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.font-mono {
|
|
139
|
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
140
|
-
background-color: var(--color-bg-code);
|
|
141
|
-
padding: 1px 3px;
|
|
142
|
-
border-radius: 2px;
|
|
143
|
-
}
|
|
144
|
-
</style>
|
|
1
|
+
<!-- Test Results Display -->
|
|
2
|
+
<div class="test-results-display card" role="region" aria-label="Test execution results">
|
|
3
|
+
<div class="card-header flex items-center justify-between mb-3 pb-3 border-b">
|
|
4
|
+
<h4 class="font-semibold">Test Results</h4>
|
|
5
|
+
<div class="test-summary flex gap-2">
|
|
6
|
+
<span class="badge-result passed" aria-label="Passed tests">{{ passedCount }}</span>
|
|
7
|
+
<span class="badge-result failed" aria-label="Failed tests">{{ failedCount }}</span>
|
|
8
|
+
<span class="badge-result skipped" aria-label="Skipped tests">{{ skippedCount }}</span>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<!-- Summary Stats -->
|
|
13
|
+
<div class="summary-stats grid grid-cols-4 gap-3 mb-4 pb-4 border-b text-center">
|
|
14
|
+
<div>
|
|
15
|
+
<p class="text-2xl font-bold text-green-600">{{ passedCount }}</p>
|
|
16
|
+
<p class="text-xs text-secondary">Passed</p>
|
|
17
|
+
</div>
|
|
18
|
+
<div>
|
|
19
|
+
<p class="text-2xl font-bold text-red-600">{{ failedCount }}</p>
|
|
20
|
+
<p class="text-xs text-secondary">Failed</p>
|
|
21
|
+
</div>
|
|
22
|
+
<div>
|
|
23
|
+
<p class="text-2xl font-bold text-yellow-600">{{ skippedCount }}</p>
|
|
24
|
+
<p class="text-xs text-secondary">Skipped</p>
|
|
25
|
+
</div>
|
|
26
|
+
<div>
|
|
27
|
+
<p class="text-2xl font-bold font-mono">{{ passPercentage }}%</p>
|
|
28
|
+
<p class="text-xs text-secondary">Pass Rate</p>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<!-- Test Tree/List -->
|
|
33
|
+
<div class="test-list space-y-1">
|
|
34
|
+
{{ for suite in testSuites }}
|
|
35
|
+
<details class="test-suite">
|
|
36
|
+
<summary class="cursor-pointer py-2 px-3 rounded hover:bg-hover-bg flex items-center gap-2">
|
|
37
|
+
<svg class="w-4 h-4 chevron" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
38
|
+
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"/>
|
|
39
|
+
</svg>
|
|
40
|
+
<span class="font-semibold text-sm">{{ suite.name }}</span>
|
|
41
|
+
<span class="ml-auto text-xs space-x-1">
|
|
42
|
+
<span class="text-green-600">{{ suite.passed }}</span>
|
|
43
|
+
<span class="text-red-600">{{ suite.failed }}</span>
|
|
44
|
+
</span>
|
|
45
|
+
</summary>
|
|
46
|
+
|
|
47
|
+
<div class="test-cases mt-2 ml-4 space-y-1 border-l pl-3">
|
|
48
|
+
{{ for test in suite.tests }}
|
|
49
|
+
<div class="test-case flex items-center gap-2 py-1 text-sm">
|
|
50
|
+
{{ if test.status == 'passed' }}
|
|
51
|
+
<svg class="w-4 h-4 text-green-600" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
52
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"/>
|
|
53
|
+
</svg>
|
|
54
|
+
{{ else if test.status == 'failed' }}
|
|
55
|
+
<svg class="w-4 h-4 text-red-600" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
56
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"/>
|
|
57
|
+
</svg>
|
|
58
|
+
{{ else }}
|
|
59
|
+
<svg class="w-4 h-4 text-yellow-600" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true">
|
|
60
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm0-2a6 6 0 100-12 6 6 0 000 12z"/>
|
|
61
|
+
</svg>
|
|
62
|
+
{{ end }}
|
|
63
|
+
<span class="flex-1">{{ test.name }}</span>
|
|
64
|
+
<span class="text-secondary text-xs">{{ test.duration }}ms</span>
|
|
65
|
+
</div>
|
|
66
|
+
{{ end }}
|
|
67
|
+
</div>
|
|
68
|
+
</details>
|
|
69
|
+
{{ end }}
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<!-- Execution Metadata -->
|
|
73
|
+
<div class="mt-4 pt-4 border-t text-xs text-secondary space-y-1">
|
|
74
|
+
<p>Total Duration: <code class="font-mono">{{ totalDuration }}</code></p>
|
|
75
|
+
<p>Framework: <code class="font-mono">{{ framework }}</code></p>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<style scoped>
|
|
80
|
+
.test-results-display {
|
|
81
|
+
padding: 16px;
|
|
82
|
+
max-height: 600px;
|
|
83
|
+
overflow-y: auto;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.badge-result {
|
|
87
|
+
padding: 4px 8px;
|
|
88
|
+
border-radius: 3px;
|
|
89
|
+
font-size: 12px;
|
|
90
|
+
font-weight: 600;
|
|
91
|
+
color: white;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.badge-result.passed {
|
|
95
|
+
background-color: #10b981;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.badge-result.failed {
|
|
99
|
+
background-color: #ef4444;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.badge-result.skipped {
|
|
103
|
+
background-color: #6b7280;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.test-suite {
|
|
107
|
+
background-color: var(--color-bg-secondary);
|
|
108
|
+
border: 1px solid var(--color-border);
|
|
109
|
+
border-radius: 4px;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.test-suite[open] summary {
|
|
114
|
+
background-color: var(--color-bg-hover);
|
|
115
|
+
border-bottom: 1px solid var(--color-border);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
summary {
|
|
119
|
+
list-style: none;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
summary::-webkit-details-marker {
|
|
123
|
+
display: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.chevron {
|
|
127
|
+
transition: transform 0.2s;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
details[open] .chevron {
|
|
131
|
+
transform: rotate(180deg);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.test-case {
|
|
135
|
+
padding: 4px 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.font-mono {
|
|
139
|
+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
140
|
+
background-color: var(--color-bg-code);
|
|
141
|
+
padding: 1px 3px;
|
|
142
|
+
border-radius: 2px;
|
|
143
|
+
}
|
|
144
|
+
</style>
|
package/static/theme.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
// Theme management for dark/light mode
|
|
2
|
-
class ThemeManager {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.THEME_KEY = 'gmgui-theme';
|
|
5
|
-
this.SYSTEM_DARK_MODE = window.matchMedia('(prefers-color-scheme: dark)');
|
|
6
|
-
this.init();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
init() {
|
|
10
|
-
// Load saved theme or use system preference
|
|
11
|
-
const savedTheme = localStorage.getItem(this.THEME_KEY);
|
|
12
|
-
const prefersDark = this.SYSTEM_DARK_MODE.matches;
|
|
13
|
-
|
|
14
|
-
if (savedTheme) {
|
|
15
|
-
this.setTheme(savedTheme);
|
|
16
|
-
} else {
|
|
17
|
-
// Use system preference
|
|
18
|
-
this.setTheme(prefersDark ? 'dark' : 'light');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Listen for system theme changes
|
|
22
|
-
this.SYSTEM_DARK_MODE.addEventListener('change', (e) => {
|
|
23
|
-
const savedTheme = localStorage.getItem(this.THEME_KEY);
|
|
24
|
-
// Only auto-switch if user hasn't manually set a preference
|
|
25
|
-
if (!savedTheme) {
|
|
26
|
-
this.setTheme(e.matches ? 'dark' : 'light');
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Setup theme toggle button
|
|
31
|
-
const themeToggle = document.getElementById('themeToggle');
|
|
32
|
-
if (themeToggle) {
|
|
33
|
-
themeToggle.addEventListener('click', () => this.toggleTheme());
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
setTheme(theme) {
|
|
38
|
-
if (theme !== 'dark' && theme !== 'light') {
|
|
39
|
-
theme = 'light';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
document.documentElement.setAttribute('data-theme', theme);
|
|
43
|
-
localStorage.setItem(this.THEME_KEY, theme);
|
|
44
|
-
this.updateThemeIcon(theme);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
toggleTheme() {
|
|
48
|
-
const currentTheme = document.documentElement.getAttribute('data-theme') || 'light';
|
|
49
|
-
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
50
|
-
this.setTheme(newTheme);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
updateThemeIcon(theme) {
|
|
54
|
-
const icon = document.querySelector('.theme-icon');
|
|
55
|
-
if (icon) {
|
|
56
|
-
icon.textContent = theme === 'dark' ? '☀️' : '🌙';
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
getCurrentTheme() {
|
|
61
|
-
return document.documentElement.getAttribute('data-theme') || 'light';
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Initialize theme manager when DOM is ready
|
|
66
|
-
if (document.readyState === 'loading') {
|
|
67
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
68
|
-
window.themeManager = new ThemeManager();
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
window.themeManager = new ThemeManager();
|
|
72
|
-
}
|
|
1
|
+
// Theme management for dark/light mode
|
|
2
|
+
class ThemeManager {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.THEME_KEY = 'gmgui-theme';
|
|
5
|
+
this.SYSTEM_DARK_MODE = window.matchMedia('(prefers-color-scheme: dark)');
|
|
6
|
+
this.init();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
init() {
|
|
10
|
+
// Load saved theme or use system preference
|
|
11
|
+
const savedTheme = localStorage.getItem(this.THEME_KEY);
|
|
12
|
+
const prefersDark = this.SYSTEM_DARK_MODE.matches;
|
|
13
|
+
|
|
14
|
+
if (savedTheme) {
|
|
15
|
+
this.setTheme(savedTheme);
|
|
16
|
+
} else {
|
|
17
|
+
// Use system preference
|
|
18
|
+
this.setTheme(prefersDark ? 'dark' : 'light');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Listen for system theme changes
|
|
22
|
+
this.SYSTEM_DARK_MODE.addEventListener('change', (e) => {
|
|
23
|
+
const savedTheme = localStorage.getItem(this.THEME_KEY);
|
|
24
|
+
// Only auto-switch if user hasn't manually set a preference
|
|
25
|
+
if (!savedTheme) {
|
|
26
|
+
this.setTheme(e.matches ? 'dark' : 'light');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Setup theme toggle button
|
|
31
|
+
const themeToggle = document.getElementById('themeToggle');
|
|
32
|
+
if (themeToggle) {
|
|
33
|
+
themeToggle.addEventListener('click', () => this.toggleTheme());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setTheme(theme) {
|
|
38
|
+
if (theme !== 'dark' && theme !== 'light') {
|
|
39
|
+
theme = 'light';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
document.documentElement.setAttribute('data-theme', theme);
|
|
43
|
+
localStorage.setItem(this.THEME_KEY, theme);
|
|
44
|
+
this.updateThemeIcon(theme);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
toggleTheme() {
|
|
48
|
+
const currentTheme = document.documentElement.getAttribute('data-theme') || 'light';
|
|
49
|
+
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
50
|
+
this.setTheme(newTheme);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
updateThemeIcon(theme) {
|
|
54
|
+
const icon = document.querySelector('.theme-icon');
|
|
55
|
+
if (icon) {
|
|
56
|
+
icon.textContent = theme === 'dark' ? '☀️' : '🌙';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getCurrentTheme() {
|
|
61
|
+
return document.documentElement.getAttribute('data-theme') || 'light';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Initialize theme manager when DOM is ready
|
|
66
|
+
if (document.readyState === 'loading') {
|
|
67
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
68
|
+
window.themeManager = new ThemeManager();
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
window.themeManager = new ThemeManager();
|
|
72
|
+
}
|