nitropack-nightly 2.11.4-20250306-162545.4eb905b7 → 2.11.4-20250306-175805.31dde1e4
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/dist/core/index.mjs +7 -4
- package/dist/deps/youch/public/error_cause/style.css +5 -0
- package/dist/deps/youch/public/error_info/style.css +55 -0
- package/dist/deps/youch/public/error_stack/script.js +74 -0
- package/dist/deps/youch/public/error_stack/style.css +206 -0
- package/dist/deps/youch/public/error_stack_source/style.css +122 -0
- package/dist/deps/youch/public/header/script.js +16 -0
- package/dist/deps/youch/public/header/style.css +55 -0
- package/dist/deps/youch/public/layout/script.js +11 -0
- package/dist/deps/youch/public/layout/style.css +414 -0
- package/dist/deps/youch/youch.mjs +239 -0
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/meta/index.mjs +1 -1
- package/dist/runtime/internal/error/dev.mjs +7 -4
- package/package.json +6 -5
package/dist/core/index.mjs
CHANGED
|
@@ -43,9 +43,9 @@ import { walk, parse } from 'ultrahtml';
|
|
|
43
43
|
import { createError, getRequestURL, getRequestHeader, getResponseHeader, getRequestHeaders, setResponseHeaders, setResponseStatus, send, eventHandler, getRequestIP, toNodeListener, createApp, fromNodeMiddleware } from 'h3';
|
|
44
44
|
import { Worker } from 'node:worker_threads';
|
|
45
45
|
import { createProxyServer } from 'httpxy';
|
|
46
|
+
import nodeCrypto from 'node:crypto';
|
|
46
47
|
import { resolve as resolve$1, dirname as dirname$1 } from 'node:path';
|
|
47
|
-
import
|
|
48
|
-
import { Youch } from 'youch';
|
|
48
|
+
import * as _youch from 'nitropack/internal/deps/youch';
|
|
49
49
|
import { SourceMapConsumer } from 'source-map';
|
|
50
50
|
import serveStatic from 'serve-static';
|
|
51
51
|
import { listen } from 'listhen';
|
|
@@ -2421,7 +2421,7 @@ async function defaultHandler(error, event, opts) {
|
|
|
2421
2421
|
}
|
|
2422
2422
|
}
|
|
2423
2423
|
await loadStackTrace(error).catch(consola.error);
|
|
2424
|
-
const youch = new Youch();
|
|
2424
|
+
const youch = new _youch.Youch();
|
|
2425
2425
|
if (isSensitive && !opts?.silent) {
|
|
2426
2426
|
const tags = [error.unhandled && "[unhandled]", error.fatal && "[fatal]"].filter(Boolean).join(" ");
|
|
2427
2427
|
const ansiError = await (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
@@ -2447,6 +2447,9 @@ async function defaultHandler(error, event, opts) {
|
|
|
2447
2447
|
if (statusCode === 404 || !getResponseHeader(event, "cache-control")) {
|
|
2448
2448
|
headers["cache-control"] = "no-cache";
|
|
2449
2449
|
}
|
|
2450
|
+
if (!globalThis.crypto && !useJSON) {
|
|
2451
|
+
globalThis.crypto = nodeCrypto;
|
|
2452
|
+
}
|
|
2450
2453
|
const body = useJSON ? {
|
|
2451
2454
|
error: true,
|
|
2452
2455
|
url,
|
|
@@ -2473,7 +2476,7 @@ async function loadStackTrace(error) {
|
|
|
2473
2476
|
if (!(error instanceof Error)) {
|
|
2474
2477
|
return;
|
|
2475
2478
|
}
|
|
2476
|
-
const parsed = await new ErrorParser().defineSourceLoader(sourceLoader).parse(error);
|
|
2479
|
+
const parsed = await new _youch.ErrorParser().defineSourceLoader(sourceLoader).parse(error);
|
|
2477
2480
|
const stack = error.message + "\n" + parsed.frames.map((frame) => fmtFrame(frame)).join("\n");
|
|
2478
2481
|
Object.defineProperty(error, "stack", { value: stack });
|
|
2479
2482
|
if (error.cause) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#error-name {
|
|
2
|
+
color: var(--danger-fg);
|
|
3
|
+
font-size: 16px;
|
|
4
|
+
-webkit-font-smoothing: antialiased;
|
|
5
|
+
-moz-osx-font-smoothing: grayscale;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
#error-title {
|
|
9
|
+
color: var(--title-fg);
|
|
10
|
+
font-size: 32px;
|
|
11
|
+
-webkit-font-smoothing: antialiased;
|
|
12
|
+
-moz-osx-font-smoothing: grayscale;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#error-message {
|
|
16
|
+
color: var(--danger-fg);
|
|
17
|
+
font-size: 22px;
|
|
18
|
+
font-weight: 700;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
align-items: flex-start;
|
|
22
|
+
gap: 12px;
|
|
23
|
+
-webkit-font-smoothing: antialiased;
|
|
24
|
+
-moz-osx-font-smoothing: grayscale;
|
|
25
|
+
}
|
|
26
|
+
#error-message svg {
|
|
27
|
+
margin-top: 1.5px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#error-hint {
|
|
31
|
+
border-top: 1px solid var(--border);
|
|
32
|
+
padding-top: 15px;
|
|
33
|
+
margin-top: 15px;
|
|
34
|
+
font-size: 15px;
|
|
35
|
+
font-style: italic;
|
|
36
|
+
display: flex;
|
|
37
|
+
gap: 12px;
|
|
38
|
+
align-items: flex-start;
|
|
39
|
+
padding-left: 1px;
|
|
40
|
+
}
|
|
41
|
+
#error-hint svg {
|
|
42
|
+
margin-bottom: -2px;
|
|
43
|
+
}
|
|
44
|
+
#error-hint strong {
|
|
45
|
+
color: var(--title-fg);
|
|
46
|
+
}
|
|
47
|
+
#error-hint a {
|
|
48
|
+
color: var(--links-fg);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@media (min-width: 1024px) {
|
|
52
|
+
#error-hint {
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function showFormattedFrames(button) {
|
|
2
|
+
document.querySelector('#all-frames-toggle input[type="checkbox"]').disabled = false
|
|
3
|
+
const parent = button.closest('section')
|
|
4
|
+
|
|
5
|
+
const formattedFrames = parent.querySelector('#stack-frames-formatted')
|
|
6
|
+
formattedFrames.classList.add('visible')
|
|
7
|
+
|
|
8
|
+
const rawFrames = parent.querySelector('#stack-frames-raw')
|
|
9
|
+
rawFrames.classList.remove('visible')
|
|
10
|
+
|
|
11
|
+
button.parentElement.querySelectorAll('button').forEach((btn) => btn.classList.remove('active'))
|
|
12
|
+
button.classList.add('active')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function showRawFrames(button) {
|
|
16
|
+
document.querySelector('#all-frames-toggle input[type="checkbox"]').disabled = true
|
|
17
|
+
const parent = button.closest('section')
|
|
18
|
+
|
|
19
|
+
const formattedFrames = parent.querySelector('#stack-frames-formatted')
|
|
20
|
+
formattedFrames.classList.remove('visible')
|
|
21
|
+
|
|
22
|
+
const rawFrames = parent.querySelector('#stack-frames-raw')
|
|
23
|
+
rawFrames.classList.add('visible')
|
|
24
|
+
|
|
25
|
+
button.parentElement.querySelectorAll('button').forEach((btn) => btn.classList.remove('active'))
|
|
26
|
+
button.classList.add('active')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function toggleFrameSource(parent) {
|
|
30
|
+
if (parent.classList.contains('expanded')) {
|
|
31
|
+
parent.classList.remove('expanded')
|
|
32
|
+
} else {
|
|
33
|
+
parent.classList.add('expanded')
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toggleAllFrames() {
|
|
38
|
+
const wrapper = document.querySelector('#stack-frames-wrapper')
|
|
39
|
+
const indicator = document.querySelector('#all-frames-toggle input[type="checkbox"]')
|
|
40
|
+
if (indicator.checked) {
|
|
41
|
+
wrapper.classList.add('display-all')
|
|
42
|
+
} else {
|
|
43
|
+
wrapper.classList.remove('display-all')
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
48
|
+
document.querySelector('#formatted-frames-toggle').addEventListener('click', function () {
|
|
49
|
+
showFormattedFrames(this)
|
|
50
|
+
})
|
|
51
|
+
document.querySelector('#raw-frames-toggle').addEventListener('click', function () {
|
|
52
|
+
showRawFrames(this)
|
|
53
|
+
})
|
|
54
|
+
document
|
|
55
|
+
.querySelector('#all-frames-toggle input[type="checkbox"]')
|
|
56
|
+
.addEventListener('change', function () {
|
|
57
|
+
toggleAllFrames()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
document.querySelectorAll('button[class="stack-frame-location"]').forEach((sfl) => {
|
|
61
|
+
sfl.addEventListener('click', function (e) {
|
|
62
|
+
if (e.target.tagName === 'A') {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
toggleFrameSource(e.target.closest('li'))
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
document.querySelectorAll('button[class="stack-frame-toggle-indicator"]').forEach((sfl) => {
|
|
70
|
+
sfl.addEventListener('click', function (e) {
|
|
71
|
+
toggleFrameSource(e.target.closest('li'))
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--frame-bg: var(--slate-2);
|
|
3
|
+
--label-bg: var(--green-5);
|
|
4
|
+
--label-fg: var(--green-12);
|
|
5
|
+
--switch-bg: var(--slate-3);
|
|
6
|
+
--switch-active-bg: var(--slate-a4);
|
|
7
|
+
--switch-border: var(--slate-7);
|
|
8
|
+
}
|
|
9
|
+
html.dark {
|
|
10
|
+
--frame-bg: var(--slate-2);
|
|
11
|
+
--label-bg: var(--green-3);
|
|
12
|
+
--label-fg: var(--green-11);
|
|
13
|
+
--switch-bg: var(--slate-3);
|
|
14
|
+
--switch-active-bg: var(--slate-a4);
|
|
15
|
+
--switch-border: var(--slate-7);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#stack-frames-wrapper {
|
|
19
|
+
border: 1px solid var(--border);
|
|
20
|
+
border-radius: var(--radius);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#stack-frames-header {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
align-items: center;
|
|
27
|
+
padding: 10px 16px;
|
|
28
|
+
border-radius: var(--radius) var(--radius) 0 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#all-frames-toggle {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: 6px;
|
|
35
|
+
font-size: 13px;
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
user-select: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#stack-frames {
|
|
41
|
+
list-style: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.stack-frame {
|
|
45
|
+
border-top: 1px solid var(--border);
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
}
|
|
48
|
+
.stack-frame.stack-frame-native {
|
|
49
|
+
display: none;
|
|
50
|
+
font-style: italic;
|
|
51
|
+
}
|
|
52
|
+
.stack-frame.stack-frame-native a,
|
|
53
|
+
.stack-frame.stack-frame-native code {
|
|
54
|
+
color: var(--muted-fg);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#stack-frames-wrapper.display-all .stack-frame.stack-frame-native {
|
|
58
|
+
display: block;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.stack-frame-contents {
|
|
62
|
+
background: var(--frame-bg);
|
|
63
|
+
display: flex;
|
|
64
|
+
padding: 0 12px;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
}
|
|
68
|
+
.stack-frame:not(.stack-frame-native) .stack-frame-contents:hover {
|
|
69
|
+
background: var(--card-bg);
|
|
70
|
+
}
|
|
71
|
+
.stack-frame:last-child:not(.expanded) .stack-frame-contents {
|
|
72
|
+
border-radius: 0 0 var(--radius) var(--radius);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.stack-frame-location {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
gap: 7px;
|
|
80
|
+
border: none;
|
|
81
|
+
background: none;
|
|
82
|
+
flex: 1;
|
|
83
|
+
color: inherit;
|
|
84
|
+
font: inherit;
|
|
85
|
+
padding: 9px 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.stack-frame-location a {
|
|
89
|
+
text-decoration: none;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
}
|
|
94
|
+
.stack-frame-location span {
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
text-overflow: ellipsis;
|
|
98
|
+
}
|
|
99
|
+
.stack-frame-location code {
|
|
100
|
+
font-family: var(--font-sans);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.stack-frame-extras {
|
|
104
|
+
display: flex;
|
|
105
|
+
gap: 6px;
|
|
106
|
+
align-items: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.stack-frame-toggle-indicator {
|
|
110
|
+
border: none;
|
|
111
|
+
border-radius: var(--radius);
|
|
112
|
+
height: 22px;
|
|
113
|
+
width: 22px;
|
|
114
|
+
display: flex;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
align-items: center;
|
|
117
|
+
background: none;
|
|
118
|
+
color: inherit;
|
|
119
|
+
font: inherit;
|
|
120
|
+
}
|
|
121
|
+
.stack-frame-toggle-indicator:hover {
|
|
122
|
+
border: 1px solid var(--switch-border);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.stack-frame-toggle-indicator svg {
|
|
126
|
+
width: 16px;
|
|
127
|
+
display: block;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.stack-frame.expanded .stack-frame-toggle-indicator svg {
|
|
131
|
+
transform: rotate(180deg);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.frame-label {
|
|
135
|
+
padding: 0px 8px;
|
|
136
|
+
border-radius: 20px;
|
|
137
|
+
align-items: center;
|
|
138
|
+
height: 20px;
|
|
139
|
+
background: var(--label-bg);
|
|
140
|
+
font-size: 12px;
|
|
141
|
+
font-weight: 500;
|
|
142
|
+
color: var(--label-fg);
|
|
143
|
+
display: none;
|
|
144
|
+
}
|
|
145
|
+
.stack-frame-source {
|
|
146
|
+
display: none;
|
|
147
|
+
}
|
|
148
|
+
.stack-frame.expanded .stack-frame-source {
|
|
149
|
+
display: block;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#stack-frames-raw {
|
|
153
|
+
--pre-bg-color: transparent;
|
|
154
|
+
border-top: 1px solid var(--border);
|
|
155
|
+
}
|
|
156
|
+
#stack-frames-formatted,
|
|
157
|
+
#stack-frames-raw {
|
|
158
|
+
display: none;
|
|
159
|
+
}
|
|
160
|
+
#stack-frames-formatted.visible,
|
|
161
|
+
#stack-frames-raw.visible {
|
|
162
|
+
display: block;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.toggle-switch {
|
|
166
|
+
display: flex;
|
|
167
|
+
background: var(--switch-bg);
|
|
168
|
+
border: 1px solid var(--switch-border);
|
|
169
|
+
border-radius: var(--radius);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.toggle-switch button {
|
|
173
|
+
background: none;
|
|
174
|
+
border: none;
|
|
175
|
+
font-family: inherit;
|
|
176
|
+
color: inherit;
|
|
177
|
+
font-size: 13px;
|
|
178
|
+
font-weight: 500;
|
|
179
|
+
padding: 4px 8px;
|
|
180
|
+
border-right: 1px solid var(--switch-border);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.toggle-switch button:first-child {
|
|
184
|
+
border-radius: var(--radius) 0 0 var(--radius);
|
|
185
|
+
}
|
|
186
|
+
.toggle-switch button:last-child {
|
|
187
|
+
border-radius: 0 var(--radius) var(--radius) 0;
|
|
188
|
+
border: none;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.toggle-switch button.active {
|
|
192
|
+
background: var(--switch-active-bg);
|
|
193
|
+
color: var(--title-fg);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@media (min-width: 768px) {
|
|
197
|
+
.stack-frame-location {
|
|
198
|
+
flex-direction: row;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@media (min-width: 1024px) {
|
|
203
|
+
.frame-label {
|
|
204
|
+
display: inline-flex;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--error-bg: #ff000632;
|
|
3
|
+
--pre-selection-bg: var(--slate-a5);
|
|
4
|
+
--line-numbers-fg: var(--slate-a11);
|
|
5
|
+
}
|
|
6
|
+
html.dark {
|
|
7
|
+
--error-bg: #ff173f2d;
|
|
8
|
+
--pre-selection-bg: var(--slate-a5);
|
|
9
|
+
--line-numbers-fg: var(--slate-a11);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.line-highlight {
|
|
13
|
+
position: absolute;
|
|
14
|
+
left: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
background: var(--error-bg);
|
|
17
|
+
height: 24px;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[class*='shj-lang-'] {
|
|
22
|
+
white-space: pre;
|
|
23
|
+
border-top: 1px solid var(--border);
|
|
24
|
+
background: var(--pre-bg-color);
|
|
25
|
+
color: var(--pre-fg-color);
|
|
26
|
+
line-height: 24px;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
max-width: min(100%, 100vw);
|
|
29
|
+
display: block;
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
font-family: var(--font-mono);
|
|
32
|
+
position: relative;
|
|
33
|
+
padding: 10px 12px 12px 12px;
|
|
34
|
+
}
|
|
35
|
+
[class*='shj-lang-'] * {
|
|
36
|
+
-webkit-font-smoothing: initial;
|
|
37
|
+
-moz-osx-font-smoothing: initial;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.shj-inline {
|
|
41
|
+
margin: 0;
|
|
42
|
+
padding: 2px 5px;
|
|
43
|
+
display: inline-block;
|
|
44
|
+
border-radius: 5px;
|
|
45
|
+
}
|
|
46
|
+
[class*='shj-lang-']::selection,
|
|
47
|
+
[class*='shj-lang-'] ::selection {
|
|
48
|
+
background: var(--pre-selection-bg);
|
|
49
|
+
}
|
|
50
|
+
[class*='shj-lang-'] > div {
|
|
51
|
+
display: flex;
|
|
52
|
+
overflow: auto;
|
|
53
|
+
}
|
|
54
|
+
[class*='shj-lang-'] > div :last-child {
|
|
55
|
+
flex: 1;
|
|
56
|
+
outline: none;
|
|
57
|
+
}
|
|
58
|
+
.shj-numbers {
|
|
59
|
+
padding-left: 5px;
|
|
60
|
+
counter-reset: line;
|
|
61
|
+
}
|
|
62
|
+
.shj-numbers div {
|
|
63
|
+
padding-right: 5px;
|
|
64
|
+
}
|
|
65
|
+
.shj-numbers div:before {
|
|
66
|
+
color: var(--line-numbers-fg);
|
|
67
|
+
display: block;
|
|
68
|
+
content: counter(line);
|
|
69
|
+
opacity: 0.5;
|
|
70
|
+
text-align: right;
|
|
71
|
+
margin-right: 5px;
|
|
72
|
+
counter-increment: line;
|
|
73
|
+
}
|
|
74
|
+
.shj-syn-cmnt {
|
|
75
|
+
font-style: italic;
|
|
76
|
+
}
|
|
77
|
+
.shj-syn-err,
|
|
78
|
+
.shj-syn-kwd {
|
|
79
|
+
color: var(--dt-symbol-fg-color);
|
|
80
|
+
}
|
|
81
|
+
.shj-syn-num {
|
|
82
|
+
color: var(--dt-number-fg-color);
|
|
83
|
+
}
|
|
84
|
+
.shj-syn-class {
|
|
85
|
+
color: var(--class-label-fg-color);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.shj-numbers,
|
|
89
|
+
.shj-syn-cmnt {
|
|
90
|
+
color: var(--dt-undefined-fg-color);
|
|
91
|
+
}
|
|
92
|
+
.shj-syn-insert,
|
|
93
|
+
.shj-syn-str {
|
|
94
|
+
color: var(--dt-string-fg-color);
|
|
95
|
+
}
|
|
96
|
+
.shj-syn-bool {
|
|
97
|
+
color: var(--dt-boolean-fg-color);
|
|
98
|
+
}
|
|
99
|
+
.shj-syn-type,
|
|
100
|
+
.shj-syn-oper {
|
|
101
|
+
color: var(--braces-fg-color);
|
|
102
|
+
}
|
|
103
|
+
.shj-syn-section,
|
|
104
|
+
.shj-syn-func {
|
|
105
|
+
color: var(--pre-fg-color);
|
|
106
|
+
}
|
|
107
|
+
.shj-syn-deleted,
|
|
108
|
+
.shj-syn-var {
|
|
109
|
+
color: var(--brackets-fg-color);
|
|
110
|
+
}
|
|
111
|
+
.shj-oneline {
|
|
112
|
+
padding: 12px 10px;
|
|
113
|
+
}
|
|
114
|
+
.shj-multiline.shj-mode-header {
|
|
115
|
+
padding: 20px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (min-width: 768px) {
|
|
119
|
+
[class*='shj-lang-'] {
|
|
120
|
+
border-top: none;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function toggleTheme(input) {
|
|
2
|
+
if (input.checked) {
|
|
3
|
+
document.documentElement.classList.add('dark')
|
|
4
|
+
localStorage.setItem('youch-theme', 'dark')
|
|
5
|
+
} else {
|
|
6
|
+
document.documentElement.classList.remove('dark')
|
|
7
|
+
localStorage.setItem('youch-theme', 'light')
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
12
|
+
document.querySelector('#toggle-theme-checkbox').checked = usesDarkMode()
|
|
13
|
+
document.querySelector('#toggle-theme-checkbox').addEventListener('change', function () {
|
|
14
|
+
toggleTheme(this)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#header-actions {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row-reverse;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
#toggle-theme-container {
|
|
7
|
+
position: relative;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
padding-right: 10px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#toggle-theme-container input[type='checkbox'] {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
position: absolute;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#toggle-theme-label {
|
|
18
|
+
position: relative;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
border-radius: 50px;
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#toggle-theme-checkbox:focus + #toggle-theme-label {
|
|
25
|
+
outline: 2px solid var(--slate-a6);
|
|
26
|
+
outline-offset: 4px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#light-theme-indicator,
|
|
30
|
+
#dark-theme-indicator {
|
|
31
|
+
position: relative;
|
|
32
|
+
z-index: 1;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#toggle-theme-label svg {
|
|
39
|
+
width: 30px;
|
|
40
|
+
height: 30px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#toggle-theme-container #dark-theme-indicator {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#toggle-theme-container
|
|
48
|
+
input[type='checkbox']:checked
|
|
49
|
+
+ #toggle-theme-label
|
|
50
|
+
#light-theme-indicator {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
#toggle-theme-container input[type='checkbox']:checked + #toggle-theme-label #dark-theme-indicator {
|
|
54
|
+
display: flex;
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function usesDarkMode() {
|
|
2
|
+
let youchTheme = localStorage.getItem('youch-theme')
|
|
3
|
+
let hasDarkMode = false
|
|
4
|
+
if (youchTheme === null) {
|
|
5
|
+
hasDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
6
|
+
} else if (youchTheme === 'dark') {
|
|
7
|
+
hasDarkMode = true
|
|
8
|
+
}
|
|
9
|
+
return hasDarkMode
|
|
10
|
+
}
|
|
11
|
+
document.documentElement.classList.add(usesDarkMode() ? 'dark' : 'light')
|