iconpeek 1.0.1
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/LICENSE +21 -0
- package/README.md +140 -0
- package/assets/placeholder-icon.png +0 -0
- package/generate_icons.py +219 -0
- package/package.json +24 -0
- package/server.js +1454 -0
package/server.js
ADDED
|
@@ -0,0 +1,1454 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { exec } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const DEFAULT_PORT = 4200;
|
|
9
|
+
const PLACEHOLDER_ICON = path.join(__dirname, 'assets', 'placeholder-icon.png');
|
|
10
|
+
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
11
|
+
|
|
12
|
+
function parseArgs(argv) {
|
|
13
|
+
const options = {
|
|
14
|
+
projectRoot: process.cwd(),
|
|
15
|
+
port: DEFAULT_PORT,
|
|
16
|
+
open: true,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
20
|
+
const arg = argv[index];
|
|
21
|
+
if (arg === '--project') {
|
|
22
|
+
const value = argv[index + 1];
|
|
23
|
+
if (!value) {
|
|
24
|
+
throw new Error('Missing value for --project');
|
|
25
|
+
}
|
|
26
|
+
options.projectRoot = path.resolve(value);
|
|
27
|
+
index += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (arg === '--port') {
|
|
32
|
+
const value = argv[index + 1];
|
|
33
|
+
const parsed = value && /^\d+$/.test(value) ? Number(value) : NaN;
|
|
34
|
+
if (!value || Number.isNaN(parsed) || parsed < 1 || parsed > 65535) {
|
|
35
|
+
throw new Error('Missing or invalid value for --port (expected 1-65535)');
|
|
36
|
+
}
|
|
37
|
+
options.port = parsed;
|
|
38
|
+
index += 1;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (arg === '--no-open') {
|
|
43
|
+
options.open = false;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (arg === '--help' || arg === '-h') {
|
|
48
|
+
printHelp();
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return options;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function printHelp() {
|
|
59
|
+
process.stdout.write(
|
|
60
|
+
[
|
|
61
|
+
'iconpeek',
|
|
62
|
+
'',
|
|
63
|
+
'Usage:',
|
|
64
|
+
' npx iconpeek',
|
|
65
|
+
' npx iconpeek --project /path/to/expo/app',
|
|
66
|
+
' npx iconpeek --port 5000',
|
|
67
|
+
' npx iconpeek --no-open',
|
|
68
|
+
'',
|
|
69
|
+
'Flags:',
|
|
70
|
+
' --project <path> Expo project root (default: current working directory)',
|
|
71
|
+
' --port <number> Starting port (default: 4200)',
|
|
72
|
+
' --no-open Do not open a browser window',
|
|
73
|
+
'',
|
|
74
|
+
].join('\n')
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function ensurePlaceholderAsset() {
|
|
79
|
+
if (fs.existsSync(PLACEHOLDER_ICON)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fs.mkdirSync(path.dirname(PLACEHOLDER_ICON), { recursive: true });
|
|
84
|
+
const placeholderBase64 =
|
|
85
|
+
'iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAARwElEQVR4nO3dQXLkxrWGUUghr8PrUnjgNfRIEVqAIzTqNXjg0Lq8Dg/0Bv0oFdlFslAAMu/N/5yxbQEJIu9XWaT8w8ZQX778+sfsawCo6OvXf/0w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AEQAA+4yYnUO+AhABAPCYUTNz2O8AiAAA+NjIWTn0lwBFAADcN3pGDv8rABEAAK/NmI1T/gxQBADAN7Nm4rR/D4AIACDdzFk49V8EJAIASDV7Bk7/NwHOXgAAGK3C7JseANtWYyEAYIQqM69EAGxbnQUBgKtUmnVlAmDbai0MAJyp2owrFQDbVm+BAOCoirOt3AXd+vLl1z9mXwMAPKvi4H9R7gTgVuWFA4CPVJ9hpQNg2+ovIAC81WF2lb/AW74SAKCyDoP/RfkTgFudFhaALN1mVKsA2LZ+CwzA+jrOpnYXfMtXAgDM1HHwv2h3AnCr88ID0Fv3GdT64m85DQBghO6D/8USN3FLCABwhVUG/4ulbuaWEADgDKsN/hetfwfgI6s+MADGWXmWLHtjt5wGALDHyoP/xfI3+JYYAOCehKF/K+pmbwkBALYtb/C/iLzpW0IAIFPq4H8RffNviQGAtaUP/VsW4g4hALAWg/97FuQBggCgFwP/cxZoJzEAUJOhv4/FOkgQAMxh4B9j8S4gCgDOZdifz4IOJg4A7jPkx/o/rsTlUKe3I3IAAAAASUVORK5CYII=';
|
|
86
|
+
fs.writeFileSync(PLACEHOLDER_ICON, Buffer.from(placeholderBase64, 'base64'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function parseConfigFile(filePath) {
|
|
90
|
+
if (!fs.existsSync(filePath)) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
96
|
+
return JSON.parse(raw);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return {
|
|
99
|
+
__error: `Failed to parse ${path.basename(filePath)}: ${error.message}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function parseJsConfigFile(filePath) {
|
|
105
|
+
if (!fs.existsSync(filePath)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
delete require.cache[require.resolve(filePath)];
|
|
111
|
+
const loaded = require(filePath);
|
|
112
|
+
const config = loaded && loaded.default ? loaded.default : loaded;
|
|
113
|
+
if (typeof config === 'function') {
|
|
114
|
+
return config({ config: {} });
|
|
115
|
+
}
|
|
116
|
+
return config;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// Node 20.19+/22.12+ ship require(esm) unflagged, so "export default" in
|
|
119
|
+
// app.config.js works natively there and this branch won't be hit. On
|
|
120
|
+
// older Node (down to this package's declared >=14 floor), require()
|
|
121
|
+
// still throws ERR_REQUIRE_ESM on ESM syntax, so give a specific,
|
|
122
|
+
// actionable message instead of a generic parse failure.
|
|
123
|
+
const looksLikeEsm =
|
|
124
|
+
error.code === 'ERR_REQUIRE_ESM' ||
|
|
125
|
+
(error instanceof SyntaxError && /export|import/.test(error.message));
|
|
126
|
+
|
|
127
|
+
const message = looksLikeEsm
|
|
128
|
+
? `Failed to load ${path.basename(filePath)}: it uses ES module syntax (import/export). ` +
|
|
129
|
+
`This Node.js version (${process.version}) can't require() that. Either upgrade to ` +
|
|
130
|
+
`Node 20.19+/22.12+ (which support this natively), convert the file to ` +
|
|
131
|
+
`"module.exports = ({ config }) => ({ ...config })", or use app.json / app.config.json instead.`
|
|
132
|
+
: `Failed to load ${path.basename(filePath)}: ${error.message}`;
|
|
133
|
+
|
|
134
|
+
return { __error: message };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function detectConfig(projectRoot) {
|
|
138
|
+
const jsonCandidates = ['app.json', 'app.config.json'];
|
|
139
|
+
|
|
140
|
+
for (const name of jsonCandidates) {
|
|
141
|
+
const filePath = path.join(projectRoot, name);
|
|
142
|
+
const parsed = parseConfigFile(filePath);
|
|
143
|
+
if (parsed) {
|
|
144
|
+
return {
|
|
145
|
+
configPath: filePath,
|
|
146
|
+
configName: name,
|
|
147
|
+
raw: parsed,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const jsConfigPath = path.join(projectRoot, 'app.config.js');
|
|
153
|
+
const parsedJsConfig = parseJsConfigFile(jsConfigPath);
|
|
154
|
+
if (parsedJsConfig) {
|
|
155
|
+
return {
|
|
156
|
+
configPath: jsConfigPath,
|
|
157
|
+
configName: 'app.config.js',
|
|
158
|
+
raw: parsedJsConfig,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
configPath: null,
|
|
164
|
+
configName: null,
|
|
165
|
+
raw: null,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function normalizeHexColor(value, fallback) {
|
|
169
|
+
if (typeof value !== 'string') {
|
|
170
|
+
return fallback;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const trimmed = value.trim();
|
|
174
|
+
if (/^#[0-9a-fA-F]{6}$/.test(trimmed)) {
|
|
175
|
+
return trimmed.toUpperCase();
|
|
176
|
+
}
|
|
177
|
+
if (/^#[0-9a-fA-F]{3}$/.test(trimmed)) {
|
|
178
|
+
return `#${trimmed[1]}${trimmed[1]}${trimmed[2]}${trimmed[2]}${trimmed[3]}${trimmed[3]}`.toUpperCase();
|
|
179
|
+
}
|
|
180
|
+
// Expo allows 8-digit #RRGGBBAA colors. CSS background-color in this preview
|
|
181
|
+
// doesn't need the alpha channel, so keep the RGB and drop AA rather than
|
|
182
|
+
// silently discarding the whole value to the fallback.
|
|
183
|
+
if (/^#[0-9a-fA-F]{8}$/.test(trimmed)) {
|
|
184
|
+
return trimmed.slice(0, 7).toUpperCase();
|
|
185
|
+
}
|
|
186
|
+
return fallback;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function safeProjectAsset(projectRoot, relativePath) {
|
|
190
|
+
if (typeof relativePath !== 'string' || !relativePath.trim()) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
195
|
+
const resolvedPath = path.resolve(resolvedRoot, relativePath);
|
|
196
|
+
const relativeFromRoot = path.relative(resolvedRoot, resolvedPath);
|
|
197
|
+
|
|
198
|
+
// Reject anything that escapes the project root (e.g. "../../etc/foo.png")
|
|
199
|
+
// so a hostile or malformed app.json can't be used to read arbitrary files.
|
|
200
|
+
if (relativeFromRoot.startsWith('..') || path.isAbsolute(relativeFromRoot)) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return resolvedPath;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function resolveAsset(projectRoot, relativePath) {
|
|
208
|
+
const absolutePath = safeProjectAsset(projectRoot, relativePath);
|
|
209
|
+
if (!absolutePath) {
|
|
210
|
+
return {
|
|
211
|
+
path: PLACEHOLDER_ICON,
|
|
212
|
+
relative: 'assets/placeholder-icon.png',
|
|
213
|
+
placeholder: true,
|
|
214
|
+
missing: false,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
if (fs.existsSync(absolutePath) && fs.statSync(absolutePath).isFile()) {
|
|
220
|
+
return {
|
|
221
|
+
path: absolutePath,
|
|
222
|
+
relative: path.relative(projectRoot, absolutePath).replace(/\\/g, '/'),
|
|
223
|
+
placeholder: false,
|
|
224
|
+
missing: false,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return {
|
|
229
|
+
path: PLACEHOLDER_ICON,
|
|
230
|
+
relative: 'assets/placeholder-icon.png',
|
|
231
|
+
placeholder: true,
|
|
232
|
+
missing: true,
|
|
233
|
+
error: error.message,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
path: PLACEHOLDER_ICON,
|
|
239
|
+
relative: 'assets/placeholder-icon.png',
|
|
240
|
+
placeholder: true,
|
|
241
|
+
missing: true,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function buildState(projectRoot) {
|
|
246
|
+
ensurePlaceholderAsset();
|
|
247
|
+
const detected = detectConfig(projectRoot);
|
|
248
|
+
const rawConfig = detected.raw && !detected.raw.__error ? detected.raw : {};
|
|
249
|
+
const expo = rawConfig.expo || {};
|
|
250
|
+
const android = expo.android || {};
|
|
251
|
+
const adaptiveIcon = android.adaptiveIcon || {};
|
|
252
|
+
const splash = expo.splash || {};
|
|
253
|
+
const splashDark = splash.dark || {};
|
|
254
|
+
|
|
255
|
+
const iconAsset = resolveAsset(projectRoot, adaptiveIcon.foregroundImage || expo.icon);
|
|
256
|
+
const iosIconAsset = resolveAsset(projectRoot, expo.icon);
|
|
257
|
+
const splashAsset = resolveAsset(projectRoot, splash.image);
|
|
258
|
+
const splashDarkAsset = resolveAsset(projectRoot, splashDark.image || splash.image);
|
|
259
|
+
|
|
260
|
+
const warningMessages = [];
|
|
261
|
+
if (!detected.configPath) {
|
|
262
|
+
warningMessages.push('No app.json, app.config.json, or app.config.js found. Showing placeholder assets and default colors.');
|
|
263
|
+
}
|
|
264
|
+
if (detected.raw && detected.raw.__error) {
|
|
265
|
+
warningMessages.push(detected.raw.__error);
|
|
266
|
+
}
|
|
267
|
+
if (iconAsset.missing) {
|
|
268
|
+
warningMessages.push('Android foreground icon was missing. Using the bundled placeholder.');
|
|
269
|
+
}
|
|
270
|
+
if (iosIconAsset.missing) {
|
|
271
|
+
warningMessages.push('Expo icon was missing. Using the bundled placeholder for iOS.');
|
|
272
|
+
}
|
|
273
|
+
if (splashAsset.missing) {
|
|
274
|
+
warningMessages.push('Splash image was missing. Using the bundled placeholder.');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
projectRoot,
|
|
279
|
+
configName: detected.configName,
|
|
280
|
+
configPath: detected.configPath,
|
|
281
|
+
warnings: warningMessages,
|
|
282
|
+
assets: {
|
|
283
|
+
icon: iconAsset,
|
|
284
|
+
iosIcon: iosIconAsset,
|
|
285
|
+
splash: splashAsset,
|
|
286
|
+
splashDark: splashDarkAsset,
|
|
287
|
+
},
|
|
288
|
+
expo: {
|
|
289
|
+
name: typeof expo.name === 'string' && expo.name.trim() ? expo.name.trim() : 'Your App',
|
|
290
|
+
icon: expo.icon || null,
|
|
291
|
+
androidForegroundImage: adaptiveIcon.foregroundImage || null,
|
|
292
|
+
adaptiveBackgroundColor: normalizeHexColor(adaptiveIcon.backgroundColor, '#FFFFFF'),
|
|
293
|
+
splashImage: splash.image || null,
|
|
294
|
+
splashImageWidth: typeof splash.imageWidth === 'number' ? splash.imageWidth : null,
|
|
295
|
+
splashBackgroundColor: normalizeHexColor(splash.backgroundColor, '#FFFFFF'),
|
|
296
|
+
splashDarkBackgroundColor: normalizeHexColor(splashDark.backgroundColor, '#121212'),
|
|
297
|
+
splashDarkImage: splashDark.image || null,
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function escapeHtml(value) {
|
|
303
|
+
return String(value)
|
|
304
|
+
.replace(/&/g, '&')
|
|
305
|
+
.replace(/</g, '<')
|
|
306
|
+
.replace(/>/g, '>')
|
|
307
|
+
.replace(/"/g, '"')
|
|
308
|
+
.replace(/'/g, ''');
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function createHtml(state) {
|
|
312
|
+
const payload = JSON.stringify({
|
|
313
|
+
warnings: state.warnings,
|
|
314
|
+
projectRoot: state.projectRoot,
|
|
315
|
+
configName: state.configName,
|
|
316
|
+
assets: {
|
|
317
|
+
iconPath: state.assets.icon.relative,
|
|
318
|
+
iosIconPath: state.assets.iosIcon.relative,
|
|
319
|
+
splashPath: state.assets.splash.relative,
|
|
320
|
+
splashDarkPath: state.assets.splashDark.relative,
|
|
321
|
+
},
|
|
322
|
+
expo: state.expo,
|
|
323
|
+
}).replace(/</g, '\\u003c');
|
|
324
|
+
|
|
325
|
+
return `<!DOCTYPE html>
|
|
326
|
+
<html lang="en">
|
|
327
|
+
<head>
|
|
328
|
+
<meta charset="UTF-8">
|
|
329
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
330
|
+
<title>iconpeek</title>
|
|
331
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
332
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
333
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
|
334
|
+
<style>
|
|
335
|
+
:root {
|
|
336
|
+
--bg: #0c0c0e;
|
|
337
|
+
--surface: #18181b;
|
|
338
|
+
--card: #1f1f23;
|
|
339
|
+
--border: #2e2e35;
|
|
340
|
+
--accent: #f97316;
|
|
341
|
+
--text: #fafafa;
|
|
342
|
+
--muted: #71717a;
|
|
343
|
+
--green: #22c55e;
|
|
344
|
+
--red: #ef4444;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
* { box-sizing: border-box; }
|
|
348
|
+
|
|
349
|
+
body {
|
|
350
|
+
margin: 0;
|
|
351
|
+
font-family: 'Inter', sans-serif;
|
|
352
|
+
color: var(--text);
|
|
353
|
+
background:
|
|
354
|
+
radial-gradient(circle at top left, rgba(249,115,22,0.12), transparent 22%),
|
|
355
|
+
radial-gradient(circle at top right, rgba(34,197,94,0.08), transparent 20%),
|
|
356
|
+
linear-gradient(180deg, #101014 0%, var(--bg) 18%, #09090b 100%);
|
|
357
|
+
min-height: 100vh;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
a { color: inherit; }
|
|
361
|
+
|
|
362
|
+
.header {
|
|
363
|
+
position: sticky;
|
|
364
|
+
top: 0;
|
|
365
|
+
z-index: 100;
|
|
366
|
+
display: flex;
|
|
367
|
+
justify-content: space-between;
|
|
368
|
+
gap: 1rem;
|
|
369
|
+
align-items: center;
|
|
370
|
+
padding: 1rem 1.5rem;
|
|
371
|
+
background: rgba(12, 12, 14, 0.72);
|
|
372
|
+
border-bottom: 1px solid rgba(46, 46, 53, 0.8);
|
|
373
|
+
backdrop-filter: blur(20px);
|
|
374
|
+
-webkit-backdrop-filter: blur(20px);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.brand {
|
|
378
|
+
display: flex;
|
|
379
|
+
gap: 0.9rem;
|
|
380
|
+
align-items: center;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.brand-mark {
|
|
384
|
+
width: 12px;
|
|
385
|
+
height: 12px;
|
|
386
|
+
border-radius: 999px;
|
|
387
|
+
background: linear-gradient(135deg, #fb923c, #f97316);
|
|
388
|
+
box-shadow: 0 0 24px rgba(249,115,22,0.5);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.brand-title {
|
|
392
|
+
margin: 0;
|
|
393
|
+
font-size: 1.1rem;
|
|
394
|
+
font-weight: 800;
|
|
395
|
+
letter-spacing: -0.03em;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.brand-copy {
|
|
399
|
+
margin: 0.15rem 0 0;
|
|
400
|
+
color: var(--muted);
|
|
401
|
+
font-size: 0.78rem;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.header-pill {
|
|
405
|
+
padding: 0.45rem 0.8rem;
|
|
406
|
+
border-radius: 999px;
|
|
407
|
+
border: 1px solid rgba(249,115,22,0.3);
|
|
408
|
+
background: rgba(249,115,22,0.1);
|
|
409
|
+
color: var(--accent);
|
|
410
|
+
font-size: 0.72rem;
|
|
411
|
+
letter-spacing: 0.08em;
|
|
412
|
+
text-transform: uppercase;
|
|
413
|
+
font-weight: 700;
|
|
414
|
+
white-space: nowrap;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.page {
|
|
418
|
+
max-width: 1320px;
|
|
419
|
+
margin: 0 auto;
|
|
420
|
+
padding: 1.5rem;
|
|
421
|
+
display: flex;
|
|
422
|
+
flex-direction: column;
|
|
423
|
+
gap: 1.5rem;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.summary {
|
|
427
|
+
display: grid;
|
|
428
|
+
grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
|
|
429
|
+
gap: 1rem;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.hero {
|
|
433
|
+
padding: 1.3rem 1.4rem;
|
|
434
|
+
border-radius: 16px;
|
|
435
|
+
border: 1px solid var(--border);
|
|
436
|
+
background:
|
|
437
|
+
linear-gradient(135deg, rgba(249,115,22,0.14), rgba(24,24,27,0.92) 36%),
|
|
438
|
+
var(--card);
|
|
439
|
+
box-shadow: 0 24px 60px rgba(0,0,0,0.25);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.hero h2 {
|
|
443
|
+
margin: 0;
|
|
444
|
+
font-size: clamp(1.5rem, 3vw, 2.2rem);
|
|
445
|
+
letter-spacing: -0.04em;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.hero p {
|
|
449
|
+
margin: 0.75rem 0 0;
|
|
450
|
+
color: #d4d4d8;
|
|
451
|
+
max-width: 62ch;
|
|
452
|
+
line-height: 1.55;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.meta-card, .card {
|
|
456
|
+
background: rgba(31,31,35,0.92);
|
|
457
|
+
border: 1px solid var(--border);
|
|
458
|
+
border-radius: 16px;
|
|
459
|
+
box-shadow: 0 18px 48px rgba(0,0,0,0.22);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.meta-card {
|
|
463
|
+
padding: 1.15rem;
|
|
464
|
+
display: flex;
|
|
465
|
+
flex-direction: column;
|
|
466
|
+
gap: 0.8rem;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.meta-label {
|
|
470
|
+
color: var(--muted);
|
|
471
|
+
text-transform: uppercase;
|
|
472
|
+
letter-spacing: 0.07em;
|
|
473
|
+
font-size: 0.72rem;
|
|
474
|
+
font-weight: 700;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.meta-value {
|
|
478
|
+
font-size: 0.95rem;
|
|
479
|
+
word-break: break-word;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.warning-banner {
|
|
483
|
+
display: none;
|
|
484
|
+
padding: 0.9rem 1rem;
|
|
485
|
+
border-radius: 14px;
|
|
486
|
+
border: 1px solid rgba(239,68,68,0.3);
|
|
487
|
+
background: rgba(127,29,29,0.24);
|
|
488
|
+
color: #fecaca;
|
|
489
|
+
line-height: 1.45;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.grid {
|
|
493
|
+
display: grid;
|
|
494
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
495
|
+
gap: 1.5rem;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.card {
|
|
499
|
+
padding: 1.25rem;
|
|
500
|
+
display: flex;
|
|
501
|
+
flex-direction: column;
|
|
502
|
+
gap: 1rem;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
.card-head {
|
|
506
|
+
display: flex;
|
|
507
|
+
justify-content: space-between;
|
|
508
|
+
gap: 0.75rem;
|
|
509
|
+
align-items: center;
|
|
510
|
+
flex-wrap: wrap;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.card-title {
|
|
514
|
+
margin: 0;
|
|
515
|
+
color: var(--muted);
|
|
516
|
+
text-transform: uppercase;
|
|
517
|
+
letter-spacing: 0.07em;
|
|
518
|
+
font-size: 0.78rem;
|
|
519
|
+
font-weight: 700;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.hint {
|
|
523
|
+
color: #d4d4d8;
|
|
524
|
+
font-size: 0.84rem;
|
|
525
|
+
line-height: 1.5;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.controls {
|
|
529
|
+
display: flex;
|
|
530
|
+
flex-wrap: wrap;
|
|
531
|
+
gap: 0.75rem;
|
|
532
|
+
align-items: center;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.segment {
|
|
536
|
+
display: inline-flex;
|
|
537
|
+
background: var(--surface);
|
|
538
|
+
border: 1px solid var(--border);
|
|
539
|
+
border-radius: 10px;
|
|
540
|
+
overflow: hidden;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.segment button {
|
|
544
|
+
border: 0;
|
|
545
|
+
background: transparent;
|
|
546
|
+
color: var(--muted);
|
|
547
|
+
padding: 0.55rem 0.85rem;
|
|
548
|
+
font: inherit;
|
|
549
|
+
font-size: 0.82rem;
|
|
550
|
+
cursor: pointer;
|
|
551
|
+
transition: background 160ms ease, color 160ms ease;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.segment button.active {
|
|
555
|
+
background: var(--accent);
|
|
556
|
+
color: white;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.segment button + button {
|
|
560
|
+
border-left: 1px solid var(--border);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.toggle {
|
|
564
|
+
display: inline-flex;
|
|
565
|
+
align-items: center;
|
|
566
|
+
gap: 0.45rem;
|
|
567
|
+
color: #d4d4d8;
|
|
568
|
+
font-size: 0.82rem;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.toggle input {
|
|
572
|
+
accent-color: var(--accent);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.stage {
|
|
576
|
+
display: flex;
|
|
577
|
+
justify-content: center;
|
|
578
|
+
align-items: center;
|
|
579
|
+
min-height: 360px;
|
|
580
|
+
padding: 1rem;
|
|
581
|
+
border-radius: 14px;
|
|
582
|
+
background:
|
|
583
|
+
radial-gradient(circle at top, rgba(249,115,22,0.12), transparent 38%),
|
|
584
|
+
linear-gradient(180deg, rgba(24,24,27,0.95), rgba(12,12,14,0.96));
|
|
585
|
+
border: 1px solid rgba(46,46,53,0.9);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.adaptive-wrap {
|
|
589
|
+
display: flex;
|
|
590
|
+
flex-direction: column;
|
|
591
|
+
gap: 0.9rem;
|
|
592
|
+
align-items: center;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.adaptive-mask {
|
|
596
|
+
width: 216px;
|
|
597
|
+
height: 216px;
|
|
598
|
+
position: relative;
|
|
599
|
+
overflow: hidden;
|
|
600
|
+
box-shadow: 0 16px 44px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
|
|
601
|
+
background: #fff;
|
|
602
|
+
transition: border-radius 220ms ease, clip-path 220ms ease;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.mask-squircle {
|
|
606
|
+
clip-path: path('M108,0 C173,0 216,43 216,108 C216,173 173,216 108,216 C43,216 0,173 0,108 C0,43 43,0 108,0 Z');
|
|
607
|
+
border-radius: 0;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.mask-rounded { border-radius: 48px; clip-path: none; }
|
|
611
|
+
.mask-circle { border-radius: 50%; clip-path: none; }
|
|
612
|
+
.mask-square { border-radius: 0; clip-path: none; }
|
|
613
|
+
|
|
614
|
+
.adaptive-layer {
|
|
615
|
+
position: absolute;
|
|
616
|
+
width: 324px;
|
|
617
|
+
height: 324px;
|
|
618
|
+
left: -54px;
|
|
619
|
+
top: -54px;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.adaptive-bg {
|
|
623
|
+
background: #FFFFFF;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.adaptive-fg {
|
|
627
|
+
background-position: center;
|
|
628
|
+
background-repeat: no-repeat;
|
|
629
|
+
background-size: contain;
|
|
630
|
+
will-change: transform;
|
|
631
|
+
transition: transform 80ms ease-out;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.safe-zone {
|
|
635
|
+
position: absolute;
|
|
636
|
+
left: 9px;
|
|
637
|
+
top: 9px;
|
|
638
|
+
width: 198px;
|
|
639
|
+
height: 198px;
|
|
640
|
+
border-radius: 50%;
|
|
641
|
+
border: 2px dashed rgba(239,68,68,0.9);
|
|
642
|
+
z-index: 3;
|
|
643
|
+
display: none;
|
|
644
|
+
pointer-events: none;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.safe-zone span {
|
|
648
|
+
position: absolute;
|
|
649
|
+
top: -1.6rem;
|
|
650
|
+
left: 50%;
|
|
651
|
+
transform: translateX(-50%);
|
|
652
|
+
font-size: 0.68rem;
|
|
653
|
+
color: #fca5a5;
|
|
654
|
+
font-weight: 700;
|
|
655
|
+
white-space: nowrap;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
.shape-caption {
|
|
659
|
+
color: var(--muted);
|
|
660
|
+
font-size: 0.82rem;
|
|
661
|
+
text-align: center;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.spec-grid {
|
|
665
|
+
display: grid;
|
|
666
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
667
|
+
gap: 0.75rem;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.spec-pill {
|
|
671
|
+
padding: 0.75rem 0.85rem;
|
|
672
|
+
border-radius: 12px;
|
|
673
|
+
background: var(--surface);
|
|
674
|
+
border: 1px solid var(--border);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
.spec-pill strong {
|
|
678
|
+
display: block;
|
|
679
|
+
font-size: 0.68rem;
|
|
680
|
+
text-transform: uppercase;
|
|
681
|
+
letter-spacing: 0.07em;
|
|
682
|
+
color: var(--muted);
|
|
683
|
+
margin-bottom: 0.28rem;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.spec-pill span {
|
|
687
|
+
font-size: 0.93rem;
|
|
688
|
+
font-weight: 600;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.size-row {
|
|
692
|
+
display: flex;
|
|
693
|
+
justify-content: center;
|
|
694
|
+
gap: 1.2rem;
|
|
695
|
+
flex-wrap: wrap;
|
|
696
|
+
padding: 1rem;
|
|
697
|
+
border-radius: 14px;
|
|
698
|
+
background: var(--surface);
|
|
699
|
+
border: 1px solid rgba(46,46,53,0.9);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.size-item {
|
|
703
|
+
display: flex;
|
|
704
|
+
flex-direction: column;
|
|
705
|
+
align-items: center;
|
|
706
|
+
gap: 0.45rem;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
.size-label {
|
|
710
|
+
color: var(--muted);
|
|
711
|
+
font-size: 0.73rem;
|
|
712
|
+
line-height: 1.3;
|
|
713
|
+
text-align: center;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
.mini-mask, .launcher-mask {
|
|
717
|
+
position: relative;
|
|
718
|
+
overflow: hidden;
|
|
719
|
+
background: #fff;
|
|
720
|
+
box-shadow: 0 10px 20px rgba(0,0,0,0.35);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.mini-bg, .mini-fg, .launcher-bg, .launcher-fg {
|
|
724
|
+
position: absolute;
|
|
725
|
+
background-position: center;
|
|
726
|
+
background-repeat: no-repeat;
|
|
727
|
+
background-size: contain;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.ios-preview {
|
|
731
|
+
display: flex;
|
|
732
|
+
flex-direction: column;
|
|
733
|
+
align-items: center;
|
|
734
|
+
gap: 1rem;
|
|
735
|
+
padding: 1rem;
|
|
736
|
+
border-radius: 14px;
|
|
737
|
+
background: linear-gradient(180deg, rgba(24,24,27,0.95), rgba(12,12,14,0.96));
|
|
738
|
+
border: 1px solid rgba(46,46,53,0.9);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
.ios-mask {
|
|
742
|
+
width: 216px;
|
|
743
|
+
height: 216px;
|
|
744
|
+
border-radius: 47px;
|
|
745
|
+
overflow: hidden;
|
|
746
|
+
background: #fff;
|
|
747
|
+
box-shadow: 0 16px 44px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.ios-mask img {
|
|
751
|
+
width: 100%;
|
|
752
|
+
height: 100%;
|
|
753
|
+
object-fit: cover;
|
|
754
|
+
display: block;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
.context {
|
|
758
|
+
display: grid;
|
|
759
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
760
|
+
gap: 1.5rem;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.screen {
|
|
764
|
+
border-radius: 16px;
|
|
765
|
+
padding: 1rem;
|
|
766
|
+
overflow: hidden;
|
|
767
|
+
position: relative;
|
|
768
|
+
min-height: 250px;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.android-screen {
|
|
772
|
+
background: linear-gradient(155deg, #231942, #1d3557 55%, #0b1020);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.ios-screen {
|
|
776
|
+
background: linear-gradient(160deg, #11324d, #0b1c2d 55%, #191936);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
.screen::before {
|
|
780
|
+
content: '';
|
|
781
|
+
position: absolute;
|
|
782
|
+
inset: 0;
|
|
783
|
+
background:
|
|
784
|
+
radial-gradient(circle at 20% 10%, rgba(255,255,255,0.06), transparent 18%),
|
|
785
|
+
radial-gradient(circle at 80% 40%, rgba(255,255,255,0.06), transparent 20%);
|
|
786
|
+
pointer-events: none;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.screen-grid {
|
|
790
|
+
position: relative;
|
|
791
|
+
display: grid;
|
|
792
|
+
grid-template-columns: repeat(4, 1fr);
|
|
793
|
+
gap: 0.8rem;
|
|
794
|
+
align-items: start;
|
|
795
|
+
justify-items: center;
|
|
796
|
+
z-index: 1;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.app-chip {
|
|
800
|
+
display: flex;
|
|
801
|
+
flex-direction: column;
|
|
802
|
+
align-items: center;
|
|
803
|
+
gap: 0.4rem;
|
|
804
|
+
width: 100%;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
.app-label {
|
|
808
|
+
width: 100%;
|
|
809
|
+
text-align: center;
|
|
810
|
+
color: rgba(255,255,255,0.92);
|
|
811
|
+
text-shadow: 0 1px 3px rgba(0,0,0,0.6);
|
|
812
|
+
font-size: 0.7rem;
|
|
813
|
+
overflow: hidden;
|
|
814
|
+
text-overflow: ellipsis;
|
|
815
|
+
white-space: nowrap;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
.placeholder {
|
|
819
|
+
width: 96px;
|
|
820
|
+
height: 96px;
|
|
821
|
+
border-radius: 24px;
|
|
822
|
+
display: flex;
|
|
823
|
+
align-items: center;
|
|
824
|
+
justify-content: center;
|
|
825
|
+
font-size: 1.7rem;
|
|
826
|
+
box-shadow: 0 10px 20px rgba(0,0,0,0.35);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.ios-placeholder {
|
|
830
|
+
border-radius: 21px;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.ring {
|
|
834
|
+
box-shadow: 0 0 0 3px rgba(249,115,22,0.95), 0 10px 20px rgba(0,0,0,0.35);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.splash-pair {
|
|
838
|
+
display: flex;
|
|
839
|
+
justify-content: center;
|
|
840
|
+
gap: 1.4rem;
|
|
841
|
+
flex-wrap: wrap;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
.phone {
|
|
845
|
+
width: 200px;
|
|
846
|
+
height: 420px;
|
|
847
|
+
border-radius: 34px;
|
|
848
|
+
border: 7px solid #232329;
|
|
849
|
+
overflow: hidden;
|
|
850
|
+
position: relative;
|
|
851
|
+
box-shadow: 0 22px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.04);
|
|
852
|
+
background: #000;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
.notch {
|
|
856
|
+
position: absolute;
|
|
857
|
+
top: 0;
|
|
858
|
+
left: 50%;
|
|
859
|
+
transform: translateX(-50%);
|
|
860
|
+
width: 82px;
|
|
861
|
+
height: 14px;
|
|
862
|
+
border-bottom-left-radius: 10px;
|
|
863
|
+
border-bottom-right-radius: 10px;
|
|
864
|
+
background: #18181b;
|
|
865
|
+
z-index: 3;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.statusbar {
|
|
869
|
+
position: absolute;
|
|
870
|
+
top: 0;
|
|
871
|
+
left: 0;
|
|
872
|
+
right: 0;
|
|
873
|
+
height: 26px;
|
|
874
|
+
display: flex;
|
|
875
|
+
justify-content: space-between;
|
|
876
|
+
align-items: flex-end;
|
|
877
|
+
padding: 0 14px 4px;
|
|
878
|
+
font-size: 0.62rem;
|
|
879
|
+
font-weight: 700;
|
|
880
|
+
z-index: 4;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
.splash-surface {
|
|
884
|
+
position: absolute;
|
|
885
|
+
inset: 0;
|
|
886
|
+
display: flex;
|
|
887
|
+
align-items: center;
|
|
888
|
+
justify-content: center;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.splash-image {
|
|
892
|
+
width: 38%;
|
|
893
|
+
height: auto;
|
|
894
|
+
object-fit: contain;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
.theme-chip {
|
|
898
|
+
position: absolute;
|
|
899
|
+
bottom: 15px;
|
|
900
|
+
left: 50%;
|
|
901
|
+
transform: translateX(-50%);
|
|
902
|
+
padding: 0.28rem 0.7rem;
|
|
903
|
+
border-radius: 999px;
|
|
904
|
+
font-size: 0.64rem;
|
|
905
|
+
letter-spacing: 0.08em;
|
|
906
|
+
text-transform: uppercase;
|
|
907
|
+
font-weight: 700;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
.theme-chip.light {
|
|
911
|
+
color: rgba(0,0,0,0.52);
|
|
912
|
+
background: rgba(0,0,0,0.08);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.theme-chip.dark {
|
|
916
|
+
color: rgba(255,255,255,0.72);
|
|
917
|
+
background: rgba(255,255,255,0.08);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
.footnote {
|
|
921
|
+
color: var(--muted);
|
|
922
|
+
font-size: 0.78rem;
|
|
923
|
+
line-height: 1.5;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
@media (max-width: 900px) {
|
|
927
|
+
.summary, .grid, .context {
|
|
928
|
+
grid-template-columns: 1fr;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
.header {
|
|
932
|
+
padding: 1rem;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
.page {
|
|
936
|
+
padding: 1rem;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
.spec-grid {
|
|
940
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
@media (max-width: 640px) {
|
|
945
|
+
.spec-grid {
|
|
946
|
+
grid-template-columns: 1fr;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
.screen-grid {
|
|
950
|
+
grid-template-columns: repeat(2, 1fr);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
</style>
|
|
954
|
+
</head>
|
|
955
|
+
<body>
|
|
956
|
+
<header class="header">
|
|
957
|
+
<div class="brand">
|
|
958
|
+
<div class="brand-mark"></div>
|
|
959
|
+
<div>
|
|
960
|
+
<h1 class="brand-title">iconpeek</h1>
|
|
961
|
+
<p class="brand-copy">Local Expo icon and splash previewer</p>
|
|
962
|
+
</div>
|
|
963
|
+
</div>
|
|
964
|
+
<div class="header-pill">Zero Dependencies</div>
|
|
965
|
+
</header>
|
|
966
|
+
|
|
967
|
+
<main class="page">
|
|
968
|
+
<section class="summary">
|
|
969
|
+
<div class="hero">
|
|
970
|
+
<h2>Preview Android adaptive icons, iOS icons, and splash screens without a native build.</h2>
|
|
971
|
+
<p>iconpeek reads your Expo config directly, mirrors Android adaptive icon canvas and safe-zone math, and gives you instant browser feedback while you tweak assets in your project.</p>
|
|
972
|
+
</div>
|
|
973
|
+
<aside class="meta-card">
|
|
974
|
+
<div>
|
|
975
|
+
<div class="meta-label">Project Root</div>
|
|
976
|
+
<div class="meta-value">${escapeHtml(state.projectRoot)}</div>
|
|
977
|
+
</div>
|
|
978
|
+
<div>
|
|
979
|
+
<div class="meta-label">Config Source</div>
|
|
980
|
+
<div class="meta-value">${escapeHtml(state.configName || 'Not found')}</div>
|
|
981
|
+
</div>
|
|
982
|
+
<div>
|
|
983
|
+
<div class="meta-label">App Label</div>
|
|
984
|
+
<div class="meta-value" id="appLabelMeta">${escapeHtml(state.expo.name)}</div>
|
|
985
|
+
</div>
|
|
986
|
+
</aside>
|
|
987
|
+
</section>
|
|
988
|
+
|
|
989
|
+
<section class="warning-banner" id="warningBanner"></section>
|
|
990
|
+
|
|
991
|
+
<section class="grid">
|
|
992
|
+
<article class="card">
|
|
993
|
+
<div class="card-head">
|
|
994
|
+
<h3 class="card-title">Android Adaptive Icon Simulator</h3>
|
|
995
|
+
<div class="controls">
|
|
996
|
+
<div class="segment" id="shapeControl">
|
|
997
|
+
<button type="button" data-shape="squircle" class="active">Squircle</button>
|
|
998
|
+
<button type="button" data-shape="rounded">Rounded</button>
|
|
999
|
+
<button type="button" data-shape="circle">Circle</button>
|
|
1000
|
+
<button type="button" data-shape="square">Square</button>
|
|
1001
|
+
</div>
|
|
1002
|
+
<label class="toggle">
|
|
1003
|
+
<input type="checkbox" id="safeZoneToggle">
|
|
1004
|
+
Show safe zone
|
|
1005
|
+
</label>
|
|
1006
|
+
</div>
|
|
1007
|
+
</div>
|
|
1008
|
+
|
|
1009
|
+
<div class="stage">
|
|
1010
|
+
<div class="adaptive-wrap">
|
|
1011
|
+
<div class="adaptive-mask mask-squircle" id="adaptiveMask">
|
|
1012
|
+
<div class="adaptive-layer adaptive-bg" id="adaptiveBg"></div>
|
|
1013
|
+
<div class="adaptive-layer adaptive-fg" id="adaptiveFg"></div>
|
|
1014
|
+
<div class="safe-zone" id="safeZone">
|
|
1015
|
+
<span>66dp Safe Zone</span>
|
|
1016
|
+
</div>
|
|
1017
|
+
</div>
|
|
1018
|
+
<div class="shape-caption" id="shapeCaption">Android 12+ default squircle mask</div>
|
|
1019
|
+
</div>
|
|
1020
|
+
</div>
|
|
1021
|
+
|
|
1022
|
+
<div class="spec-grid">
|
|
1023
|
+
<div class="spec-pill"><strong>Layer Canvas</strong><span>108dp / 324px</span></div>
|
|
1024
|
+
<div class="spec-pill"><strong>Visible Mask</strong><span>72dp / 216px</span></div>
|
|
1025
|
+
<div class="spec-pill"><strong>Safe Zone</strong><span>66dp / 198px</span></div>
|
|
1026
|
+
<div class="spec-pill"><strong>BG Color</strong><span id="bgColorValue">#FFFFFF</span></div>
|
|
1027
|
+
<div class="spec-pill"><strong>Crop Margin</strong><span>18dp / 54px</span></div>
|
|
1028
|
+
<div class="spec-pill"><strong>Preview Scale</strong><span>3x</span></div>
|
|
1029
|
+
</div>
|
|
1030
|
+
|
|
1031
|
+
<div class="size-row" id="androidSizeRow"></div>
|
|
1032
|
+
</article>
|
|
1033
|
+
|
|
1034
|
+
<article class="card">
|
|
1035
|
+
<div class="card-head">
|
|
1036
|
+
<h3 class="card-title">iOS Icon Preview</h3>
|
|
1037
|
+
<div class="header-pill" style="padding:0.35rem 0.65rem;font-size:0.66rem;">Flat Asset</div>
|
|
1038
|
+
</div>
|
|
1039
|
+
<div class="ios-preview">
|
|
1040
|
+
<div class="ios-mask">
|
|
1041
|
+
<img src="/assets/ios-icon" alt="iOS app icon">
|
|
1042
|
+
</div>
|
|
1043
|
+
<div class="hint">iOS app icons should be opaque; this preview approximates the system mask so you can judge edge composition quickly.</div>
|
|
1044
|
+
</div>
|
|
1045
|
+
<div class="size-row" id="iosSizeRow"></div>
|
|
1046
|
+
</article>
|
|
1047
|
+
</section>
|
|
1048
|
+
|
|
1049
|
+
<section class="context">
|
|
1050
|
+
<article class="card">
|
|
1051
|
+
<div class="card-head">
|
|
1052
|
+
<h3 class="card-title">Android Launcher Context</h3>
|
|
1053
|
+
<div class="hint">96x96 highlight ring in a mock launcher grid</div>
|
|
1054
|
+
</div>
|
|
1055
|
+
<div class="screen android-screen">
|
|
1056
|
+
<div class="screen-grid">
|
|
1057
|
+
<div class="app-chip">
|
|
1058
|
+
<div class="placeholder" style="background:linear-gradient(135deg,#2563eb,#38bdf8)">MSG</div>
|
|
1059
|
+
<div class="app-label">Messages</div>
|
|
1060
|
+
</div>
|
|
1061
|
+
<div class="app-chip">
|
|
1062
|
+
<div class="launcher-mask ring mask-squircle" id="launcherMask" style="width:96px;height:96px;">
|
|
1063
|
+
<div class="launcher-bg" id="launcherBg"></div>
|
|
1064
|
+
<div class="launcher-fg" id="launcherFg"></div>
|
|
1065
|
+
</div>
|
|
1066
|
+
<div class="app-label" id="androidAppLabel">${escapeHtml(state.expo.name)}</div>
|
|
1067
|
+
</div>
|
|
1068
|
+
<div class="app-chip">
|
|
1069
|
+
<div class="placeholder" style="background:linear-gradient(135deg,#16a34a,#4ade80)">IMG</div>
|
|
1070
|
+
<div class="app-label">Gallery</div>
|
|
1071
|
+
</div>
|
|
1072
|
+
<div class="app-chip">
|
|
1073
|
+
<div class="placeholder" style="background:linear-gradient(135deg,#9333ea,#c084fc)">AUD</div>
|
|
1074
|
+
<div class="app-label">Music</div>
|
|
1075
|
+
</div>
|
|
1076
|
+
</div>
|
|
1077
|
+
</div>
|
|
1078
|
+
</article>
|
|
1079
|
+
|
|
1080
|
+
<article class="card">
|
|
1081
|
+
<div class="card-head">
|
|
1082
|
+
<h3 class="card-title">iOS Homescreen Context</h3>
|
|
1083
|
+
<div class="hint">96x96 highlight ring in a mock homescreen grid</div>
|
|
1084
|
+
</div>
|
|
1085
|
+
<div class="screen ios-screen">
|
|
1086
|
+
<div class="screen-grid">
|
|
1087
|
+
<div class="app-chip">
|
|
1088
|
+
<div class="placeholder ios-placeholder" style="background:linear-gradient(135deg,#0ea5e9,#67e8f9)">TEL</div>
|
|
1089
|
+
<div class="app-label">Phone</div>
|
|
1090
|
+
</div>
|
|
1091
|
+
<div class="app-chip">
|
|
1092
|
+
<div class="ios-placeholder ring" style="width:96px;height:96px;border-radius:21px;overflow:hidden;background:#fff;">
|
|
1093
|
+
<img src="/assets/ios-icon" alt="iOS homescreen icon" style="width:100%;height:100%;object-fit:cover;display:block;">
|
|
1094
|
+
</div>
|
|
1095
|
+
<div class="app-label" id="iosAppLabel">${escapeHtml(state.expo.name)}</div>
|
|
1096
|
+
</div>
|
|
1097
|
+
<div class="app-chip">
|
|
1098
|
+
<div class="placeholder ios-placeholder" style="background:linear-gradient(135deg,#f59e0b,#fcd34d)">SET</div>
|
|
1099
|
+
<div class="app-label">Settings</div>
|
|
1100
|
+
</div>
|
|
1101
|
+
<div class="app-chip">
|
|
1102
|
+
<div class="placeholder ios-placeholder" style="background:linear-gradient(135deg,#dc2626,#fb7185)">HLT</div>
|
|
1103
|
+
<div class="app-label">Health</div>
|
|
1104
|
+
</div>
|
|
1105
|
+
</div>
|
|
1106
|
+
</div>
|
|
1107
|
+
</article>
|
|
1108
|
+
</section>
|
|
1109
|
+
|
|
1110
|
+
<section class="card">
|
|
1111
|
+
<div class="card-head">
|
|
1112
|
+
<h3 class="card-title">Splash Screen Preview</h3>
|
|
1113
|
+
<div class="hint">Light and dark frames with auto-inverted status bar text based on background luminance</div>
|
|
1114
|
+
</div>
|
|
1115
|
+
<div class="splash-pair">
|
|
1116
|
+
<div class="phone">
|
|
1117
|
+
<div class="notch"></div>
|
|
1118
|
+
<div class="statusbar" id="statusbarLight">
|
|
1119
|
+
<span>9:41</span>
|
|
1120
|
+
<span>||| 100%</span>
|
|
1121
|
+
</div>
|
|
1122
|
+
<div class="splash-surface" id="splashLightSurface">
|
|
1123
|
+
<img class="splash-image" src="/assets/splash" alt="Light splash preview">
|
|
1124
|
+
<div class="theme-chip light">Light Mode</div>
|
|
1125
|
+
</div>
|
|
1126
|
+
</div>
|
|
1127
|
+
<div class="phone">
|
|
1128
|
+
<div class="notch"></div>
|
|
1129
|
+
<div class="statusbar" id="statusbarDark">
|
|
1130
|
+
<span>9:41</span>
|
|
1131
|
+
<span>||| 100%</span>
|
|
1132
|
+
</div>
|
|
1133
|
+
<div class="splash-surface" id="splashDarkSurface">
|
|
1134
|
+
<img class="splash-image" src="/assets/splash-dark" alt="Dark splash preview">
|
|
1135
|
+
<div class="theme-chip dark">Dark Mode</div>
|
|
1136
|
+
</div>
|
|
1137
|
+
</div>
|
|
1138
|
+
</div>
|
|
1139
|
+
<div class="footnote" id="splashFootnote">Splash image width defaults to 38% of the frame width unless imageWidth is set in Expo config.</div>
|
|
1140
|
+
</section>
|
|
1141
|
+
</main>
|
|
1142
|
+
|
|
1143
|
+
<script>
|
|
1144
|
+
const STATE = ${payload};
|
|
1145
|
+
const shapeMap = {
|
|
1146
|
+
squircle: { className: 'mask-squircle', caption: 'Android 12+ default squircle mask' },
|
|
1147
|
+
rounded: { className: 'mask-rounded', caption: 'Rounded rectangle mask' },
|
|
1148
|
+
circle: { className: 'mask-circle', caption: 'Circle mask' },
|
|
1149
|
+
square: { className: 'mask-square', caption: 'Square mask' }
|
|
1150
|
+
};
|
|
1151
|
+
const maskClasses = Object.values(shapeMap).map((entry) => entry.className);
|
|
1152
|
+
const androidSizes = [
|
|
1153
|
+
{ px: 36, label: 'Status bar', dp: '24dp' },
|
|
1154
|
+
{ px: 54, label: 'Notification', dp: '36dp' },
|
|
1155
|
+
{ px: 72, label: 'Launcher', dp: '48dp' },
|
|
1156
|
+
{ px: 96, label: 'App drawer', dp: '64dp' }
|
|
1157
|
+
];
|
|
1158
|
+
const iosSizes = [
|
|
1159
|
+
{ px: 40, label: 'Settings', pt: '29pt' },
|
|
1160
|
+
{ px: 57, label: 'Spotlight', pt: '40pt' },
|
|
1161
|
+
{ px: 86, label: 'Home Screen', pt: '60pt' },
|
|
1162
|
+
{ px: 128, label: 'App Store display', pt: '1024px source' }
|
|
1163
|
+
];
|
|
1164
|
+
|
|
1165
|
+
function isDarkColor(hex) {
|
|
1166
|
+
const normalized = (hex || '#FFFFFF').replace('#', '');
|
|
1167
|
+
const expanded = normalized.length === 3
|
|
1168
|
+
? normalized.split('').map((char) => char + char).join('')
|
|
1169
|
+
: normalized;
|
|
1170
|
+
const r = parseInt(expanded.slice(0, 2), 16);
|
|
1171
|
+
const g = parseInt(expanded.slice(2, 4), 16);
|
|
1172
|
+
const b = parseInt(expanded.slice(4, 6), 16);
|
|
1173
|
+
return (0.299 * r + 0.587 * g + 0.114 * b) < 128;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function buildAndroidSizeRow() {
|
|
1177
|
+
const container = document.getElementById('androidSizeRow');
|
|
1178
|
+
container.innerHTML = '';
|
|
1179
|
+
const bgColor = STATE.expo.adaptiveBackgroundColor;
|
|
1180
|
+
androidSizes.forEach((item) => {
|
|
1181
|
+
const mask = document.createElement('div');
|
|
1182
|
+
mask.className = 'mini-mask mask-squircle';
|
|
1183
|
+
mask.style.width = item.px + 'px';
|
|
1184
|
+
mask.style.height = item.px + 'px';
|
|
1185
|
+
|
|
1186
|
+
const layerSize = item.px * (108 / 72);
|
|
1187
|
+
const offset = (layerSize - item.px) / 2;
|
|
1188
|
+
|
|
1189
|
+
const bg = document.createElement('div');
|
|
1190
|
+
bg.className = 'mini-bg';
|
|
1191
|
+
bg.style.width = layerSize + 'px';
|
|
1192
|
+
bg.style.height = layerSize + 'px';
|
|
1193
|
+
bg.style.left = (-offset) + 'px';
|
|
1194
|
+
bg.style.top = (-offset) + 'px';
|
|
1195
|
+
bg.style.backgroundColor = bgColor;
|
|
1196
|
+
|
|
1197
|
+
const fg = document.createElement('div');
|
|
1198
|
+
fg.className = 'mini-fg';
|
|
1199
|
+
fg.style.width = layerSize + 'px';
|
|
1200
|
+
fg.style.height = layerSize + 'px';
|
|
1201
|
+
fg.style.left = (-offset) + 'px';
|
|
1202
|
+
fg.style.top = (-offset) + 'px';
|
|
1203
|
+
fg.style.backgroundImage = "url('/assets/icon')";
|
|
1204
|
+
|
|
1205
|
+
mask.appendChild(bg);
|
|
1206
|
+
mask.appendChild(fg);
|
|
1207
|
+
|
|
1208
|
+
const itemNode = document.createElement('div');
|
|
1209
|
+
itemNode.className = 'size-item';
|
|
1210
|
+
itemNode.appendChild(mask);
|
|
1211
|
+
|
|
1212
|
+
const label = document.createElement('div');
|
|
1213
|
+
label.className = 'size-label';
|
|
1214
|
+
label.innerHTML = item.px + '×' + item.px + 'px<br>' + item.dp + ' ' + item.label;
|
|
1215
|
+
itemNode.appendChild(label);
|
|
1216
|
+
|
|
1217
|
+
container.appendChild(itemNode);
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
function buildIosSizeRow() {
|
|
1222
|
+
const container = document.getElementById('iosSizeRow');
|
|
1223
|
+
container.innerHTML = '';
|
|
1224
|
+
iosSizes.forEach((item) => {
|
|
1225
|
+
const itemNode = document.createElement('div');
|
|
1226
|
+
itemNode.className = 'size-item';
|
|
1227
|
+
|
|
1228
|
+
const mask = document.createElement('div');
|
|
1229
|
+
mask.style.width = item.px + 'px';
|
|
1230
|
+
mask.style.height = item.px + 'px';
|
|
1231
|
+
mask.style.borderRadius = Math.round(item.px * 0.2237) + 'px';
|
|
1232
|
+
mask.style.overflow = 'hidden';
|
|
1233
|
+
mask.style.background = '#fff';
|
|
1234
|
+
mask.style.boxShadow = '0 10px 20px rgba(0,0,0,0.35)';
|
|
1235
|
+
|
|
1236
|
+
const img = document.createElement('img');
|
|
1237
|
+
img.src = '/assets/ios-icon';
|
|
1238
|
+
img.alt = item.label;
|
|
1239
|
+
img.style.width = '100%';
|
|
1240
|
+
img.style.height = '100%';
|
|
1241
|
+
img.style.objectFit = 'cover';
|
|
1242
|
+
img.style.display = 'block';
|
|
1243
|
+
mask.appendChild(img);
|
|
1244
|
+
|
|
1245
|
+
const label = document.createElement('div');
|
|
1246
|
+
label.className = 'size-label';
|
|
1247
|
+
label.innerHTML = item.px + '×' + item.px + 'px<br>' + item.pt;
|
|
1248
|
+
|
|
1249
|
+
itemNode.appendChild(mask);
|
|
1250
|
+
itemNode.appendChild(label);
|
|
1251
|
+
container.appendChild(itemNode);
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
function setShape(shape) {
|
|
1256
|
+
const mapping = shapeMap[shape] || shapeMap.squircle;
|
|
1257
|
+
const adaptiveMask = document.getElementById('adaptiveMask');
|
|
1258
|
+
const launcherMask = document.getElementById('launcherMask');
|
|
1259
|
+
|
|
1260
|
+
[adaptiveMask, launcherMask].forEach((element) => {
|
|
1261
|
+
maskClasses.forEach((className) => element.classList.remove(className));
|
|
1262
|
+
element.classList.add(mapping.className);
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
document.getElementById('shapeCaption').textContent = mapping.caption;
|
|
1266
|
+
document.querySelectorAll('#shapeControl button').forEach((button) => {
|
|
1267
|
+
button.classList.toggle('active', button.dataset.shape === shape);
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
function applyState() {
|
|
1272
|
+
const warnings = STATE.warnings || [];
|
|
1273
|
+
const warningBanner = document.getElementById('warningBanner');
|
|
1274
|
+
if (warnings.length) {
|
|
1275
|
+
warningBanner.style.display = 'block';
|
|
1276
|
+
warningBanner.innerHTML = warnings.map((warning) => '<div>' + warning + '</div>').join('');
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
document.getElementById('adaptiveBg').style.backgroundColor = STATE.expo.adaptiveBackgroundColor;
|
|
1280
|
+
document.getElementById('launcherBg').style.backgroundColor = STATE.expo.adaptiveBackgroundColor;
|
|
1281
|
+
document.getElementById('bgColorValue').textContent = STATE.expo.adaptiveBackgroundColor;
|
|
1282
|
+
|
|
1283
|
+
document.getElementById('adaptiveFg').style.backgroundImage = "url('/assets/icon')";
|
|
1284
|
+
document.getElementById('launcherFg').style.backgroundImage = "url('/assets/icon')";
|
|
1285
|
+
|
|
1286
|
+
document.getElementById('splashLightSurface').style.backgroundColor = STATE.expo.splashBackgroundColor;
|
|
1287
|
+
document.getElementById('splashDarkSurface').style.backgroundColor = STATE.expo.splashDarkBackgroundColor;
|
|
1288
|
+
document.getElementById('statusbarLight').style.color = isDarkColor(STATE.expo.splashBackgroundColor) ? '#FFFFFF' : '#000000';
|
|
1289
|
+
document.getElementById('statusbarDark').style.color = isDarkColor(STATE.expo.splashDarkBackgroundColor) ? '#FFFFFF' : '#000000';
|
|
1290
|
+
if (STATE.expo.splashImageWidth) {
|
|
1291
|
+
document.querySelectorAll('.splash-image').forEach((image) => {
|
|
1292
|
+
image.style.width = Math.max(24, Math.min(70, (STATE.expo.splashImageWidth / 200) * 100)) + '%';
|
|
1293
|
+
});
|
|
1294
|
+
document.getElementById('splashFootnote').textContent = 'Splash image width reflects Expo imageWidth: ' + STATE.expo.splashImageWidth + 'px.';
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
buildAndroidSizeRow();
|
|
1298
|
+
buildIosSizeRow();
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
document.getElementById('shapeControl').addEventListener('click', (event) => {
|
|
1302
|
+
if (event.target.tagName === 'BUTTON') {
|
|
1303
|
+
setShape(event.target.dataset.shape);
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
|
|
1307
|
+
document.getElementById('safeZoneToggle').addEventListener('change', (event) => {
|
|
1308
|
+
document.getElementById('safeZone').style.display = event.target.checked ? 'block' : 'none';
|
|
1309
|
+
});
|
|
1310
|
+
|
|
1311
|
+
const adaptiveMask = document.getElementById('adaptiveMask');
|
|
1312
|
+
adaptiveMask.addEventListener('mousemove', (event) => {
|
|
1313
|
+
const rect = adaptiveMask.getBoundingClientRect();
|
|
1314
|
+
const x = event.clientX - rect.left;
|
|
1315
|
+
const y = event.clientY - rect.top;
|
|
1316
|
+
const dx = ((x / rect.width) - 0.5) * 32;
|
|
1317
|
+
const dy = ((y / rect.height) - 0.5) * 32;
|
|
1318
|
+
document.getElementById('adaptiveFg').style.transform = 'translate3d(' + dx.toFixed(2) + 'px,' + dy.toFixed(2) + 'px,0)';
|
|
1319
|
+
});
|
|
1320
|
+
adaptiveMask.addEventListener('mouseleave', () => {
|
|
1321
|
+
document.getElementById('adaptiveFg').style.transform = 'translate3d(0,0,0)';
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
const launcherBg = document.getElementById('launcherBg');
|
|
1325
|
+
const launcherFg = document.getElementById('launcherFg');
|
|
1326
|
+
launcherBg.style.width = '144px';
|
|
1327
|
+
launcherBg.style.height = '144px';
|
|
1328
|
+
launcherBg.style.left = '-24px';
|
|
1329
|
+
launcherBg.style.top = '-24px';
|
|
1330
|
+
launcherFg.style.width = '144px';
|
|
1331
|
+
launcherFg.style.height = '144px';
|
|
1332
|
+
launcherFg.style.left = '-24px';
|
|
1333
|
+
launcherFg.style.top = '-24px';
|
|
1334
|
+
|
|
1335
|
+
setShape('squircle');
|
|
1336
|
+
applyState();
|
|
1337
|
+
</script>
|
|
1338
|
+
</body>
|
|
1339
|
+
</html>`;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
function openBrowser(url) {
|
|
1343
|
+
const command =
|
|
1344
|
+
process.platform === 'darwin'
|
|
1345
|
+
? `open "${url}"`
|
|
1346
|
+
: process.platform === 'win32'
|
|
1347
|
+
? `start "" "${url}"`
|
|
1348
|
+
: `xdg-open "${url}"`;
|
|
1349
|
+
|
|
1350
|
+
exec(command, (error) => {
|
|
1351
|
+
if (error) {
|
|
1352
|
+
process.stdout.write(`Open manually: ${url}\n`);
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
function servePng(res, filePath) {
|
|
1358
|
+
fs.readFile(filePath, (error, data) => {
|
|
1359
|
+
if (error || !data || data.length < PNG_SIGNATURE.length || !data.subarray(0, PNG_SIGNATURE.length).equals(PNG_SIGNATURE)) {
|
|
1360
|
+
res.writeHead(404, {
|
|
1361
|
+
'Content-Type': 'text/plain; charset=utf-8',
|
|
1362
|
+
'Cache-Control': 'no-store',
|
|
1363
|
+
});
|
|
1364
|
+
res.end('Not Found');
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
res.writeHead(200, {
|
|
1369
|
+
'Content-Type': 'image/png',
|
|
1370
|
+
'Cache-Control': 'no-store',
|
|
1371
|
+
});
|
|
1372
|
+
res.end(data);
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function createServer(options) {
|
|
1377
|
+
return http.createServer((req, res) => {
|
|
1378
|
+
const requestUrl = new URL(req.url, 'http://localhost');
|
|
1379
|
+
const state = buildState(options.projectRoot);
|
|
1380
|
+
|
|
1381
|
+
if (requestUrl.pathname === '/') {
|
|
1382
|
+
const html = createHtml(state);
|
|
1383
|
+
res.writeHead(200, {
|
|
1384
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
1385
|
+
'Cache-Control': 'no-store',
|
|
1386
|
+
});
|
|
1387
|
+
res.end(html);
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if (requestUrl.pathname === '/assets/icon') {
|
|
1392
|
+
servePng(res, state.assets.icon.path);
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
if (requestUrl.pathname === '/assets/ios-icon') {
|
|
1397
|
+
servePng(res, state.assets.iosIcon.path);
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
if (requestUrl.pathname === '/assets/splash') {
|
|
1402
|
+
servePng(res, state.assets.splash.path);
|
|
1403
|
+
return;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
if (requestUrl.pathname === '/assets/splash-dark') {
|
|
1407
|
+
servePng(res, state.assets.splashDark.path);
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
res.writeHead(404, {
|
|
1412
|
+
'Content-Type': 'text/plain; charset=utf-8',
|
|
1413
|
+
'Cache-Control': 'no-store',
|
|
1414
|
+
});
|
|
1415
|
+
res.end('Not Found');
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
function startServer(options) {
|
|
1420
|
+
const server = createServer(options);
|
|
1421
|
+
let currentPort = options.port;
|
|
1422
|
+
let browserOpened = false;
|
|
1423
|
+
|
|
1424
|
+
server.on('error', (error) => {
|
|
1425
|
+
if (error && error.code === 'EADDRINUSE') {
|
|
1426
|
+
currentPort += 1;
|
|
1427
|
+
server.listen(currentPort);
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
process.stderr.write(`${error.message}\n`);
|
|
1432
|
+
process.exit(1);
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
server.on('listening', () => {
|
|
1436
|
+
const url = `http://localhost:${currentPort}`;
|
|
1437
|
+
process.stdout.write(`iconpeek running at ${url}\n`);
|
|
1438
|
+
if (options.open && !browserOpened) {
|
|
1439
|
+
browserOpened = true;
|
|
1440
|
+
openBrowser(url);
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
|
|
1444
|
+
server.listen(currentPort);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
try {
|
|
1448
|
+
const options = parseArgs(process.argv.slice(2));
|
|
1449
|
+
startServer(options);
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
process.stderr.write(`${error.message}\n\n`);
|
|
1452
|
+
printHelp();
|
|
1453
|
+
process.exit(1);
|
|
1454
|
+
}
|