@gallop.software/studio 1.5.0 → 1.5.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/dist/{StudioUI-7QQIKNTF.mjs → StudioUI-BHFZVR57.mjs} +89 -19
- package/dist/StudioUI-BHFZVR57.mjs.map +1 -0
- package/dist/{StudioUI-MZENRXN3.js → StudioUI-GULMXZQF.js} +95 -25
- package/dist/StudioUI-GULMXZQF.js.map +1 -0
- package/dist/handlers/index.js +89 -58
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/index.mjs +89 -58
- package/dist/handlers/index.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/StudioUI-7QQIKNTF.mjs.map +0 -1
- package/dist/StudioUI-MZENRXN3.js.map +0 -1
package/dist/handlers/index.mjs
CHANGED
|
@@ -2214,74 +2214,105 @@ var FAVICON_CONFIGS = [
|
|
|
2214
2214
|
{ name: "apple-icon.png", size: 180 }
|
|
2215
2215
|
];
|
|
2216
2216
|
async function handleGenerateFavicon(request) {
|
|
2217
|
+
const encoder = new TextEncoder();
|
|
2218
|
+
let imagePath;
|
|
2217
2219
|
try {
|
|
2218
2220
|
const body = await request.json();
|
|
2219
|
-
|
|
2221
|
+
imagePath = body.imagePath;
|
|
2220
2222
|
if (!imagePath) {
|
|
2221
2223
|
return NextResponse5.json({ error: "No image path provided" }, { status: 400 });
|
|
2222
2224
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2225
|
+
} catch {
|
|
2226
|
+
return NextResponse5.json({ error: "Invalid request body" }, { status: 400 });
|
|
2227
|
+
}
|
|
2228
|
+
const fileName = path9.basename(imagePath).toLowerCase();
|
|
2229
|
+
if (fileName !== "favicon.png" && fileName !== "favicon.jpg") {
|
|
2230
|
+
return NextResponse5.json({
|
|
2231
|
+
error: "Source file must be named favicon.png or favicon.jpg"
|
|
2232
|
+
}, { status: 400 });
|
|
2233
|
+
}
|
|
2234
|
+
const sourcePath = path9.join(process.cwd(), "public", imagePath.replace(/^\//, ""));
|
|
2235
|
+
try {
|
|
2236
|
+
await fs8.access(sourcePath);
|
|
2237
|
+
} catch {
|
|
2238
|
+
return NextResponse5.json({ error: "Source file not found" }, { status: 404 });
|
|
2239
|
+
}
|
|
2240
|
+
let metadata;
|
|
2241
|
+
try {
|
|
2242
|
+
metadata = await sharp5(sourcePath).metadata();
|
|
2243
|
+
} catch {
|
|
2244
|
+
return NextResponse5.json({ error: "Source file is not a valid image" }, { status: 400 });
|
|
2245
|
+
}
|
|
2246
|
+
const outputDir = path9.join(process.cwd(), "src", "app");
|
|
2247
|
+
try {
|
|
2248
|
+
await fs8.access(outputDir);
|
|
2249
|
+
} catch {
|
|
2250
|
+
return NextResponse5.json({
|
|
2251
|
+
error: "Output directory src/app/ not found"
|
|
2252
|
+
}, { status: 500 });
|
|
2253
|
+
}
|
|
2254
|
+
const stream = new ReadableStream({
|
|
2255
|
+
async start(controller) {
|
|
2256
|
+
const sendEvent = (data) => {
|
|
2257
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(data)}
|
|
2258
|
+
|
|
2259
|
+
`));
|
|
2260
|
+
};
|
|
2251
2261
|
try {
|
|
2252
|
-
const
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
size: config.size,
|
|
2260
|
-
success: true
|
|
2262
|
+
const total = FAVICON_CONFIGS.length;
|
|
2263
|
+
const generated = [];
|
|
2264
|
+
const errors = [];
|
|
2265
|
+
sendEvent({
|
|
2266
|
+
type: "start",
|
|
2267
|
+
total,
|
|
2268
|
+
sourceSize: `${metadata.width}x${metadata.height}`
|
|
2261
2269
|
});
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2270
|
+
for (let i = 0; i < FAVICON_CONFIGS.length; i++) {
|
|
2271
|
+
const config = FAVICON_CONFIGS[i];
|
|
2272
|
+
sendEvent({
|
|
2273
|
+
type: "progress",
|
|
2274
|
+
current: i + 1,
|
|
2275
|
+
total,
|
|
2276
|
+
percent: Math.round((i + 1) / total * 100),
|
|
2277
|
+
message: `Generating ${config.name} (${config.size}x${config.size})...`
|
|
2278
|
+
});
|
|
2279
|
+
try {
|
|
2280
|
+
const outputPath = path9.join(outputDir, config.name);
|
|
2281
|
+
await sharp5(sourcePath).resize(config.size, config.size, {
|
|
2282
|
+
fit: "cover",
|
|
2283
|
+
position: "center"
|
|
2284
|
+
}).png({ quality: 100 }).toFile(outputPath);
|
|
2285
|
+
generated.push(config.name);
|
|
2286
|
+
} catch (error) {
|
|
2287
|
+
console.error(`Failed to generate ${config.name}:`, error);
|
|
2288
|
+
errors.push(config.name);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
let message = `Generated ${generated.length} favicon${generated.length !== 1 ? "s" : ""} to src/app/.`;
|
|
2292
|
+
if (errors.length > 0) {
|
|
2293
|
+
message += ` ${errors.length} failed.`;
|
|
2294
|
+
}
|
|
2295
|
+
sendEvent({
|
|
2296
|
+
type: "complete",
|
|
2297
|
+
processed: generated.length,
|
|
2298
|
+
errors: errors.length,
|
|
2299
|
+
message
|
|
2268
2300
|
});
|
|
2301
|
+
controller.close();
|
|
2302
|
+
} catch (error) {
|
|
2303
|
+
console.error("Favicon generation error:", error);
|
|
2304
|
+
sendEvent({ type: "error", message: "Failed to generate favicons" });
|
|
2305
|
+
controller.close();
|
|
2269
2306
|
}
|
|
2270
2307
|
}
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
} catch (error) {
|
|
2280
|
-
console.error("Favicon generation error:", error);
|
|
2281
|
-
return NextResponse5.json({
|
|
2282
|
-
error: "Failed to generate favicons"
|
|
2283
|
-
}, { status: 500 });
|
|
2284
|
-
}
|
|
2308
|
+
});
|
|
2309
|
+
return new Response(stream, {
|
|
2310
|
+
headers: {
|
|
2311
|
+
"Content-Type": "text/event-stream",
|
|
2312
|
+
"Cache-Control": "no-cache",
|
|
2313
|
+
Connection: "keep-alive"
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
2285
2316
|
}
|
|
2286
2317
|
|
|
2287
2318
|
// src/handlers/index.ts
|