-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathindex.html
More file actions
245 lines (241 loc) · 10.4 KB
/
Copy pathindex.html
File metadata and controls
245 lines (241 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Async</title>
<link rel="icon" type="image/png" href="/favicon.png" />
<script>
(() => {
const COLOR_MODE_STORAGE_KEY = 'async:color-mode-v1';
const INITIAL_WINDOW_THEME_STORAGE_KEY = 'async:initial-window-theme-v1';
const INITIAL_WINDOW_THEME_QUERY_PARAM = 'initialWindowTheme';
const DEFAULTS = {
dark: { backgroundColor: '#111111', foregroundColor: '#FCFCFC', accentColor: '#0169CC' },
light: { backgroundColor: '#F5F5F7', foregroundColor: '#1D1D1F', accentColor: '#0169CC' },
};
const root = document.documentElement;
const normalizeColorMode = (raw) =>
raw === 'light' || raw === 'dark' || raw === 'system' ? raw : 'dark';
const normalizeHexColor = (raw, fallback) => {
const value = String(raw ?? '').trim();
if (/^#[0-9a-fA-F]{6}$/.test(value)) {
return value.toUpperCase();
}
if (/^#[0-9a-fA-F]{3}$/.test(value)) {
const parts = value.slice(1).split('');
return `#${parts.map((part) => part + part).join('')}`.toUpperCase();
}
return fallback.toUpperCase();
};
const hexToRgb = (hex) => {
const normalized = normalizeHexColor(hex, '#000000');
return {
r: Number.parseInt(normalized.slice(1, 3), 16),
g: Number.parseInt(normalized.slice(3, 5), 16),
b: Number.parseInt(normalized.slice(5, 7), 16),
};
};
const rgbToHex = ({ r, g, b }) =>
`#${[r, g, b]
.map((channel) => Math.max(0, Math.min(255, Math.round(channel))).toString(16).padStart(2, '0'))
.join('')}`.toUpperCase();
const mixHex = (baseHex, overlayHex, overlayWeight) => {
const base = hexToRgb(baseHex);
const overlay = hexToRgb(overlayHex);
const weight = Math.max(0, Math.min(1, overlayWeight));
return rgbToHex({
r: base.r * (1 - weight) + overlay.r * weight,
g: base.g * (1 - weight) + overlay.g * weight,
b: base.b * (1 - weight) + overlay.b * weight,
});
};
const hexToRgba = (hex, alpha) => {
const { r, g, b } = hexToRgb(hex);
return `rgba(${r}, ${g}, ${b}, ${Math.max(0, Math.min(1, alpha))})`;
};
const parseThemePayload = (raw) => {
if (!raw) {
return null;
}
try {
const parsed = JSON.parse(raw);
return parsed && typeof parsed === 'object' ? parsed : null;
} catch {
return null;
}
};
const readThemePayload = () => {
try {
const params = new URLSearchParams(window.location.search);
return (
parseThemePayload(params.get(INITIAL_WINDOW_THEME_QUERY_PARAM)) ||
parseThemePayload(window.localStorage.getItem(INITIAL_WINDOW_THEME_STORAGE_KEY))
);
} catch {
return null;
}
};
const payload = readThemePayload();
let colorMode = normalizeColorMode(payload?.colorMode);
if (!payload) {
try {
colorMode = normalizeColorMode(window.localStorage.getItem(COLOR_MODE_STORAGE_KEY));
} catch {
colorMode = 'dark';
}
}
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const scheme =
payload?.scheme === 'light' || payload?.scheme === 'dark'
? payload.scheme
: colorMode === 'system'
? prefersDark
? 'dark'
: 'light'
: colorMode;
const defaults = DEFAULTS[scheme];
const ui = payload?.ui && typeof payload.ui === 'object' ? payload.ui : {};
const backgroundColor = normalizeHexColor(ui.backgroundColor, defaults.backgroundColor);
const foregroundColor = normalizeHexColor(ui.foregroundColor, defaults.foregroundColor);
const accentColor = normalizeHexColor(ui.accentColor, defaults.accentColor);
const bodyBg = mixHex(backgroundColor, scheme === 'dark' ? '#000000' : '#FFFFFF', scheme === 'dark' ? 0.08 : 0.02);
const splashTop = mixHex(backgroundColor, accentColor, scheme === 'dark' ? 0.14 : 0.08);
const splashBottom = mixHex(backgroundColor, scheme === 'dark' ? '#000000' : '#FFFFFF', scheme === 'dark' ? 0.16 : 0.08);
const cardBg = mixHex(backgroundColor, scheme === 'dark' ? '#FFFFFF' : '#FFFFFF', scheme === 'dark' ? 0.1 : 0.62);
const cardBorder = mixHex(backgroundColor, foregroundColor, scheme === 'dark' ? 0.2 : 0.16);
const subtitleColor = mixHex(backgroundColor, foregroundColor, scheme === 'dark' ? 0.62 : 0.58);
const loaderRing = mixHex(backgroundColor, foregroundColor, scheme === 'dark' ? 0.18 : 0.12);
const cardShadow = scheme === 'dark'
? `0 28px 80px ${hexToRgba('#000000', 0.34)}, inset 0 1px 0 ${hexToRgba('#FFFFFF', 0.04)}`
: `0 28px 80px ${hexToRgba('#5B6472', 0.16)}, inset 0 1px 0 ${hexToRgba('#FFFFFF', 0.72)}`;
root.setAttribute('data-ui-style', 'mac-codex');
root.setAttribute('data-color-scheme', scheme);
root.style.setProperty('--boot-body-bg', bodyBg);
root.style.setProperty('--boot-body-fg', foregroundColor);
root.style.setProperty(
'--boot-splash-bg',
[
`radial-gradient(circle at top center, ${hexToRgba(accentColor, scheme === 'dark' ? 0.14 : 0.1)} 0%, transparent 30%)`,
`radial-gradient(circle at 82% 16%, ${hexToRgba(foregroundColor, scheme === 'dark' ? 0.08 : 0.05)} 0%, transparent 18%)`,
`linear-gradient(180deg, ${splashTop} 0%, ${splashBottom} 100%)`,
].join(', ')
);
root.style.setProperty('--boot-card-bg', `linear-gradient(180deg, ${cardBg} 0%, ${mixHex(cardBg, backgroundColor, 0.22)} 100%)`);
root.style.setProperty('--boot-card-border', cardBorder);
root.style.setProperty('--boot-card-shadow', cardShadow);
root.style.setProperty('--boot-subtitle-color', subtitleColor);
root.style.setProperty('--boot-loader-ring', loaderRing);
root.style.setProperty('--boot-loader-accent', accentColor);
root.style.setProperty('--boot-logo-shadow', `drop-shadow(0 12px 24px ${hexToRgba(accentColor, scheme === 'dark' ? 0.18 : 0.12)})`);
})();
</script>
<style>
html, body {
margin: 0;
width: 100%;
height: 100%;
background: var(--boot-body-bg, #0b0f13);
color: var(--boot-body-fg, #f4f4f5);
overflow: hidden;
}
body {
font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#root {
width: 100%;
height: 100%;
}
#boot-splash {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
background: var(
--boot-splash-bg,
radial-gradient(circle at top center, rgba(56, 189, 248, 0.10) 0%, transparent 28%),
radial-gradient(circle at 82% 16%, rgba(251, 146, 60, 0.08) 0%, transparent 18%),
linear-gradient(180deg, #0f1419 0%, #0a0e12 100%)
);
transition: opacity 280ms ease, visibility 280ms ease;
}
#boot-splash.is-hidden {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
.boot-splash-card {
display: flex;
align-items: center;
gap: 16px;
padding: 22px 24px;
border-radius: 20px;
border: 1px solid var(--boot-card-border, rgba(255,255,255,0.08));
background: var(--boot-card-bg, linear-gradient(180deg, rgba(25, 32, 39, 0.96) 0%, rgba(18, 24, 30, 0.96) 100%));
box-shadow: var(--boot-card-shadow, 0 28px 80px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.04));
}
.boot-splash-logo {
width: 42px;
height: 42px;
flex-shrink: 0;
animation: boot-float 1.8s ease-in-out infinite;
filter: var(--boot-logo-shadow, drop-shadow(0 12px 24px rgba(255,255,255,0.08)));
}
.boot-splash-copy {
display: flex;
flex-direction: column;
gap: 4px;
}
.boot-splash-title {
font-size: 20px;
font-weight: 700;
letter-spacing: -0.03em;
}
.boot-splash-subtitle {
font-size: 12px;
color: var(--boot-subtitle-color, rgba(228, 228, 231, 0.72));
}
.boot-splash-loader {
width: 18px;
height: 18px;
margin-left: 6px;
border-radius: 999px;
border: 2px solid var(--boot-loader-ring, rgba(255,255,255,0.14));
border-top-color: var(--boot-loader-accent, #67e8f9);
animation: boot-spin 0.9s linear infinite;
}
@keyframes boot-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes boot-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
</style>
</head>
<body>
<div id="boot-splash" aria-hidden="true">
<div class="boot-splash-card">
<svg class="boot-splash-logo" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="bootOuter" x1="0" y1="24" x2="24" y2="0" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#E2E8F0" />
<stop offset="0.5" stop-color="#FFFFFF" />
<stop offset="1" stop-color="#F1F5F9" />
</linearGradient>
<linearGradient id="bootInner" x1="0" y1="24" x2="24" y2="0" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#94A3B8" />
<stop offset="1" stop-color="#CBD5E1" />
</linearGradient>
</defs>
<path d="M12 3L3.5 18.5H8.5L12 12L15.5 18.5H20.5L12 3Z" fill="url(#bootOuter)" />
<circle cx="12" cy="16" r="2" fill="url(#bootInner)" />
</svg>
<div class="boot-splash-copy">
<div class="boot-splash-title">Async</div>
<div class="boot-splash-subtitle">Ultra · AI Editor</div>
</div>
<div class="boot-splash-loader"></div>
</div>
</div>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>