@hyperframes/core 0.7.14 → 0.7.15

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 (238) hide show
  1. package/dist/compiler/staticGuard.js +1 -1
  2. package/dist/compiler/staticGuard.js.map +1 -1
  3. package/dist/core.types.d.ts +2 -369
  4. package/dist/core.types.d.ts.map +1 -1
  5. package/dist/core.types.js +1 -84
  6. package/dist/core.types.js.map +1 -1
  7. package/dist/generators/hyperframes.d.ts +1 -1
  8. package/dist/generators/hyperframes.d.ts.map +1 -1
  9. package/dist/generators/hyperframes.js +1 -1
  10. package/dist/generators/hyperframes.js.map +1 -1
  11. package/dist/index.d.ts +5 -7
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +7 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/lint/index.d.ts +2 -2
  16. package/dist/lint/index.d.ts.map +1 -1
  17. package/dist/lint/index.js +2 -1
  18. package/dist/lint/index.js.map +1 -1
  19. package/dist/parsers/gsapConstants.d.ts +2 -12
  20. package/dist/parsers/gsapConstants.d.ts.map +1 -1
  21. package/dist/parsers/gsapConstants.js +2 -110
  22. package/dist/parsers/gsapConstants.js.map +1 -1
  23. package/dist/parsers/gsapParserAcorn.d.ts +2 -48
  24. package/dist/parsers/gsapParserAcorn.d.ts.map +1 -1
  25. package/dist/parsers/gsapParserAcorn.js +2 -1057
  26. package/dist/parsers/gsapParserAcorn.js.map +1 -1
  27. package/dist/parsers/gsapParserExports.d.ts +2 -20
  28. package/dist/parsers/gsapParserExports.d.ts.map +1 -1
  29. package/dist/parsers/gsapParserExports.js +2 -8
  30. package/dist/parsers/gsapParserExports.js.map +1 -1
  31. package/dist/parsers/gsapWriterAcorn.d.ts +2 -90
  32. package/dist/parsers/gsapWriterAcorn.d.ts.map +1 -1
  33. package/dist/parsers/gsapWriterAcorn.js +2 -2016
  34. package/dist/parsers/gsapWriterAcorn.js.map +1 -1
  35. package/dist/parsers/hfIds.d.ts +2 -16
  36. package/dist/parsers/hfIds.d.ts.map +1 -1
  37. package/dist/parsers/hfIds.js +2 -127
  38. package/dist/parsers/hfIds.js.map +1 -1
  39. package/dist/parsers/springEase.d.ts +2 -28
  40. package/dist/parsers/springEase.d.ts.map +1 -1
  41. package/dist/parsers/springEase.js +2 -69
  42. package/dist/parsers/springEase.js.map +1 -1
  43. package/dist/slideshow/index.d.ts +1 -0
  44. package/dist/slideshow/index.d.ts.map +1 -1
  45. package/dist/slideshow/index.js +1 -0
  46. package/dist/slideshow/index.js.map +1 -1
  47. package/dist/studio-api/helpers/draftMarkers.d.ts +2 -10
  48. package/dist/studio-api/helpers/draftMarkers.d.ts.map +1 -1
  49. package/dist/studio-api/helpers/draftMarkers.js +2 -10
  50. package/dist/studio-api/helpers/draftMarkers.js.map +1 -1
  51. package/dist/studio-api/helpers/finiteMutation.d.ts +2 -10
  52. package/dist/studio-api/helpers/finiteMutation.d.ts.map +1 -1
  53. package/dist/studio-api/helpers/finiteMutation.js +2 -20
  54. package/dist/studio-api/helpers/finiteMutation.js.map +1 -1
  55. package/dist/studio-api/helpers/manualEditsRenderScript.d.ts +2 -12
  56. package/dist/studio-api/helpers/manualEditsRenderScript.d.ts.map +1 -1
  57. package/dist/studio-api/helpers/manualEditsRenderScript.js +2 -632
  58. package/dist/studio-api/helpers/manualEditsRenderScript.js.map +1 -1
  59. package/dist/studio-api/helpers/screenshotClip.d.ts +2 -7
  60. package/dist/studio-api/helpers/screenshotClip.d.ts.map +1 -1
  61. package/dist/studio-api/helpers/screenshotClip.js +2 -21
  62. package/dist/studio-api/helpers/screenshotClip.js.map +1 -1
  63. package/dist/studio-api/helpers/studioMotionRenderScript.d.ts +2 -8
  64. package/dist/studio-api/helpers/studioMotionRenderScript.d.ts.map +1 -1
  65. package/dist/studio-api/helpers/studioMotionRenderScript.js +2 -207
  66. package/dist/studio-api/helpers/studioMotionRenderScript.js.map +1 -1
  67. package/dist/studio-api/index.d.ts +2 -9
  68. package/dist/studio-api/index.d.ts.map +1 -1
  69. package/dist/studio-api/index.js +2 -8
  70. package/dist/studio-api/index.js.map +1 -1
  71. package/package.json +16 -18
  72. package/dist/generated/runtime-inline.js +0 -11
  73. package/dist/hyperframe.manifest.json +0 -22
  74. package/dist/hyperframe.runtime.mjs +0 -325
  75. package/dist/lint/context.d.ts +0 -17
  76. package/dist/lint/context.d.ts.map +0 -1
  77. package/dist/lint/context.js +0 -37
  78. package/dist/lint/context.js.map +0 -1
  79. package/dist/lint/hyperframeLinter.d.ts +0 -14
  80. package/dist/lint/hyperframeLinter.d.ts.map +0 -1
  81. package/dist/lint/hyperframeLinter.js +0 -132
  82. package/dist/lint/hyperframeLinter.js.map +0 -1
  83. package/dist/lint/rules/adapters.d.ts +0 -3
  84. package/dist/lint/rules/adapters.d.ts.map +0 -1
  85. package/dist/lint/rules/adapters.js +0 -40
  86. package/dist/lint/rules/adapters.js.map +0 -1
  87. package/dist/lint/rules/captions.d.ts +0 -3
  88. package/dist/lint/rules/captions.d.ts.map +0 -1
  89. package/dist/lint/rules/captions.js +0 -242
  90. package/dist/lint/rules/captions.js.map +0 -1
  91. package/dist/lint/rules/composition.d.ts +0 -5
  92. package/dist/lint/rules/composition.d.ts.map +0 -1
  93. package/dist/lint/rules/composition.js +0 -694
  94. package/dist/lint/rules/composition.js.map +0 -1
  95. package/dist/lint/rules/core.d.ts +0 -3
  96. package/dist/lint/rules/core.d.ts.map +0 -1
  97. package/dist/lint/rules/core.js +0 -432
  98. package/dist/lint/rules/core.js.map +0 -1
  99. package/dist/lint/rules/fonts.d.ts +0 -3
  100. package/dist/lint/rules/fonts.d.ts.map +0 -1
  101. package/dist/lint/rules/fonts.js +0 -205
  102. package/dist/lint/rules/fonts.js.map +0 -1
  103. package/dist/lint/rules/gsap.d.ts +0 -4
  104. package/dist/lint/rules/gsap.d.ts.map +0 -1
  105. package/dist/lint/rules/gsap.js +0 -1039
  106. package/dist/lint/rules/gsap.js.map +0 -1
  107. package/dist/lint/rules/media.d.ts +0 -3
  108. package/dist/lint/rules/media.d.ts.map +0 -1
  109. package/dist/lint/rules/media.js +0 -491
  110. package/dist/lint/rules/media.js.map +0 -1
  111. package/dist/lint/rules/slideshow.d.ts +0 -4
  112. package/dist/lint/rules/slideshow.d.ts.map +0 -1
  113. package/dist/lint/rules/slideshow.js +0 -74
  114. package/dist/lint/rules/slideshow.js.map +0 -1
  115. package/dist/lint/rules/textures.d.ts +0 -3
  116. package/dist/lint/rules/textures.d.ts.map +0 -1
  117. package/dist/lint/rules/textures.js +0 -192
  118. package/dist/lint/rules/textures.js.map +0 -1
  119. package/dist/lint/types.d.ts +0 -36
  120. package/dist/lint/types.d.ts.map +0 -1
  121. package/dist/lint/types.js +0 -2
  122. package/dist/lint/types.js.map +0 -1
  123. package/dist/lint/utils.d.ts +0 -55
  124. package/dist/lint/utils.d.ts.map +0 -1
  125. package/dist/lint/utils.js +0 -264
  126. package/dist/lint/utils.js.map +0 -1
  127. package/dist/parsers/gsapInline.d.ts +0 -47
  128. package/dist/parsers/gsapInline.d.ts.map +0 -1
  129. package/dist/parsers/gsapInline.js +0 -513
  130. package/dist/parsers/gsapInline.js.map +0 -1
  131. package/dist/parsers/gsapParser.d.ts +0 -158
  132. package/dist/parsers/gsapParser.d.ts.map +0 -1
  133. package/dist/parsers/gsapParser.js +0 -2634
  134. package/dist/parsers/gsapParser.js.map +0 -1
  135. package/dist/parsers/gsapParser.test-helpers.d.ts +0 -49
  136. package/dist/parsers/gsapParser.test-helpers.d.ts.map +0 -1
  137. package/dist/parsers/gsapParser.test-helpers.js +0 -97
  138. package/dist/parsers/gsapParser.test-helpers.js.map +0 -1
  139. package/dist/parsers/gsapSerialize.d.ts +0 -191
  140. package/dist/parsers/gsapSerialize.d.ts.map +0 -1
  141. package/dist/parsers/gsapSerialize.js +0 -410
  142. package/dist/parsers/gsapSerialize.js.map +0 -1
  143. package/dist/parsers/gsapUnroll.d.ts +0 -7
  144. package/dist/parsers/gsapUnroll.d.ts.map +0 -1
  145. package/dist/parsers/gsapUnroll.js +0 -137
  146. package/dist/parsers/gsapUnroll.js.map +0 -1
  147. package/dist/parsers/htmlParser.d.ts +0 -27
  148. package/dist/parsers/htmlParser.d.ts.map +0 -1
  149. package/dist/parsers/htmlParser.js +0 -731
  150. package/dist/parsers/htmlParser.js.map +0 -1
  151. package/dist/studio-api/createStudioApi.d.ts +0 -10
  152. package/dist/studio-api/createStudioApi.d.ts.map +0 -1
  153. package/dist/studio-api/createStudioApi.js +0 -32
  154. package/dist/studio-api/createStudioApi.js.map +0 -1
  155. package/dist/studio-api/helpers/backupJournal.d.ts +0 -9
  156. package/dist/studio-api/helpers/backupJournal.d.ts.map +0 -1
  157. package/dist/studio-api/helpers/backupJournal.js +0 -81
  158. package/dist/studio-api/helpers/backupJournal.js.map +0 -1
  159. package/dist/studio-api/helpers/hfIdPersist.d.ts +0 -11
  160. package/dist/studio-api/helpers/hfIdPersist.d.ts.map +0 -1
  161. package/dist/studio-api/helpers/hfIdPersist.js +0 -39
  162. package/dist/studio-api/helpers/hfIdPersist.js.map +0 -1
  163. package/dist/studio-api/helpers/mediaValidation.d.ts +0 -20
  164. package/dist/studio-api/helpers/mediaValidation.d.ts.map +0 -1
  165. package/dist/studio-api/helpers/mediaValidation.js +0 -56
  166. package/dist/studio-api/helpers/mediaValidation.js.map +0 -1
  167. package/dist/studio-api/helpers/mime.d.ts +0 -4
  168. package/dist/studio-api/helpers/mime.d.ts.map +0 -1
  169. package/dist/studio-api/helpers/mime.js +0 -39
  170. package/dist/studio-api/helpers/mime.js.map +0 -1
  171. package/dist/studio-api/helpers/previewAdapter.d.ts +0 -43
  172. package/dist/studio-api/helpers/previewAdapter.d.ts.map +0 -1
  173. package/dist/studio-api/helpers/previewAdapter.js +0 -118
  174. package/dist/studio-api/helpers/previewAdapter.js.map +0 -1
  175. package/dist/studio-api/helpers/projectSignature.d.ts +0 -5
  176. package/dist/studio-api/helpers/projectSignature.d.ts.map +0 -1
  177. package/dist/studio-api/helpers/projectSignature.js +0 -154
  178. package/dist/studio-api/helpers/projectSignature.js.map +0 -1
  179. package/dist/studio-api/helpers/safePath.d.ts +0 -12
  180. package/dist/studio-api/helpers/safePath.d.ts.map +0 -1
  181. package/dist/studio-api/helpers/safePath.js +0 -38
  182. package/dist/studio-api/helpers/safePath.js.map +0 -1
  183. package/dist/studio-api/helpers/sourceMutation.d.ts +0 -28
  184. package/dist/studio-api/helpers/sourceMutation.d.ts.map +0 -1
  185. package/dist/studio-api/helpers/sourceMutation.js +0 -339
  186. package/dist/studio-api/helpers/sourceMutation.js.map +0 -1
  187. package/dist/studio-api/helpers/subComposition.d.ts +0 -20
  188. package/dist/studio-api/helpers/subComposition.d.ts.map +0 -1
  189. package/dist/studio-api/helpers/subComposition.js +0 -289
  190. package/dist/studio-api/helpers/subComposition.js.map +0 -1
  191. package/dist/studio-api/helpers/waveform.d.ts +0 -4
  192. package/dist/studio-api/helpers/waveform.d.ts.map +0 -1
  193. package/dist/studio-api/helpers/waveform.js +0 -80
  194. package/dist/studio-api/helpers/waveform.js.map +0 -1
  195. package/dist/studio-api/routes/files.d.ts +0 -4
  196. package/dist/studio-api/routes/files.d.ts.map +0 -1
  197. package/dist/studio-api/routes/files.js +0 -1200
  198. package/dist/studio-api/routes/files.js.map +0 -1
  199. package/dist/studio-api/routes/fonts.d.ts +0 -3
  200. package/dist/studio-api/routes/fonts.d.ts.map +0 -1
  201. package/dist/studio-api/routes/fonts.js +0 -157
  202. package/dist/studio-api/routes/fonts.js.map +0 -1
  203. package/dist/studio-api/routes/lint.d.ts +0 -4
  204. package/dist/studio-api/routes/lint.d.ts.map +0 -1
  205. package/dist/studio-api/routes/lint.js +0 -29
  206. package/dist/studio-api/routes/lint.js.map +0 -1
  207. package/dist/studio-api/routes/preview.d.ts +0 -4
  208. package/dist/studio-api/routes/preview.d.ts.map +0 -1
  209. package/dist/studio-api/routes/preview.js +0 -331
  210. package/dist/studio-api/routes/preview.js.map +0 -1
  211. package/dist/studio-api/routes/projects.d.ts +0 -4
  212. package/dist/studio-api/routes/projects.d.ts.map +0 -1
  213. package/dist/studio-api/routes/projects.js +0 -45
  214. package/dist/studio-api/routes/projects.js.map +0 -1
  215. package/dist/studio-api/routes/registry.d.ts +0 -4
  216. package/dist/studio-api/routes/registry.d.ts.map +0 -1
  217. package/dist/studio-api/routes/registry.js +0 -31
  218. package/dist/studio-api/routes/registry.js.map +0 -1
  219. package/dist/studio-api/routes/render.d.ts +0 -4
  220. package/dist/studio-api/routes/render.d.ts.map +0 -1
  221. package/dist/studio-api/routes/render.js +0 -269
  222. package/dist/studio-api/routes/render.js.map +0 -1
  223. package/dist/studio-api/routes/storyboard.d.ts +0 -4
  224. package/dist/studio-api/routes/storyboard.d.ts.map +0 -1
  225. package/dist/studio-api/routes/storyboard.js +0 -65
  226. package/dist/studio-api/routes/storyboard.js.map +0 -1
  227. package/dist/studio-api/routes/thumbnail.d.ts +0 -4
  228. package/dist/studio-api/routes/thumbnail.d.ts.map +0 -1
  229. package/dist/studio-api/routes/thumbnail.js +0 -107
  230. package/dist/studio-api/routes/thumbnail.js.map +0 -1
  231. package/dist/studio-api/routes/waveform.d.ts +0 -4
  232. package/dist/studio-api/routes/waveform.d.ts.map +0 -1
  233. package/dist/studio-api/routes/waveform.js +0 -41
  234. package/dist/studio-api/routes/waveform.js.map +0 -1
  235. package/dist/studio-api/types.d.ts +0 -120
  236. package/dist/studio-api/types.d.ts.map +0 -1
  237. package/dist/studio-api/types.js +0 -2
  238. package/dist/studio-api/types.js.map +0 -1
@@ -1,269 +0,0 @@
1
- import { streamSSE } from "hono/streaming";
2
- import { existsSync, readFileSync, mkdirSync, unlinkSync, readdirSync, statSync } from "node:fs";
3
- import { join } from "node:path";
4
- import { VALID_CANVAS_RESOLUTIONS, parseFps } from "../../core.types.js";
5
- import { resolveWithinProject } from "../helpers/safePath.js";
6
- const VALID_RESOLUTIONS = new Set(VALID_CANVAS_RESOLUTIONS);
7
- export function registerRenderRoutes(api, adapter) {
8
- // Scoped job store — not shared across createStudioApi() calls
9
- const renderJobs = new Map();
10
- // TTL cleanup for completed jobs (5 minutes)
11
- const TTL_MS = 300_000;
12
- const CLEANUP_INTERVAL_MS = 60_000;
13
- let cleanupTimer = null;
14
- const cleanupEnabled = () => typeof process !== "undefined" &&
15
- process.env.NODE_ENV !== "production" &&
16
- !process.argv.includes("build");
17
- const cleanupFinishedJobs = () => {
18
- const now = Date.now();
19
- for (const [key, job] of renderJobs) {
20
- if ((job.status === "complete" || job.status === "failed") && now - job.createdAt > TTL_MS) {
21
- renderJobs.delete(key);
22
- }
23
- }
24
- if (renderJobs.size === 0 && cleanupTimer) {
25
- clearInterval(cleanupTimer);
26
- cleanupTimer = null;
27
- }
28
- };
29
- const ensureCleanupTimer = () => {
30
- if (cleanupTimer || !cleanupEnabled())
31
- return;
32
- cleanupTimer = setInterval(cleanupFinishedJobs, CLEANUP_INTERVAL_MS);
33
- if (typeof cleanupTimer === "object" && "unref" in cleanupTimer) {
34
- cleanupTimer.unref();
35
- }
36
- };
37
- ensureCleanupTimer();
38
- // Start a render
39
- api.post("/projects/:id/render", async (c) => {
40
- const project = await adapter.resolveProject(c.req.param("id"));
41
- if (!project)
42
- return c.json({ error: "not found" }, 404);
43
- const body = (await c.req.json().catch(() => ({})));
44
- const VALID_FORMATS = new Set(["mp4", "webm", "mov"]);
45
- const FORMAT_EXT = { mp4: ".mp4", webm: ".webm", mov: ".mov" };
46
- const format = VALID_FORMATS.has(body.format ?? "") ? body.format : "mp4";
47
- // Default to 30 fps when unset or unparseable. The route stays lenient on
48
- // invalid fps values (matching the lenient handling of `resolution` and
49
- // `quality` already in this file) — the producer surfaces a clearer error
50
- // message if the caller really did mean to fail loudly.
51
- const fpsParse = body.fps === undefined ? null : parseFps(body.fps);
52
- const fps = fpsParse && fpsParse.ok ? fpsParse.value : { num: 30, den: 1 };
53
- const quality = ["draft", "standard", "high"].includes(body.quality ?? "")
54
- ? body.quality
55
- : "standard";
56
- const outputResolution = VALID_RESOLUTIONS.has(body.resolution ?? "")
57
- ? body.resolution
58
- : undefined;
59
- let composition;
60
- if (typeof body.composition === "string" && body.composition.length > 0) {
61
- // `body.composition` is attacker-controlled (from c.req.json()).
62
- // resolveWithinProject dereferences symlinks, so an in-project symlink
63
- // pointing outside the root can't smuggle the render target out.
64
- if (!resolveWithinProject(project.dir, body.composition)) {
65
- return c.json({ error: "composition path must be within the project directory" }, 400);
66
- }
67
- composition = body.composition;
68
- }
69
- // fallow-ignore-next-line code-duplication
70
- const now = new Date();
71
- const datePart = now.toISOString().slice(0, 10);
72
- const timePart = now.toTimeString().slice(0, 8).replace(/:/g, "-");
73
- const jobId = `${project.id}_${datePart}_${timePart}`;
74
- const rendersDir = adapter.rendersDir(project);
75
- if (!existsSync(rendersDir))
76
- mkdirSync(rendersDir, { recursive: true });
77
- const ext = FORMAT_EXT[format] ?? ".mp4";
78
- const outputPath = join(rendersDir, `${jobId}${ext}`);
79
- const jobState = adapter.startRender({
80
- project,
81
- outputPath,
82
- format: format,
83
- fps,
84
- quality,
85
- jobId,
86
- outputResolution,
87
- composition,
88
- distinctId: typeof body.telemetryDistinctId === "string" ? body.telemetryDistinctId : undefined,
89
- });
90
- jobState.createdAt = Date.now();
91
- renderJobs.set(jobId, jobState);
92
- ensureCleanupTimer();
93
- return c.json({ jobId, status: "rendering" });
94
- });
95
- // SSE progress stream
96
- api.get("/render/:jobId/progress", (c) => {
97
- const { jobId } = c.req.param();
98
- const job = renderJobs.get(jobId);
99
- if (!job)
100
- return c.json({ error: "not found" }, 404);
101
- return streamSSE(c, async (stream) => {
102
- while (true) {
103
- const current = renderJobs.get(jobId);
104
- if (!current)
105
- break;
106
- await stream.writeSSE({
107
- event: "progress",
108
- data: JSON.stringify({
109
- progress: current.progress,
110
- status: current.status,
111
- stage: current.stage,
112
- error: current.error,
113
- }),
114
- });
115
- if (current.status === "complete" || current.status === "failed")
116
- break;
117
- await stream.sleep(500);
118
- }
119
- });
120
- });
121
- const RENDER_MIME = {
122
- ".mp4": "video/mp4",
123
- ".webm": "video/webm",
124
- ".mov": "video/quicktime",
125
- };
126
- const RENDER_EXTENSIONS = Object.keys(RENDER_MIME);
127
- function renderContentType(filePath) {
128
- const ext = RENDER_EXTENSIONS.find((e) => filePath.endsWith(e));
129
- return (ext && RENDER_MIME[ext]) ?? "video/mp4";
130
- }
131
- // Serve render inline (for in-browser playback — opens in a new tab)
132
- api.get("/render/:jobId/view", (c) => {
133
- const { jobId } = c.req.param();
134
- const job = renderJobs.get(jobId);
135
- if (!job?.outputPath || !existsSync(job.outputPath)) {
136
- return c.json({ error: "not found" }, 404);
137
- }
138
- const contentType = renderContentType(job.outputPath);
139
- const filename = job.outputPath.split("/").pop() ?? `render.mp4`;
140
- const content = readFileSync(job.outputPath);
141
- return new Response(content, {
142
- headers: {
143
- "Content-Type": contentType,
144
- "Content-Disposition": `inline; filename="${filename}"`,
145
- "Accept-Ranges": "bytes",
146
- "Content-Length": String(content.length),
147
- },
148
- });
149
- });
150
- // Download render
151
- api.get("/render/:jobId/download", (c) => {
152
- const { jobId } = c.req.param();
153
- const job = renderJobs.get(jobId);
154
- if (!job?.outputPath || !existsSync(job.outputPath)) {
155
- return c.json({ error: "not found" }, 404);
156
- }
157
- const contentType = renderContentType(job.outputPath);
158
- const filename = job.outputPath.split("/").pop() ?? `render.mp4`;
159
- const content = readFileSync(job.outputPath);
160
- return new Response(content, {
161
- headers: {
162
- "Content-Type": contentType,
163
- "Content-Disposition": `attachment; filename="${filename}"`,
164
- },
165
- });
166
- });
167
- // Delete render
168
- api.delete("/render/:jobId", (c) => {
169
- const { jobId } = c.req.param();
170
- for (const [, state] of renderJobs) {
171
- if (state.id === jobId && state.outputPath) {
172
- const dir = state.outputPath.replace(/\/[^/]+$/, "");
173
- for (const ext of [".mp4", ".webm", ".mov", ".meta.json"]) {
174
- const fp = join(dir, `${jobId}${ext}`);
175
- if (existsSync(fp))
176
- unlinkSync(fp);
177
- }
178
- break;
179
- }
180
- }
181
- renderJobs.delete(jobId);
182
- return c.json({ deleted: true });
183
- });
184
- // Serve render file directly from disk (no in-memory map dependency)
185
- api.get("/projects/:id/renders/file/*", async (c) => {
186
- const project = await adapter.resolveProject(c.req.param("id"));
187
- if (!project)
188
- return c.json({ error: "not found" }, 404);
189
- const filename = c.req.path.split("/renders/file/")[1];
190
- if (!filename)
191
- return c.json({ error: "missing filename" }, 400);
192
- const rendersDir = adapter.rendersDir(project);
193
- // Containment guard: the filename is attacker-controlled wildcard input, so
194
- // route it through the same chokepoint every other project-scoped path uses.
195
- // Literal `..` is collapsed upstream by the URL parser, but a bare join() +
196
- // readFileSync still followed an in-rendersDir symlink pointing outside the
197
- // dir; resolveWithinProject canonicalizes with realpath before serving.
198
- const fp = resolveWithinProject(rendersDir, filename);
199
- if (!fp)
200
- return c.json({ error: "forbidden" }, 403);
201
- if (!existsSync(fp))
202
- return c.json({ error: "not found" }, 404);
203
- const contentType = renderContentType(fp);
204
- const content = readFileSync(fp);
205
- return new Response(content, {
206
- headers: {
207
- "Content-Type": contentType,
208
- "Content-Disposition": `inline; filename="${filename}"`,
209
- "Accept-Ranges": "bytes",
210
- "Content-Length": String(content.length),
211
- },
212
- });
213
- });
214
- // List renders
215
- api.get("/projects/:id/renders", async (c) => {
216
- const project = await adapter.resolveProject(c.req.param("id"));
217
- if (!project)
218
- return c.json({ error: "not found" }, 404);
219
- const rendersDir = adapter.rendersDir(project);
220
- if (!existsSync(rendersDir))
221
- return c.json({ renders: [] });
222
- const files = readdirSync(rendersDir)
223
- .filter((f) => f.endsWith(".mp4") || f.endsWith(".webm") || f.endsWith(".mov"))
224
- .map((f) => {
225
- const fp = join(rendersDir, f);
226
- const stat = statSync(fp);
227
- const rid = f.replace(/\.(mp4|webm|mov)$/, "");
228
- const metaPath = join(rendersDir, `${rid}.meta.json`);
229
- let status = "complete";
230
- let durationMs;
231
- if (existsSync(metaPath)) {
232
- try {
233
- const meta = JSON.parse(readFileSync(metaPath, "utf-8"));
234
- if (meta.status === "failed")
235
- status = "failed";
236
- if (meta.durationMs)
237
- durationMs = meta.durationMs;
238
- }
239
- catch {
240
- /* ignore */
241
- }
242
- }
243
- return {
244
- id: rid,
245
- filename: f,
246
- size: stat.size,
247
- createdAt: stat.mtimeMs,
248
- status,
249
- durationMs,
250
- };
251
- })
252
- .sort((a, b) => b.createdAt - a.createdAt);
253
- // Register on-disk renders that aren't in the current session's job map
254
- // so they remain downloadable after a server restart.
255
- for (const file of files) {
256
- if (!renderJobs.has(file.id)) {
257
- renderJobs.set(file.id, {
258
- id: file.id,
259
- status: file.status,
260
- progress: 100,
261
- outputPath: join(rendersDir, file.filename),
262
- createdAt: file.createdAt,
263
- });
264
- }
265
- }
266
- return c.json({ renders: files });
267
- });
268
- }
269
- //# sourceMappingURL=render.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/studio-api/routes/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAAyB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS,wBAAwB,CAAC,CAAC;AAEpE,MAAM,UAAU,oBAAoB,CAAC,GAAS,EAAE,OAAyB;IACvE,+DAA+D;IAC/D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkD,CAAC;IAE7E,6CAA6C;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,mBAAmB,GAAG,MAAM,CAAC;IACnC,IAAI,YAAY,GAA0C,IAAI,CAAC;IAE/D,MAAM,cAAc,GAAG,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I,IAAI,CAAC,MAAM,KAAK,QAAQ;wBAAE,MAAM,GAAG,QAAQ,CAAC;oBAChD,IAAI,IAAI,CAAC,UAAU;wBAAE,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;gBACpD,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC;YACD,OAAO;gBACL,EAAE,EAAE,GAAG;gBACP,QAAQ,EAAE,CAAC;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,SAAS,EAAE,IAAI,CAAC,OAAO;gBACvB,MAAM;gBACN,UAAU;aACX,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;QAC7C,wEAAwE;QACxE,sDAAsD;QACtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC7B,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE;oBACtB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,QAAQ,EAAE,GAAG;oBACb,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC;oBAC3C,SAAS,EAAE,IAAI,CAAC,SAAS;iBACgB,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Hono } from "hono";
2
- import type { StudioApiAdapter } from "../types.js";
3
- export declare function registerStoryboardRoutes(api: Hono, adapter: StudioApiAdapter): void;
4
- //# sourceMappingURL=storyboard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storyboard.d.ts","sourceRoot":"","sources":["../../../src/studio-api/routes/storyboard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAuCpD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAsCnF"}
@@ -1,65 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { resolveWithinProject } from "../helpers/safePath.js";
3
- import { parseStoryboard, SCRIPT_FILENAME, STORYBOARD_FILENAME, } from "../../storyboard/index.js";
4
- function resolveFrames(projectDir, frames) {
5
- return frames.map((frame) => {
6
- let srcExists = false;
7
- if (frame.src) {
8
- const abs = resolveWithinProject(projectDir, frame.src);
9
- srcExists = abs ? existsSync(abs) : false;
10
- }
11
- return { ...frame, srcExists };
12
- });
13
- }
14
- /** Read the companion SCRIPT.md narration doc if it exists alongside the storyboard. */
15
- function readScript(projectDir) {
16
- const abs = resolveWithinProject(projectDir, SCRIPT_FILENAME);
17
- if (abs && existsSync(abs)) {
18
- try {
19
- return { exists: true, path: SCRIPT_FILENAME, content: readFileSync(abs, "utf-8") };
20
- }
21
- catch {
22
- /* fall through to absent */
23
- }
24
- }
25
- return { exists: false, path: SCRIPT_FILENAME, content: "" };
26
- }
27
- export function registerStoryboardRoutes(api, adapter) {
28
- // Parsed storyboard manifest for a project. Markdown (STORYBOARD.md) stays
29
- // canonical on disk; this returns the derived, normalized structure. When the
30
- // file is absent we return `exists: false` with empty frames rather than 404,
31
- // so the Studio can render an opt-in empty state.
32
- api.get("/projects/:id/storyboard", async (c) => {
33
- const project = await adapter.resolveProject(c.req.param("id"));
34
- if (!project)
35
- return c.json({ error: "not found" }, 404);
36
- const abs = resolveWithinProject(project.dir, STORYBOARD_FILENAME);
37
- if (!abs || !existsSync(abs)) {
38
- return c.json({
39
- exists: false,
40
- path: STORYBOARD_FILENAME,
41
- globals: { extra: {} },
42
- frames: [],
43
- warnings: [],
44
- script: readScript(project.dir),
45
- });
46
- }
47
- let source;
48
- try {
49
- source = readFileSync(abs, "utf-8");
50
- }
51
- catch {
52
- return c.json({ error: "failed to read storyboard" }, 500);
53
- }
54
- const manifest = parseStoryboard(source);
55
- return c.json({
56
- exists: true,
57
- path: STORYBOARD_FILENAME,
58
- globals: manifest.globals,
59
- frames: resolveFrames(project.dir, manifest.frames),
60
- warnings: manifest.warnings,
61
- script: readScript(project.dir),
62
- });
63
- });
64
- }
65
- //# sourceMappingURL=storyboard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storyboard.js","sourceRoot":"","sources":["../../../src/studio-api/routes/storyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AAQnC,SAAS,aAAa,CAAC,UAAkB,EAAE,MAAyB;IAClE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,GAAG,GAAG,oBAAoB,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACxD,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5C,CAAC;QACD,OAAO,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,wFAAwF;AACxF,SAAS,UAAU,CAAC,UAAkB;IACpC,MAAM,GAAG,GAAG,oB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AG,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,MAAc,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,2BAA2B,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,CAAC;YACZ,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC;YACnD,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Hono } from "hono";
2
- import type { StudioApiAdapter } from "../types.js";
3
- export declare function registerThumbnailRoutes(api: Hono, adapter: StudioApiAdapter): void;
4
- //# sourceMappingURL=thumbnail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thumbnail.d.ts","sourceRoot":"","sources":["../../../src/studio-api/routes/thumbnail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAIjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CA0GlF"}
@@ -1,107 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync, mkdirSync, statSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { createHash } from "node:crypto";
4
- import { STUDIO_MANUAL_EDITS_PATH } from "../helpers/manualEditsRenderScript.js";
5
- import { STUDIO_MOTION_PATH } from "../helpers/studioMotionRenderScript.js";
6
- const THUMBNAIL_CACHE_VERSION = "v4";
7
- export function registerThumbnailRoutes(api, adapter) {
8
- api.get("/projects/:id/thumbnail/*", async (c) => {
9
- if (!adapter.generateThumbnail) {
10
- return c.json({ error: "Thumbnails not available" }, 501);
11
- }
12
- const project = await adapter.resolveProject(c.req.param("id"));
13
- if (!project)
14
- return c.json({ error: "not found" }, 404);
15
- let compPath = decodeURIComponent(c.req.path.replace(`/projects/${project.id}/thumbnail/`, "").split("?")[0] ?? "");
16
- if (compPath && !compPath.includes("."))
17
- compPath += ".html";
18
- const url = new URL(c.req.url, `http://${c.req.header("host") || "localhost"}`);
19
- const rawSeekTime = url.searchParams.get("t");
20
- const parsedSeekTime = rawSeekTime == null ? Number.NaN : parseFloat(rawSeekTime);
21
- const seekTime = Number.isFinite(parsedSeekTime) ? parsedSeekTime : 0.5;
22
- const vpWidth = parseInt(url.searchParams.get("w") || "0") || 0;
23
- const vpHeight = parseInt(url.searchParams.get("h") || "0") || 0;
24
- const selector = url.searchParams.get("selector") || undefined;
25
- const format = url.searchParams.get("format") === "png" ? "png" : "jpeg";
26
- const contentType = format === "png" ? "image/png" : "image/jpeg";
27
- const rawSelectorIndex = Number.parseInt(url.searchParams.get("selectorIndex") || "0", 10);
28
- const selectorIndex = Number.isFinite(rawSelectorIndex) && rawSelectorIndex > 0 ? rawSelectorIndex : undefined;
29
- const urlVersion = url.searchParams.get("v") || "";
30
- // Determine composition dimensions from HTML
31
- let compW = vpWidth || 1920;
32
- let compH = vpHeight || 1080;
33
- let sourceMtime = 0;
34
- if (!vpWidth) {
35
- const htmlFile = join(project.dir, compPath);
36
- if (existsSync(htmlFile)) {
37
- sourceMtime = Math.round(statSync(htmlFile).mtimeMs);
38
- const html = readFileSync(htmlFile, "utf-8");
39
- const wMatch = html.match(/data-width=["'](\d+)["']/);
40
- const hMatch = html.match(/data-height=["'](\d+)["']/);
41
- if (wMatch?.[1])
42
- compW = parseInt(wMatch[1]);
43
- if (hMatch?.[1])
44
- compH = parseInt(hMatch[1]);
45
- }
46
- }
47
- const manualEditsFile = join(project.dir, STUDIO_MANUAL_EDITS_PATH);
48
- let manualEditsKey = "";
49
- if (existsSync(manualEditsFile)) {
50
- const manualEditsContent = readFileSync(manualEditsFile, "utf-8");
51
- manualEditsKey = `_${createHash("sha1").update(manualEditsContent).digest("hex").slice(0, 16)}`;
52
- sourceMtime = Math.max(sourceMtime, Math.round(statSync(manualEditsFile).mtimeMs));
53
- }
54
- const motionFile = join(project.dir, STUDIO_MOTION_PATH);
55
- let motionKey = "";
56
- if (existsSync(motionFile)) {
57
- const motionContent = readFileSync(motionFile, "utf-8");
58
- motionKey = `_${createHash("sha1").update(motionContent).digest("hex").slice(0, 16)}`;
59
- sourceMtime = Math.max(sourceMtime, Math.round(statSync(motionFile).mtimeMs));
60
- }
61
- const previewUrl = compPath === "index.html"
62
- ? `http://${c.req.header("host")}/api/projects/${project.id}/preview`
63
- : `http://${c.req.header("host")}/api/projects/${project.id}/preview/comp/${compPath}`;
64
- // Cache
65
- const cacheDir = join(project.dir, ".thumbnails");
66
- const selectorKey = selector
67
- ? `_${selector.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 80)}_${selectorIndex ?? 0}`
68
- : "";
69
- const urlVersionKey = urlVersion
70
- ? `_${urlVersion.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 32)}`
71
- : "";
72
- const cacheKey = `${THUMBNAIL_CACHE_VERSION}${urlVersionKey}${manualEditsKey}${motionKey}_${format}_${compPath.replace(/\//g, "_")}_${compW}x${compH}_${sourceMtime}_${seekTime.toFixed(2)}${selectorKey}.${format === "png" ? "png" : "jpg"}`;
73
- const cachePath = join(cacheDir, cacheKey);
74
- if (existsSync(cachePath)) {
75
- return new Response(new Uint8Array(readFileSync(cachePath)), {
76
- headers: { "Content-Type": contentType, "Cache-Control": "public, max-age=60" },
77
- });
78
- }
79
- try {
80
- const buffer = await adapter.generateThumbnail({
81
- project,
82
- compPath,
83
- seekTime,
84
- width: compW,
85
- height: compH,
86
- previewUrl,
87
- selector,
88
- format,
89
- selectorIndex,
90
- });
91
- if (!buffer) {
92
- return c.json({ error: "Thumbnail generation failed — Chrome browser may not be available" }, 500);
93
- }
94
- if (!existsSync(cacheDir))
95
- mkdirSync(cacheDir, { recursive: true });
96
- writeFileSync(cachePath, buffer);
97
- return new Response(new Uint8Array(buffer), {
98
- headers: { "Content-Type": contentType, "Cache-Control": "public, max-age=60" },
99
- });
100
- }
101
- catch (err) {
102
- const msg = err instanceof Error ? err.message : String(err);
103
- return c.json({ error: `Thumbnail generation failed: ${msg}` }, 500);
104
- }
105
- });
106
- }
107
- //# sourceMappingURL=thumbnail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thumbnail.js","sourceRoot":"","sources":["../../../src/studio-api/routes/thumbnail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,MAAM,UAAU,uBAAuB,CAAC,GAAS,EAAE,OAAyB;IAC1E,GAAG,CAAC,GAAG,CAAC,2BAA2B,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/C,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC/B,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,EAAE,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AC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,gCAAgC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QACvE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Hono } from "hono";
2
- import type { StudioApiAdapter } from "../types.js";
3
- export declare function registerWaveformRoutes(api: Hono, adapter: StudioApiAdapter): void;
4
- //# sourceMappingURL=waveform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"waveform.d.ts","sourceRoot":"","sources":["../../../src/studio-api/routes/waveform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAuCjF"}
@@ -1,41 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { decodeAudioPeaks, buildWaveformCacheKey } from "../helpers/waveform.js";
4
- export function registerWaveformRoutes(api, adapter) {
5
- api.get("/projects/:id/waveform/*", async (c) => {
6
- const project = await adapter.resolveProject(c.req.param("id"));
7
- if (!project)
8
- return c.json({ error: "not found" }, 404);
9
- const assetPath = decodeURIComponent(c.req.path.replace(`/projects/${project.id}/waveform/`, "").split("?")[0] ?? "");
10
- const audioPath = join(project.dir, assetPath);
11
- if (!existsSync(audioPath))
12
- return c.json({ error: "file not found" }, 404);
13
- const cacheDir = join(project.dir, ".waveform-cache");
14
- const cachePath = join(cacheDir, buildWaveformCacheKey(assetPath));
15
- if (existsSync(cachePath)) {
16
- try {
17
- const peaks = JSON.parse(readFileSync(cachePath, "utf-8"));
18
- return c.json({ peaks });
19
- }
20
- catch {
21
- // corrupt cache — regenerate
22
- }
23
- }
24
- let peaks;
25
- try {
26
- peaks = await decodeAudioPeaks(audioPath);
27
- }
28
- catch {
29
- return c.json({ error: "failed to decode audio" }, 500);
30
- }
31
- try {
32
- mkdirSync(cacheDir, { recursive: true });
33
- writeFileSync(cachePath, JSON.stringify(peaks));
34
- }
35
- catch {
36
- // cache write failure is non-fatal
37
- }
38
- return c.json({ peaks });
39
- });
40
- }
41
- //# sourceMappingURL=waveform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"waveform.js","sourceRoot":"","sources":["../../../src/studio-api/routes/waveform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,MAAM,UAAU,sBAAsB,CAAC,GAAS,EAAE,OAAyB;IACzE,GAAG,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAAC;QAEzD,MAAM,SAAS,GAAG,kBAAkB,CAClC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,OAAO,CAAC,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAChF,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,C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