@hyperframes/studio-server 0.8.3 → 0.8.4

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/index.js CHANGED
@@ -2519,6 +2519,24 @@ function registerFileRoutes(api, adapter) {
2519
2519
  removeElementFromHtml(originalContent, parsed.target)
2520
2520
  );
2521
2521
  });
2522
+ api.post("/projects/:id/file-mutations/remove-elements/*", async (c) => {
2523
+ const ctx = await resolveFileMutationContext(c, adapter, "remove-elements");
2524
+ if ("error" in ctx) return ctx.error;
2525
+ if (!existsSync4(ctx.absPath)) {
2526
+ return c.json({ error: "not found" }, 404);
2527
+ }
2528
+ const body = await c.req.json().catch(() => null);
2529
+ const targets = body?.targets;
2530
+ if (!Array.isArray(targets) || targets.length === 0) {
2531
+ return c.json({ error: "targets required" }, 400);
2532
+ }
2533
+ const originalContent = readFileSync5(ctx.absPath, "utf-8");
2534
+ let next = originalContent;
2535
+ for (const target of targets) {
2536
+ next = removeElementFromHtml(next, target);
2537
+ }
2538
+ return writeIfChanged(c, ctx.project.dir, ctx.filePath, ctx.absPath, originalContent, next);
2539
+ });
2522
2540
  api.post("/projects/:id/file-mutations/split-batch", async (c) => {
2523
2541
  const body = await c.req.json().catch(() => null);
2524
2542
  if (!Array.isArray(body?.files) || body.files.length === 0 || !body.files.every(isAtomicCutFileRequest)) {