@hyperframes/studio-server 0.8.76 → 0.8.78
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/{chunk-5PGWTBCL.js → chunk-X3T65KC2.js} +5 -8
- package/dist/chunk-X3T65KC2.js.map +1 -0
- package/dist/helpers/mediaProxyPreview.d.ts +1 -1
- package/dist/helpers/mediaProxyPreview.js +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.js +348 -198
- package/dist/index.js.map +1 -1
- package/dist/{mediaProxyPreview-DZD3iu_2.d.ts → mediaProxyPreview-BmJ8AmLd.d.ts} +15 -1
- package/package.json +3 -3
- package/dist/chunk-5PGWTBCL.js.map +0 -1
|
@@ -45,6 +45,10 @@ interface ProjectHistoryOptions {
|
|
|
45
45
|
budgetBytes?: number;
|
|
46
46
|
/** A sweep or commit that a watcher or timer started failed. */
|
|
47
47
|
onError?: (error: unknown) => void;
|
|
48
|
+
/** How long an open waits for another process to close the same history (default 5 s). */
|
|
49
|
+
ownerWaitMs?: number;
|
|
50
|
+
/** A CLI turn's window from an earlier open: writes since, within its idle limit, become the entry with its id. */
|
|
51
|
+
closedWindow?: ClosedWindow;
|
|
48
52
|
}
|
|
49
53
|
interface ClaimOptions {
|
|
50
54
|
coalesceKey?: string;
|
|
@@ -55,6 +59,15 @@ interface ClaimOptions {
|
|
|
55
59
|
interface Writing {
|
|
56
60
|
writeToken?: string;
|
|
57
61
|
}
|
|
62
|
+
interface ClosedWindow {
|
|
63
|
+
id: string;
|
|
64
|
+
who: HistoryWho;
|
|
65
|
+
label: string;
|
|
66
|
+
startedAt: number;
|
|
67
|
+
lastWriteAt: number;
|
|
68
|
+
idleMs: number;
|
|
69
|
+
}
|
|
70
|
+
declare const MAX_WINDOW_IDLE_MS: number;
|
|
58
71
|
interface HistoryListItem extends HistoryEntry {
|
|
59
72
|
pinned: boolean;
|
|
60
73
|
undone: boolean;
|
|
@@ -71,6 +84,7 @@ type HistoryResult = {
|
|
|
71
84
|
};
|
|
72
85
|
interface HistoryWindow {
|
|
73
86
|
readonly id: string;
|
|
87
|
+
readonly startedAt: number;
|
|
74
88
|
/** Records everything written since the window opened as one entry (null when nothing changed); after the window
|
|
75
89
|
* ended by itself or by flush, returns the entry it became. */
|
|
76
90
|
close(): Promise<HistoryEntry | null>;
|
|
@@ -407,4 +421,4 @@ declare function injectMediaCodecMapIntoHtml(html: string, projectDir: string, h
|
|
|
407
421
|
*/
|
|
408
422
|
declare function injectMediaCodecMap(html: string, adapter: PreviewApiAdapter, projectDir: string, compSrcPath: string, probeCache: MediaCodecProbeCache): Promise<string>;
|
|
409
423
|
|
|
410
|
-
export { DEFAULT_HISTORY_ROOT as D, type HistoryEntry as H, type LintResult as L, type MediaProcessingJobState as M, type PreviewDocumentStore as P, type RenderJobState as R, type StudioApiAdapter as S, START as a, type HistoryFileChange as b, type HistoryListItem as c, type HistoryResult as d, type HistoryWho as e, type HistoryWindow as f,
|
|
424
|
+
export { type ClosedWindow as C, DEFAULT_HISTORY_ROOT as D, type HistoryEntry as H, type LintResult as L, type MediaProcessingJobState as M, type PreviewDocumentStore as P, type RenderJobState as R, type StudioApiAdapter as S, START as a, type HistoryFileChange as b, type HistoryListItem as c, type HistoryResult as d, type HistoryWho as e, type HistoryWindow as f, MAX_WINDOW_IDLE_MS as g, type PreviewApiAdapter as h, type ProjectHistory as i, type ProjectHistoryOptions as j, type ResolvedProject as k, type StudioSelectionResponse as l, type StudioSelectionSnapshot as m, type StudioSelectionTextField as n, openProjectHistory as o, injectMediaCodecMap as p, injectMediaCodecMapIntoHtml as q, isAutoProxyEnabled as r, proxyEtagSalt as s, resolvePreviewMediaCodecProbeCache as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.78",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"linkedom": "^0.18.12",
|
|
65
65
|
"postcss": "^8.5.8",
|
|
66
66
|
"postcss-selector-parser": "^7.1.2",
|
|
67
|
-
"@hyperframes/
|
|
68
|
-
"@hyperframes/
|
|
67
|
+
"@hyperframes/core": "0.8.78",
|
|
68
|
+
"@hyperframes/parsers": "0.8.78"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.0.10",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/mediaProxyPreview.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport type { StudioApiAdapter } from \"../types.js\";\nimport {\n createMediaCodecProbeCache,\n proxyVariantFor,\n recordProxyPrewarm,\n scanProjectMediaCodecMap,\n shouldPrewarmProxy,\n type HtmlSourceLike,\n type MediaCodecMap,\n type MediaCodecProbeCache,\n} from \"./mediaCodecMap.js\";\nimport { resolveProxy, PROXY_PARAMS_VERSION } from \"./proxyTranscoder.js\";\n\n/**\n * Transparent-media-proxy wiring shared by `routes/preview.ts`\n * (docs/plans/2026-07-14-002-feat-transparent-media-proxies-plan.md, unit U3).\n * Split out of the route module to keep it under the repo's 600-line file cap.\n */\n\n/**\n * Preview-route-local adapter surface for the auto-proxy feature. Both\n * fields are optional so any existing `StudioApiAdapter` value remains\n * structurally assignable without editing the shared interface:\n * `autoProxy` defaults to true (on) when omitted — a later unit wires the\n * CLI `--no-proxy` flag / `hyperframes.json` setting through it;\n * `mediaCodecProbeCache` lets a host share one probe cache across\n * preview/play/static-server surfaces instead of each constructing its own.\n */\nexport type PreviewApiAdapter = StudioApiAdapter & {\n autoProxy?: boolean;\n mediaCodecProbeCache?: MediaCodecProbeCache;\n /** Keeps built preview documents across restarts, keyed by project id and preview ETag. */\n previewDocuments?: PreviewDocumentStore;\n};\n\nexport interface PreviewDocumentStore {\n read(key: string): string | null;\n write(key: string, html: string): void;\n}\n\nexport function isAutoProxyEnabled(adapter: PreviewApiAdapter): boolean {\n return adapter.autoProxy !== false;\n}\n\n/** One probe cache per server instance — construct once in `registerPreviewRoutes`\n * and reuse across every request so the mtime-cache benefit in\n * `scanProjectMediaCodecMap` actually applies. A host that wants to share the\n * cache across other surfaces (play, static project server) can pass its own\n * via `adapter.mediaCodecProbeCache`. */\nexport function resolvePreviewMediaCodecProbeCache(\n adapter: PreviewApiAdapter,\n): MediaCodecProbeCache {\n return adapter.mediaCodecProbeCache ?? createMediaCodecProbeCache();\n}\n\n/**\n * ETag salt for `?hf-proxy=` asset requests, mirroring `variablesEtagSalt` in\n * preview.ts: salted by the raw param value plus the transcoder's params\n * version, so a future proxy-recipe change (which bumps `PROXY_PARAMS_VERSION`)\n * or a different proxy variant invalidates cached 304s without needing to\n * touch the proxy file itself.\n */\nexport function proxyEtagSalt(raw: string | undefined): string {\n if (raw === undefined) return \"\";\n return `:proxy:${raw}:${PROXY_PARAMS_VERSION}`;\n}\n\n// Mirrors `injectScriptTagIntoHead` in routes/preview.ts (kept local rather\n// than imported to avoid a helpers → routes dependency edge for one\n// two-line utility).\nfunction injectScriptTagIntoHead(html: string, scriptTag: string): string {\n if (html.includes(\"</head>\")) return html.replace(\"</head>\", `${scriptTag}\\n</head>`);\n return `${scriptTag}\\n${html}`;\n}\n\n/**\n * Injects `window.__HF_MEDIA_CODEC_MAP__` (the U1 codec-facts scan) into\n * served composition HTML, and fire-and-forget pre-warms `resolveProxy` for\n * every entry whose codec no browser decodes, so an element's proactive swap\n * usually hits a warm cache (KTD: protects the per-origin connection budget\n * under held responses). Conditionally hostile codecs are injected but NOT\n * pre-warmed: the requesting browser usually plays them, and the transcode\n * runs concurrently with its first layout. No second concurrency limiter here\n * — the transcoder's own global bound throttles both pre-warm and\n * element-triggered calls. Pre-warm failures are swallowed; an actual\n * `?hf-proxy=` request surfaces them as a 502 and transcodes lazily.\n * Alpha-bearing entries pre-warm their VP8/WebM variant.\n *\n * The single shared implementation for every auto-proxy surface — the studio\n * preview route (via `injectMediaCodecMap` below) and the CLI's composition /\n * static project servers (via the `./media-proxy-preview` subpath export).\n * Empty maps leave HTML untouched, preserving the normal no-hostile-media\n * preview path. On-demand proxy requests enforce the same eligibility gate.\n */\nexport async function injectMediaCodecMapIntoHtml(\n html: string,\n projectDir: string,\n htmlSources: HtmlSourceLike[],\n probeCache?: MediaCodecProbeCache,\n): Promise<string> {\n let map: MediaCodecMap;\n try {\n map = await scanProjectMediaCodecMap(\n projectDir,\n htmlSources,\n probeCache ? { cache: probeCache } : {},\n );\n } catch {\n // Best-effort: a scan failure must never block serving the page.\n return html;\n }\n if (Object.keys(map).length === 0) return html;\n for (const [rootRelativePathname, facts] of Object.entries(map)) {\n if (!shouldPrewarmProxy(facts)) continue;\n recordProxyPrewarm();\n resolveProxy(\n projectDir,\n resolve(projectDir, rootRelativePathname.replace(/^\\/+/, \"\")),\n proxyVariantFor(facts),\n ).catch(() => {\n // Swallowed: the pre-warm is best-effort. A real `?hf-proxy=` request\n // for this asset re-attempts the transcode and reports failure (502).\n });\n }\n // <-escape prevents a src path containing \"</script>\" from breaking out of\n // the injected tag, mirroring injectPreviewVariables in helpers/previewVariables.ts.\n const json = JSON.stringify(map)\n .replace(/</g, \"\\\\u003c\")\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\");\n const tag = `<script data-hf-media-codec-map>window.__HF_MEDIA_CODEC_MAP__=${json};</script>`;\n return injectScriptTagIntoHead(html, tag);\n}\n\n/**\n * Adapter-aware wrapper used by the studio preview routes: skipped entirely\n * (no scan, no injection) when auto-proxy is off for this adapter.\n */\nexport async function injectMediaCodecMap(\n html: string,\n adapter: PreviewApiAdapter,\n projectDir: string,\n compSrcPath: string,\n probeCache: MediaCodecProbeCache,\n): Promise<string> {\n if (!isAutoProxyEnabled(adapter)) return html;\n return injectMediaCodecMapIntoHtml(html, projectDir, [{ html, compSrcPath }], probeCache);\n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