@hyperframes/studio-server 0.7.60 → 0.7.61

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 (40) hide show
  1. package/dist/chunk-4ETS2LXI.js +192 -0
  2. package/dist/chunk-4ETS2LXI.js.map +1 -0
  3. package/dist/chunk-6XMC64FJ.js +584 -0
  4. package/dist/chunk-6XMC64FJ.js.map +1 -0
  5. package/dist/chunk-LVXVG4V6.js +282 -0
  6. package/dist/chunk-LVXVG4V6.js.map +1 -0
  7. package/dist/chunk-W2SBTCO2.js +32 -0
  8. package/dist/chunk-W2SBTCO2.js.map +1 -0
  9. package/dist/chunk-X62ASOGO.js +30 -0
  10. package/dist/chunk-X62ASOGO.js.map +1 -0
  11. package/dist/chunk-XVQX2JHE.js +422 -0
  12. package/dist/chunk-XVQX2JHE.js.map +1 -0
  13. package/dist/chunk-YBR7MXIO.js +459 -0
  14. package/dist/chunk-YBR7MXIO.js.map +1 -0
  15. package/dist/chunk-ZUW4PULZ.js +66 -0
  16. package/dist/chunk-ZUW4PULZ.js.map +1 -0
  17. package/dist/helpers/finiteMutation.js +4 -24
  18. package/dist/helpers/finiteMutation.js.map +1 -1
  19. package/dist/helpers/manualEditsRenderScript.js +5 -577
  20. package/dist/helpers/manualEditsRenderScript.js.map +1 -1
  21. package/dist/helpers/mediaCodecMap.d.ts +100 -0
  22. package/dist/helpers/mediaCodecMap.js +25 -0
  23. package/dist/helpers/mediaCodecMap.js.map +1 -0
  24. package/dist/helpers/mediaProxyPreview.d.ts +4 -0
  25. package/dist/helpers/mediaProxyPreview.js +17 -0
  26. package/dist/helpers/mediaProxyPreview.js.map +1 -0
  27. package/dist/helpers/proxyTranscoder.d.ts +61 -0
  28. package/dist/helpers/proxyTranscoder.js +30 -0
  29. package/dist/helpers/proxyTranscoder.js.map +1 -0
  30. package/dist/helpers/screenshotClip.js +3 -22
  31. package/dist/helpers/screenshotClip.js.map +1 -1
  32. package/dist/helpers/sourceMutation.js +9 -419
  33. package/dist/helpers/sourceMutation.js.map +1 -1
  34. package/dist/helpers/studioMotionRenderScript.js +4 -186
  35. package/dist/helpers/studioMotionRenderScript.js.map +1 -1
  36. package/dist/index.d.ts +6 -202
  37. package/dist/index.js +172 -1373
  38. package/dist/index.js.map +1 -1
  39. package/dist/mediaProxyPreview-CeshDUjE.d.ts +259 -0
  40. package/package.json +15 -3
@@ -1,189 +1,7 @@
1
- // src/helpers/studioMotionRenderScript.ts
2
- var STUDIO_MOTION_PATH = ".hyperframes/studio-motion.json";
3
- function hasStudioMotionEntries(manifestContent) {
4
- try {
5
- const parsed = JSON.parse(manifestContent);
6
- return Array.isArray(parsed.motions) && parsed.motions.length > 0;
7
- } catch {
8
- return false;
9
- }
10
- }
11
- function createStudioMotionRenderBodyScript(manifestContent, options = {}) {
12
- if (!manifestContent.trim() || !hasStudioMotionEntries(manifestContent)) return null;
13
- return `(${studioMotionRenderRuntime.toString()})(${JSON.stringify(manifestContent)}, ${JSON.stringify(options.activeCompositionPath ?? null)});`;
14
- }
15
- function studioMotionRenderRuntime(manifestContent, activeCompositionPath) {
16
- const STUDIO_MOTION_TIMELINE_ID = "studio-motion";
17
- const STUDIO_MOTION_ATTR = "data-hf-studio-motion";
18
- const ORIGINAL_TRANSFORM_ATTR = "data-hf-studio-motion-original-transform";
19
- const ORIGINAL_OPACITY_ATTR = "data-hf-studio-motion-original-opacity";
20
- const ORIGINAL_VISIBILITY_ATTR = "data-hf-studio-motion-original-visibility";
21
- const objectRecord = (value) => value && typeof value === "object" ? value : null;
22
- const finiteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
23
- const runtimeWindow = window;
24
- const parseMotionValues = (value) => {
25
- const record = objectRecord(value);
26
- if (!record) return null;
27
- const parsed = {};
28
- for (const key of ["x", "y", "scale", "rotation", "opacity", "autoAlpha"]) {
29
- const next = finiteNumber(record[key]);
30
- if (next != null) parsed[key] = next;
31
- }
32
- return Object.keys(parsed).length > 0 ? parsed : null;
33
- };
34
- const parseCustomEase = (value) => {
35
- const record = objectRecord(value);
36
- if (!record) return null;
37
- const id = typeof record.id === "string" ? record.id.trim() : "";
38
- const data = typeof record.data === "string" ? record.data.trim() : "";
39
- if (!id || !data) return null;
40
- return { id, data };
41
- };
42
- const parsedManifest = (() => {
43
- try {
44
- return objectRecord(JSON.parse(manifestContent));
45
- } catch {
46
- return null;
47
- }
48
- })();
49
- const manifestMotions = Array.isArray(parsedManifest?.motions) ? parsedManifest.motions : [];
50
- const sourceFileForElement = (element) => {
51
- let current = element;
52
- while (current) {
53
- const sourceFile = current.getAttribute("data-composition-file") ?? current.getAttribute("data-composition-src");
54
- if (sourceFile) return sourceFile;
55
- current = current.parentElement;
56
- }
57
- return activeCompositionPath ?? "index.html";
58
- };
59
- const elementMatchesSourceFile = (element, sourceFile) => sourceFileForElement(element) === sourceFile;
60
- const isHTMLElement = (element) => element instanceof HTMLElement;
61
- const querySelectorCandidates = (selector) => {
62
- const className = selector.match(/^\.([A-Za-z0-9_-]+)$/)?.[1];
63
- if (className) {
64
- return Array.from(document.getElementsByTagName("*")).filter(
65
- (element) => isHTMLElement(element) && element.classList.contains(className)
66
- );
67
- }
68
- if (/^[A-Za-z][A-Za-z0-9-]*$/.test(selector)) {
69
- return Array.from(document.getElementsByTagName(selector)).filter(isHTMLElement);
70
- }
71
- return Array.from(document.querySelectorAll(selector)).filter(isHTMLElement);
72
- };
73
- const resolveTarget = (targetRecord) => {
74
- const sourceFile = typeof targetRecord.sourceFile === "string" ? targetRecord.sourceFile : "";
75
- if (!sourceFile) return null;
76
- const id = typeof targetRecord.id === "string" ? targetRecord.id : "";
77
- if (id) {
78
- const byId = document.getElementById(id);
79
- if (isHTMLElement(byId) && elementMatchesSourceFile(byId, sourceFile)) return byId;
80
- }
81
- const selector = typeof targetRecord.selector === "string" ? targetRecord.selector : "";
82
- if (!selector) return null;
83
- try {
84
- const selectorIndex = Math.max(0, Math.floor(finiteNumber(targetRecord.selectorIndex) ?? 0));
85
- return querySelectorCandidates(selector).filter(
86
- (element) => elementMatchesSourceFile(element, sourceFile)
87
- )[selectorIndex] ?? null;
88
- } catch {
89
- return null;
90
- }
91
- };
92
- const restoreElement = (element) => {
93
- runtimeWindow.gsap?.set?.(element, { clearProps: "transform,opacity,visibility" });
94
- element.style.transform = element.getAttribute(ORIGINAL_TRANSFORM_ATTR) ?? "";
95
- element.style.opacity = element.getAttribute(ORIGINAL_OPACITY_ATTR) ?? "";
96
- element.style.visibility = element.getAttribute(ORIGINAL_VISIBILITY_ATTR) ?? "";
97
- element.removeAttribute(STUDIO_MOTION_ATTR);
98
- element.removeAttribute(ORIGINAL_TRANSFORM_ATTR);
99
- element.removeAttribute(ORIGINAL_OPACITY_ATTR);
100
- element.removeAttribute(ORIGINAL_VISIBILITY_ATTR);
101
- };
102
- const restoreStudioMotionElements = () => {
103
- for (const element of Array.from(document.querySelectorAll(`[${STUDIO_MOTION_ATTR}]`))) {
104
- if (isHTMLElement(element)) restoreElement(element);
105
- }
106
- };
107
- const readCurrentTime = () => {
108
- try {
109
- const playerTime = runtimeWindow.__player?.getTime?.();
110
- if (typeof playerTime === "number" && Number.isFinite(playerTime)) {
111
- return Math.max(0, playerTime);
112
- }
113
- } catch {
114
- }
115
- try {
116
- const timelineTime = runtimeWindow.__timeline?.time?.();
117
- if (typeof timelineTime === "number" && Number.isFinite(timelineTime)) {
118
- return Math.max(0, timelineTime);
119
- }
120
- } catch {
121
- }
122
- return 0;
123
- };
124
- const resolveEase = (motion) => {
125
- const fallback = typeof motion.ease === "string" && motion.ease.trim() ? motion.ease.trim() : "none";
126
- const customEase = parseCustomEase(motion.customEase);
127
- const customEasePlugin = runtimeWindow.CustomEase;
128
- if (!customEase || typeof customEasePlugin?.create !== "function") return fallback;
129
- try {
130
- runtimeWindow.gsap?.registerPlugin?.(customEasePlugin);
131
- customEasePlugin.create(customEase.id, customEase.data);
132
- return customEase.id;
133
- } catch {
134
- return fallback;
135
- }
136
- };
137
- const applyManifest = () => {
138
- runtimeWindow.__timelines = runtimeWindow.__timelines ?? {};
139
- runtimeWindow.__timelines[STUDIO_MOTION_TIMELINE_ID]?.kill?.();
140
- delete runtimeWindow.__timelines[STUDIO_MOTION_TIMELINE_ID];
141
- restoreStudioMotionElements();
142
- const gsap = runtimeWindow.gsap;
143
- if (!gsap?.timeline || manifestMotions.length === 0) return 0;
144
- const timeline = gsap.timeline({ paused: true, defaults: { overwrite: "auto" } });
145
- let applied = 0;
146
- for (const motionValue of manifestMotions) {
147
- const motion = objectRecord(motionValue);
148
- if (!motion || motion.kind !== "gsap-motion") continue;
149
- const targetRecord = objectRecord(motion.target);
150
- if (!targetRecord) continue;
151
- const target = resolveTarget(targetRecord);
152
- if (!target || typeof timeline.fromTo !== "function") continue;
153
- const start = finiteNumber(motion.start);
154
- const duration = finiteNumber(motion.duration);
155
- if (start == null || duration == null || start < 0 || duration <= 0) continue;
156
- const from = parseMotionValues(motion.from);
157
- const to = parseMotionValues(motion.to);
158
- if (!from || !to) continue;
159
- if (!target.hasAttribute(STUDIO_MOTION_ATTR)) {
160
- target.setAttribute(ORIGINAL_TRANSFORM_ATTR, target.style.transform);
161
- target.setAttribute(ORIGINAL_OPACITY_ATTR, target.style.opacity);
162
- target.setAttribute(ORIGINAL_VISIBILITY_ATTR, target.style.visibility);
163
- }
164
- target.setAttribute(STUDIO_MOTION_ATTR, "true");
165
- timeline.fromTo(
166
- target,
167
- from,
168
- { ...to, duration, ease: resolveEase(motion), overwrite: "auto", immediateRender: false },
169
- start
170
- );
171
- applied += 1;
172
- }
173
- if (applied === 0) {
174
- timeline.kill?.();
175
- return 0;
176
- }
177
- runtimeWindow.__timelines[STUDIO_MOTION_TIMELINE_ID] = timeline;
178
- timeline.pause?.();
179
- const currentTime = readCurrentTime();
180
- if (typeof timeline.totalTime === "function") timeline.totalTime(currentTime, false);
181
- else timeline.time?.(currentTime);
182
- return applied;
183
- };
184
- runtimeWindow.__hfStudioMotionApply = applyManifest;
185
- applyManifest();
186
- }
1
+ import {
2
+ STUDIO_MOTION_PATH,
3
+ createStudioMotionRenderBodyScript
4
+ } from "../chunk-4ETS2LXI.js";
187
5
  export {
188
6
  STUDIO_MOTION_PATH,
189
7
  createStudioMotionRenderBodyScript
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/helpers/studioMotionRenderScript.ts"],"sourcesContent":["export interface StudioMotionRenderScriptOptions {\n activeCompositionPath?: string | null;\n}\n\nexport const STUDIO_MOTION_PATH = \".hyperframes/studio-motion.json\";\n\nfunction hasStudioMotionEntries(manifestContent: string): boolean {\n try {\n const parsed = JSON.parse(manifestContent) as { motions?: unknown };\n return Array.isArray(parsed.motions) && parsed.motions.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds the render-time Studio motion runtime script, or null when no owned motion exists.\n */\nexport function createStudioMotionRenderBodyScript(\n manifestContent: string,\n options: StudioMotionRenderScriptOptions = {},\n): string | null {\n if (!manifestContent.trim() || !hasStudioMotionEntries(manifestContent)) return null;\n return `(${studioMotionRenderRuntime.toString()})(${JSON.stringify(manifestContent)}, ${JSON.stringify(options.activeCompositionPath ?? null)});`;\n}\n\nfunction studioMotionRenderRuntime(\n manifestContent: string,\n activeCompositionPath: string | null,\n): void {\n const STUDIO_MOTION_TIMELINE_ID = \"studio-motion\";\n const STUDIO_MOTION_ATTR = \"data-hf-studio-motion\";\n const ORIGINAL_TRANSFORM_ATTR = \"data-hf-studio-motion-original-transform\";\n const ORIGINAL_OPACITY_ATTR = \"data-hf-studio-motion-original-opacity\";\n const ORIGINAL_VISIBILITY_ATTR = \"data-hf-studio-motion-original-visibility\";\n\n const objectRecord = (value: unknown): Record<string, unknown> | null =>\n value && typeof value === \"object\" ? (value as Record<string, unknown>) : null;\n\n const finiteNumber = (value: unknown): number | null =>\n typeof value === \"number\" && Number.isFinite(value) ? value : null;\n\n const runtimeWindow = window as Window & {\n gsap?: {\n timeline?: (vars?: Record<string, unknown>) => {\n fromTo?: (\n target: HTMLElement,\n from: Record<string, unknown>,\n to: Record<string, unknown>,\n at: number,\n ) => unknown;\n totalTime?: (time: number, suppressEvents?: boolean) => unknown;\n time?: (time: number) => unknown;\n pause?: () => unknown;\n kill?: () => unknown;\n };\n set?: (target: HTMLElement, vars: Record<string, unknown>) => unknown;\n registerPlugin?: (...plugins: unknown[]) => unknown;\n };\n CustomEase?: { create?: (id: string, data: string) => unknown };\n __player?: { getTime?: () => number };\n __timeline?: { time?: () => number };\n __timelines?: Record<\n string,\n | {\n kill?: () => unknown;\n }\n | undefined\n >;\n __hfStudioMotionApply?: () => number;\n };\n\n const parseMotionValues = (value: unknown): Record<string, number> | null => {\n const record = objectRecord(value);\n if (!record) return null;\n const parsed: Record<string, number> = {};\n for (const key of [\"x\", \"y\", \"scale\", \"rotation\", \"opacity\", \"autoAlpha\"]) {\n const next = finiteNumber(record[key]);\n if (next != null) parsed[key] = next;\n }\n return Object.keys(parsed).length > 0 ? parsed : null;\n };\n\n const parseCustomEase = (value: unknown): { id: string; data: string } | null => {\n const record = objectRecord(value);\n if (!record) return null;\n const id = typeof record.id === \"string\" ? record.id.trim() : \"\";\n const data = typeof record.data === \"string\" ? record.data.trim() : \"\";\n if (!id || !data) return null;\n return { id, data };\n };\n\n const parsedManifest = (() => {\n try {\n return objectRecord(JSON.parse(manifestContent));\n } catch {\n return null;\n }\n })();\n const manifestMotions = Array.isArray(parsedManifest?.motions) ? parsedManifest.motions : [];\n\n const sourceFileForElement = (element: HTMLElement): string => {\n let current: HTMLElement | null = element;\n while (current) {\n const sourceFile =\n current.getAttribute(\"data-composition-file\") ??\n current.getAttribute(\"data-composition-src\");\n if (sourceFile) return sourceFile;\n current = current.parentElement;\n }\n return activeCompositionPath ?? \"index.html\";\n };\n\n const elementMatchesSourceFile = (element: HTMLElement, sourceFile: string): boolean =>\n sourceFileForElement(element) === sourceFile;\n\n const isHTMLElement = (element: Element | null): element is HTMLElement =>\n element instanceof HTMLElement;\n\n const querySelectorCandidates = (selector: string): HTMLElement[] => {\n const className = selector.match(/^\\.([A-Za-z0-9_-]+)$/)?.[1];\n if (className) {\n return Array.from(document.getElementsByTagName(\"*\")).filter(\n (element): element is HTMLElement =>\n isHTMLElement(element) && element.classList.contains(className),\n );\n }\n if (/^[A-Za-z][A-Za-z0-9-]*$/.test(selector)) {\n return Array.from(document.getElementsByTagName(selector)).filter(isHTMLElement);\n }\n return Array.from(document.querySelectorAll(selector)).filter(isHTMLElement);\n };\n\n const resolveTarget = (targetRecord: Record<string, unknown>): HTMLElement | null => {\n const sourceFile = typeof targetRecord.sourceFile === \"string\" ? targetRecord.sourceFile : \"\";\n if (!sourceFile) return null;\n const id = typeof targetRecord.id === \"string\" ? targetRecord.id : \"\";\n if (id) {\n const byId = document.getElementById(id);\n if (isHTMLElement(byId) && elementMatchesSourceFile(byId, sourceFile)) return byId;\n }\n const selector = typeof targetRecord.selector === \"string\" ? targetRecord.selector : \"\";\n if (!selector) return null;\n try {\n const selectorIndex = Math.max(0, Math.floor(finiteNumber(targetRecord.selectorIndex) ?? 0));\n return (\n querySelectorCandidates(selector).filter((element) =>\n elementMatchesSourceFile(element, sourceFile),\n )[selectorIndex] ?? null\n );\n } catch {\n return null;\n }\n };\n\n const restoreElement = (element: HTMLElement): void => {\n runtimeWindow.gsap?.set?.(element, { clearProps: \"transform,opacity,visibility\" });\n element.style.transform = element.getAttribute(ORIGINAL_TRANSFORM_ATTR) ?? \"\";\n element.style.opacity = element.getAttribute(ORIGINAL_OPACITY_ATTR) ?? \"\";\n element.style.visibility = element.getAttribute(ORIGINAL_VISIBILITY_ATTR) ?? \"\";\n element.removeAttribute(STUDIO_MOTION_ATTR);\n element.removeAttribute(ORIGINAL_TRANSFORM_ATTR);\n element.removeAttribute(ORIGINAL_OPACITY_ATTR);\n element.removeAttribute(ORIGINAL_VISIBILITY_ATTR);\n };\n\n const restoreStudioMotionElements = (): void => {\n for (const element of Array.from(document.querySelectorAll(`[${STUDIO_MOTION_ATTR}]`))) {\n if (isHTMLElement(element)) restoreElement(element);\n }\n };\n\n const readCurrentTime = (): number => {\n try {\n const playerTime = runtimeWindow.__player?.getTime?.();\n if (typeof playerTime === \"number\" && Number.isFinite(playerTime)) {\n return Math.max(0, playerTime);\n }\n } catch {\n // fall through\n }\n try {\n const timelineTime = runtimeWindow.__timeline?.time?.();\n if (typeof timelineTime === \"number\" && Number.isFinite(timelineTime)) {\n return Math.max(0, timelineTime);\n }\n } catch {\n // fall through\n }\n return 0;\n };\n\n const resolveEase = (motion: Record<string, unknown>): string => {\n const fallback =\n typeof motion.ease === \"string\" && motion.ease.trim() ? motion.ease.trim() : \"none\";\n const customEase = parseCustomEase(motion.customEase);\n const customEasePlugin = runtimeWindow.CustomEase;\n if (!customEase || typeof customEasePlugin?.create !== \"function\") return fallback;\n try {\n runtimeWindow.gsap?.registerPlugin?.(customEasePlugin);\n customEasePlugin.create(customEase.id, customEase.data);\n return customEase.id;\n } catch {\n return fallback;\n }\n };\n\n const applyManifest = (): number => {\n runtimeWindow.__timelines = runtimeWindow.__timelines ?? {};\n runtimeWindow.__timelines[STUDIO_MOTION_TIMELINE_ID]?.kill?.();\n delete runtimeWindow.__timelines[STUDIO_MOTION_TIMELINE_ID];\n restoreStudioMotionElements();\n const gsap = runtimeWindow.gsap;\n if (!gsap?.timeline || manifestMotions.length === 0) return 0;\n\n const timeline = gsap.timeline({ paused: true, defaults: { overwrite: \"auto\" } });\n let applied = 0;\n for (const motionValue of manifestMotions) {\n const motion = objectRecord(motionValue);\n if (!motion || motion.kind !== \"gsap-motion\") continue;\n const targetRecord = objectRecord(motion.target);\n if (!targetRecord) continue;\n const target = resolveTarget(targetRecord);\n if (!target || typeof timeline.fromTo !== \"function\") continue;\n const start = finiteNumber(motion.start);\n const duration = finiteNumber(motion.duration);\n if (start == null || duration == null || start < 0 || duration <= 0) continue;\n const from = parseMotionValues(motion.from);\n const to = parseMotionValues(motion.to);\n if (!from || !to) continue;\n if (!target.hasAttribute(STUDIO_MOTION_ATTR)) {\n target.setAttribute(ORIGINAL_TRANSFORM_ATTR, target.style.transform);\n target.setAttribute(ORIGINAL_OPACITY_ATTR, target.style.opacity);\n target.setAttribute(ORIGINAL_VISIBILITY_ATTR, target.style.visibility);\n }\n target.setAttribute(STUDIO_MOTION_ATTR, \"true\");\n timeline.fromTo(\n target,\n from,\n { ...to, duration, ease: resolveEase(motion), overwrite: \"auto\", immediateRender: false },\n start,\n );\n applied += 1;\n }\n\n if (applied === 0) {\n timeline.kill?.();\n return 0;\n }\n runtimeWindow.__timelines[STUDIO_MOTION_TIMELINE_ID] = timeline;\n timeline.pause?.();\n const currentTime = readCurrentTime();\n if (typeof timeline.totalTime === \"function\") timeline.totalTime(currentTime, false);\n else timeline.time?.(currentTime);\n return applied;\n };\n\n runtimeWindow.__hfStudioMotionApply = applyManifest;\n applyManifest();\n}\n"],"mappings":";AAIO,IAAM,qBAAqB;AAElC,SAAS,uBAAuB,iBAAkC;AAChE,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,eAAe;AACzC,WAAO,MAAM,QAAQ,OAAO,OAAO,KAAK,OAAO,QAAQ,SAAS;AAAA,EAClE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKO,SAAS,mCACd,iBACA,UAA2C,CAAC,GAC7B;AACf,MAAI,CAAC,gBAAgB,KAAK,KAAK,CAAC,uBAAuB,eAAe,EAAG,QAAO;AAChF,SAAO,IAAI,0BAA0B,SAAS,CAAC,KAAK,KAAK,UAAU,eAAe,CAAC,KAAK,KAAK,UAAU,QAAQ,yBAAyB,IAAI,CAAC;AAC/I;AAEA,SAAS,0BACP,iBACA,uBACM;AACN,QAAM,4BAA4B;AAClC,QAAM,qBAAqB;AAC3B,QAAM,0BAA0B;AAChC,QAAM,wBAAwB;AAC9B,QAAM,2BAA2B;AAEjC,QAAM,eAAe,CAAC,UACpB,SAAS,OAAO,UAAU,WAAY,QAAoC;AAE5E,QAAM,eAAe,CAAC,UACpB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AAEhE,QAA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AY,GAAG;AACjB,eAAS,OAAO;AAChB,aAAO;AAAA,IACT;AACA,kBAAc,YAAY,yBAAyB,IAAI;AACvD,aAAS,QAAQ;AACjB,UAAM,cAAc,gBAAgB;AACpC,QAAI,OAAO,SAAS,cAAc,WAAY,UAAS,UAAU,aAAa,KAAK;AAAA,QAC9E,UAAS,OAAO,WAAW;AAChC,WAAO;AAAA,EACT;AAEA,gBAAc,wBAAwB;AACtC,gBAAc;AAChB;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,208 +1,12 @@
1
1
  import { Hono } from 'hono';
2
- import * as _hyperframes_core from '@hyperframes/core';
3
- import { RegistryItem } from '@hyperframes/core';
4
- export { isSafePath } from '@hyperframes/core';
5
- import { CanvasResolution } from '@hyperframes/parsers';
2
+ import { S as StudioApiAdapter, M as MediaProcessingJobState } from './mediaProxyPreview-CeshDUjE.js';
3
+ export { L as LintResult, P as PreviewApiAdapter, R as RenderJobState, a as ResolvedProject, b as StudioSelectionResponse, c as StudioSelectionSnapshot, d as StudioSelectionTextField } from './mediaProxyPreview-CeshDUjE.js';
6
4
  export { ScreenshotClip, getElementScreenshotClip } from './helpers/screenshotClip.js';
7
5
  export { STUDIO_MANUAL_EDITS_PATH, StudioManualEditsRenderScriptOptions, createStudioManualEditsRenderBodyScript, createStudioPositionSeekReapplyScript } from './helpers/manualEditsRenderScript.js';
8
6
  export { STUDIO_MOTION_PATH, StudioMotionRenderScriptOptions, createStudioMotionRenderBodyScript } from './helpers/studioMotionRenderScript.js';
9
-
10
- /** Resolved info about a single project. */
11
- interface ResolvedProject {
12
- id: string;
13
- dir: string;
14
- title?: string;
15
- sessionId?: string;
16
- }
17
- /** Observable render job state, polled by the SSE progress handler. */
18
- interface RenderJobState {
19
- id: string;
20
- status: "rendering" | "complete" | "failed" | "cancelled";
21
- progress: number;
22
- stage?: string;
23
- outputPath: string;
24
- error?: string;
25
- /**
26
- * Optional abort hook set by the adapter. The cancel route calls this to
27
- * stop an in-flight render; adapters that can't abort may omit it (the
28
- * route still marks the job cancelled so the SSE stream terminates).
29
- */
30
- cancel?: () => void;
31
- }
32
- interface MediaProcessingJobState {
33
- id: string;
34
- status: "processing" | "complete" | "failed";
35
- progress: number;
36
- stage?: string;
37
- inputAssetPath: string;
38
- outputAssetPath: string;
39
- outputPath: string;
40
- backgroundOutputAssetPath?: string;
41
- backgroundOutputPath?: string;
42
- error?: string;
43
- provider?: string;
44
- framesProcessed?: number;
45
- durationSeconds?: number;
46
- avgMsPerFrame?: number;
47
- }
48
- /** Lint result from the core linter. */
49
- interface LintResult {
50
- findings: Array<{
51
- severity: string;
52
- message: string;
53
- file?: string;
54
- fixHint?: string;
55
- }>;
56
- }
57
- interface StudioSelectionTextField {
58
- key: string;
59
- label: string;
60
- value: string;
61
- tagName: string;
62
- source: "self" | "child" | "text-node";
63
- }
64
- interface StudioSelectionSnapshot {
65
- schemaVersion: 1;
66
- projectId: string;
67
- compositionPath: string;
68
- sourceFile: string;
69
- currentTime: number;
70
- target: {
71
- id?: string | null;
72
- hfId?: string;
73
- selector?: string;
74
- selectorIndex?: number;
75
- };
76
- label: string;
77
- tagName: string;
78
- boundingBox: {
79
- x: number;
80
- y: number;
81
- width: number;
82
- height: number;
83
- };
84
- textContent: string | null;
85
- dataAttributes: Record<string, string>;
86
- inlineStyles: Record<string, string>;
87
- computedStyles: Record<string, string>;
88
- textFields: StudioSelectionTextField[];
89
- capabilities: Record<string, boolean | string | undefined>;
90
- thumbnailUrl: string;
91
- }
92
- interface StudioSelectionResponse {
93
- selection: StudioSelectionSnapshot | null;
94
- updatedAt: string | null;
95
- }
96
- /**
97
- * Adapter interface — injected by each consumer to handle host-specific behavior.
98
- * The shared API module calls these methods; each host (vite dev, CLI embedded)
99
- * provides its own implementation.
100
- */
101
- interface StudioApiAdapter {
102
- /** List all available projects. */
103
- listProjects(): Promise<ResolvedProject[]> | ResolvedProject[];
104
- /** Resolve a project ID (or session ID) to its directory. Returns null if not found. */
105
- resolveProject(id: string): Promise<ResolvedProject | null> | ResolvedProject | null;
106
- /** Bundle a project directory into a single HTML string. Returns null if unavailable. */
107
- bundle(projectDir: string): Promise<string | null>;
108
- /** Optional: cached signature for project files that should invalidate preview frame caches. */
109
- getProjectSignature?: (projectDir: string) => string;
110
- /** Lint a single HTML string. */
111
- lint(html: string, opts?: {
112
- filePath?: string;
113
- }): Promise<LintResult> | LintResult;
114
- /** URL to the hyperframe runtime JS (injected into preview HTML). */
115
- runtimeUrl: string;
116
- /**
117
- * Optional: post-process preview HTML before Studio augments it.
118
- * Useful when preview must mirror render-time compilation steps.
119
- */
120
- transformPreviewHtml?: (opts: {
121
- html: string;
122
- project: ResolvedProject;
123
- activeCompositionPath: string;
124
- }) => Promise<string> | string;
125
- /** Directory where render output files are stored. */
126
- rendersDir(project: ResolvedProject): string;
127
- /**
128
- * Start a render job. The adapter owns the async execution and must
129
- * update the returned RenderJobState object reactively.
130
- */
131
- startRender(opts: {
132
- project: ResolvedProject;
133
- outputPath: string;
134
- format: "mp4" | "webm" | "mov";
135
- /**
136
- * Frame rate as an exact rational. The HTTP layer (POST
137
- * `/projects/:id/render`) accepts either a JSON number (integer fps,
138
- * `30`) or a JSON string (ffmpeg-style rational, `"30000/1001"`); the
139
- * route normalizes both into `Fps` before invoking the adapter, so
140
- * adapter implementations only ever see the rational form.
141
- */
142
- fps: _hyperframes_core.Fps;
143
- quality: string;
144
- jobId: string;
145
- /**
146
- * Optional output resolution preset. See `resolveDeviceScaleFactor` in
147
- * the producer for the integer-scale + aspect + HDR constraints.
148
- */
149
- outputResolution?: CanvasResolution;
150
- /** Entry file relative to projectDir (e.g. "compositions/intro.html"). Defaults to index.html. */
151
- composition?: string;
152
- /**
153
- * Composition-variable overrides ({variableId: value}), forwarded to the
154
- * producer's RenderConfig.variables and injected as window.__hfVariables —
155
- * the same channel `hyperframes render --variables` uses.
156
- */
157
- variables?: Record<string, unknown>;
158
- /**
159
- * Telemetry id of the browser user who triggered the render. Lets the
160
- * adapter attribute the server-emitted render_complete/render_error to
161
- * that user so the studio render funnel is joinable. Undefined for older
162
- * clients → falls back to the install's anonymous id.
163
- */
164
- distinctId?: string;
165
- }): RenderJobState;
166
- startBackgroundRemoval?: (opts: {
167
- project: ResolvedProject;
168
- inputPath: string;
169
- inputAssetPath: string;
170
- outputPath: string;
171
- outputAssetPath: string;
172
- backgroundOutputPath?: string;
173
- backgroundOutputAssetPath?: string;
174
- quality: "fast" | "balanced" | "best";
175
- device?: "auto" | "cpu" | "coreml" | "cuda";
176
- jobId: string;
177
- }) => MediaProcessingJobState;
178
- /** Optional: generate a JPEG thumbnail via Puppeteer or similar. */
179
- generateThumbnail?: (opts: {
180
- project: ResolvedProject;
181
- compPath: string;
182
- seekTime: number;
183
- width: number;
184
- height: number;
185
- previewUrl: string;
186
- selector?: string;
187
- format?: "jpeg" | "png";
188
- selectorIndex?: number;
189
- }) => Promise<Buffer | null>;
190
- /** Optional: resolve session ID to project (multi-project mode). */
191
- resolveSession?: (sessionId: string) => Promise<{
192
- projectId: string;
193
- title: string;
194
- } | null>;
195
- /** Optional: list all registry items (blocks + components) for the catalog. */
196
- listRegistryCatalog?(): Promise<RegistryItem[]>;
197
- /** Optional: install a registry item into a project directory. */
198
- installRegistryBlock?(opts: {
199
- project: ResolvedProject;
200
- blockName: string;
201
- }): Promise<{
202
- written: string[];
203
- block: RegistryItem;
204
- }>;
205
- }
7
+ export { isSafePath } from '@hyperframes/core';
8
+ import '@hyperframes/parsers';
9
+ import './helpers/mediaCodecMap.js';
206
10
 
207
11
  /**
208
12
  * Create a Hono sub-app with all studio API routes.
@@ -284,4 +88,4 @@ type BackgroundRemovalRender = (options: {
284
88
  }>;
285
89
  declare function createBackgroundRemovalJob(opts: BackgroundRemovalJobOptions, render: BackgroundRemovalRender): MediaProcessingJobState;
286
90
 
287
- export { type BackgroundRemovalRender, type FileWriteReceipt, type LintResult, MIME_TYPES, type MediaProcessingJobState, type RenderJobState, type ResolvedProject, type StudioApiAdapter, type StudioSelectionResponse, type StudioSelectionSnapshot, type StudioSelectionTextField, buildSubCompositionHtml, consumeFileWriteReceipt, createBackgroundRemovalJob, createProjectSignature, createStudioApi, fileContentVersion, getMimeType, walkDir };
91
+ export { type BackgroundRemovalRender, type FileWriteReceipt, MIME_TYPES, MediaProcessingJobState, StudioApiAdapter, buildSubCompositionHtml, consumeFileWriteReceipt, createBackgroundRemovalJob, createProjectSignature, createStudioApi, fileContentVersion, getMimeType, walkDir };