storyforge 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/dist/index.js +36 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -566,6 +566,42 @@ Return ONLY the complete updated TSX. No markdown fences, no explanation.`;
566
566
  res.end(fs2.readFileSync(compPath));
567
567
  return;
568
568
  }
569
+ if (pathname === "/api/chunk-compositions/append-images" && req.method === "POST") {
570
+ const bodyChunks = [];
571
+ req.on("data", (c2) => bodyChunks.push(c2));
572
+ req.on("end", () => {
573
+ try {
574
+ const { assemblyId, paths } = JSON.parse(Buffer.concat(bodyChunks).toString("utf-8"));
575
+ const compPath = path2.join(dir, "chunk-compositions.json");
576
+ if (!fs2.existsSync(compPath)) {
577
+ res.writeHead(404, CORS_HEADERS);
578
+ res.end(JSON.stringify({ error: "chunk-compositions.json not found" }));
579
+ return;
580
+ }
581
+ const doc = JSON.parse(fs2.readFileSync(compPath, "utf-8"));
582
+ const scene = doc.scenes?.find((c2) => c2.assemblyId === assemblyId);
583
+ if (!scene) {
584
+ res.writeHead(404, CORS_HEADERS);
585
+ res.end(JSON.stringify({ error: `scene ${assemblyId} not found` }));
586
+ return;
587
+ }
588
+ const existing = Array.isArray(scene.images) ? scene.images : [];
589
+ const deduped = [...existing];
590
+ for (const p of paths) {
591
+ if (p && !deduped.includes(p)) deduped.push(p);
592
+ }
593
+ scene.images = deduped;
594
+ scene.imageCount = deduped.length;
595
+ fs2.writeFileSync(compPath, JSON.stringify(doc, null, 2), "utf-8");
596
+ res.writeHead(200, { ...CORS_HEADERS, "Content-Type": "application/json" });
597
+ res.end(JSON.stringify({ ok: true, images: deduped }));
598
+ } catch (e) {
599
+ res.writeHead(500, CORS_HEADERS);
600
+ res.end(JSON.stringify({ error: e.message }));
601
+ }
602
+ });
603
+ return;
604
+ }
569
605
  const listMatch = pathname.match(/^\/api\/list\/(.+)$/);
570
606
  if (listMatch) {
571
607
  const relPath = decodeURIComponent(listMatch[1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyforge",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "StoryForge — local bridge for the Forge video production web app. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "bin": {