@hyperframes/studio-server 0.8.40 → 0.8.41
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 +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1150,7 +1150,7 @@ function writeFileWithReceipt(c, filePath, absPath, html) {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
function writeMutationResult(c, projectDir, filePath, absPath, html) {
|
|
1152
1152
|
const backup = snapshotBeforeWrite(projectDir, absPath);
|
|
1153
|
-
if (backup.error)
|
|
1153
|
+
if (backup.error) return c.json({ error: `backup failed: ${backup.error}` }, 500);
|
|
1154
1154
|
const { version } = writeFileWithReceipt(c, filePath, absPath, html);
|
|
1155
1155
|
return { backupPath: backupPathForResponse(projectDir, backup.backupPath), version };
|
|
1156
1156
|
}
|
|
@@ -1158,7 +1158,9 @@ function writeIfChanged(c, projectDir, filePath, absPath, original, next) {
|
|
|
1158
1158
|
if (next === original) {
|
|
1159
1159
|
return c.json({ ok: true, changed: false, content: original, path: filePath });
|
|
1160
1160
|
}
|
|
1161
|
-
const
|
|
1161
|
+
const mutationResult = writeMutationResult(c, projectDir, filePath, absPath, next);
|
|
1162
|
+
if (mutationResult instanceof Response) return mutationResult;
|
|
1163
|
+
const { backupPath } = mutationResult;
|
|
1162
1164
|
return c.json({
|
|
1163
1165
|
ok: true,
|
|
1164
1166
|
changed: true,
|
|
@@ -1573,13 +1575,15 @@ async function applyGsapMutations(c, res, mutations) {
|
|
|
1573
1575
|
return c.json({ error: "file changed during GSAP mutation", conflict: true }, 409);
|
|
1574
1576
|
}
|
|
1575
1577
|
if (changed) {
|
|
1576
|
-
|
|
1578
|
+
const mutationResult = writeMutationResult(
|
|
1577
1579
|
c,
|
|
1578
1580
|
res.project.dir,
|
|
1579
1581
|
res.filePath,
|
|
1580
1582
|
res.absPath,
|
|
1581
1583
|
newHtml
|
|
1582
|
-
)
|
|
1584
|
+
);
|
|
1585
|
+
if (mutationResult instanceof Response) return mutationResult;
|
|
1586
|
+
backupPath = mutationResult.backupPath;
|
|
1583
1587
|
}
|
|
1584
1588
|
const responsePayload = {
|
|
1585
1589
|
ok: true,
|
|
@@ -2476,8 +2480,7 @@ function registerFileRoutes(api, adapter) {
|
|
|
2476
2480
|
);
|
|
2477
2481
|
}
|
|
2478
2482
|
backup = snapshotBeforeWrite(res.project.dir, res.absPath);
|
|
2479
|
-
if (backup.error)
|
|
2480
|
-
console.warn(`Failed to create backup for ${res.filePath}: ${backup.error}`);
|
|
2483
|
+
if (backup.error) return c.json({ error: `backup failed: ${backup.error}` }, 500);
|
|
2481
2484
|
ftruncateSync(fd, 0);
|
|
2482
2485
|
writeSync(fd, body, 0, body.length, 0);
|
|
2483
2486
|
} finally {
|
|
@@ -2516,7 +2519,7 @@ function registerFileRoutes(api, adapter) {
|
|
|
2516
2519
|
if ("error" in res) return res.error;
|
|
2517
2520
|
const stat = statSync2(res.absPath);
|
|
2518
2521
|
const backup = snapshotBeforeWrite(res.project.dir, res.absPath);
|
|
2519
|
-
if (backup.error)
|
|
2522
|
+
if (backup.error) return c.json({ error: `backup failed: ${backup.error}` }, 500);
|
|
2520
2523
|
if (stat.isDirectory()) {
|
|
2521
2524
|
rmSync3(res.absPath, { recursive: true });
|
|
2522
2525
|
} else {
|
|
@@ -2786,13 +2789,15 @@ function registerFileRoutes(api, adapter) {
|
|
|
2786
2789
|
version: version2
|
|
2787
2790
|
});
|
|
2788
2791
|
}
|
|
2789
|
-
const
|
|
2792
|
+
const mutationResult = writeMutationResult(
|
|
2790
2793
|
c,
|
|
2791
2794
|
ctx.project.dir,
|
|
2792
2795
|
ctx.filePath,
|
|
2793
2796
|
ctx.absPath,
|
|
2794
2797
|
result.html
|
|
2795
2798
|
);
|
|
2799
|
+
if (mutationResult instanceof Response) return mutationResult;
|
|
2800
|
+
const { version, backupPath } = mutationResult;
|
|
2796
2801
|
c.header("ETag", version);
|
|
2797
2802
|
return c.json({
|
|
2798
2803
|
ok: true,
|
|
@@ -2839,13 +2844,15 @@ function registerFileRoutes(api, adapter) {
|
|
|
2839
2844
|
version: version2
|
|
2840
2845
|
});
|
|
2841
2846
|
}
|
|
2842
|
-
const
|
|
2847
|
+
const mutationResult = writeMutationResult(
|
|
2843
2848
|
c,
|
|
2844
2849
|
ctx.project.dir,
|
|
2845
2850
|
ctx.filePath,
|
|
2846
2851
|
ctx.absPath,
|
|
2847
2852
|
patched
|
|
2848
2853
|
);
|
|
2854
|
+
if (mutationResult instanceof Response) return mutationResult;
|
|
2855
|
+
const { backupPath, version } = mutationResult;
|
|
2849
2856
|
c.header("ETag", version);
|
|
2850
2857
|
return c.json({
|
|
2851
2858
|
ok: true,
|
|
@@ -2940,13 +2947,15 @@ function registerFileRoutes(api, adapter) {
|
|
|
2940
2947
|
result.error === "grouped elements must share a single parent" ? 422 : 400
|
|
2941
2948
|
);
|
|
2942
2949
|
}
|
|
2943
|
-
const
|
|
2950
|
+
const mutationResult = writeMutationResult(
|
|
2944
2951
|
c,
|
|
2945
2952
|
ctx.project.dir,
|
|
2946
2953
|
ctx.filePath,
|
|
2947
2954
|
ctx.absPath,
|
|
2948
2955
|
result.html
|
|
2949
2956
|
);
|
|
2957
|
+
if (mutationResult instanceof Response) return mutationResult;
|
|
2958
|
+
const { backupPath } = mutationResult;
|
|
2950
2959
|
return c.json({
|
|
2951
2960
|
ok: true,
|
|
2952
2961
|
changed: true,
|