framefields 2.4.1 → 2.4.2

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 (43) hide show
  1. package/README.md +11 -33
  2. package/dist/audio/index.d.mts +1 -1
  3. package/dist/audio/index.mjs +1 -1
  4. package/dist/{audio-CPApYcWF.mjs → audio-Bb31xJuX.mjs} +2 -2
  5. package/dist/{audio-CPApYcWF.mjs.map → audio-Bb31xJuX.mjs.map} +1 -1
  6. package/dist/{dist-CrK3rmyN.mjs → dist-CxGfrigI.mjs} +43 -3
  7. package/dist/{dist-CrK3rmyN.mjs.map → dist-CxGfrigI.mjs.map} +1 -1
  8. package/dist/effects/index.mjs +1 -1
  9. package/dist/{effects-DxylPSuI.mjs → effects-BOk_2kzM.mjs} +2 -2
  10. package/dist/{effects-DxylPSuI.mjs.map → effects-BOk_2kzM.mjs.map} +1 -1
  11. package/dist/{index-C0o3lLyA.d.mts → index-B3-gwjK6.d.mts} +14 -2
  12. package/dist/index-B3-gwjK6.d.mts.map +1 -0
  13. package/dist/{index-BxARm93R.d.mts → index-BTPLbjt4.d.mts} +40 -11
  14. package/dist/index-BTPLbjt4.d.mts.map +1 -0
  15. package/dist/index.d.mts +7 -3
  16. package/dist/index.d.mts.map +1 -1
  17. package/dist/index.mjs +5 -5
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/preview/index.d.mts +1 -1
  20. package/dist/preview/index.mjs +1 -1
  21. package/dist/{preview-D2dMmokw.mjs → preview-DyGw2b3_.mjs} +2 -2
  22. package/dist/{preview-D2dMmokw.mjs.map → preview-DyGw2b3_.mjs.map} +1 -1
  23. package/dist/preview-engine/audio.mjs +1 -1
  24. package/dist/preview-engine/{chunk-NTVDL3RS.mjs → chunk-AQNTIWTK.mjs} +1 -1
  25. package/dist/preview-engine/{chunk-5E5J4KT4.mjs → chunk-RHRMEBNK.mjs} +1 -1
  26. package/dist/preview-engine/chunk-VONDRBA2.mjs +1 -0
  27. package/dist/preview-engine/effects.mjs +1 -1
  28. package/dist/preview-engine/framefields.mjs +1 -1
  29. package/dist/preview-engine/player.mjs +1 -1
  30. package/dist/preview-engine/{renderers-U55KRIOV.mjs → renderers-EI6MQ2EL.mjs} +1 -1
  31. package/dist/preview-engine/signals.mjs +1 -1
  32. package/dist/renderer/index.d.mts +1 -1
  33. package/dist/renderer/index.mjs +1 -1
  34. package/dist/{renderer-Czxgaygb.mjs → renderer-BV48PFjX.mjs} +2 -2
  35. package/dist/{renderer-Czxgaygb.mjs.map → renderer-BV48PFjX.mjs.map} +1 -1
  36. package/dist/{renderer-CNb-DG00.mjs → renderer-CoWfz-9p.mjs} +373 -109
  37. package/dist/renderer-CoWfz-9p.mjs.map +1 -0
  38. package/dist/signals/index.mjs +1 -1
  39. package/package.json +57 -57
  40. package/dist/index-BxARm93R.d.mts.map +0 -1
  41. package/dist/index-C0o3lLyA.d.mts.map +0 -1
  42. package/dist/preview-engine/chunk-266DECPQ.mjs +0 -1
  43. package/dist/renderer-CNb-DG00.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BxARm93R.d.mts","names":["pino","VideoColorPrimaries","VideoFrame","VideoMatrixCoefficients","VideoTransferCharacteristics","RenderDiagnostic","VirtualMediaData","VideoSampleSource","preloadFonts","GPUDevice","Promise","StagingSlotStatus","VideoColorSpaceConfig","DmaStagingRingOptions","GPUTextureFormat","StagingSlotInfo","DmaStagingRing","GPUCommandEncoder","GPUTexture","Uint8Array","findNodesDir","discoverAndRegisterNodeRenderers","VideoQaOptions","QaSegment","QaIssue","VideoQaStats","AudioQaStats","VideoQaReport","FrameInspector","analyzeAudio","Float32Array","integratedLoudness","buildQaReport","formatQaReport","WorkerInput","WorkerMessage","Array","RenderSemaphore","renderSemaphore","HeadlessWebGPURenderer","Buffer","AbortSignal","RenderProgress","HeadlessMediaRenderer","resetRenderCaches","rendererLogger","Logger","NODE_KINDS","NodeKind","NodeRendererExports","NodeManifest","NodeManifestError","Error","parseNodeManifest","loadNodeManifests","ZeroCopyWebCodecsPipelineOptions","WebCodecsPipelineStats","ZeroCopyWebCodecsPipeline"],"sources":["../../renderer/dist/index.d.mts","../src/renderer/framegrid.ts"],"sourcesContent":["import pino from \"pino\";\nimport { VideoColorPrimaries, VideoFrame, VideoMatrixCoefficients, VideoTransferCharacteristics } from \"@napi-rs/webcodecs\";\nimport { RenderDiagnostic, VirtualMediaData } from \"@framefields/core\";\nimport { VideoSampleSource } from \"mediabunny\";\n\n//#region src/asset-preloader.d.ts\n\n/**\n * Preloads only the fonts (and emoji) a VirtualMediaData tree's text uses, so\n * typography renders correctly on Node.js without loading its media. Shared\n * with the browser preview; emoji need a font set with\n * `FontManager.registerEmojiFont()`.\n */\ndeclare function preloadFonts(media: VirtualMediaData, device?: GPUDevice | null): Promise<void>;\n//#endregion\n//#region src/dma-staging-ring.d.ts\ntype StagingSlotStatus = \"idle\" | \"rendering\" | \"mapping\" | \"mapped\";\ninterface VideoColorSpaceConfig {\n readonly primaries?: VideoColorPrimaries;\n readonly transfer?: VideoTransferCharacteristics;\n readonly matrix?: VideoMatrixCoefficients;\n readonly fullRange?: boolean;\n}\ninterface DmaStagingRingOptions {\n readonly width: number;\n readonly height: number;\n readonly capacity?: number;\n readonly format?: GPUTextureFormat;\n}\ninterface StagingSlotInfo {\n readonly index: number;\n readonly status: StagingSlotStatus;\n readonly inFlightFrame: number | null;\n}\n/**\n * Pipelined Asynchronous DMA Staging Ring for WebGPU.\n *\n * Implements double-buffered (or N-buffered) GPU staging buffers to overlap\n * GPU render passes with asynchronous DMA host transfers and WebCodecs hardware encoding.\n * Eliminates GPU stalls by allowing Frame i+1 to execute on the GPU while Frame i\n * is asynchronously mapped and consumed by the hardware video encoder.\n */\ndeclare class DmaStagingRing {\n readonly width: number;\n readonly height: number;\n readonly capacity: number;\n readonly bytesPerRow: number;\n readonly unpaddedBytesPerRow: number;\n readonly bufferSize: number;\n readonly format: GPUTextureFormat;\n readonly device: GPUDevice;\n private readonly slots;\n private isDestroyed;\n constructor(device: GPUDevice, options: DmaStagingRingOptions);\n /**\n * Prepares the staging buffer slot for writing by ensuring any prior mapping\n * from a previous cycle has been completed and unmapped.\n */\n prepareSlot(frameIndex: number): Promise<void>;\n /**\n * Records a GPU-to-buffer DMA copy command into the provided command encoder.\n */\n stageTexture(encoder: GPUCommandEncoder, texture: GPUTexture, frameIndex: number): void;\n /**\n * Initiates asynchronous DMA mapping on the slot for the specified frame.\n * Must be called immediately after submitting the command encoder to the device queue.\n */\n scheduleMap(frameIndex: number): Promise<void>;\n /**\n * Awaits asynchronous mapping and extracts pixels into a tightly packed Uint8Array.\n * The slot remains in the \"mapped\" state until releaseFrame() is called.\n */\n readFramePixels(frameIndex: number): Promise<Uint8Array>;\n /**\n * Awaits asynchronous mapping, extracts pixels, and immediately unmaps the staging buffer,\n * returning the slot to \"idle\" state so it can be reused immediately.\n */\n readAndReleaseFrame(frameIndex: number): Promise<Uint8Array>;\n /**\n * Directly reads the mapped staging buffer into a WebCodecs VideoFrame,\n * bypassing redundant intermediate JS allocations when row pitches align,\n * and immediately unmaps the buffer.\n */\n readFrameToVideoFrame(frameIndex: number, timestampUs: number, colorSpace?: VideoColorSpaceConfig, /** Sees the tightly packed RGBA pixels while they are mapped; must not keep them. */\n inspect?: (rgba: Uint8Array) => void): Promise<VideoFrame>;\n /**\n * Unmaps the staging buffer for the specified frame and marks the slot idle.\n */\n releaseFrame(frameIndex: number): void;\n /**\n * Returns current status info for each slot in the ring.\n */\n getSlotInfos(): readonly StagingSlotInfo[];\n /**\n * Destroys all staging buffers and releases resources.\n */\n destroy(): void;\n private checkDestroyed;\n}\n//#endregion\n//#region src/dynamic-node-discovery.d.ts\n/** Locates the workspace `nodes/` directory by climbing up from this file. */\ndeclare function findNodesDir(startDir?: string): string | null;\n/**\n * Registers the built-in node renderers, then any extra nodes found in the\n * directory named by `FRAMEFIELDS_NODES_DIR` (local node development). A node in\n * that directory overrides the built-in renderer for the same op.\n */\ndeclare function discoverAndRegisterNodeRenderers(): Promise<void>;\n//#endregion\n//#region src/video-qa.d.ts\n/**\n * Quality checks run on a video while it renders: frames are measured as\n * they are read back for the encoder and audio as it is mixed, so the report\n * describes exactly what was encoded without decoding the file again.\n */\ninterface VideoQaOptions {\n /** Luma (0-1) at or below which a pixel counts as black. Default 0.1. */\n readonly blackPixelThreshold?: number;\n /** Share of black pixels that makes a frame black. Default 0.98. */\n readonly blackFrameRatio?: number;\n /** Shortest run of black frames reported. Default 0.5 s. */\n readonly minBlackSec?: number;\n /** Shortest run of unchanging frames reported. Default 2 s. */\n readonly minFrozenSec?: number;\n /** Level (dBFS, 100 ms windows) below which audio counts as silent. Default -60. */\n readonly silenceDbfs?: number;\n /** Shortest silent stretch reported. Default 2 s. */\n readonly minSilenceSec?: number;\n /** Integrated loudness to hit, e.g. -14 for most streaming platforms. Unchecked when unset. */\n readonly targetLufs?: number;\n /** Allowed distance from `targetLufs`, in LU. Default 1. */\n readonly lufsTolerance?: number;\n}\ninterface QaSegment {\n readonly startSec: number;\n readonly endSec: number;\n}\ninterface QaIssue {\n readonly severity: \"error\" | \"warning\" | \"info\";\n /** Stable machine-readable kind, e.g. \"black_frames\", \"audio_clipping\" */\n readonly code: string;\n readonly message: string;\n readonly startSec?: number;\n readonly endSec?: number;\n readonly layerId?: string;\n}\ninterface VideoQaStats {\n readonly expectedFrames: number;\n readonly encodedFrames: number;\n readonly fps: number;\n readonly width: number;\n readonly height: number;\n /** Average luma over the whole video, 0-1 */\n readonly meanLuma: number;\n readonly blackSegments: readonly QaSegment[];\n readonly frozenSegments: readonly QaSegment[];\n}\ninterface AudioQaStats {\n readonly sampleRate: number;\n readonly channels: number;\n readonly durationSec: number;\n /** Highest sample, dBFS (sample peak, not true peak) */\n readonly peakDbfs: number;\n /** Mean level over the whole track, dBFS */\n readonly rmsDbfs: number;\n /** ITU-R BS.1770 integrated loudness; null when the track is silent */\n readonly integratedLufs: number | null;\n /** Samples at or beyond full scale */\n readonly clippedSamples: number;\n readonly silentSegments: readonly QaSegment[];\n}\ninterface VideoQaReport {\n /** No errors or warnings (info issues do not fail a render) */\n readonly passed: boolean;\n readonly video?: VideoQaStats;\n readonly audio?: AudioQaStats;\n readonly issues: readonly QaIssue[];\n}\n/** Measures frames handed to it in order, as RGBA bytes. */\ndeclare class FrameInspector {\n private readonly blackLuma;\n private readonly blackRatio;\n private readonly black;\n private readonly sameAsPrevious;\n private lumaSum;\n private previous;\n constructor(options?: VideoQaOptions);\n get frameCount(): number;\n inspect(rgba: Uint8Array, width: number, height: number): void;\n stats(expectedFrames: number, encodedFrames: number, fps: number, width: number, height: number, options?: VideoQaOptions): VideoQaStats;\n}\n/** Measures a mixed audio track (one Float32Array per channel). */\ndeclare function analyzeAudio(channels: readonly Float32Array[], sampleRate: number, options?: VideoQaOptions): AudioQaStats;\n/**\n * ITU-R BS.1770-4 integrated loudness (LUFS): K-weighted mean square in\n * 400 ms blocks with 75% overlap, gated at -70 LUFS and then at 10 LU below\n * the mean of what passed. Channels weigh 1 (stereo and mono layouts).\n */\ndeclare function integratedLoudness(channels: readonly Float32Array[], sampleRate: number): number | null;\n/** Turn measurements and document diagnostics into a report with issues. */\ndeclare function buildQaReport(parts: {\n video?: VideoQaStats;\n audio?: AudioQaStats;\n diagnostics?: readonly RenderDiagnostic[];\n options?: VideoQaOptions;\n}): VideoQaReport;\n/** A short human- and agent-readable summary of a report. */\ndeclare function formatQaReport(report: VideoQaReport): string;\n//#endregion\n//#region src/headless-webgpu-renderer.d.ts\ninterface WorkerInput {\n virtualMedia: VirtualMediaData;\n width: number;\n height: number;\n fps: number;\n startFrame: number;\n endFrame: number;\n renderId: string;\n outputFormat: \"png\" | \"pixels\";\n workerIndex: number;\n}\ntype WorkerMessage = {\n type: \"frame\";\n renderId: string;\n frameIndex: number;\n pixels: Uint8Array;\n} | {\n type: \"png\";\n renderId: string;\n data: Uint8Array;\n} | {\n type: \"done\";\n renderId: string;\n} | {\n type: \"lut\";\n renderId: string;\n raw: {\n points: Array<[number, number, number]>;\n size: number;\n type: \"1D\" | \"3D\";\n };\n} | {\n type: \"error\";\n renderId?: string;\n error: string;\n};\ndeclare class RenderSemaphore {\n private _running;\n private readonly _max;\n private readonly _queue;\n constructor(max: number);\n acquire(timeoutMs?: number): Promise<void>;\n release(): void;\n get stats(): {\n active: number;\n queued: number;\n max: number;\n };\n}\ndeclare const renderSemaphore: RenderSemaphore;\ndeclare class HeadlessWebGPURenderer {\n private static isInitialized;\n private static initPromise;\n private static initFailureCount;\n private static readonly MAX_INIT_FAILURES;\n private static nextRetryAt;\n static initialize(): Promise<void>;\n renderImage(virtualMedia: VirtualMediaData, frame?: number, fps?: number, options?: {\n renderId?: string;\n /** \"rgba\" skips PNG encoding and returns width*height*4 raw pixels. */\n format?: \"png\" | \"rgba\";\n }): Promise<Buffer>;\n /**\n * Renders a single frame to a PNG buffer at a specified timestamp in milliseconds or frame index.\n */\n renderFrame(source: VirtualMediaData | {\n toVirtualMedia(): VirtualMediaData;\n }, options?: {\n atMs?: number;\n frame?: number;\n fps?: number;\n /** Reuse compiled state across calls; see `renderImage`. */\n renderId?: string;\n /** \"rgba\" returns raw width*height*4 pixels instead of a PNG. */\n format?: \"png\" | \"rgba\";\n }): Promise<Buffer>;\n /**\n * Mixes the composition's full audio timeline (clips, effects, synthesized\n * tracks) to stereo PCM, exactly as `renderVideo` muxes it.\n */\n renderAudio(virtualMedia: VirtualMediaData, options?: {\n fps?: number;\n sampleRate?: number;\n }): Promise<{\n channels: Float32Array[];\n sampleRate: number;\n }>;\n renderLut(virtualMedia: VirtualMediaData, frame?: number, fps?: number): Promise<Buffer>;\n private resolveMediaDuration;\n renderVideo(virtualMedia: VirtualMediaData, options?: {\n codec?: string;\n audioCodec?: string;\n quality?: string;\n concurrency?: number;\n /**\n * Depth of the DMA staging ring (default 2, clamped 2–8). A deeper\n * ring overlaps more encoder latency at the cost of VRAM\n * (~8.3MB/slot at 1080p RGBA). Also settable via\n * `FRAMEFIELDS_RING_CAPACITY`.\n */\n ringCapacity?: number;\n /**\n * Measure the output while it renders (black and frozen frames,\n * dropped frames, loudness, clipping, silence, document warnings)\n * and return the findings as `qa`. `true` uses default thresholds.\n */\n qa?: boolean | VideoQaOptions;\n /**\n * Aborts the render between frames; the promise rejects with\n * `signal.reason` and the partial output is deleted.\n */\n signal?: AbortSignal;\n /** Called after each frame is queued for encoding, then once for audio. */\n onProgress?: (progress: RenderProgress) => void;\n }): Promise<{\n filePath: string;\n cleanup: () => Promise<void>;\n qa?: VideoQaReport;\n }>;\n}\n/** Progress reported by `renderVideo({ onProgress })`. */\ninterface RenderProgress {\n /** \"render\" while frames are drawn and encoded, \"audio\" while mixing. */\n phase: \"render\" | \"audio\";\n /** Frames finished so far (1-based). */\n frame: number;\n totalFrames: number;\n}\ndeclare const HeadlessMediaRenderer: typeof HeadlessWebGPURenderer;\ntype HeadlessMediaRenderer = HeadlessWebGPURenderer;\n//#endregion\n//#region src/job-reset.d.ts\n/**\n * Drops every cache keyed by a file path or URL: media inputs and decoders,\n * textures, LUTs, fonts and downloaded font files. A long-lived worker calls this between jobs,\n * because the next checkout may hold different bytes at the same path. The\n * GPU device and compiled pipelines stay warm.\n */\ndeclare function resetRenderCaches(): void;\n//#endregion\n//#region src/logger.d.ts\ndeclare const rendererLogger: pino.Logger<never, boolean>;\n//#endregion\n//#region src/node-manifest.d.ts\n/**\n * The `framefields` block of a node package's `package.json`.\n *\n * This is the single declaration of a node's op: renderer discovery, the\n * effects generator (`scripts/generate-effects.ts`) and the skill catalog all\n * read it from here. There is deliberately no fallback that derives an op from\n * the package name. See `spec/sync-node.md` §5.1.\n */\ndeclare const NODE_KINDS: readonly [\"effect\", \"audio\", \"source\", \"signal\", \"utility\"];\ntype NodeKind = (typeof NODE_KINDS)[number];\ninterface NodeRendererExports {\n development?: string;\n import?: string;\n default?: string;\n}\ninterface NodeManifest {\n /** Directory name under `nodes/`, e.g. `node-apply-lut`. */\n dir: string;\n /** Absolute path of the node package. */\n path: string;\n /** npm package name, e.g. `@framefields/node-lut`. */\n packageName: string;\n /** Canonical op literal used in the operation AST and the renderer registry. */\n type: string;\n kind: NodeKind;\n /** Legacy ops that resolve to the same renderer. */\n aliases: readonly string[];\n /** Named zod schema export of `src/shared/config.ts`. */\n schema?: string;\n /** Authoring class name. Defaults to `type`. */\n className?: string;\n /** Key on `Effect.*`. Defaults to `className` with a lower-cased first letter. */\n factory?: string;\n /** A hand-written subclass exists under `effects/custom/`. */\n custom: boolean;\n /** `false` when the package opts out of discovery. */\n enabled: boolean;\n rendererExports?: NodeRendererExports;\n}\ndeclare class NodeManifestError extends Error {\n readonly problems: readonly string[];\n constructor(problems: readonly string[]);\n}\n/**\n * Validates one parsed `package.json`. Returns the manifest, or the list of\n * problems that make it unusable. Never throws.\n */\ndeclare function parseNodeManifest(pkg: unknown, dir: string, nodePath?: string): {\n manifest?: NodeManifest;\n problems: string[];\n};\n/**\n * Reads every `nodes/node-*` package and returns its manifest, sorted by\n * directory name. Throws a single {@link NodeManifestError} listing every\n * problem: a missing or malformed block, or an op/alias claimed twice.\n */\ndeclare function loadNodeManifests(nodesDir: string): NodeManifest[];\n//#endregion\n//#region src/zero-copy-webcodecs-pipeline.d.ts\ninterface ZeroCopyWebCodecsPipelineOptions {\n readonly width: number;\n readonly height: number;\n readonly fps: number;\n readonly videoSource: VideoSampleSource;\n readonly ringCapacity?: number;\n readonly colorSpace?: VideoColorSpaceConfig;\n readonly directCanvasSource?: unknown;\n /**\n * Called with each frame's RGBA pixels, in frame order, just before it is\n * encoded (staging-ring path only). The buffer is reused: read, don't keep.\n */\n readonly onFrame?: (rgba: Uint8Array, frameIndex: number) => void;\n}\ninterface WebCodecsPipelineStats {\n readonly totalFramesEnqueued: number;\n readonly totalFramesEncoded: number;\n readonly averageGpuSubmitTimeMs: number;\n readonly averageEncodeTimeMs: number;\n readonly averageCycleTimeMs: number;\n readonly maxCycleTimeMs: number;\n readonly minCycleTimeMs: number;\n readonly throughputFps: number;\n readonly ringCapacity: number;\n readonly isDirectZeroCopy: boolean;\n}\n/**\n * High-performance hardware video encoding pipeline integrating WebGPU textures with WebCodecs.\n *\n * Provides:\n * 1. Direct hardware acceleration when running with WebCodecs / OffscreenCanvas.\n * 2. Pipelined asynchronous double-buffered DMA staging ring for headless Node.js (Dawn native),\n * allowing GPU Frame i+1 rendering to overlap concurrently with Frame i hardware encoding.\n */\ndeclare class ZeroCopyWebCodecsPipeline {\n readonly width: number;\n readonly height: number;\n readonly fps: number;\n readonly ringCapacity: number;\n private readonly device;\n private readonly videoSource;\n private readonly stagingRing;\n private readonly colorSpace?;\n private readonly directCanvasSource?;\n private readonly onFrame?;\n private readonly inFlightFrames;\n private readonly cycleStartTimes;\n private totalFramesEnqueued;\n private totalFramesEncoded;\n private totalGpuSubmitTimeMs;\n private totalEncodeTimeMs;\n private totalCycleTimeMs;\n private maxCycleTimeMs;\n private minCycleTimeMs;\n private pipelineStartTime;\n constructor(device: GPUDevice, options: ZeroCopyWebCodecsPipelineOptions);\n /**\n * Returns true if direct zero-copy from an OffscreenCanvas or texture is active.\n */\n canDirectZeroCopy(): boolean;\n /**\n * Enqueues a rendered GPU texture frame into the pipeline.\n *\n * Uses double-buffered DMA staging: if the staging ring has reached capacity,\n * the oldest in-flight frame is asynchronously consumed and added to the video encoder\n * before staging the new frame, guaranteeing constant bounded VRAM usage and zero GPU stalls.\n */\n enqueueFrame(frameIndex: number, targetTexture: GPUTexture, encoder: GPUCommandEncoder): Promise<void>;\n /**\n * Drains all remaining in-flight frames in the pipeline, ensuring every enqueued\n * frame has been encoded and added to the video sample source.\n */\n drain(): Promise<void>;\n /**\n * Returns runtime throughput, latency, and pipeline statistics.\n */\n getStats(): WebCodecsPipelineStats;\n /**\n * Destroys the pipeline and releases all staging buffers.\n */\n destroy(): void;\n private consumeAndEncode;\n}\n//#endregion\nexport { AudioQaStats, DmaStagingRing, DmaStagingRingOptions, FrameInspector, HeadlessMediaRenderer, HeadlessWebGPURenderer, NODE_KINDS, NodeKind, NodeManifest, NodeManifestError, NodeRendererExports, QaIssue, QaSegment, RenderProgress, StagingSlotInfo, StagingSlotStatus, VideoColorSpaceConfig, VideoQaOptions, VideoQaReport, VideoQaStats, WebCodecsPipelineStats, WorkerInput, WorkerMessage, ZeroCopyWebCodecsPipeline, ZeroCopyWebCodecsPipelineOptions, analyzeAudio, buildQaReport, discoverAndRegisterNodeRenderers, findNodesDir, formatQaReport, integratedLoudness, loadNodeManifests, parseNodeManifest, preloadFonts, renderSemaphore, rendererLogger, resetRenderCaches };\n//# sourceMappingURL=index.d.mts.map"],"mappings":";;;;;;;;;;;;;;UAoHUsB,cAAAA;;;;;;;;;;;;;;;;;;UAkBAC,SAAAA;;;;UAIAC,OAAAA;;;;;;;;;UASAC,YAAAA;;;;;;;;mCAQyBF;oCACCA;;UAE1BG,YAAAA;;;;;;;;;;;;oCAY0BH;;UAE1BI,aAAAA;;;mBAGSF;mBACAC;4BACSF;;;;;iBA+BXS,cAAAA,SAAuBN;;;;cAuC1BU,eAAAA;;;;;+BAKiB3B;;;;;;;;cAQjB4B,iBAAiBD;cACjBE,sBAAAA;;;;;;uBAMS7B;4BACKJ;;;;MAItBI,QAAQ8B;;;;sBAIQlC;sBACAA;;;;;;;;;MAShBI,QAAQ8B;;;;;4BAKclC;;;MAGtBI;cACQoB;;;0BAGYxB,iDAAiDI,QAAQ8B;;4BAEvDlC;;;;;;;;;;;;;;;;;mBAiBTgB;;;;;aAKNmB;;4BAEeC;MACtBhC;;mBAEaA;SACViB;;;;UAICe,cAAAA;;;;;;;cAOIC,8BAA8BJ;KACvCI,qBAAAA,GAAwBJ;;;;;;;;;iBASZK,iBAAAA,CAAAA;;;;;UCxVA,gBAAA;;;;AD+GPtB,UC1GO,gBAAA,CD0GO;EAkBdC;AAAS;AAIF;EAoBPG,UAAAA,CAAAA,EAAAA,MAAY;EAcZC;;;EAKkBH,QAAAA,CAAAA,EAAAA,MAAAA;EAAO;AA6BlB;AAgCA;EAsBHc,UAAAA,CAAAA,EAAAA,MAAgC;EAChCC;;;EAWAC,MAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAR9B;;;EAcQ8B,OAAAA,CAAAA,EAAAA,MAAAA;EAAR9B;;;EAQAA,KAAAA,CAAAA,EAAAA,MAAAA;EAIoBJ;;;EAEEA,MAAAA,CAAAA,EAAAA,MAAAA;EAiBTgB;;;EAUAZ,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EACViB;;;EAICe,GAAAA,CAAAA,EAAAA,MAAAA;EAOIC;AAAoD;AACf;;;;AC/UnD;AAKA;EA0HgB,SAAA,CAAA,EAAA,MAAA;EAsGA;AAiFhB;;EAMa,UAAA,CAAA,EAAA,MAAA;EACA;;;EAWS,GAAA,CAAA,EAAA,MAAA;EACb;;;EAEN,OAAA,CAAA,EAAA,MAAA;EAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAlNE;;;;;iBAMI,mBAAA,UACN;WAGI;;;;;;iBAkGE,iBAAA,mDAGN;;;;;;;;;;;KA8EE,mBAAA;oBACO;;;;;eAKN;MACR,QAAQ;;;;;;;;;;iBAWS,eAAA,SACb,+BACC,mBACP,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-C0o3lLyA.d.mts","names":["a","isStaticVisualMedia","c","RenderParams","i","calculateLayerTransform","l","computeRenderParams","n","framesToSeconds","o","resolveLayerDuration","r","secondsToFrames","s","CropRegion","t","formatTimecode","VirtualMediaData","GPUCommandEncoder","GPUTexture","GPUTextureView","NodeRenderProps","RenderContextValue","drawCompositionTree","Promise","CompositionStateStore","compositionStateStore","SceneProps","AudioClip","decodeAudioSource","Float32Array","mixAudioTracks","GPUDevice","NormalizationContext","normalizeTimeline","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default","_framefields_node_sdk_renderer0","_default","NodeRendererPlugin","Readonly","default"],"sources":["../../compositions/dist/index.d.mts","../../../nodes/node-audio-compressor/dist/renderer.d.mts","../../../nodes/node-audio-delay/dist/renderer.d.mts","../../../nodes/node-audio-fade/dist/renderer.d.mts","../../../nodes/node-audio-noise-gate/dist/renderer.d.mts","../../../nodes/node-audio-parametric-eq/dist/renderer.d.mts","../../../nodes/node-audio-reverb/dist/renderer.d.mts","../../../nodes/node-stereo-panning/dist/renderer.d.mts","../src/audio/synth/sfx.ts","../src/audio/synth/wav-encoder.ts"],"sourcesContent":["import { a as isStaticVisualMedia, c as RenderParams, i as calculateLayerTransform, l as computeRenderParams, n as framesToSeconds, o as resolveLayerDuration, r as secondsToFrames, s as CropRegion, t as formatTimecode } from \"./timing-CluwdKGr.mjs\";\nimport { VirtualMediaData } from \"@framefields/core\";\nimport { GPUCommandEncoder, GPUTexture, GPUTextureView, NodeRenderProps } from \"@framefields/node-sdk\";\nimport { RenderContextValue } from \"@framefields/webgpu-renderers\";\n\n//#region src/compositions/canvas-composition.d.ts\ndeclare function drawCompositionTree(ctx: RenderContextValue, encoder: GPUCommandEncoder, targetView: GPUTextureView, targetTexture: GPUTexture, targetWidth: number, targetHeight: number, virtualMedia: VirtualMediaData, props: NodeRenderProps, inheritedSeekOffset?: number, inheritedClockOffset?: number): Promise<void>;\n//#endregion\n//#region src/compositions/composition-state.d.ts\ndeclare class CompositionStateStore {\n private states;\n private listeners;\n setState(key: string, frame: number, fps: number, isPlaying?: boolean): void;\n getState(key: string): {\n frame: number;\n fps: number;\n isPlaying: boolean;\n };\n subscribe(key: string, listener: () => void): () => void;\n clearKey(key: string): void;\n private notify;\n}\ndeclare const compositionStateStore: CompositionStateStore;\ninterface SceneProps {\n viewportWidth: number;\n viewportHeight: number;\n containerWidth?: number;\n containerHeight?: number;\n virtualMedia?: VirtualMediaData;\n backgroundColor?: string;\n type?: \"Video\" | \"Audio\" | \"Image\";\n volume?: number;\n renderId?: string;\n frame?: number;\n fps?: number;\n [key: string]: unknown;\n}\n//#endregion\n//#region src/utils/audio-extractor.d.ts\ninterface AudioClip {\n sourceUrl: string;\n destStartFrame: number;\n trimStartSec: number;\n durationFrames: number;\n speed: number;\n volume: number;\n}\n/**\n * Decodes all audio samples from a given source URL into raw Float32 mono/stereo channel buffers.\n */\ndeclare function decodeAudioSource(url: string): Promise<{\n channels: Float32Array[];\n sampleRate: number;\n} | null>;\n/**\n * Recursively parses the VirtualMediaData tree and mixes all active audio tracks\n * into a single unified stereo PCM stream (Float32Array channels).\n */\ndeclare function mixAudioTracks(virtualMedia: VirtualMediaData, fps: number, targetSampleRate?: number, device?: GPUDevice, renderId?: string): Promise<{\n channels: Float32Array[];\n sampleRate: number;\n}>;\n//#endregion\n//#region src/utils/normalization.d.ts\n/**\n * NormalizationContext carries the accumulated offsets and limits\n * as we traverse down the virtual media tree.\n */\ninterface NormalizationContext {\n timeOffsetSec: number;\n durationLimitMs?: number;\n}\n/**\n * normalizeTimeline recurses through the virtual media tree and \"absorbs\"\n * generic timeline-shifting operations into standard properties\n * of their children.\n */\ndeclare function normalizeTimeline(vv: VirtualMediaData, fps: number, context?: NormalizationContext): VirtualMediaData;\n//#endregion\nexport { AudioClip, CropRegion, RenderParams, SceneProps, calculateLayerTransform, compositionStateStore, computeRenderParams, decodeAudioSource, drawCompositionTree, formatTimecode, framesToSeconds, isStaticVisualMedia, mixAudioTracks, normalizeTimeline, resolveLayerDuration, secondsToFrames };\n//# sourceMappingURL=index.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map","import * as _framefields_node_sdk_renderer0 from \"@framefields/node-sdk/renderer\";\n\n//#region src/renderers/index.d.ts\ndeclare const _default: Readonly<_framefields_node_sdk_renderer0.NodeRendererPlugin>;\n//#endregion\nexport { _default as default };\n//# sourceMappingURL=renderer.d.mts.map"],"mappings":";;;;;;ASKA;AAOA;;iBT8CiBgC,cAAAA,CS7CS,YAAA,ET6CoBd,gBS7CpB,EAAA,GAAA,EAAA,MAAA,EAAA,gBAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,ET6CuFe,SS7CvF,EAAA,QAAA,CAAA,EAAA,MAAA,CAAA,ET6CsHR,OS7CtH,CAAA;EAChB,QAAA,ET6CEM,YS7CF,EAAA;EACP,UAAA,EAAA,MAAA;CAAM,CAAA;;;;;;;;;;cRZKM,YAAUE,SAASH;AD+CuB;;;;cE/C1CM,YAAUE,SAASH;AF+CuB;;;;cG/C1CM,YAAUE,SAASH;AH+CuB;;;;cI/C1CM,YAAUE,SAASH;AJ+CuB;;;;cK/C1CM,YAAUE,SAASH;AL+CuB;;;;cM/C1CM,YAAUE,SAASH;AN+CuB;;;;cO/C1CM,UAAUE,SAASH;AP+CuB;;;;;;;;AAAA;;;;;AAQ+F,UQhDtI,UAAA,CRgDsI;;;;ECvDzI7B,WAAAA,CAAAA,EAAsE,MAAA;;;KOexE,YAAA,IAAgB,cAAc;ANf5BK,UMiBG,WAAA,CNjBgBD;;;YMoBtB;ALvBuE;UK0BjE,gBAAA;;;EJvBHW;;;;ACHoE;;;;ACGpEU,iBEsLE,SAAA,CFtLiBD,OAAAA,EEuLvB,UFvLcG,EAAAA,GAAAA,EEwLlB,gBFxL0B,CAAA,EEyL7B,WFzL6B;;iBEiOhB,UAAA,SACP,gCACU;;ADtO+D;;;iBC6PlE,SAAA,SACP;;;;;;;ARpMQhC,USrDA,gBAAA,CTqDc;EAAed,UAAAA,CAAAA,EAAAA,MAAAA;;;;;iBS9C9B,eAAA,YACJ,cAAc,yBAChB,mBACP"}
@@ -1 +0,0 @@
1
- import{a as pe}from"./chunk-37EFVZWT.mjs";import{c as be}from"./chunk-2SJ4BBMT.mjs";import{c as ye,e as se}from"./chunk-NIRW77QA.mjs";import{i as ae,l as H}from"./chunk-24P6DAB3.mjs";import{D as ie}from"./chunk-XDMZP3E2.mjs";import{d as N,e as X}from"./chunk-BVF64D6H.mjs";X();X();X();function Se(t,e){return Math.round(t*e)}function oe(t,e,o={timeOffsetSec:0}){if(!t)return t;let{operation:y,metadata:c={},children:s=[]}=t,{timeOffsetSec:f,durationLimitMs:l}=o;if(!y)return{...t,children:(s||[]).map(r=>oe(r,e,o))};let p=y.timeline,b=p?.segments||[],h=H(t)?.durationMs??0;if(b.length>0){let r=b.reduce((x,u)=>{let S=u.endSec!=null?u.endSec-u.startSec:0,n=Math.max(1,Math.round(S*e));return x+n},0);r>0&&(h=r/e*1e3)}let d={...y},F=p?.startFrame??d.startFrame;if(typeof F=="number"){let r=Se(f,e);d.startFrame=F-r}let w={...c,durationMs:h},m=typeof F=="number"||d.op==="compose"?{timeOffsetSec:0,durationLimitMs:void 0}:{timeOffsetSec:f,durationLimitMs:l},T=(s||[]).map(r=>oe(r,e,m));return{metadata:w,operation:d,children:T}}var Ce=typeof N<"u"&&/^(debug|trace)$/i.test(N.env?.LOG_LEVEL??""),A={debug:(t,...e)=>{Ce&&(typeof t=="object"&&t!==null?console.info("[AudioExtractor]",t,...e):console.info(`[AudioExtractor] ${t}`,...e))},warn:(t,...e)=>{typeof t=="object"&&t!==null?console.warn("[AudioExtractor]",t,...e):console.warn(`[AudioExtractor] ${t}`,...e)},error:(t,...e)=>{typeof t=="object"&&t!==null?console.error("[AudioExtractor]",t,...e):console.error(`[AudioExtractor] ${t}`,...e)}},Ae=()=>{if(typeof window>"u")return Promise.resolve();let t=globalThis.scheduler;return typeof t?.yield=="function"?t.yield():new Promise(e=>setTimeout(e,0))},Ie=async(t=3e4)=>{await new Promise(o=>setTimeout(o,100));let e=Date.now();return new Promise(o=>{let y=()=>{let c=typeof window<"u"&&window.renderer_delayRenderHandles?window.renderer_delayRenderHandles:[],s=typeof globalThis<"u"?globalThis.__GATEWAI_DELAYS__:null,f=c.length>0,l=s instanceof Set&&s.size>0;if(!f&&!l){o();return}if(Date.now()-e>t){A.warn(`[AudioExtractor] waitForDelayRender timed out waiting for handles: ${JSON.stringify({browserHandles:c,globalDelays:s?Array.from(s):[]})}`),o();return}setTimeout(y,50)};y()})};async function Ue(t){let e=await Fe(t);return e?{channels:e.channels,sampleRate:e.sampleRate}:null}var De=.5;async function Fe(t,e){A.debug(`[AudioExtractor] decodeAudioSource started for url: ${t}`);try{if(typeof window<"u"&&typeof window.document<"u"&&!(typeof N<"u"&&N.versions&&N.versions.node)){A.debug(`[AudioExtractor] Browser detected. Fetching arrayBuffer for ${t}...`);let c=window.AudioContext||window.webkitAudioContext;if(!c)throw new Error("AudioContext is not supported in this browser");let s=new c;try{let f=await fetch(t);if(A.debug(`[AudioExtractor] Fetch response status for ${t}: ${f.status} (${f.statusText})`),!f.ok)throw new Error(`Failed to fetch audio source: ${f.statusText}`);let l=await f.arrayBuffer();A.debug(`[AudioExtractor] Fetched ${l.byteLength} bytes. Decoding audio data...`);let p=await s.decodeAudioData(l);A.debug(`[AudioExtractor] Decoded successfully: ${p.numberOfChannels} channels, sampleRate: ${p.sampleRate}, duration: ${p.duration}s`);let b=[];for(let h=0;h<p.numberOfChannels;h++)b.push(new Float32Array(p.getChannelData(h)));return{channels:b,sampleRate:p.sampleRate,startIndex:0,validFromSec:0,validToSec:Number.POSITIVE_INFINITY}}finally{s.close(),A.debug(`[AudioExtractor] AudioContext closed for ${t}`)}}let y=!1;try{A.debug(`[AudioExtractor] Server / Node.js detected. Acquiring from inputStore for ${t}...`);let c=await se.acquire(t);y=!0,A.debug("[AudioExtractor] inputStore acquired. Retrieving primary audio track...");let s=await c.getPrimaryAudioTrack();if(!s)return A.warn(`[AudioExtractor] No primary audio track found in input for ${t}`),null;let f=new ye(s),l=e?Math.max(0,e.startSec-De):0,p=f.samples(l,e?.endSec),b=[],h=0,d=48e3,F=1,w=null;A.debug(`[AudioExtractor] Starting mediabunny generator loop for ${t}...`);for await(let r of p){w===null&&(w=r.timestamp),d=r.sampleRate,F=r.numberOfChannels;let x=r.numberOfFrames;if(b.length===0)for(let u=0;u<F;u++)b.push([]);for(let u=0;u<F;u++){let S;try{let n=r.allocationSize({planeIndex:u,format:"f32-planar"});S=new Float32Array(n/4),r.copyTo(S,{planeIndex:u,format:"f32-planar"})}catch{let n=r.allocationSize({planeIndex:u});if(r.format==="s16"||r.format==="s16-planar"){let i=new Int16Array(n/2);r.copyTo(i,{planeIndex:u}),S=new Float32Array(i.length);for(let a=0;a<i.length;a++)S[a]=(i[a]??0)/32768}else if(r.format==="s32"||r.format==="s32-planar"){let i=new Int32Array(n/4);r.copyTo(i,{planeIndex:u}),S=new Float32Array(i.length);for(let a=0;a<i.length;a++)S[a]=(i[a]??0)/2147483648}else if(r.format==="u8"||r.format==="u8-planar"){let i=new Uint8Array(n);r.copyTo(i,{planeIndex:u}),S=new Float32Array(i.length);for(let a=0;a<i.length;a++)S[a]=((i[a]??128)-128)/128}else S=new Float32Array(n/4),r.copyTo(S,{planeIndex:u})}b[u].push(S)}h+=x,r.close()}if(A.debug(`[AudioExtractor] Generator loop finished. Decoded total frames: ${h}`),h===0||b.length===0)return null;let $=b.map(r=>{let x=new Float32Array(h),u=0;for(let S of r)x.set(S,u),u+=S.length;return x}),m=0;if(l>0&&w!==null){let r=await f.getSample(0),x=r?.timestamp??await s.getFirstTimestamp();r?.close(),m=Math.round((w-x)*d)}let T=!e||(m+h)/d<e.endSec;return{channels:$,sampleRate:d,startIndex:m,validFromSec:l>0&&e?e.startSec:0,validToSec:T||!e?Number.POSITIVE_INFINITY:e.endSec}}catch(c){if(c instanceof Error&&c.message.includes("Cannot open local media file"))throw c;if(typeof N<"u"&&N.versions?.node)try{let{execFileSync:s}=await import("./child_process-AIL2NBWS.mjs"),f=e?Math.round(Math.max(0,e.startSec)*48e3):0,l=f/48e3,p=s("ffmpeg",["-v","error",...l>0?["-ss",String(l)]:[],"-i",t,...e?["-t",String(e.endSec-l)]:[],"-f","f32le","-ar","48000","-ac","2","pipe:1"],{maxBuffer:Number.POSITIVE_INFINITY}),b=p.byteLength/4,h=b/2,d=new Float32Array(p.buffer,p.byteOffset,b),F=new Float32Array(h),w=new Float32Array(h);for(let m=0;m<h;m++)F[m]=d[m*2],w[m]=d[m*2+1];let $=!e||l+h/48e3<e.endSec;return{channels:[F,w],sampleRate:48e3,startIndex:f,validFromSec:l,validToSec:$||!e?Number.POSITIVE_INFINITY:e.endSec}}catch(s){A.warn({ffmpegErr:s},`[AudioExtractor] ffmpeg fallback decode failed for ${t}`)}return A.error({err:c},`[AudioExtractor] Failed to decode source ${t}`),null}finally{y&&se.release(t)}}catch(o){if(o instanceof Error&&o.message.includes("Cannot open local media file"))throw o;return A.error({err:o},`[AudioExtractor] Failed to decode source ${t}`),null}}async function we(t,e,o,y,c,s,f=0){let l=new Float32Array(c),b=e/o*y,h=1e5;for(let d=0;d<c;d++){d>0&&d%h===0&&await Ae();let F=s+d*b-f,w=Math.floor(F),$=Math.ceil(F);if(w<0){l[d]=0;continue}if(w>=t.length)break;let m=F-w,T=t[w]??0,r=$>=0&&$<t.length?t[$]??T:T,x=T+m*(r-T);l[d]=Number.isFinite(x)?x:0}return l}var Re=.05,$e=new Set(["Compositor","CompositorLayer"]);function ke(t,e,o){let y=Math.max(0,-o),c=Math.min(e.length,t.length-o);for(let s=y;s<c;s++)t[o+s]+=e[s]}var re=class{constructor(e){this.length=e}length;channels=null;get(){return this.channels??=[new Float32Array(this.length),new Float32Array(this.length)],this.channels}canAdopt(e,o){return this.channels===null&&o===0&&e.every(y=>y.length===this.length)}add(e,o){if(this.canAdopt(e,o)&&e[0]!==e[1]){this.channels=e;return}let y=this.get();for(let c=0;c<2;c++)ke(y[c],e[c],o)}};async function je(t,e,o=48e3,y,c){A.debug(`[AudioExtractor] mixAudioTracks started. FPS: ${e}, targetSampleRate: ${o}`),await Ie(),pe.registerSignalsFromComposition(c,t);let s=H(t)?.durationMs||1e3,f=s/1e3,l=Math.ceil(f*o);A.debug(`[AudioExtractor] Composition total duration: ${s}ms (${f}s). Total mixed samples to allocate: ${l}`);let p=new Map,b=new Set;async function h(n,i,a){if(b.has(n))return null;let g=p.get(n),M=g?.find(E=>E.validFromSec<=i&&E.validToSec>=a);if(M)return M;let I=await Fe(n,{startSec:i,endSec:a});return I?(g||(g=[],p.set(n,g)),g.push(I),I):(b.add(n),null)}let d=new WeakMap;function F(n){let i=d.get(n);if(i!==void 0)return i;let a=n.operation,g=!1;if(a?.op==="source"){let M=ae(n);g=M==="Audio"||M==="Video"}else a?.op&&!$e.has(a.op)&&ie.get(a.op)&&(g=!0);return!g&&n.children&&(g=n.children.some(M=>M&&F(M))),d.set(n,g),g}async function w(n,i,a,g,M,I){if(!n||!F(n))return null;let E=n.operation;if(!E){let k=H(n)?.durationMs??0,P=Math.round(k/1e3*e),W=I!==null?P>0?Math.min(I,P):I:P,L=Math.ceil(W/e*o);if(L<=0)return null;let J=new re(L);for(let G of n.children){let K=await w(G,i,a,g,M,W);if(K){let C=G.operation,ne=C?.startFrame??C?.timeline?.startFrame??0,D=Math.round(ne/e*o);J.add(K,D)}}return J.channels}let z=g*(E.volume??1)*(E.opacity===0?0:1)*(E.muted?0:1),ce=M,ge=E.startFrame??E.timeline?.startFrame??0,le=a+ge,ue=E.timeline?.segments||[],U=E,de=U.op==="CompositorLayer"?(U.mediaStartFrame??U.trimStartFrames??null)!==null?(U.mediaStartFrame??U.trimStartFrames??0)/e:Math.round((U.trimStartSec??0)*e)/e:0,Me=H(n)?.durationMs??0,te=Math.round(Me/1e3*e),xe=I!==null?te>0?Math.min(I,te):I:te,j=Math.ceil(xe/e*o);if(j<=0)return null;let q=new re(j),me=async(k,P)=>{let W=k?k.startSec:0,L=i+de+W,J=le+P,G=0;k?G=Math.max(1,Math.round(((k.endSec??0)-k.startSec)*e)):G=te;let K=I!==null?Math.min(I,G):G,C=Math.round(P/e*o);if(E.op==="source"){let D=ae(n),v=be(n);if(v.sourceUrl&&(D==="Audio"||D==="Video")&&z>0){let V=Math.max(.5,ce*(Number(v.speed)||1)),Y=Math.max(0,(Number(v.trimStartSec)||0)+L),Z=K/e,O=Math.min(j-C,Math.ceil(Z*o)),R=O>0&&C<j?await h(v.sourceUrl,Y,Y+O/o*V+Re):null;if(R){let fe=Math.round(Y*R.sampleRate),B=await we(R.channels[0],R.sampleRate,o,V,O,fe,R.startIndex),Q=R.channels.length>1?await we(R.channels[1],R.sampleRate,o,V,O,fe,R.startIndex):B,Ee=[B,Q];if(q.canAdopt(Ee,C)){if(z!==1){for(let _=0;_<O;_++)B[_]*=z;if(Q!==B)for(let _=0;_<O;_++)Q[_]*=z}q.channels=[B,Q===B?B.slice():Q]}else{let[_,Te]=q.get();for(let ee=0;ee<O;ee++){let he=C+ee;_[he]+=B[ee]*z,Te[he]+=Q[ee]*z}}}await Ae()}}if(n.children)for(let D of n.children){let v=await w(D,L,J,z,ce,K);if(v){let V=D.operation,Y=V?.startFrame??V?.timeline?.startFrame??0,Z=Math.round(Y/e*o);q.add(v,C+Z)}}let ne=ie.get(E.op);if(ne)try{let D=K/e,v=Math.min(j-C,Math.ceil(D*o));if(v>0&&C<j&&C>=0){let V=q.get().map(R=>R.subarray(C,C+v)),Y=E.op==="CompositorLayer"?le:0,Z=((J-Y)/e+L-de)*1e3,O=H(n)?.durationMs??void 0;await ne(V,o,n,{device:y,frame:J,fps:e,renderId:c,elapsedMs:Z,durationMs:O})}}catch(D){A.error({err:D},`[AudioExtractor] Custom plugin for operation '${E.op}' failed`)}};if(ue.length>0){let k=0;for(let P of ue){let W=(P.endSec??0)-P.startSec,L=Math.max(1,Math.round(W*e));await me(P,k),k+=L}}else await me(null,0);return q.channels}let $=oe(t,e),m=await w($,0,0,1,1,null),T=m?.every(n=>n.length===l)&&m[0]!==m[1]?m:[new Float32Array(l),new Float32Array(l)],[r,x]=T;if(m&&T!==m)for(let n=0;n<2;n++){let i=T[n],a=m[n],g=Math.min(a.length,i.length);for(let M=0;M<g;M++)i[M]=a[M]}p.clear();let u=0;for(let n=0;n<l;n++){let i=Math.abs(r[n]??0),a=Math.abs(x[n]??0);i>u&&(u=i),a>u&&(u=a)}let S=u>.95?.92/u:1;for(let n=0;n<l;n++){let i=(r[n]??0)*S,a=(x[n]??0)*S;r[n]=Number.isFinite(i)?Math.tanh(i):0,x[n]=Number.isFinite(a)?Math.tanh(a):0}return{channels:T,sampleRate:o}}export{Ue as a,je as b};
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderer-CNb-DG00.mjs","names":["resolve","resolve","HeadlessWebGPURenderer","fs","fs"],"sources":["../../renderer/dist/bootstrap-mediabunny-BgWuVtxx.mjs","../../renderer/dist/headless-webgpu-renderer-1QAxgoPn.mjs","../../renderer/dist/index.mjs","../src/renderer/framegrid.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { preloadCompositionFonts } from \"@framefields/renderers\";\nimport pino from \"pino\";\nimport * as webcodecs from \"@napi-rs/webcodecs\";\nimport { VideoFrame } from \"@napi-rs/webcodecs\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { audioRegistry, registerWebGPURenderer } from \"@framefields/node-sdk\";\nimport { registerMediabunnyServer } from \"@mediabunny/server\";\n\n//#region src/logger.ts\nconst rendererLogger = pino({\n\tlevel: typeof process !== \"undefined\" && process.env?.LOG_LEVEL || \"info\",\n\ttimestamp: pino.stdTimeFunctions.isoTime,\n\tbase: { component: \"renderer\" }\n});\n\n//#endregion\n//#region src/asset-preloader.ts\n/**\n* Preloads only the fonts (and emoji) a VirtualMediaData tree's text uses, so\n* typography renders correctly on Node.js without loading its media. Shared\n* with the browser preview; emoji need a font set with\n* `FontManager.registerEmojiFont()`.\n*/\nasync function preloadFonts(media, device = null) {\n\tif (!media) return;\n\tawait preloadCompositionFonts(media, device, (err, what) => rendererLogger.error(err, `[HeadlessMediaRenderer] Failed to preload ${what}`));\n}\n\n//#endregion\n//#region src/dma-staging-ring.ts\n/**\n* Pipelined Asynchronous DMA Staging Ring for WebGPU.\n*\n* Implements double-buffered (or N-buffered) GPU staging buffers to overlap\n* GPU render passes with asynchronous DMA host transfers and WebCodecs hardware encoding.\n* Eliminates GPU stalls by allowing Frame i+1 to execute on the GPU while Frame i\n* is asynchronously mapped and consumed by the hardware video encoder.\n*/\nvar DmaStagingRing = class {\n\twidth;\n\theight;\n\tcapacity;\n\tbytesPerRow;\n\tunpaddedBytesPerRow;\n\tbufferSize;\n\tformat;\n\tdevice;\n\tslots;\n\tisDestroyed = false;\n\tconstructor(device, options) {\n\t\tthis.device = device;\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.capacity = Math.max(2, options.capacity ?? 2);\n\t\tthis.format = options.format ?? \"rgba8unorm\";\n\t\tthis.unpaddedBytesPerRow = this.width * 4;\n\t\tconst rowAlignment = 256;\n\t\tthis.bytesPerRow = Math.ceil(this.unpaddedBytesPerRow / rowAlignment) * rowAlignment;\n\t\tthis.bufferSize = this.bytesPerRow * this.height;\n\t\tthis.slots = [];\n\t\tfor (let i = 0; i < this.capacity; i++) {\n\t\t\tconst buffer = device.createBuffer({\n\t\t\t\tsize: this.bufferSize,\n\t\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t\t});\n\t\t\tthis.slots.push({\n\t\t\t\tindex: i,\n\t\t\t\tbuffer,\n\t\t\t\tstatus: \"idle\",\n\t\t\t\tinFlightFrame: null,\n\t\t\t\tmapPromise: null\n\t\t\t});\n\t\t}\n\t}\n\t/**\n\t* Prepares the staging buffer slot for writing by ensuring any prior mapping\n\t* from a previous cycle has been completed and unmapped.\n\t*/\n\tasync prepareSlot(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) return;\n\t\tif (slot.status === \"mapping\" && slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status === \"mapped\") {\n\t\t\tslot.buffer.unmap();\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t}\n\t/**\n\t* Records a GPU-to-buffer DMA copy command into the provided command encoder.\n\t*/\n\tstageTexture(encoder, texture, frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.status === \"mapped\" || slot.status === \"mapping\") throw new Error(`Staging buffer slot ${slot.index} is busy (status: ${slot.status}) for frame ${frameIndex}. Call prepareSlot() before staging.`);\n\t\tencoder.copyTextureToBuffer({ texture }, {\n\t\t\tbuffer: slot.buffer,\n\t\t\tbytesPerRow: this.bytesPerRow\n\t\t}, [this.width, this.height]);\n\t\tslot.status = \"rendering\";\n\t\tslot.inFlightFrame = frameIndex;\n\t}\n\t/**\n\t* Initiates asynchronous DMA mapping on the slot for the specified frame.\n\t* Must be called immediately after submitting the command encoder to the device queue.\n\t*/\n\tscheduleMap(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tslot.status = \"mapping\";\n\t\tconst mapPromise = slot.buffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tslot.status = \"mapped\";\n\t\t});\n\t\tslot.mapPromise = mapPromise;\n\t\treturn mapPromise;\n\t}\n\t/**\n\t* Awaits asynchronous mapping and extracts pixels into a tightly packed Uint8Array.\n\t* The slot remains in the \"mapped\" state until releaseFrame() is called.\n\t*/\n\tasync readFramePixels(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status !== \"mapped\") throw new Error(`Staging slot ${slot.index} is not mapped (status: ${slot.status}) for frame ${frameIndex}`);\n\t\tconst mappedRange = slot.buffer.getMappedRange();\n\t\tconst sourceView = new Uint8Array(mappedRange);\n\t\tconst output = new Uint8Array(this.unpaddedBytesPerRow * this.height);\n\t\tif (this.bytesPerRow === this.unpaddedBytesPerRow) output.set(sourceView);\n\t\telse for (let y = 0; y < this.height; y++) {\n\t\t\tconst srcOffset = y * this.bytesPerRow;\n\t\t\tconst dstOffset = y * this.unpaddedBytesPerRow;\n\t\t\toutput.set(sourceView.subarray(srcOffset, srcOffset + this.unpaddedBytesPerRow), dstOffset);\n\t\t}\n\t\treturn output;\n\t}\n\t/**\n\t* Awaits asynchronous mapping, extracts pixels, and immediately unmaps the staging buffer,\n\t* returning the slot to \"idle\" state so it can be reused immediately.\n\t*/\n\tasync readAndReleaseFrame(frameIndex) {\n\t\tconst pixels = await this.readFramePixels(frameIndex);\n\t\tthis.releaseFrame(frameIndex);\n\t\treturn pixels;\n\t}\n\t/**\n\t* Directly reads the mapped staging buffer into a WebCodecs VideoFrame,\n\t* bypassing redundant intermediate JS allocations when row pitches align,\n\t* and immediately unmaps the buffer.\n\t*/\n\tasync readFrameToVideoFrame(frameIndex, timestampUs, colorSpace, inspect) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status !== \"mapped\") throw new Error(`Staging slot ${slot.index} is not mapped (status: ${slot.status}) for frame ${frameIndex}`);\n\t\tconst mappedRange = slot.buffer.getMappedRange();\n\t\tconst sourceView = new Uint8Array(mappedRange);\n\t\tlet pixelData;\n\t\tif (this.bytesPerRow === this.unpaddedBytesPerRow) pixelData = sourceView;\n\t\telse {\n\t\t\tpixelData = new Uint8Array(this.unpaddedBytesPerRow * this.height);\n\t\t\tfor (let y = 0; y < this.height; y++) {\n\t\t\t\tconst srcOffset = y * this.bytesPerRow;\n\t\t\t\tconst dstOffset = y * this.unpaddedBytesPerRow;\n\t\t\t\tpixelData.set(sourceView.subarray(srcOffset, srcOffset + this.unpaddedBytesPerRow), dstOffset);\n\t\t\t}\n\t\t}\n\t\tinspect?.(pixelData);\n\t\tconst vf = new VideoFrame(pixelData, {\n\t\t\tformat: \"RGBA\",\n\t\t\tcodedWidth: this.width,\n\t\t\tcodedHeight: this.height,\n\t\t\ttimestamp: timestampUs,\n\t\t\tcolorSpace: {\n\t\t\t\tprimaries: colorSpace?.primaries ?? \"bt709\",\n\t\t\t\ttransfer: colorSpace?.transfer ?? \"bt709\",\n\t\t\t\tmatrix: colorSpace?.matrix ?? \"bt709\",\n\t\t\t\tfullRange: colorSpace?.fullRange ?? false\n\t\t\t}\n\t\t});\n\t\tthis.releaseFrame(frameIndex);\n\t\treturn vf;\n\t}\n\t/**\n\t* Unmaps the staging buffer for the specified frame and marks the slot idle.\n\t*/\n\treleaseFrame(frameIndex) {\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) return;\n\t\tif (slot.status === \"mapped\") {\n\t\t\ttry {\n\t\t\t\tslot.buffer.unmap();\n\t\t\t} catch (_) {}\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t}\n\t/**\n\t* Returns current status info for each slot in the ring.\n\t*/\n\tgetSlotInfos() {\n\t\treturn this.slots.map((slot) => ({\n\t\t\tindex: slot.index,\n\t\t\tstatus: slot.status,\n\t\t\tinFlightFrame: slot.inFlightFrame\n\t\t}));\n\t}\n\t/**\n\t* Destroys all staging buffers and releases resources.\n\t*/\n\tdestroy() {\n\t\tif (this.isDestroyed) return;\n\t\tthis.isDestroyed = true;\n\t\tfor (const slot of this.slots) {\n\t\t\tif (slot.status === \"mapped\") try {\n\t\t\t\tslot.buffer.unmap();\n\t\t\t} catch (_) {}\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t\tthis.slots.length = 0;\n\t}\n\tcheckDestroyed() {\n\t\tif (this.isDestroyed) throw new Error(\"DmaStagingRing has been destroyed\");\n\t}\n};\n\n//#endregion\n//#region src/generated/node-renderers.ts\nconst BUILTIN_NODE_RENDERERS = [\n\t{\n\t\tpackageName: \"@framefields/node-lut\",\n\t\tops: [\"ApplyLUT\"],\n\t\tload: () => import(\"@framefields/node-lut/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-ascii\",\n\t\tops: [\"Ascii\"],\n\t\tload: () => import(\"@framefields/node-ascii/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-compressor\",\n\t\tops: [\"AudioCompressor\"],\n\t\tload: () => import(\"@framefields/node-audio-compressor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-delay\",\n\t\tops: [\"AudioDelay\"],\n\t\tload: () => import(\"@framefields/node-audio-delay/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-fade\",\n\t\tops: [\"AudioFade\"],\n\t\tload: () => import(\"@framefields/node-audio-fade/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-noise-gate\",\n\t\tops: [\"AudioNoiseGate\"],\n\t\tload: () => import(\"@framefields/node-audio-noise-gate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-parametric-eq\",\n\t\tops: [\"AudioParametricEq\"],\n\t\tload: () => import(\"@framefields/node-audio-parametric-eq/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-reverb\",\n\t\tops: [\"AudioReverb\"],\n\t\tload: () => import(\"@framefields/node-audio-reverb/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-signal-extractor\",\n\t\tops: [\"AudioSignalExtractor\"],\n\t\tload: () => import(\"@framefields/node-audio-signal-extractor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-blur\",\n\t\tops: [\"Blur\"],\n\t\tload: () => import(\"@framefields/node-blur/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-camera-parallax-3d\",\n\t\tops: [\"CameraParallax3D\"],\n\t\tload: () => import(\"@framefields/node-camera-parallax-3d/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-canvas-generator\",\n\t\tops: [\"CanvasGenerator\"],\n\t\tload: () => import(\"@framefields/node-canvas-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-channel-merger\",\n\t\tops: [\"ChannelMerger\"],\n\t\tload: () => import(\"@framefields/node-channel-merger/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-channel-splitter\",\n\t\tops: [\"ChannelSplitter\"],\n\t\tload: () => import(\"@framefields/node-channel-splitter/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-color-balance\",\n\t\tops: [\"ColorBalance\"],\n\t\tload: () => import(\"@framefields/node-color-balance/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-colorkey\",\n\t\tops: [\"ColorKey\"],\n\t\tload: () => import(\"@framefields/node-colorkey/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-compositor\",\n\t\tops: [\"Compositor\"],\n\t\tload: () => import(\"@framefields/node-compositor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-contour\",\n\t\tops: [\"Contour\"],\n\t\tload: () => import(\"@framefields/node-contour/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-corner-pin\",\n\t\tops: [\"CornerPin\"],\n\t\tload: () => import(\"@framefields/node-corner-pin/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-crop\",\n\t\tops: [\"Crop\"],\n\t\tload: () => import(\"@framefields/node-crop/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-crt\",\n\t\tops: [\"CRT\"],\n\t\tload: () => import(\"@framefields/node-crt/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-curves\",\n\t\tops: [\"Curves\"],\n\t\tload: () => import(\"@framefields/node-curves/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-datamosh\",\n\t\tops: [\"Datamosh\"],\n\t\tload: () => import(\"@framefields/node-datamosh/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-deflicker\",\n\t\tops: [\"TemporalDeflicker\", \"Deflicker\"],\n\t\tload: () => import(\"@framefields/node-deflicker/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-displacement-map\",\n\t\tops: [\"DisplacementMap\"],\n\t\tload: () => import(\"@framefields/node-displacement-map/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-dither\",\n\t\tops: [\"Dither\"],\n\t\tload: () => import(\"@framefields/node-dither/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-extract-frame\",\n\t\tops: [\"ExtractFrame\"],\n\t\tload: () => import(\"@framefields/node-extract-frame/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-extract-lut\",\n\t\tops: [\"ExtractLUT\"],\n\t\tload: () => import(\"@framefields/node-extract-lut/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-film-grain\",\n\t\tops: [\"FilmGrain\"],\n\t\tload: () => import(\"@framefields/node-film-grain/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-flip\",\n\t\tops: [\"Flip\"],\n\t\tload: () => import(\"@framefields/node-flip/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-gooey\",\n\t\tops: [\"Gooey\"],\n\t\tload: () => import(\"@framefields/node-gooey/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-gradient-map\",\n\t\tops: [\"GradientMap\"],\n\t\tload: () => import(\"@framefields/node-gradient-map/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-halftone-screen\",\n\t\tops: [\"HalftoneScreen\"],\n\t\tload: () => import(\"@framefields/node-halftone-screen/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-high-pass\",\n\t\tops: [\"HighPass\"],\n\t\tload: () => import(\"@framefields/node-high-pass/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-iridescence\",\n\t\tops: [\"Iridescence\"],\n\t\tload: () => import(\"@framefields/node-iridescence/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-kaleidoscope\",\n\t\tops: [\"Kaleidoscope\"],\n\t\tload: () => import(\"@framefields/node-kaleidoscope/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-kenburns\",\n\t\tops: [\"KenBurns\"],\n\t\tload: () => import(\"@framefields/node-kenburns/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-layer-style\",\n\t\tops: [\"LayerStyle\"],\n\t\tload: () => import(\"@framefields/node-layer-style/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-levels\",\n\t\tops: [\"Levels\"],\n\t\tload: () => import(\"@framefields/node-levels/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-liquify\",\n\t\tops: [\"Liquify\"],\n\t\tload: () => import(\"@framefields/node-liquify/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-mask-math\",\n\t\tops: [\"MaskMath\"],\n\t\tload: () => import(\"@framefields/node-mask-math/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-mesh-warp\",\n\t\tops: [\"MeshWarp\"],\n\t\tload: () => import(\"@framefields/node-mesh-warp/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-modulate\",\n\t\tops: [\"Modulate\"],\n\t\tload: () => import(\"@framefields/node-modulate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-noise-generator\",\n\t\tops: [\"NoiseGenerator\"],\n\t\tload: () => import(\"@framefields/node-noise-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-op-art\",\n\t\tops: [\"OpArt\"],\n\t\tload: () => import(\"@framefields/node-op-art/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-paint\",\n\t\tops: [\"Paint\"],\n\t\tload: () => import(\"@framefields/node-paint/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-painterly\",\n\t\tops: [\"Painterly\"],\n\t\tload: () => import(\"@framefields/node-painterly/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-particles\",\n\t\tops: [\"Particles\"],\n\t\tload: () => import(\"@framefields/node-particles/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-patch-heal\",\n\t\tops: [\"PatchHeal\"],\n\t\tload: () => import(\"@framefields/node-patch-heal/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-pixelate\",\n\t\tops: [\"Pixelate\"],\n\t\tload: () => import(\"@framefields/node-pixelate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-posterize\",\n\t\tops: [\"Posterize\"],\n\t\tload: () => import(\"@framefields/node-posterize/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-procedural-vfx\",\n\t\tops: [\"ProceduralVFX\"],\n\t\tload: () => import(\"@framefields/node-procedural-vfx/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-refine-edge\",\n\t\tops: [\"RefineEdge\"],\n\t\tload: () => import(\"@framefields/node-refine-edge/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-refraction-caustics\",\n\t\tops: [\"RefractionCaustics3D\"],\n\t\tload: () => import(\"@framefields/node-refraction-caustics/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-relight-3d\",\n\t\tops: [\"Relight3D\"],\n\t\tload: () => import(\"@framefields/node-relight-3d/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-resizer-scaler\",\n\t\tops: [\"ResizerScaler\"],\n\t\tload: () => import(\"@framefields/node-resizer-scaler/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-rgb-split\",\n\t\tops: [\"RGBSplit\"],\n\t\tload: () => import(\"@framefields/node-rgb-split/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-rotate\",\n\t\tops: [\"Rotate\"],\n\t\tload: () => import(\"@framefields/node-rotate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-selective-color\",\n\t\tops: [\"SelectiveColor\"],\n\t\tload: () => import(\"@framefields/node-selective-color/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-shadows-highlights\",\n\t\tops: [\"ShadowsHighlights\"],\n\t\tload: () => import(\"@framefields/node-shadows-highlights/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-shape-generator\",\n\t\tops: [\"ShapeGenerator\"],\n\t\tload: () => import(\"@framefields/node-shape-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-signal-gate\",\n\t\tops: [\"SignalGate\"],\n\t\tload: () => import(\"@framefields/node-signal-gate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-stereo-panning\",\n\t\tops: [\"StereoPanning\"],\n\t\tload: () => import(\"@framefields/node-stereo-panning/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-tile-offset\",\n\t\tops: [\"TileOffset\"],\n\t\tload: () => import(\"@framefields/node-tile-offset/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-toon\",\n\t\tops: [\"Toon\"],\n\t\tload: () => import(\"@framefields/node-toon/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-trails\",\n\t\tops: [\"Trails\"],\n\t\tload: () => import(\"@framefields/node-trails/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-unsharp-mask\",\n\t\tops: [\"UnsharpMask\"],\n\t\tload: () => import(\"@framefields/node-unsharp-mask/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-vignette\",\n\t\tops: [\"Vignette\"],\n\t\tload: () => import(\"@framefields/node-vignette/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-vision\",\n\t\tops: [\"Vision\"],\n\t\tload: () => import(\"@framefields/node-vision/renderer\")\n\t}\n];\n\n//#endregion\n//#region src/node-manifest.ts\n/**\n* The `framefields` block of a node package's `package.json`.\n*\n* This is the single declaration of a node's op: renderer discovery, the\n* effects generator (`scripts/generate-effects.ts`) and the skill catalog all\n* read it from here. There is deliberately no fallback that derives an op from\n* the package name. See `spec/sync-node.md` §5.1.\n*/\nconst NODE_KINDS = [\n\t\"effect\",\n\t\"audio\",\n\t\"source\",\n\t\"signal\",\n\t\"utility\"\n];\nconst IDENTIFIER = /^[A-Za-z][A-Za-z0-9]*$/;\nvar NodeManifestError = class extends Error {\n\tconstructor(problems) {\n\t\tsuper(`Invalid node manifest(s):\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n\t\tthis.problems = problems;\n\t\tthis.name = \"NodeManifestError\";\n\t}\n};\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n/**\n* Validates one parsed `package.json`. Returns the manifest, or the list of\n* problems that make it unusable. Never throws.\n*/\nfunction parseNodeManifest(pkg, dir, nodePath = dir) {\n\tconst problems = [];\n\tif (!isRecord(pkg)) return { problems: [`${dir}: package.json is not an object`] };\n\tconst block = pkg.framefields;\n\tif (!isRecord(block)) return { problems: [`${dir}: package.json has no \"framefields\" block (expected { \"type\": \"<Op>\", \"kind\": \"<kind>\" })`] };\n\tconst { type, kind, aliases, schema, className, factory, custom } = block;\n\tif (typeof type !== \"string\" || !IDENTIFIER.test(type)) problems.push(`${dir}: framefields.type must be an op identifier`);\n\tif (typeof kind !== \"string\" || !NODE_KINDS.includes(kind)) problems.push(`${dir}: framefields.kind must be one of ${NODE_KINDS.join(\", \")}`);\n\tif (aliases !== void 0 && !(Array.isArray(aliases) && aliases.every((a) => typeof a === \"string\" && IDENTIFIER.test(a)))) problems.push(`${dir}: framefields.aliases must be an array of op identifiers`);\n\tfor (const [key, value] of Object.entries({\n\t\tschema,\n\t\tclassName,\n\t\tfactory\n\t})) if (value !== void 0 && (typeof value !== \"string\" || !IDENTIFIER.test(value))) problems.push(`${dir}: framefields.${key} must be an identifier`);\n\tif (custom !== void 0 && typeof custom !== \"boolean\") problems.push(`${dir}: framefields.custom must be a boolean`);\n\tif (problems.length > 0) return { problems };\n\tconst exportsField = isRecord(pkg.exports) ? pkg.exports[\"./renderer\"] : null;\n\tconst legacy = isRecord(pkg.gatewai) ? pkg.gatewai : {};\n\treturn {\n\t\tproblems,\n\t\tmanifest: {\n\t\t\tdir,\n\t\t\tpath: nodePath,\n\t\t\tpackageName: typeof pkg.name === \"string\" ? pkg.name : dir,\n\t\t\ttype,\n\t\t\tkind,\n\t\t\taliases: aliases ?? [],\n\t\t\tschema,\n\t\t\tclassName,\n\t\t\tfactory,\n\t\t\tcustom: custom === true,\n\t\t\tenabled: legacy.enabled !== false,\n\t\t\trendererExports: isRecord(exportsField) ? exportsField : void 0\n\t\t}\n\t};\n}\n/**\n* Reads every `nodes/node-*` package and returns its manifest, sorted by\n* directory name. Throws a single {@link NodeManifestError} listing every\n* problem: a missing or malformed block, or an op/alias claimed twice.\n*/\nfunction loadNodeManifests(nodesDir) {\n\tconst problems = [];\n\tconst manifests = [];\n\tconst dirs = fs.readdirSync(nodesDir).filter((d) => d.startsWith(\"node-\") && fs.existsSync(path.join(nodesDir, d, \"package.json\"))).sort();\n\tfor (const dir of dirs) {\n\t\tconst nodePath = path.join(nodesDir, dir);\n\t\tlet pkg;\n\t\ttry {\n\t\t\tpkg = JSON.parse(fs.readFileSync(path.join(nodePath, \"package.json\"), \"utf-8\"));\n\t\t} catch (err) {\n\t\t\tproblems.push(`${dir}: package.json is not valid JSON (${String(err)})`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst parsed = parseNodeManifest(pkg, dir, nodePath);\n\t\tproblems.push(...parsed.problems);\n\t\tif (parsed.manifest) manifests.push(parsed.manifest);\n\t}\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const manifest of manifests) for (const op of [manifest.type, ...manifest.aliases]) {\n\t\tconst owner = owners.get(op);\n\t\tif (owner) problems.push(`${manifest.dir}: op \"${op}\" is already declared by ${owner}`);\n\t\telse owners.set(op, manifest.dir);\n\t}\n\tif (problems.length > 0) throw new NodeManifestError(problems);\n\treturn manifests;\n}\n\n//#endregion\n//#region src/dynamic-node-discovery.ts\nlet __filename = \"\";\nlet __dirname = \"\";\nif (typeof process !== \"undefined\" && !!process.versions?.node) {\n\t__filename = fileURLToPath(import.meta.url);\n\t__dirname = path.dirname(__filename);\n}\n/** Locates the workspace `nodes/` directory by climbing up from this file. */\nfunction findNodesDir(startDir = __dirname) {\n\tlet nodesDir = path.resolve(startDir, \"../../../nodes\");\n\tlet currentDir = startDir;\n\twhile (true) {\n\t\tif (fs.existsSync(nodesDir)) {\n\t\t\tif (fs.readdirSync(nodesDir).some((d) => d.startsWith(\"node-\") && fs.existsSync(path.join(nodesDir, d, \"package.json\")))) return nodesDir;\n\t\t}\n\t\tconst parentDir = path.dirname(currentDir);\n\t\tif (parentDir === currentDir) return null;\n\t\tcurrentDir = parentDir;\n\t\tnodesDir = path.resolve(currentDir, \"nodes\");\n\t}\n}\n/**\n* Picks the renderer entry file: development source in dev/vitest, otherwise\n* the bundled dist, falling back to source when dist has not been built.\n*/\nfunction resolveRendererEntry(nodePath, rendererExports) {\n\tconst exists = (rel) => !!rel && fs.existsSync(path.join(nodePath, rel));\n\tif ((process.env.NODE_ENV !== \"production\" || Boolean(process.env.VITEST)) && exists(rendererExports.development)) return rendererExports.development;\n\tconst bundled = rendererExports.import || rendererExports.default;\n\tif (exists(bundled)) return bundled;\n\tif (exists(rendererExports.development)) return rendererExports.development;\n}\nasync function registerNode(manifest) {\n\tif (!manifest.rendererExports) return;\n\tconst entry = resolveRendererEntry(manifest.path, manifest.rendererExports);\n\tif (!entry) return;\n\tconst mod = await import(pathToFileURL(path.join(manifest.path, entry)).href);\n\tregisterPlugin([manifest.type, ...manifest.aliases], mod?.default);\n}\nfunction registerPlugin(ops, rendererPlugin) {\n\tif (!rendererPlugin) return;\n\tif (rendererPlugin.WebGPURenderer) for (const op of ops) registerWebGPURenderer(op, rendererPlugin.WebGPURenderer);\n\tif (rendererPlugin.audioProcessor) for (const op of ops) audioRegistry.register(op, rendererPlugin.audioProcessor);\n}\n/**\n* Registers the renderers bundled with this package. They are imported by\n* package name, so they resolve from `node_modules` (or the published bundle)\n* and never depend on a `nodes/` directory on disk.\n*/\nasync function registerBuiltinNodeRenderers() {\n\tconst failed = [];\n\tawait Promise.all(BUILTIN_NODE_RENDERERS.map(async ({ packageName, ops, load }) => {\n\t\ttry {\n\t\t\tregisterPlugin(ops, (await load()).default);\n\t\t} catch (err) {\n\t\t\tfailed.push(packageName);\n\t\t\tconsole.error(`[HeadlessWebGPURenderer] Failed to load renderer ${packageName}:`, err);\n\t\t}\n\t}));\n\tif (failed.length === BUILTIN_NODE_RENDERERS.length) throw new Error(\"[HeadlessWebGPURenderer] No built-in node renderers could be loaded.\");\n}\n/**\n* Registers the built-in node renderers, then any extra nodes found in the\n* directory named by `FRAMEFIELDS_NODES_DIR` (local node development). A node in\n* that directory overrides the built-in renderer for the same op.\n*/\nasync function discoverAndRegisterNodeRenderers() {\n\tif (typeof process === \"undefined\" || !process.versions?.node) return;\n\tawait registerBuiltinNodeRenderers();\n\tconst extraDir = process.env.FRAMEFIELDS_NODES_DIR;\n\tif (!extraDir) return;\n\tconst nodesDir = path.resolve(extraDir);\n\tif (!fs.existsSync(nodesDir)) {\n\t\tconsole.warn(`[HeadlessWebGPURenderer] FRAMEFIELDS_NODES_DIR does not exist: ${nodesDir}`);\n\t\treturn;\n\t}\n\trendererLogger.debug(`[HeadlessWebGPURenderer] Discovering node renderers in: ${nodesDir}`);\n\tconst manifests = loadNodeManifests(nodesDir);\n\tfor (const manifest of manifests) {\n\t\tif (!manifest.enabled) continue;\n\t\ttry {\n\t\t\tawait registerNode(manifest);\n\t\t} catch (err) {\n\t\t\tconsole.error(`[HeadlessWebGPURenderer] Failed to discover renderer for node ${manifest.dir}:`, err);\n\t\t}\n\t}\n}\n\n//#endregion\n//#region src/video-encoders.ts\nlet nodeAv;\n/**\n* node-av as @mediabunny/server loads it, with software encoders as the\n* default. The patch and the HardwareContext instances returned to the server\n* must come from that exact module instance, so the file is resolved from the\n* server package and imported natively (a `require()` can be routed through\n* a loader such as tsx and produce a second copy).\n*/\nfunction loadNodeAv() {\n\tnodeAv ??= (async () => {\n\t\tconst av = await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(\"@mediabunny/server\")).resolve(\"node-av\")).href);\n\t\tpreferSoftwareEncoders(av);\n\t\treturn av;\n\t})();\n\treturn nodeAv;\n}\n/**\n* Software encoders to use per codec, best first. @mediabunny/server takes\n* `Codec.findEncoder(id)` as its software encoder, which returns whichever\n* encoder FFmpeg registered first. In node-av's linux-arm64 build that is a\n* hardware encoder (h264_rkmpp, hevc_rkmpp), which fails without Rockchip\n* hardware.\n*/\nconst SOFTWARE_ENCODERS = {\n\tAV_CODEC_ID_H264: [\"libx264\", \"libopenh264\"],\n\tAV_CODEC_ID_HEVC: [\"libx265\"],\n\tAV_CODEC_ID_VP8: [\"libvpx\"],\n\tAV_CODEC_ID_VP9: [\"libvpx-vp9\"],\n\tAV_CODEC_ID_AV1: [\n\t\t\"libsvtav1\",\n\t\t\"libaom-av1\",\n\t\t\"libdav1d\"\n\t]\n};\nlet patched = false;\n/** Makes `Codec.findEncoder` return a software encoder when one exists. */\nfunction preferSoftwareEncoders(av) {\n\tif (patched) return;\n\tpatched = true;\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const [constant, names] of Object.entries(SOFTWARE_ENCODERS)) {\n\t\tconst id = av[constant];\n\t\tif (typeof id === \"number\") byId.set(id, names);\n\t}\n\tconst findEncoder = av.Codec.findEncoder.bind(av.Codec);\n\tav.Codec.findEncoder = ((id) => {\n\t\tfor (const name of byId.get(id) ?? []) {\n\t\t\tconst codec = av.Codec.findEncoderByName(name);\n\t\t\tif (codec) return codec;\n\t\t}\n\t\treturn findEncoder(id);\n\t});\n}\n/**\n* Opens the encoder with the settings @mediabunny/server uses and encodes one\n* frame. A hardware encoder can be compiled in and still be unusable: no such\n* hardware (rkmpp on a non-Rockchip board), or a GPU without an encoder block\n* (NVIDIA A100/H100 have no NVENC).\n*/\nasync function encoderWorks(av, codec) {\n\tconst ctx = new av.CodecContext();\n\tconst frame = new av.Frame();\n\tconst packet = new av.Packet();\n\ttry {\n\t\tctx.allocContext3(codec);\n\t\tconst formats = codec.pixelFormats;\n\t\tconst pixelFormat = !formats || formats.includes(av.AV_PIX_FMT_YUV420P) ? av.AV_PIX_FMT_YUV420P : formats[0];\n\t\tctx.width = 256;\n\t\tctx.height = 256;\n\t\tctx.pixelFormat = pixelFormat;\n\t\tctx.timeBase = new av.Rational(1, 1e6);\n\t\tctx.framerate = new av.Rational(30, 1);\n\t\tctx.gopSize = 60;\n\t\tctx.bitRate = 1000000n;\n\t\tif (await ctx.open2() < 0) return false;\n\t\tframe.alloc();\n\t\tframe.format = pixelFormat;\n\t\tframe.width = 256;\n\t\tframe.height = 256;\n\t\tif (frame.getBuffer() < 0) return false;\n\t\tframe.pts = 0n;\n\t\tpacket.alloc();\n\t\tif (await ctx.sendFrame(frame) < 0) return false;\n\t\tif (await ctx.sendFrame(null) < 0) return false;\n\t\tfor (;;) {\n\t\t\tconst ret = await ctx.receivePacket(packet);\n\t\t\tif (ret >= 0) return true;\n\t\t\tif (ret !== av.AVERROR_EAGAIN) return false;\n\t\t}\n\t} catch {\n\t\treturn false;\n\t} finally {\n\t\tpacket.free();\n\t\tframe.free();\n\t\tctx.freeContext();\n\t}\n}\n/** True when the env turns hardware video encoding/decoding off. */\nfunction hardwareDisabled() {\n\tconst value = process.env.FRAMEFIELDS_HW_CODECS?.toLowerCase();\n\treturn value === \"0\" || value === \"off\" || value === \"false\";\n}\n/**\n* Returns the `hardwareContext` option for registerMediabunnyServer: the\n* platform's hardware context for codecs whose hardware encoder actually\n* works (NVENC, VideoToolbox, ...), and null otherwise, so that codec is\n* encoded in software. Each codec is tested once per process.\n*\n* The server calls this before it picks any encoder (unless the encoder is\n* created with \"prefer-software\"), so the software default is patched in by\n* then.\n*/\nfunction hardwareContextResolver(forceSoftware) {\n\tlet hw;\n\tconst verdicts = /* @__PURE__ */ new Map();\n\tconst resolve = async (codecId) => {\n\t\tconst av = await loadNodeAv();\n\t\tif (forceSoftware || hardwareDisabled()) return null;\n\t\tif (hw === void 0) hw = av.HardwareContext.auto();\n\t\tif (!hw) return null;\n\t\tconst encoder = hw.getEncoderCodec(codecId);\n\t\tif (!encoder) return hw;\n\t\tif (await encoderWorks(av, encoder)) {\n\t\t\trendererLogger.info({\n\t\t\t\tencoder: encoder.name,\n\t\t\t\tdevice: hw.deviceTypeName\n\t\t\t}, \"[video-encoders] Using hardware video encoder\");\n\t\t\treturn hw;\n\t\t}\n\t\trendererLogger.warn({\n\t\t\tencoder: encoder.name,\n\t\t\tdevice: hw.deviceTypeName\n\t\t}, \"[video-encoders] Hardware video encoder unusable; encoding in software\");\n\t\treturn null;\n\t};\n\treturn (codecId) => {\n\t\tlet verdict = verdicts.get(codecId);\n\t\tif (!verdict) {\n\t\t\tverdict = resolve(codecId).catch(async (err) => {\n\t\t\t\tawait loadNodeAv();\n\t\t\t\trendererLogger.warn({ err: err instanceof Error ? err.message : String(err) }, \"[video-encoders] Hardware probe failed; encoding in software\");\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tverdicts.set(codecId, verdict);\n\t\t}\n\t\treturn verdict;\n\t};\n}\n/**\n* Options for registerMediabunnyServer: hardware video codecs when they work,\n* software (libx264, libx265, libvpx, SVT-AV1) otherwise. `forceSoftware`\n* keeps every codec in software (used on AMD). Create encoders with\n* \"prefer-hardware\" so this decides; \"prefer-software\" skips it.\n*/\nfunction videoCodecServerOptions(forceSoftware) {\n\treturn { hardwareContext: hardwareContextResolver(forceSoftware) };\n}\n\n//#endregion\n//#region src/bootstrap-mediabunny.ts\nconst isAMD = () => {\n\tif (process.platform !== \"linux\") return false;\n\ttry {\n\t\tif (fs.existsSync(\"/sys/module/amdgpu\") || fs.existsSync(\"/dev/kfd\")) return true;\n\t\tconst drmDir = \"/sys/class/drm\";\n\t\tif (fs.existsSync(drmDir)) {\n\t\t\tconst files = fs.readdirSync(drmDir);\n\t\t\tfor (const file of files) {\n\t\t\t\tconst vendorPath = `${drmDir}/${file}/device/vendor`;\n\t\t\t\tif (fs.existsSync(vendorPath)) {\n\t\t\t\t\tif (fs.readFileSync(vendorPath, \"utf8\").trim() === \"0x1002\") return true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn false;\n};\nconst bootstrapMediabunny = () => {\n\tregisterMediabunnyServer(videoCodecServerOptions(isAMD()));\n\tfor (const key of Object.keys(webcodecs)) if (typeof globalThis[key] === \"undefined\") globalThis[key] = webcodecs[key];\n};\n\n//#endregion\nexport { NodeManifestError as a, DmaStagingRing as c, NODE_KINDS as i, preloadFonts as l, discoverAndRegisterNodeRenderers as n, loadNodeManifests as o, findNodesDir as r, parseNodeManifest as s, bootstrapMediabunny as t, rendererLogger as u };\n//# sourceMappingURL=bootstrap-mediabunny-BgWuVtxx.mjs.map","import { c as DmaStagingRing, l as preloadFonts, n as discoverAndRegisterNodeRenderers, t as bootstrapMediabunny, u as rendererLogger } from \"./bootstrap-mediabunny-BgWuVtxx.mjs\";\nimport path from \"node:path\";\nimport { exec, spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport { compositionStateStore, drawCompositionTree, mixAudioTracks } from \"@framefields/compositions\";\nimport { getMediaType, takeRenderDiagnostics, updateClockSignals } from \"@framefields/core\";\nimport { NodeSurfaceProvider, SlugFontCache, WebGPUAudioProcessor, clearAllVideoCache, ensureDevice, getRenderer2D, initHeadlessWebGPU, inputStore, lutStore, mediaDecoderCache, shaderStore, textureCache } from \"@framefields/webgpu-renderers\";\nimport { AudioSample, AudioSampleSource, FilePathTarget, Mp3OutputFormat, Mp4OutputFormat, Output, QUALITY_HIGH, QUALITY_LOW, QUALITY_VERY_HIGH, QUALITY_VERY_LOW, VideoSample, VideoSampleSource, WebMOutputFormat } from \"mediabunny\";\nimport sharp from \"sharp\";\nimport { Canvas, Image } from \"skia-canvas\";\n\n//#region src/video-qa.ts\nconst DEFAULTS = {\n\tblackPixelThreshold: .1,\n\tblackFrameRatio: .98,\n\tminBlackSec: .5,\n\tminFrozenSec: 2,\n\tsilenceDbfs: -60,\n\tminSilenceSec: 2,\n\tlufsTolerance: 1\n};\nconst SAMPLE_STEP = 4;\nconst FROZEN_DIFF = .25;\n/** Measures frames handed to it in order, as RGBA bytes. */\nvar FrameInspector = class {\n\tblackLuma;\n\tblackRatio;\n\tblack = [];\n\tsameAsPrevious = [];\n\tlumaSum = 0;\n\tprevious = null;\n\tconstructor(options = {}) {\n\t\tthis.blackLuma = (options.blackPixelThreshold ?? DEFAULTS.blackPixelThreshold) * 255;\n\t\tthis.blackRatio = options.blackFrameRatio ?? DEFAULTS.blackFrameRatio;\n\t}\n\tget frameCount() {\n\t\treturn this.black.length;\n\t}\n\tinspect(rgba, width, height) {\n\t\tconst cols = Math.ceil(width / SAMPLE_STEP);\n\t\tconst rows = Math.ceil(height / SAMPLE_STEP);\n\t\tconst luma = new Uint8Array(cols * rows);\n\t\tlet blackCount = 0;\n\t\tlet sum = 0;\n\t\tlet k = 0;\n\t\tfor (let y = 0; y < height; y += SAMPLE_STEP) {\n\t\t\tlet p = y * width * 4;\n\t\t\tfor (let x = 0; x < width; x += SAMPLE_STEP, p += SAMPLE_STEP * 4) {\n\t\t\t\tconst l = .2126 * rgba[p] + .7152 * rgba[p + 1] + .0722 * rgba[p + 2];\n\t\t\t\tluma[k++] = l;\n\t\t\t\tsum += l;\n\t\t\t\tif (l <= this.blackLuma) blackCount++;\n\t\t\t}\n\t\t}\n\t\tconst n = luma.length;\n\t\tthis.lumaSum += sum / n / 255;\n\t\tthis.black.push(blackCount / n >= this.blackRatio);\n\t\tlet same = false;\n\t\tif (this.previous && this.previous.length === n) {\n\t\t\tlet diff = 0;\n\t\t\tfor (let i = 0; i < n; i++) diff += Math.abs(luma[i] - this.previous[i]);\n\t\t\tsame = diff / n < FROZEN_DIFF;\n\t\t}\n\t\tthis.sameAsPrevious.push(same);\n\t\tthis.previous = luma;\n\t}\n\tstats(expectedFrames, encodedFrames, fps, width, height, options = {}) {\n\t\tconst minBlack = Math.max(1, Math.round((options.minBlackSec ?? DEFAULTS.minBlackSec) * fps));\n\t\tconst minFrozen = Math.max(2, Math.round((options.minFrozenSec ?? DEFAULTS.minFrozenSec) * fps));\n\t\tconst blackSegments = runs(this.black, minBlack).map(([a, b]) => ({\n\t\t\tstartSec: a / fps,\n\t\t\tendSec: b / fps\n\t\t}));\n\t\tconst frozenSegments = runs(this.sameAsPrevious, minFrozen - 1).map(([a, b]) => ({\n\t\t\tstartSec: (a - 1) / fps,\n\t\t\tendSec: b / fps\n\t\t}));\n\t\treturn {\n\t\t\texpectedFrames,\n\t\t\tencodedFrames,\n\t\t\tfps,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tmeanLuma: this.frameCount > 0 ? this.lumaSum / this.frameCount : 0,\n\t\t\tblackSegments,\n\t\t\tfrozenSegments\n\t\t};\n\t}\n};\n/** [start, end) index ranges where flags hold for at least minLength in a row. */\nfunction runs(flags, minLength) {\n\tconst out = [];\n\tlet start = -1;\n\tfor (let i = 0; i <= flags.length; i++) if (i < flags.length && flags[i]) {\n\t\tif (start < 0) start = i;\n\t} else if (start >= 0) {\n\t\tif (i - start >= minLength) out.push([start, i]);\n\t\tstart = -1;\n\t}\n\treturn out;\n}\nconst toDb = (power) => power > 0 ? 10 * Math.log10(power) : -Infinity;\n/** Measures a mixed audio track (one Float32Array per channel). */\nfunction analyzeAudio(channels, sampleRate, options = {}) {\n\tconst length = channels[0]?.length ?? 0;\n\tlet peak = 0;\n\tlet sumSquares = 0;\n\tlet clipped = 0;\n\tfor (const ch of channels) for (let i = 0; i < length; i++) {\n\t\tconst v = Math.abs(ch[i]);\n\t\tif (v > peak) peak = v;\n\t\tif (v >= .9999) clipped++;\n\t\tsumSquares += v * v;\n\t}\n\tconst total = length * Math.max(1, channels.length);\n\tconst silenceDbfs = options.silenceDbfs ?? DEFAULTS.silenceDbfs;\n\tconst window = Math.max(1, Math.round(sampleRate * .1));\n\tconst silent = [];\n\tfor (let start = 0; start < length; start += window) {\n\t\tconst end = Math.min(length, start + window);\n\t\tlet s = 0;\n\t\tfor (const ch of channels) for (let i = start; i < end; i++) s += ch[i] * ch[i];\n\t\tsilent.push(toDb(s / ((end - start) * channels.length)) < silenceDbfs);\n\t}\n\tconst silentSegments = runs(silent, Math.max(1, Math.round((options.minSilenceSec ?? DEFAULTS.minSilenceSec) / .1))).map(([a, b]) => ({\n\t\tstartSec: a * window / sampleRate,\n\t\tendSec: Math.min(length, b * window) / sampleRate\n\t}));\n\tconst peakDbfs = 20 * Math.log10(Math.max(peak, 1e-12));\n\treturn {\n\t\tsampleRate,\n\t\tchannels: channels.length,\n\t\tdurationSec: length / sampleRate,\n\t\tpeakDbfs,\n\t\trmsDbfs: toDb(sumSquares / Math.max(1, total)),\n\t\tintegratedLufs: peakDbfs < silenceDbfs ? null : integratedLoudness(channels, sampleRate),\n\t\tclippedSamples: clipped,\n\t\tsilentSegments\n\t};\n}\n/** BS.1770 K-weighting stage 1: +4 dB high shelf around 1.5 kHz (the head). */\nfunction highShelf(sampleRate) {\n\tconst A = 10 ** (4 / 40);\n\tconst w0 = 2 * Math.PI * 1500 / sampleRate;\n\tconst cos = Math.cos(w0);\n\tconst alpha = Math.sin(w0) / (2 / Math.SQRT2);\n\tconst sq = 2 * Math.sqrt(A) * alpha;\n\tconst a0 = A + 1 - (A - 1) * cos + sq;\n\treturn {\n\t\tb0: A * (A + 1 + (A - 1) * cos + sq) / a0,\n\t\tb1: -2 * A * (A - 1 + (A + 1) * cos) / a0,\n\t\tb2: A * (A + 1 + (A - 1) * cos - sq) / a0,\n\t\ta1: 2 * (A - 1 - (A + 1) * cos) / a0,\n\t\ta2: (A + 1 - (A - 1) * cos - sq) / a0\n\t};\n}\n/** BS.1770 K-weighting stage 2: 38 Hz high pass, Q 0.5 (the RLB curve). */\nfunction highPass(sampleRate) {\n\tconst w0 = 2 * Math.PI * 38 / sampleRate;\n\tconst cos = Math.cos(w0);\n\tconst alpha = Math.sin(w0) / (2 * .5);\n\tconst a0 = 1 + alpha;\n\treturn {\n\t\tb0: (1 + cos) / 2 / a0,\n\t\tb1: -(1 + cos) / a0,\n\t\tb2: (1 + cos) / 2 / a0,\n\t\ta1: -2 * cos / a0,\n\t\ta2: (1 - alpha) / a0\n\t};\n}\nfunction filter(input, f) {\n\tconst out = new Float32Array(input.length);\n\tlet x1 = 0;\n\tlet x2 = 0;\n\tlet y1 = 0;\n\tlet y2 = 0;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst x = input[i];\n\t\tconst y = f.b0 * x + f.b1 * x1 + f.b2 * x2 - f.a1 * y1 - f.a2 * y2;\n\t\tout[i] = y;\n\t\tx2 = x1;\n\t\tx1 = x;\n\t\ty2 = y1;\n\t\ty1 = y;\n\t}\n\treturn out;\n}\n/**\n* ITU-R BS.1770-4 integrated loudness (LUFS): K-weighted mean square in\n* 400 ms blocks with 75% overlap, gated at -70 LUFS and then at 10 LU below\n* the mean of what passed. Channels weigh 1 (stereo and mono layouts).\n*/\nfunction integratedLoudness(channels, sampleRate) {\n\tconst shelf = highShelf(sampleRate);\n\tconst hp = highPass(sampleRate);\n\tconst weighted = channels.map((ch) => filter(filter(ch, shelf), hp));\n\tconst length = weighted[0]?.length ?? 0;\n\tconst block = Math.round(.4 * sampleRate);\n\tconst hop = Math.round(.1 * sampleRate);\n\tif (length < block) return null;\n\tconst blockPower = [];\n\tfor (let start = 0; start + block <= length; start += hop) {\n\t\tlet power = 0;\n\t\tfor (const ch of weighted) {\n\t\t\tlet s = 0;\n\t\t\tfor (let i = start; i < start + block; i++) s += ch[i] * ch[i];\n\t\t\tpower += s / block;\n\t\t}\n\t\tblockPower.push(power);\n\t}\n\tconst lufs = (power) => -.691 + toDb(power);\n\tconst mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length;\n\tconst absolute = blockPower.filter((p) => lufs(p) > -70);\n\tif (absolute.length === 0) return null;\n\tconst relativeGate = lufs(mean(absolute)) - 10;\n\tconst gated = absolute.filter((p) => lufs(p) > relativeGate);\n\treturn gated.length > 0 ? lufs(mean(gated)) : null;\n}\n/** Turn measurements and document diagnostics into a report with issues. */\nfunction buildQaReport(parts) {\n\tconst { video, audio, options = {} } = parts;\n\tconst issues = [];\n\tconst at = (s) => `${s.startSec.toFixed(2)}–${s.endSec.toFixed(2)} s`;\n\tif (video) {\n\t\tif (video.encodedFrames !== video.expectedFrames) issues.push({\n\t\t\tseverity: \"error\",\n\t\t\tcode: \"frames_missing\",\n\t\t\tmessage: `${video.encodedFrames} of ${video.expectedFrames} frames were encoded`\n\t\t});\n\t\tfor (const s of video.blackSegments) issues.push({\n\t\t\tseverity: \"warning\",\n\t\t\tcode: \"black_frames\",\n\t\t\tmessage: `Black frames at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t\tfor (const s of video.frozenSegments) issues.push({\n\t\t\tseverity: \"info\",\n\t\t\tcode: \"frozen_video\",\n\t\t\tmessage: `Picture does not change at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t}\n\tif (audio) if (audio.integratedLufs === null) issues.push({\n\t\tseverity: \"info\",\n\t\tcode: \"audio_silent\",\n\t\tmessage: \"The audio track is silent\"\n\t});\n\telse {\n\t\tif (audio.clippedSamples > 0) issues.push({\n\t\t\tseverity: \"warning\",\n\t\t\tcode: \"audio_clipping\",\n\t\t\tmessage: `${audio.clippedSamples} audio sample(s) at or beyond full scale (peak ${audio.peakDbfs.toFixed(1)} dBFS)`\n\t\t});\n\t\tfor (const s of audio.silentSegments) issues.push({\n\t\t\tseverity: \"info\",\n\t\t\tcode: \"audio_silence\",\n\t\t\tmessage: `Silence at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t\tif (options.targetLufs !== void 0) {\n\t\t\tconst off = audio.integratedLufs - options.targetLufs;\n\t\t\tconst tolerance = options.lufsTolerance ?? DEFAULTS.lufsTolerance;\n\t\t\tif (Math.abs(off) > tolerance) issues.push({\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tcode: \"loudness_off_target\",\n\t\t\t\tmessage: `Integrated loudness ${audio.integratedLufs.toFixed(1)} LUFS is ${Math.abs(off).toFixed(1)} LU ${off > 0 ? \"above\" : \"below\"} the ${options.targetLufs} LUFS target`\n\t\t\t});\n\t\t}\n\t}\n\tfor (const d of parts.diagnostics ?? []) issues.push({\n\t\tseverity: d.severity,\n\t\tcode: d.code,\n\t\tmessage: d.message,\n\t\t...d.layerId !== void 0 && { layerId: d.layerId }\n\t});\n\treturn {\n\t\tpassed: !issues.some((i) => i.severity !== \"info\"),\n\t\t...video && { video },\n\t\t...audio && { audio },\n\t\tissues\n\t};\n}\n/** A short human- and agent-readable summary of a report. */\nfunction formatQaReport(report) {\n\tconst lines = [`QA ${report.passed ? \"passed\" : \"FAILED\"}`];\n\tconst v = report.video;\n\tif (v) lines.push(` video: ${v.encodedFrames}/${v.expectedFrames} frames, ${v.width}x${v.height} @ ${v.fps} fps, mean luma ${v.meanLuma.toFixed(2)}`);\n\tconst a = report.audio;\n\tif (a) {\n\t\tconst lufs = a.integratedLufs === null ? \"silent\" : `${a.integratedLufs.toFixed(1)} LUFS`;\n\t\tlines.push(` audio: ${a.durationSec.toFixed(2)} s, ${lufs}, peak ${a.peakDbfs.toFixed(1)} dBFS, rms ${a.rmsDbfs.toFixed(1)} dBFS`);\n\t}\n\tfor (const i of report.issues) lines.push(` ${i.severity.padEnd(7)} ${i.code}: ${i.message}`);\n\treturn lines.join(\"\\n\");\n}\n\n//#endregion\n//#region src/zero-copy-webcodecs-pipeline.ts\n/**\n* High-performance hardware video encoding pipeline integrating WebGPU textures with WebCodecs.\n*\n* Provides:\n* 1. Direct hardware acceleration when running with WebCodecs / OffscreenCanvas.\n* 2. Pipelined asynchronous double-buffered DMA staging ring for headless Node.js (Dawn native),\n* allowing GPU Frame i+1 rendering to overlap concurrently with Frame i hardware encoding.\n*/\nvar ZeroCopyWebCodecsPipeline = class {\n\twidth;\n\theight;\n\tfps;\n\tringCapacity;\n\tdevice;\n\tvideoSource;\n\tstagingRing;\n\tcolorSpace;\n\tdirectCanvasSource;\n\tonFrame;\n\tinFlightFrames = [];\n\tcycleStartTimes = /* @__PURE__ */ new Map();\n\ttotalFramesEnqueued = 0;\n\ttotalFramesEncoded = 0;\n\ttotalGpuSubmitTimeMs = 0;\n\ttotalEncodeTimeMs = 0;\n\ttotalCycleTimeMs = 0;\n\tmaxCycleTimeMs = 0;\n\tminCycleTimeMs = Number.POSITIVE_INFINITY;\n\tpipelineStartTime = 0;\n\tconstructor(device, options) {\n\t\tthis.device = device;\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.fps = options.fps;\n\t\tthis.videoSource = options.videoSource;\n\t\tthis.ringCapacity = Math.max(2, options.ringCapacity ?? 2);\n\t\tthis.colorSpace = options.colorSpace;\n\t\tthis.directCanvasSource = options.directCanvasSource;\n\t\tthis.onFrame = options.onFrame;\n\t\tthis.stagingRing = new DmaStagingRing(device, {\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tcapacity: this.ringCapacity\n\t\t});\n\t\tthis.pipelineStartTime = performance.now();\n\t}\n\t/**\n\t* Returns true if direct zero-copy from an OffscreenCanvas or texture is active.\n\t*/\n\tcanDirectZeroCopy() {\n\t\treturn this.directCanvasSource !== void 0 && this.directCanvasSource !== null;\n\t}\n\t/**\n\t* Enqueues a rendered GPU texture frame into the pipeline.\n\t*\n\t* Uses double-buffered DMA staging: if the staging ring has reached capacity,\n\t* the oldest in-flight frame is asynchronously consumed and added to the video encoder\n\t* before staging the new frame, guaranteeing constant bounded VRAM usage and zero GPU stalls.\n\t*/\n\tasync enqueueFrame(frameIndex, targetTexture, encoder) {\n\t\tconst cycleStartTime = performance.now();\n\t\tif (this.inFlightFrames.length >= this.ringCapacity) {\n\t\t\tconst oldestFrame = this.inFlightFrames.shift();\n\t\t\tif (oldestFrame !== void 0) await this.consumeAndEncode(oldestFrame);\n\t\t}\n\t\tif (this.canDirectZeroCopy()) {\n\t\t\tconst gpuStart = performance.now();\n\t\t\tthis.device.queue.submit([encoder.finish()]);\n\t\t\tthis.totalGpuSubmitTimeMs += performance.now() - gpuStart;\n\t\t\tthis.cycleStartTimes.set(frameIndex, cycleStartTime);\n\t\t\tthis.totalFramesEnqueued++;\n\t\t\tawait this.consumeAndEncode(frameIndex);\n\t\t} else {\n\t\t\tawait this.stagingRing.prepareSlot(frameIndex);\n\t\t\tthis.stagingRing.stageTexture(encoder, targetTexture, frameIndex);\n\t\t\tconst gpuStart = performance.now();\n\t\t\tthis.device.queue.submit([encoder.finish()]);\n\t\t\tthis.totalGpuSubmitTimeMs += performance.now() - gpuStart;\n\t\t\tthis.stagingRing.scheduleMap(frameIndex);\n\t\t\tthis.inFlightFrames.push(frameIndex);\n\t\t\tthis.cycleStartTimes.set(frameIndex, cycleStartTime);\n\t\t\tthis.totalFramesEnqueued++;\n\t\t}\n\t}\n\t/**\n\t* Drains all remaining in-flight frames in the pipeline, ensuring every enqueued\n\t* frame has been encoded and added to the video sample source.\n\t*/\n\tasync drain() {\n\t\twhile (this.inFlightFrames.length > 0) {\n\t\t\tconst frameIndex = this.inFlightFrames.shift();\n\t\t\tif (frameIndex !== void 0) await this.consumeAndEncode(frameIndex);\n\t\t}\n\t}\n\t/**\n\t* Returns runtime throughput, latency, and pipeline statistics.\n\t*/\n\tgetStats() {\n\t\tconst totalElapsedMs = performance.now() - this.pipelineStartTime;\n\t\tconst throughputFps = totalElapsedMs > 0 ? this.totalFramesEncoded / totalElapsedMs * 1e3 : 0;\n\t\tconst avgSubmit = this.totalFramesEnqueued > 0 ? this.totalGpuSubmitTimeMs / this.totalFramesEnqueued : 0;\n\t\tconst avgEncode = this.totalFramesEncoded > 0 ? this.totalEncodeTimeMs / this.totalFramesEncoded : 0;\n\t\tconst avgCycle = this.totalFramesEncoded > 0 ? this.totalCycleTimeMs / this.totalFramesEncoded : 0;\n\t\treturn {\n\t\t\ttotalFramesEnqueued: this.totalFramesEnqueued,\n\t\t\ttotalFramesEncoded: this.totalFramesEncoded,\n\t\t\taverageGpuSubmitTimeMs: avgSubmit,\n\t\t\taverageEncodeTimeMs: avgEncode,\n\t\t\taverageCycleTimeMs: avgCycle,\n\t\t\tmaxCycleTimeMs: this.maxCycleTimeMs,\n\t\t\tminCycleTimeMs: Number.isFinite(this.minCycleTimeMs) ? this.minCycleTimeMs : 0,\n\t\t\tthroughputFps,\n\t\t\tringCapacity: this.ringCapacity,\n\t\t\tisDirectZeroCopy: this.canDirectZeroCopy()\n\t\t};\n\t}\n\t/**\n\t* Destroys the pipeline and releases all staging buffers.\n\t*/\n\tdestroy() {\n\t\tthis.inFlightFrames.length = 0;\n\t\tthis.cycleStartTimes.clear();\n\t\tthis.stagingRing.destroy();\n\t}\n\tasync consumeAndEncode(frameIndex) {\n\t\tconst encodeStart = performance.now();\n\t\tconst timestampUs = frameIndex / this.fps * 1e6;\n\t\tif (this.canDirectZeroCopy()) {\n\t\t\tconst sample = new VideoSample(this.directCanvasSource, {\n\t\t\t\tduration: 1 / this.fps,\n\t\t\t\ttimestamp: frameIndex / this.fps\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tawait this.videoSource.add(sample);\n\t\t\t} finally {\n\t\t\t\tsample.close();\n\t\t\t}\n\t\t} else {\n\t\t\tconst onFrame = this.onFrame;\n\t\t\tconst vf = await this.stagingRing.readFrameToVideoFrame(frameIndex, timestampUs, this.colorSpace, onFrame && ((rgba) => onFrame(rgba, frameIndex)));\n\t\t\ttry {\n\t\t\t\tconst sample = new VideoSample(vf, {\n\t\t\t\t\tduration: 1 / this.fps,\n\t\t\t\t\ttimestamp: frameIndex / this.fps\n\t\t\t\t});\n\t\t\t\ttry {\n\t\t\t\t\tawait this.videoSource.add(sample);\n\t\t\t\t} finally {\n\t\t\t\t\tsample.close();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tvf.close();\n\t\t\t}\n\t\t}\n\t\tconst now = performance.now();\n\t\tthis.totalEncodeTimeMs += now - encodeStart;\n\t\tthis.totalFramesEncoded++;\n\t\tconst cycleStart = this.cycleStartTimes.get(frameIndex);\n\t\tif (cycleStart !== void 0) {\n\t\t\tconst cycleDuration = now - cycleStart;\n\t\t\tthis.cycleStartTimes.delete(frameIndex);\n\t\t\tthis.totalCycleTimeMs += cycleDuration;\n\t\t\tif (cycleDuration > this.maxCycleTimeMs) this.maxCycleTimeMs = cycleDuration;\n\t\t\tif (cycleDuration < this.minCycleTimeMs) this.minCycleTimeMs = cycleDuration;\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/headless-webgpu-renderer.ts\nglobalThis[Symbol.for(\"framefields.vision.backend\")] = (info) => {\n\trendererLogger.info(info, info.backend === \"webgpu\" ? \"[vision] Inference on the GPU (WebGPU)\" : `[vision] Inference on the ${info.backend.toUpperCase()}`);\n};\nasync function convertMp4ToGif(inputMp4Path, outputGifPath) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst ffmpeg = spawn(\"ffmpeg\", [\n\t\t\t\"-i\",\n\t\t\tinputMp4Path,\n\t\t\t\"-vf\",\n\t\t\t\"split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\",\n\t\t\t\"-y\",\n\t\t\toutputGifPath\n\t\t]);\n\t\tlet errorOutput = \"\";\n\t\tffmpeg.stderr.on(\"data\", (data) => {\n\t\t\terrorOutput += data.toString();\n\t\t});\n\t\tffmpeg.on(\"close\", async (code) => {\n\t\t\tif (code === 0) resolve();\n\t\t\telse {\n\t\t\t\trendererLogger.error({\n\t\t\t\t\tcode,\n\t\t\t\t\terr: errorOutput\n\t\t\t\t}, \"[convertMp4ToGif] ffmpeg conversion failed\");\n\t\t\t\treject(/* @__PURE__ */ new Error(`ffmpeg exited with code ${code}: ${errorOutput}`));\n\t\t\t}\n\t\t});\n\t\tffmpeg.on(\"error\", (err) => {\n\t\t\trendererLogger.error({ err }, \"[convertMp4ToGif] ffmpeg spawn error\");\n\t\t\treject(err);\n\t\t});\n\t});\n}\nbootstrapMediabunny();\nconst globalObj = globalThis;\nif (typeof globalThis !== \"undefined\") {\n\tglobalObj.__IS_HEADLESS_RENDERER__ = true;\n\tglobalObj.__GATEWAI_DELAYS__ ??= /* @__PURE__ */ new Set();\n}\nif (typeof globalThis.requestAnimationFrame === \"undefined\") {\n\tglobalObj.requestAnimationFrame = (cb) => setTimeout(cb, 0);\n\tglobalObj.cancelAnimationFrame = (id) => clearTimeout(id);\n}\nconst dummyDomElement = {\n\tclientWidth: 1920,\n\tclientHeight: 1080,\n\tgetBoundingClientRect: () => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: 1920,\n\t\tbottom: 1080,\n\t\twidth: 1920,\n\t\theight: 1080\n\t}),\n\tstyle: {},\n\tappendChild: () => {},\n\tremoveChild: () => {},\n\taddEventListener: () => {},\n\tremoveEventListener: () => {},\n\tgetAttribute: () => null\n};\nif (typeof globalThis.OffscreenCanvas === \"undefined\") globalObj.OffscreenCanvas = Canvas;\nif (typeof globalThis.HTMLCanvasElement === \"undefined\") globalObj.HTMLCanvasElement = Canvas;\nif (typeof globalThis.Image === \"undefined\") globalObj.Image = Image;\nif (typeof globalThis.window === \"undefined\") globalObj.window = globalThis;\nif (!globalThis.location) globalObj.location = new URL(\"http://localhost\");\nif (typeof globalThis.IntersectionObserver === \"undefined\") globalObj.IntersectionObserver = class IntersectionObserver {\n\tobserve() {}\n\tunobserve() {}\n\tdisconnect() {}\n};\nif (typeof globalThis.document === \"undefined\") globalObj.document = {\n\tcreateElement: (tag) => {\n\t\tif (tag === \"canvas\") return new Canvas(1, 1);\n\t\treturn { ...dummyDomElement };\n\t},\n\tgetElementsByTagName: () => [],\n\tdocumentElement: dummyDomElement,\n\tbody: dummyDomElement\n};\nelse {\n\tconst docObj = globalThis.document;\n\tif (typeof docObj.getElementsByTagName === \"undefined\") docObj.getElementsByTagName = () => [];\n\tdocObj.documentElement ??= dummyDomElement;\n\tdocObj.body ??= dummyDomElement;\n}\nconst skiaProto = Canvas.prototype;\nif (typeof skiaProto.getBoundingClientRect === \"undefined\") skiaProto.getBoundingClientRect = function() {\n\tconst width = this.width || 512;\n\tconst height = this.height || 512;\n\treturn {\n\t\tx: 0,\n\t\ty: 0,\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: width,\n\t\tbottom: height,\n\t\twidth,\n\t\theight\n\t};\n};\nif (!(\"style\" in skiaProto)) Object.defineProperty(skiaProto, \"style\", {\n\tget() {\n\t\tthis._style ??= {};\n\t\treturn this._style;\n\t},\n\tconfigurable: true\n});\nif (!(\"clientWidth\" in skiaProto)) Object.defineProperty(skiaProto, \"clientWidth\", {\n\tget() {\n\t\treturn this.width || 512;\n\t},\n\tconfigurable: true\n});\nif (!(\"clientHeight\" in skiaProto)) Object.defineProperty(skiaProto, \"clientHeight\", {\n\tget() {\n\t\treturn this.height || 512;\n\t},\n\tconfigurable: true\n});\nif (!(\"parentElement\" in skiaProto)) Object.defineProperty(skiaProto, \"parentElement\", {\n\tget() {\n\t\treturn dummyDomElement;\n\t},\n\tconfigurable: true\n});\nif (typeof skiaProto.addEventListener === \"undefined\") skiaProto.addEventListener = () => {};\nif (typeof skiaProto.removeEventListener === \"undefined\") skiaProto.removeEventListener = () => {};\nif (typeof skiaProto.getAttribute === \"undefined\") skiaProto.getAttribute = () => null;\nconst CPU_COUNT = os.cpus().length;\nconst TOTAL_WORKER_BUDGET = Math.max(1, CPU_COUNT - 3);\nconst MAX_CONCURRENT_RENDERS = Math.max(1, Math.min(3, Math.floor(TOTAL_WORKER_BUDGET / 3)));\nconst QUEUE_TIMEOUT_MS = 120 * 6e4;\nvar RenderSemaphore = class {\n\t_running = 0;\n\t_max;\n\t_queue = [];\n\tconstructor(max) {\n\t\tthis._max = max;\n\t}\n\tacquire(timeoutMs = QUEUE_TIMEOUT_MS) {\n\t\tif (this._running < this._max) {\n\t\t\tthis._running++;\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tconst idx = this._queue.findIndex((e) => e.resolve === resolve);\n\t\t\t\tif (idx !== -1) this._queue.splice(idx, 1);\n\t\t\t\treject(/* @__PURE__ */ new Error(`Render queue timeout after ${timeoutMs}ms (${this._queue.length} queued, ${this._running}/${this._max} active)`));\n\t\t\t}, timeoutMs);\n\t\t\tthis._queue.push({\n\t\t\t\tresolve,\n\t\t\t\treject,\n\t\t\t\ttimer\n\t\t\t});\n\t\t});\n\t}\n\trelease() {\n\t\tif (this._queue.length > 0) {\n\t\t\tconst next = this._queue.shift();\n\t\t\tclearTimeout(next.timer);\n\t\t\tnext.resolve();\n\t\t} else this._running--;\n\t}\n\tget stats() {\n\t\treturn {\n\t\t\tactive: this._running,\n\t\t\tqueued: this._queue.length,\n\t\t\tmax: this._max\n\t\t};\n\t}\n};\nconst renderSemaphore = new RenderSemaphore(MAX_CONCURRENT_RENDERS);\n/**\n* Ids for still renders without a caller id. Media caches (video decoders,\n* last-good frames) are keyed by render id, so a fresh id per still would\n* open a new decoder for every frame of a frame-by-frame export. Stills\n* borrow an idle id instead: consecutive stills reuse it (and its decoders);\n* concurrent stills get distinct ones.\n*/\nconst idleStillIds = [];\nconst takeStillId = () => idleStillIds.pop() ?? `img-${randomUUID()}`;\nconst returnStillId = (id) => {\n\tidleStillIds.push(id);\n};\nfunction toEvenDimension(n) {\n\tconst v = Math.round(n);\n\treturn v % 2 === 0 ? v : v + 1;\n}\nfunction resolveQuality(quality) {\n\tswitch (quality) {\n\t\tcase \"very_low\": return QUALITY_VERY_LOW;\n\t\tcase \"low\": return QUALITY_LOW;\n\t\tcase \"high\": return QUALITY_HIGH;\n\t\tcase \"very_high\": return QUALITY_VERY_HIGH;\n\t\tdefault: return QUALITY_VERY_HIGH;\n\t}\n}\nlet cachedVramUsage = \"N/A\";\nlet vramProbeInFlight = false;\nfunction refreshVramUsage() {\n\tif (vramProbeInFlight) return;\n\tvramProbeInFlight = true;\n\texec(\"nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits\", {\n\t\tencoding: \"utf-8\",\n\t\ttimeout: 2e3\n\t}, (err, stdout) => {\n\t\tvramProbeInFlight = false;\n\t\tif (err || !stdout) return;\n\t\tconst [used, total] = stdout.trim().split(\",\").map((s) => s.trim());\n\t\tif (used && total) cachedVramUsage = `${used}MB / ${total}MB`;\n\t});\n}\nfunction getVramUsage() {\n\treturn cachedVramUsage;\n}\nconst DEFAULT_RING_CAPACITY = 2;\nconst MIN_RING_CAPACITY = 2;\nconst MAX_RING_CAPACITY = 8;\nfunction resolveRingCapacity(explicit) {\n\tconst fromEnv = Number(process.env.FRAMEFIELDS_RING_CAPACITY);\n\tconst requested = explicit ?? (Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : NaN);\n\tif (!Number.isFinite(requested) || requested <= 0) return DEFAULT_RING_CAPACITY;\n\treturn Math.max(MIN_RING_CAPACITY, Math.min(MAX_RING_CAPACITY, Math.floor(requested)));\n}\nvar NodeSurfacePool = class {\n\tidle = [];\n\tmaxIdle = 2;\n\tacquire(device, width, height) {\n\t\tconst index = this.idle.findIndex((entry) => entry.device === device && entry.surface.width === width && entry.surface.height === height);\n\t\tif (index >= 0) {\n\t\t\tconst [entry] = this.idle.splice(index, 1);\n\t\t\tif (entry) return entry.surface;\n\t\t}\n\t\tfor (let i = this.idle.length - 1; i >= 0; i--) {\n\t\t\tconst entry = this.idle[i];\n\t\t\tif (entry && entry.device !== device) {\n\t\t\t\tthis.idle.splice(i, 1);\n\t\t\t\ttry {\n\t\t\t\t\tentry.surface.destroy();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t\treturn new NodeSurfaceProvider(device, width, height);\n\t}\n\trelease(device, surface) {\n\t\tif (this.idle.length >= this.maxIdle) {\n\t\t\ttry {\n\t\t\t\tsurface.destroy();\n\t\t\t} catch {}\n\t\t\treturn;\n\t\t}\n\t\tthis.idle.push({\n\t\t\tdevice,\n\t\t\tsurface\n\t\t});\n\t}\n\tdestroy() {\n\t\tfor (const entry of this.idle.splice(0)) try {\n\t\t\tentry.surface.destroy();\n\t\t} catch {}\n\t}\n};\nconst nodeSurfacePool = new NodeSurfacePool();\nfunction formatLutAsCube(lut) {\n\tconst lines = [\n\t\t\"# Created by Gatewai\",\n\t\tlut.type === \"3D\" ? `LUT_3D_SIZE ${lut.size}` : `LUT_1D_SIZE ${lut.size}`,\n\t\t\"\"\n\t];\n\tfor (const p of lut.points) lines.push(`${p[0].toFixed(6)} ${p[1].toFixed(6)} ${p[2].toFixed(6)}`);\n\treturn lines.join(\"\\n\");\n}\nvar HeadlessWebGPURenderer = class HeadlessWebGPURenderer {\n\tstatic isInitialized = false;\n\tstatic initPromise = null;\n\tstatic initFailureCount = 0;\n\tstatic MAX_INIT_FAILURES = 3;\n\tstatic nextRetryAt = 0;\n\tstatic initialize() {\n\t\tif (HeadlessWebGPURenderer.isInitialized) return Promise.resolve();\n\t\tif (HeadlessWebGPURenderer.initFailureCount >= HeadlessWebGPURenderer.MAX_INIT_FAILURES) return Promise.reject(/* @__PURE__ */ new Error(\"GPU initialization permanently failed — circuit breaker open\"));\n\t\tif (Date.now() < HeadlessWebGPURenderer.nextRetryAt) return Promise.reject(/* @__PURE__ */ new Error(\"GPU initialization in backoff period\"));\n\t\tif (HeadlessWebGPURenderer.initPromise) return HeadlessWebGPURenderer.initPromise;\n\t\tHeadlessWebGPURenderer.initPromise = (async () => {\n\t\t\ttry {\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Initializing headless WebGPU…\");\n\t\t\t\tawait initHeadlessWebGPU();\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Scanning node renderers…\");\n\t\t\t\tawait discoverAndRegisterNodeRenderers();\n\t\t\t\tHeadlessWebGPURenderer.isInitialized = true;\n\t\t\t\tHeadlessWebGPURenderer.initPromise = null;\n\t\t\t\tHeadlessWebGPURenderer.initFailureCount = 0;\n\t\t\t\tHeadlessWebGPURenderer.nextRetryAt = 0;\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Initialization complete.\");\n\t\t\t} catch (error) {\n\t\t\t\tHeadlessWebGPURenderer.initFailureCount++;\n\t\t\t\tHeadlessWebGPURenderer.nextRetryAt = Date.now() + 5e3 * 2 ** HeadlessWebGPURenderer.initFailureCount;\n\t\t\t\tHeadlessWebGPURenderer.initPromise = null;\n\t\t\t\trendererLogger.error({\n\t\t\t\t\terr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\tfailureCount: HeadlessWebGPURenderer.initFailureCount,\n\t\t\t\t\tnextRetryAt: new Date(HeadlessWebGPURenderer.nextRetryAt).toISOString()\n\t\t\t\t}, \"[HeadlessWebGPURenderer] Initialization failed\");\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\t\treturn HeadlessWebGPURenderer.initPromise;\n\t}\n\tasync renderImage(virtualMedia, frame = 0, fps = 24, options = {}) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst width = toEvenDimension(virtualMedia.metadata.width ?? 0);\n\t\tconst height = toEvenDimension(virtualMedia.metadata.height ?? 0);\n\t\tif (!width || !height) throw new Error(`Invalid dimensions: ${width}x${height}`);\n\t\tconst pooledId = options.renderId ? void 0 : takeStillId();\n\t\tconst renderId = options.renderId ?? pooledId;\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\tframe,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for image render\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tconst device = await ensureDevice();\n\t\ttry {\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tsurface = nodeSurfacePool.acquire(device, width, height);\n\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\tconst ctx = {\n\t\t\t\tdevice,\n\t\t\t\trenderer,\n\t\t\t\tsurface\n\t\t\t};\n\t\t\tupdateClockSignals(frame, fps, virtualMedia.metadata.durationMs ?? void 0);\n\t\t\tif (frame === 0 || lutStore.hasPending(device) || SlugFontCache.hasPending()) {\n\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\tr: 0,\n\t\t\t\t\tg: 0,\n\t\t\t\t\tb: 0,\n\t\t\t\t\ta: 0\n\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\tframe,\n\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\tfps,\n\t\t\t\t\tisHeadless: true,\n\t\t\t\t\trenderId,\n\t\t\t\t\tvirtualMedia,\n\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t});\n\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t}\n\t\t\tcompositionStateStore.setState(renderId, frame, fps, true);\n\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\tr: 0,\n\t\t\t\tg: 0,\n\t\t\t\tb: 0,\n\t\t\t\ta: 0\n\t\t\t}, width, height, \"clear\").end();\n\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\tframe,\n\t\t\t\tcompositionFrame: frame,\n\t\t\t\tfps,\n\t\t\t\tisHeadless: true,\n\t\t\t\trenderId,\n\t\t\t\tvirtualMedia,\n\t\t\t\tcontainerWidth: width,\n\t\t\t\tcontainerHeight: height,\n\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t});\n\t\t\tdevice.queue.submit([encoder.finish()]);\n\t\t\tconst pixels = await surface.readPixels();\n\t\t\tconst pixelsArr = new Uint8Array(pixels.buffer, pixels.byteOffset, pixels.byteLength);\n\t\t\tif (options.format === \"rgba\") return Buffer.from(pixelsArr);\n\t\t\treturn await sharp(Buffer.from(pixelsArr), { raw: {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tchannels: 4\n\t\t\t} }).png().toBuffer();\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.tick();\n\t\t\t} catch {}\n\t\t\tif (pooledId) returnStillId(pooledId);\n\t\t\tif (surface) nodeSurfacePool.release(device, surface);\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Image render slot released\");\n\t\t}\n\t}\n\t/**\n\t* Renders a single frame to a PNG buffer at a specified timestamp in milliseconds or frame index.\n\t*/\n\tasync renderFrame(source, options = {}) {\n\t\tconst vm = typeof source === \"object\" && source !== null && \"toVirtualMedia\" in source ? source.toVirtualMedia() : source;\n\t\tconst fps = options.fps ?? (vm.metadata?.fps || 30);\n\t\tconst frame = options.atMs !== void 0 ? Math.round(options.atMs / 1e3 * fps) : options.frame ?? 0;\n\t\treturn this.renderImage(vm, frame, fps, {\n\t\t\trenderId: options.renderId,\n\t\t\tformat: options.format\n\t\t});\n\t}\n\t/**\n\t* Mixes the composition's full audio timeline (clips, effects, synthesized\n\t* tracks) to stereo PCM, exactly as `renderVideo` muxes it.\n\t*/\n\tasync renderAudio(virtualMedia, options = {}) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst fps = options.fps ?? (virtualMedia.metadata?.fps || 30);\n\t\tawait renderSemaphore.acquire();\n\t\ttry {\n\t\t\tconst device = await ensureDevice();\n\t\t\treturn await mixAudioTracks(virtualMedia, fps, options.sampleRate ?? 48e3, device, `aud-${randomUUID()}`);\n\t\t} finally {\n\t\t\trenderSemaphore.release();\n\t\t}\n\t}\n\tasync renderLut(virtualMedia, frame = 0, fps = 24) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst width = 32;\n\t\tconst height = 32;\n\t\tconst renderId = `lut-${randomUUID()}`;\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\tframe,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for LUT render\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tconst device = await ensureDevice();\n\t\tlet lutData = null;\n\t\tconst lutSub = lutStore.onChange((key) => {\n\t\t\tconst raw = lutStore.getRawData(key);\n\t\t\tif (raw) lutData = raw;\n\t\t});\n\t\ttry {\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tsurface = new NodeSurfaceProvider(device, width, height);\n\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\tconst ctx = {\n\t\t\t\tdevice,\n\t\t\t\trenderer,\n\t\t\t\tsurface\n\t\t\t};\n\t\t\tif (frame === 0 || lutStore.hasPending(device) || SlugFontCache.hasPending()) {\n\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\tr: 0,\n\t\t\t\t\tg: 0,\n\t\t\t\t\tb: 0,\n\t\t\t\t\ta: 0\n\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\tframe,\n\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\tfps,\n\t\t\t\t\tisHeadless: true,\n\t\t\t\t\trenderId,\n\t\t\t\t\tvirtualMedia,\n\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t});\n\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t}\n\t\t\tcompositionStateStore.setState(renderId, frame, fps, true);\n\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\tr: 0,\n\t\t\t\tg: 0,\n\t\t\t\tb: 0,\n\t\t\t\ta: 0\n\t\t\t}, width, height, \"clear\").end();\n\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\tframe,\n\t\t\t\tcompositionFrame: frame,\n\t\t\t\tfps,\n\t\t\t\tisHeadless: true,\n\t\t\t\trenderId,\n\t\t\t\tvirtualMedia,\n\t\t\t\tcontainerWidth: width,\n\t\t\t\tcontainerHeight: height,\n\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t});\n\t\t\tdevice.queue.submit([encoder.finish()]);\n\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\tif (!lutData) lutData = lutStore.getAnyRawData();\n\t\t\tif (!lutData) throw new Error(\"No LUT data generated during rendering\");\n\t\t\tconst cubeContent = formatLutAsCube(lutData);\n\t\t\treturn Buffer.from(cubeContent, \"utf-8\");\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tlutSub();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.clearNode(renderId);\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tsurface?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] LUT render slot released\");\n\t\t}\n\t}\n\tasync resolveMediaDuration(virtualMedia, fps) {\n\t\tlet maxDurationMs = 0;\n\t\tconst queue = [virtualMedia];\n\t\tconst sources = /* @__PURE__ */ new Set();\n\t\twhile (queue.length > 0) {\n\t\t\tconst current = queue.shift();\n\t\t\tif (current.metadata?.durationMs && current.metadata.durationMs > maxDurationMs) maxDurationMs = current.metadata.durationMs;\n\t\t\tconst op = current.operation;\n\t\t\tif (op) {\n\t\t\t\tif (typeof op.source === \"string\") sources.add(op.source);\n\t\t\t\tif (typeof op.url === \"string\") sources.add(op.url);\n\t\t\t\tif (typeof op.inputHandleId === \"string\") sources.add(op.inputHandleId);\n\t\t\t\tif (Array.isArray(op.layout)) for (const node of op.layout) {\n\t\t\t\t\tif (node.inputHandleId) sources.add(node.inputHandleId);\n\t\t\t\t\tif (node.src) sources.add(node.src);\n\t\t\t\t\tif (typeof node.durationFrames === \"number\") {\n\t\t\t\t\t\tconst durMs = ((typeof node.startFrame === \"number\" ? node.startFrame : 0) + node.durationFrames) / fps * 1e3;\n\t\t\t\t\t\tif (durMs > maxDurationMs) maxDurationMs = durMs;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (current.children) queue.push(...current.children);\n\t\t}\n\t\tfor (const src of sources) try {\n\t\t\tconst sec = await (await inputStore.acquire(src)).computeDuration();\n\t\t\tif (Number.isFinite(sec) && sec > 0) {\n\t\t\t\tconst ms = Math.round(sec * 1e3);\n\t\t\t\tif (ms > maxDurationMs) maxDurationMs = ms;\n\t\t\t}\n\t\t} catch (_) {}\n\t\treturn maxDurationMs > 0 ? maxDurationMs : 1e3;\n\t}\n\tasync renderVideo(virtualMedia, options) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst codecOption = options?.codec ?? \"h264\";\n\t\tconst isMp3 = codecOption === \"mp3\";\n\t\tconst isWebM = codecOption === \"vp8\" || codecOption === \"vp9\" || codecOption === \"opus\";\n\t\tconst mediaType = getMediaType(virtualMedia);\n\t\tconst isLut = mediaType === \"LUT\" || virtualMedia.operation?.dataType === \"LUT\";\n\t\tconst isAudioOnly = isMp3 || codecOption === \"aac\" || codecOption === \"opus\" || mediaType === \"Audio\";\n\t\tconst fps = virtualMedia.metadata.fps ?? (isAudioOnly || isLut ? 24 : void 0);\n\t\tif (!fps) {\n\t\t\tconst dataType = mediaType ?? virtualMedia.dataType ?? \"Unknown\";\n\t\t\tconst op = virtualMedia.operation?.op ?? virtualMedia.op ?? \"Unknown\";\n\t\t\tthrow new Error(`FPS is missing from virtualMedia metadata (dataType: \"${dataType}\", operation: \"${op}\")`);\n\t\t}\n\t\tconst width = toEvenDimension(virtualMedia.metadata.width ?? (isAudioOnly ? 1280 : 0));\n\t\tconst height = toEvenDimension(virtualMedia.metadata.height ?? (isAudioOnly ? 720 : 0));\n\t\tif (!width || !height) throw new Error(`Invalid dimensions: ${width}x${height}`);\n\t\tlet durationMs = virtualMedia.metadata.durationMs;\n\t\tif (!durationMs || durationMs <= 0) {\n\t\t\tdurationMs = await this.resolveMediaDuration(virtualMedia, fps);\n\t\t\tvirtualMedia.metadata.durationMs = durationMs;\n\t\t}\n\t\tconst totalFrames = Math.max(1, Math.round(durationMs / 1e3 * fps));\n\t\tconst renderId = `vid-${randomUUID()}`;\n\t\tconst qaOptions = options?.qa === true ? {} : options?.qa ? options.qa : void 0;\n\t\tconst inspector = qaOptions ? new FrameInspector(qaOptions) : void 0;\n\t\tlet videoQa;\n\t\tlet audioQa;\n\t\tconst videoCodec = codecOption === \"vp9\" ? \"vp9\" : codecOption === \"vp8\" ? \"vp8\" : \"avc\";\n\t\tconst audioCodec = options?.audioCodec ?? (isMp3 ? \"mp3\" : isWebM ? \"opus\" : \"aac\");\n\t\tconst quality = resolveQuality(options?.quality);\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\ttotalFrames,\n\t\t\tfps,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tcodec: codecOption,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for video render (inline)\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet lastCpuUsage = process.cpuUsage();\n\t\tlet lastCpuTime = process.hrtime.bigint();\n\t\tconst getCpuUsage = () => {\n\t\t\tconst curCpuUsage = process.cpuUsage();\n\t\t\tconst curCpuTime = process.hrtime.bigint();\n\t\t\tconst userDiff = curCpuUsage.user - lastCpuUsage.user;\n\t\t\tconst sysDiff = curCpuUsage.system - lastCpuUsage.system;\n\t\t\tconst timeDiff = Number(curCpuTime - lastCpuTime) / 1e3;\n\t\t\tlastCpuUsage = curCpuUsage;\n\t\t\tlastCpuTime = curCpuTime;\n\t\t\tif (timeDiff === 0) return \"0.0%\";\n\t\t\tconst cpus = os.cpus().length || 1;\n\t\t\treturn `${((userDiff + sysDiff) / timeDiff * 100 / cpus).toFixed(1)}%`;\n\t\t};\n\t\tconst getRamUsage = () => {\n\t\t\tconst mem = process.memoryUsage();\n\t\t\tconst freeMem = os.freemem();\n\t\t\tconst totalMem = os.totalmem();\n\t\t\tconst usedMem = totalMem - freeMem;\n\t\t\tconst heapUsedMb = Math.round(mem.heapUsed / 1024 / 1024);\n\t\t\tconst heapTotalMb = Math.round(mem.heapTotal / 1024 / 1024);\n\t\t\treturn `Process: ${Math.round(mem.rss / 1024 / 1024)}MB RSS (${heapUsedMb}MB/${heapTotalMb}MB Heap), System: ${Math.round(usedMem / 1024 / 1024)}MB/${Math.round(totalMem / 1024 / 1024)}MB`;\n\t\t};\n\t\tlet statsInterval;\n\t\tif (process.env.NODE_ENV === \"production\") statsInterval = setInterval(() => {\n\t\t\trefreshVramUsage();\n\t\t\trendererLogger.info({\n\t\t\t\trenderId,\n\t\t\t\tcpu: getCpuUsage(),\n\t\t\t\tram: getRamUsage(),\n\t\t\t\tvram: getVramUsage(),\n\t\t\t\trenderQueue: renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Performance Stats\");\n\t\t}, 5e3);\n\t\tconst tempDir = os.tmpdir();\n\t\tconst extension = isMp3 ? \"mp3\" : isWebM ? \"webm\" : \"mp4\";\n\t\tconst tempFilePath = path.join(tempDir, `render-${renderId}.${extension}`);\n\t\tconst tempGifPath = path.join(tempDir, `render-${renderId}.gif`);\n\t\tconst target = new FilePathTarget(tempFilePath);\n\t\tconst output = new Output({\n\t\t\tformat: isMp3 ? new Mp3OutputFormat() : isWebM ? new WebMOutputFormat() : new Mp4OutputFormat(),\n\t\t\ttarget\n\t\t});\n\t\tlet videoSource;\n\t\tif (!isAudioOnly) {\n\t\t\tvideoSource = new VideoSampleSource({\n\t\t\t\tcodec: videoCodec,\n\t\t\t\tbitrate: quality,\n\t\t\t\tlatencyMode: \"realtime\",\n\t\t\t\thardwareAcceleration: \"prefer-hardware\"\n\t\t\t});\n\t\t\toutput.addVideoTrack(videoSource);\n\t\t}\n\t\tconst audioSource = new AudioSampleSource({\n\t\t\tcodec: audioCodec,\n\t\t\tbitrate: quality\n\t\t});\n\t\toutput.addAudioTrack(audioSource);\n\t\tlet outputStarted = false;\n\t\tlet outputFinalized = false;\n\t\tconst device = await ensureDevice();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tlet pipeline;\n\t\ttry {\n\t\t\tawait output.start();\n\t\t\toutputStarted = true;\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tif (!isAudioOnly && videoSource) {\n\t\t\t\tsurface = new NodeSurfaceProvider(device, width, height);\n\t\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\t\tpipeline = new ZeroCopyWebCodecsPipeline(device, {\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tfps,\n\t\t\t\t\tvideoSource,\n\t\t\t\t\tringCapacity: resolveRingCapacity(options?.ringCapacity),\n\t\t\t\t\tonFrame: inspector ? (rgba) => inspector.inspect(rgba, width, height) : void 0\n\t\t\t\t});\n\t\t\t\tconst ctx = surface && renderer ? {\n\t\t\t\t\tdevice,\n\t\t\t\t\trenderer,\n\t\t\t\t\tsurface\n\t\t\t\t} : null;\n\t\t\t\tconst prePass = async (frame) => {\n\t\t\t\t\tif (!ctx || !renderer) return;\n\t\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\t\tr: 0,\n\t\t\t\t\t\tg: 0,\n\t\t\t\t\t\tb: 0,\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\t\tfps,\n\t\t\t\t\t\tisHeadless: true,\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\tvirtualMedia,\n\t\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t\t});\n\t\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t\t};\n\t\t\t\tawait prePass(0);\n\t\t\t\tfor (let i = 0; i < totalFrames; i++) {\n\t\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\t\tif (i % 10 === 0) rendererLogger.info({\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\tframe: i,\n\t\t\t\t\t\ttotalFrames\n\t\t\t\t\t}, `[HeadlessWebGPURenderer] Rendering frame ${i}/${totalFrames}`);\n\t\t\t\t\tif (ctx && surface && renderer && pipeline) {\n\t\t\t\t\t\tif (i > 0 && (lutStore.hasPending(device) || SlugFontCache.hasPending())) {\n\t\t\t\t\t\t\tupdateClockSignals(i, fps, durationMs);\n\t\t\t\t\t\t\tawait prePass(i);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcompositionStateStore.setState(renderId, i, fps, true);\n\t\t\t\t\t\tupdateClockSignals(i, fps, durationMs);\n\t\t\t\t\t\tmediaDecoderCache.tick();\n\t\t\t\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\t\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\t\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\t\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\t\t\t\tr: 0,\n\t\t\t\t\t\t\tg: 0,\n\t\t\t\t\t\t\tb: 0,\n\t\t\t\t\t\t\ta: 0\n\t\t\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\t\t\t\tframe: i,\n\t\t\t\t\t\t\tcompositionFrame: i,\n\t\t\t\t\t\t\tfps,\n\t\t\t\t\t\t\tisHeadless: true,\n\t\t\t\t\t\t\trenderId,\n\t\t\t\t\t\t\tvirtualMedia,\n\t\t\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait pipeline.enqueueFrame(i, targetTexture, encoder);\n\t\t\t\t\t\toptions?.onProgress?.({\n\t\t\t\t\t\t\tphase: \"render\",\n\t\t\t\t\t\t\tframe: i + 1,\n\t\t\t\t\t\t\ttotalFrames\n\t\t\t\t\t\t});\n\t\t\t\t\t} else throw new Error(\"Invalid render context state\");\n\t\t\t\t}\n\t\t\t\tif (pipeline) {\n\t\t\t\t\tawait pipeline.drain();\n\t\t\t\t\tconst pipelineStats = pipeline.getStats();\n\t\t\t\t\tif (inspector && qaOptions) videoQa = inspector.stats(totalFrames, pipelineStats.totalFramesEncoded, fps, width, height, qaOptions);\n\t\t\t\t\trendererLogger.debug({\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\ttotalFrames,\n\t\t\t\t\t\t...pipelineStats\n\t\t\t\t\t}, `[HeadlessWebGPURenderer] All frames rendered and encoded (avg cycle: ${pipelineStats.averageCycleTimeMs.toFixed(2)}ms, throughput: ${pipelineStats.throughputFps.toFixed(1)} fps)`);\n\t\t\t\t}\n\t\t\t}\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\toptions?.onProgress?.({\n\t\t\t\tphase: \"audio\",\n\t\t\t\tframe: totalFrames,\n\t\t\t\ttotalFrames\n\t\t\t});\n\t\t\tconst { channels, sampleRate } = await mixAudioTracks(virtualMedia, fps, 48e3, device, renderId);\n\t\t\tconst numChannels = channels.length;\n\t\t\tif (numChannels === 0) throw new Error(\"mixAudioTracks returned no channels\");\n\t\t\tif (qaOptions) audioQa = analyzeAudio(channels, sampleRate, qaOptions);\n\t\t\tconst totalSamples = channels[0].length;\n\t\t\tconst chunkSize = Math.round(.1 * sampleRate);\n\t\t\tfor (let offset = 0; offset < totalSamples; offset += chunkSize) {\n\t\t\t\tconst currentChunk = Math.min(chunkSize, totalSamples - offset);\n\t\t\t\tconst interleaved = new Float32Array(currentChunk * numChannels);\n\t\t\t\tfor (let i = 0; i < currentChunk; i++) for (let ch = 0; ch < numChannels; ch++) interleaved[i * numChannels + ch] = channels[ch]?.[offset + i] ?? 0;\n\t\t\t\tconst sample = new AudioSample({\n\t\t\t\t\tdata: interleaved,\n\t\t\t\t\tformat: \"f32\",\n\t\t\t\t\tnumberOfChannels: numChannels,\n\t\t\t\t\tsampleRate,\n\t\t\t\t\ttimestamp: offset / sampleRate\n\t\t\t\t});\n\t\t\t\ttry {\n\t\t\t\t\tawait audioSource.add(sample);\n\t\t\t\t} finally {\n\t\t\t\t\tsample.close();\n\t\t\t\t}\n\t\t\t}\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tawait output.finalize();\n\t\t\toutputFinalized = true;\n\t\t\tconst qa = qaOptions ? buildQaReport({\n\t\t\t\tvideo: videoQa,\n\t\t\t\taudio: audioQa,\n\t\t\t\tdiagnostics: takeRenderDiagnostics(renderId),\n\t\t\t\toptions: qaOptions\n\t\t\t}) : void 0;\n\t\t\tconst cleanup = async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.unlink(tempFilePath).catch(() => {});\n\t\t\t\t\tif (codecOption === \"gif\") await fs.unlink(tempGifPath).catch(() => {});\n\t\t\t\t} catch {}\n\t\t\t};\n\t\t\tif (codecOption === \"gif\") {\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Converting rendered MP4 to high-quality GIF...\");\n\t\t\t\tawait convertMp4ToGif(tempFilePath, tempGifPath);\n\t\t\t\treturn {\n\t\t\t\t\tfilePath: tempGifPath,\n\t\t\t\t\tcleanup,\n\t\t\t\t\t...qa && { qa }\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfilePath: tempFilePath,\n\t\t\t\tcleanup,\n\t\t\t\t...qa && { qa }\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (outputStarted && !outputFinalized) try {\n\t\t\t\tawait output.finalize();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(tempFilePath).catch(() => {});\n\t\t\t\tif (codecOption === \"gif\") await fs.unlink(tempGifPath).catch(() => {});\n\t\t\t} catch {}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (statsInterval) clearInterval(statsInterval);\n\t\t\ttry {\n\t\t\t\trenderer?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tpipeline?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tsurface?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.clearNode(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tWebGPUAudioProcessor.clearCache(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttakeRenderDiagnostics(renderId);\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Video render slot released\");\n\t\t}\n\t}\n};\nconst HeadlessMediaRenderer = HeadlessWebGPURenderer;\n\n//#endregion\nexport { FrameInspector as a, formatQaReport as c, ZeroCopyWebCodecsPipeline as i, integratedLoudness as l, HeadlessWebGPURenderer as n, analyzeAudio as o, renderSemaphore as r, buildQaReport as s, HeadlessMediaRenderer as t };\n//# sourceMappingURL=headless-webgpu-renderer-1QAxgoPn.mjs.map","import { a as NodeManifestError, c as DmaStagingRing, i as NODE_KINDS, l as preloadFonts, n as discoverAndRegisterNodeRenderers, o as loadNodeManifests, r as findNodesDir, s as parseNodeManifest, u as rendererLogger } from \"./bootstrap-mediabunny-BgWuVtxx.mjs\";\nimport { a as FrameInspector, c as formatQaReport, i as ZeroCopyWebCodecsPipeline, l as integratedLoudness, n as HeadlessWebGPURenderer, o as analyzeAudio, r as renderSemaphore, s as buildQaReport, t as HeadlessMediaRenderer } from \"./headless-webgpu-renderer-1QAxgoPn.mjs\";\nimport { SlugFontCache, clearAllVideoCache, clearHeadlessFonts, inputStore, lutStore, mediaDecoderCache, textureCache } from \"@framefields/webgpu-renderers\";\n\n//#region src/job-reset.ts\n/**\n* Drops every cache keyed by a file path or URL: media inputs and decoders,\n* textures, LUTs, fonts and downloaded font files. A long-lived worker calls this between jobs,\n* because the next checkout may hold different bytes at the same path. The\n* GPU device and compiled pipelines stay warm.\n*/\nfunction resetRenderCaches() {\n\tclearAllVideoCache();\n\tmediaDecoderCache.destroy();\n\ttextureCache.destroy();\n\tinputStore.clear();\n\tlutStore.destroy();\n\tSlugFontCache.destroy();\n\tclearHeadlessFonts();\n}\n\n//#endregion\nexport { DmaStagingRing, FrameInspector, HeadlessMediaRenderer, HeadlessWebGPURenderer, NODE_KINDS, NodeManifestError, ZeroCopyWebCodecsPipeline, analyzeAudio, buildQaReport, discoverAndRegisterNodeRenderers, findNodesDir, formatQaReport, integratedLoudness, loadNodeManifests, parseNodeManifest, preloadFonts, renderSemaphore, rendererLogger, resetRenderCaches };\n//# sourceMappingURL=index.mjs.map","import fs from \"node:fs/promises\";\nimport type { VirtualMediaData } from \"@framefields/core\";\nimport { Canvas, loadImage } from \"skia-canvas\";\nimport { HeadlessMediaRenderer } from \"./index.js\";\n\nexport interface FrameSamplePoint {\n\tframe: number;\n\ttimeMs: number;\n}\n\nexport interface FrameGridOptions {\n\t/**\n\t * Start frame index for sampling (inclusive). Defaults to 0.\n\t */\n\tstartFrame?: number;\n\n\t/**\n\t * End frame index for sampling (inclusive). Defaults to startFrame + 30.\n\t */\n\tendFrame?: number;\n\n\t/**\n\t * Step interval between sampled frames. Must be >= 1. Defaults to 5.\n\t */\n\tstepFrames?: number;\n\n\t/**\n\t * Explicit list of frame indices to sample. Overrides startFrame/endFrame/stepFrames.\n\t */\n\tframes?: number[];\n\n\t/**\n\t * Start time in milliseconds (alternative to startFrame).\n\t */\n\tstartMs?: number;\n\n\t/**\n\t * End time in milliseconds (alternative to endFrame).\n\t */\n\tendMs?: number;\n\n\t/**\n\t * Step interval in milliseconds (alternative to stepFrames).\n\t */\n\tstepMs?: number;\n\n\t/**\n\t * Explicit list of timestamps in milliseconds to sample.\n\t */\n\ttimesMs?: number[];\n\n\t/**\n\t * Frames per second override. If omitted, reads from media/composition metadata or defaults to 24.\n\t */\n\tfps?: number;\n\n\t/**\n\t * Number of columns in the grid. If omitted, calculated automatically to preserve balance.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Width in pixels for each individual thumbnail cell.\n\t * Clamped to [120, 960]. Defaults to 320.\n\t */\n\tcellWidth?: number;\n\n\t/**\n\t * Explicit height for each cell. If omitted, computed from aspect ratio.\n\t */\n\tcellHeight?: number;\n\n\t/**\n\t * Gap in pixels between cells. Defaults to 12.\n\t */\n\tgap?: number;\n\n\t/**\n\t * Outer padding in pixels around the grid. Defaults to 16.\n\t */\n\tpadding?: number;\n\n\t/**\n\t * Background color for the grid canvas. Defaults to \"#090a0f\".\n\t */\n\tbackgroundColor?: string;\n\n\t/**\n\t * Whether to render frame number & millisecond badges on each cell. Defaults to true.\n\t */\n\tshowLabels?: boolean;\n\n\t/**\n\t * Whether to render the metadata header banner at the top of the grid. Defaults to true.\n\t */\n\tshowHeader?: boolean;\n\n\t/**\n\t * Custom header title text.\n\t */\n\theaderText?: string;\n\n\t/**\n\t * Optional file path to write the generated grid image directly to disk.\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Safety limit for total sampled frames to prevent memory exhaustion or oversized images.\n\t * Defaults to 64. Hard maximum is 120.\n\t */\n\tmaxFrames?: number;\n\n\t/**\n\t * Maximum allowed width for the generated image canvas. Defaults to 4096.\n\t */\n\tmaxGridWidth?: number;\n\n\t/**\n\t * Maximum allowed height for the generated image canvas. Defaults to 4096.\n\t */\n\tmaxGridHeight?: number;\n\n\t/**\n\t * Optional shared HeadlessMediaRenderer instance.\n\t */\n\trenderer?: HeadlessMediaRenderer;\n}\n\n/**\n * Resolves and validates the list of sample points from the provided options.\n */\nexport function resolveSamplePoints(\n\toptions: FrameGridOptions,\n\tdefaultFps = 24,\n\tdurationMs?: number,\n): { samples: FrameSamplePoint[]; fps: number } {\n\tconst fps = options.fps ?? defaultFps;\n\tif (fps <= 0) {\n\t\tthrow new Error(`[FrameGrid] Invalid fps: ${fps}. Must be > 0.`);\n\t}\n\n\tconst samples: FrameSamplePoint[] = [];\n\n\tif (Array.isArray(options.frames) && options.frames.length > 0) {\n\t\tfor (const f of options.frames) {\n\t\t\tif (typeof f !== \"number\" || f < 0 || !Number.isFinite(f)) {\n\t\t\t\tthrow new Error(`[FrameGrid] Invalid frame index in frames list: ${f}`);\n\t\t\t}\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round(f),\n\t\t\t\ttimeMs: Math.round((f / fps) * 1000),\n\t\t\t});\n\t\t}\n\t} else if (Array.isArray(options.timesMs) && options.timesMs.length > 0) {\n\t\tfor (const ms of options.timesMs) {\n\t\t\tif (typeof ms !== \"number\" || ms < 0 || !Number.isFinite(ms)) {\n\t\t\t\tthrow new Error(`[FrameGrid] Invalid timestamp in timesMs list: ${ms}`);\n\t\t\t}\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round((ms / 1000) * fps),\n\t\t\t\ttimeMs: Math.round(ms),\n\t\t\t});\n\t\t}\n\t} else if (\n\t\toptions.startMs !== undefined ||\n\t\toptions.endMs !== undefined ||\n\t\toptions.stepMs !== undefined\n\t) {\n\t\tconst startMs = options.startMs ?? 0;\n\t\tconst endMs = options.endMs ?? durationMs ?? startMs + 1000;\n\t\tconst stepMs = options.stepMs ?? Math.round((5 / fps) * 1000);\n\n\t\tif (startMs < 0 || endMs < startMs) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid millisecond range: startMs=${startMs}, endMs=${endMs}. startMs must be <= endMs.`,\n\t\t\t);\n\t\t}\n\t\tif (stepMs <= 0) {\n\t\t\tthrow new Error(`[FrameGrid] Invalid stepMs: ${stepMs}. Must be > 0.`);\n\t\t}\n\n\t\tfor (let ms = startMs; ms <= endMs; ms += stepMs) {\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round((ms / 1000) * fps),\n\t\t\t\ttimeMs: Math.round(ms),\n\t\t\t});\n\t\t}\n\t} else {\n\t\tconst startFrame = options.startFrame ?? 0;\n\t\tconst endFrame =\n\t\t\toptions.endFrame ??\n\t\t\t(durationMs\n\t\t\t\t? Math.min(startFrame + 30, Math.floor((durationMs / 1000) * fps))\n\t\t\t\t: startFrame + 30);\n\t\tconst stepFrames = options.stepFrames ?? 5;\n\n\t\tif (startFrame < 0 || endFrame < startFrame) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid frame range: startFrame=${startFrame}, endFrame=${endFrame}. startFrame must be <= endFrame.`,\n\t\t\t);\n\t\t}\n\t\tif (stepFrames <= 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid stepFrames: ${stepFrames}. Must be > 0.`,\n\t\t\t);\n\t\t}\n\n\t\tfor (let f = startFrame; f <= endFrame; f += stepFrames) {\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round(f),\n\t\t\t\ttimeMs: Math.round((f / fps) * 1000),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst maxFramesLimit = Math.min(options.maxFrames ?? 64, 120);\n\tif (samples.length > maxFramesLimit) {\n\t\tthrow new Error(\n\t\t\t`[FrameGrid] Requested ${samples.length} frames exceeds the safety threshold of ${maxFramesLimit}. ` +\n\t\t\t\t`Increase stepFrames/stepMs or narrow the start/end range to prevent oversized images.`,\n\t\t);\n\t}\n\n\tif (samples.length === 0) {\n\t\tthrow new Error(\"[FrameGrid] Zero frames were resolved for sampling.\");\n\t}\n\n\treturn { samples, fps };\n}\n\n/**\n * Computes grid layout dimensions, ensuring resulting canvas does not exceed size limits.\n */\nexport function computeGridLayout(\n\tnumSamples: number,\n\taspectRatio: number,\n\toptions: FrameGridOptions,\n): {\n\tcolumns: number;\n\trows: number;\n\tcellWidth: number;\n\tcellHeight: number;\n\ttotalWidth: number;\n\ttotalHeight: number;\n\theaderHeight: number;\n\tgap: number;\n\tpadding: number;\n} {\n\tconst gap = options.gap ?? 12;\n\tconst padding = options.padding ?? 16;\n\tconst showHeader = options.showHeader ?? true;\n\tconst headerHeight = showHeader ? 54 : 0;\n\tconst maxGridWidth = options.maxGridWidth ?? 4096;\n\tconst maxGridHeight = options.maxGridHeight ?? 4096;\n\n\tlet columns = options.columns;\n\tif (!columns || columns <= 0) {\n\t\tif (numSamples <= 4) columns = numSamples;\n\t\telse if (numSamples <= 9) columns = 3;\n\t\telse if (numSamples <= 16) columns = 4;\n\t\telse if (numSamples <= 25) columns = 5;\n\t\telse columns = 6;\n\t}\n\tcolumns = Math.min(columns, numSamples);\n\tconst rows = Math.ceil(numSamples / columns);\n\n\tlet cellWidth = Math.max(120, Math.min(options.cellWidth ?? 320, 960));\n\tlet cellHeight =\n\t\toptions.cellHeight ??\n\t\tMath.round(cellWidth / (aspectRatio > 0 ? aspectRatio : 16 / 9));\n\n\tlet totalWidth = columns * cellWidth + (columns - 1) * gap + padding * 2;\n\tlet totalHeight =\n\t\trows * cellHeight + (rows - 1) * gap + padding * 2 + headerHeight;\n\n\t// Downscale thumbnail size if the unconstrained canvas exceeds max dimensions\n\tif (totalWidth > maxGridWidth || totalHeight > maxGridHeight) {\n\t\tconst scaleFactor = Math.min(\n\t\t\t(maxGridWidth - (columns - 1) * gap - padding * 2) /\n\t\t\t\t(columns * cellWidth),\n\t\t\t(maxGridHeight - (rows - 1) * gap - padding * 2 - headerHeight) /\n\t\t\t\t(rows * cellHeight),\n\t\t);\n\n\t\tif (scaleFactor < 0.25) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Cannot fit ${numSamples} cells (${columns}x${rows}) into max dimensions ` +\n\t\t\t\t\t`[${maxGridWidth}x${maxGridHeight}]. Reduce cell count or decrease cellWidth.`,\n\t\t\t);\n\t\t}\n\n\t\tcellWidth = Math.max(100, Math.floor(cellWidth * scaleFactor));\n\t\tcellHeight = Math.round(\n\t\t\tcellWidth / (aspectRatio > 0 ? aspectRatio : 16 / 9),\n\t\t);\n\n\t\ttotalWidth = columns * cellWidth + (columns - 1) * gap + padding * 2;\n\t\ttotalHeight =\n\t\t\trows * cellHeight + (rows - 1) * gap + padding * 2 + headerHeight;\n\t}\n\n\treturn {\n\t\tcolumns,\n\t\trows,\n\t\tcellWidth,\n\t\tcellHeight,\n\t\ttotalWidth,\n\t\ttotalHeight,\n\t\theaderHeight,\n\t\tgap,\n\t\tpadding,\n\t};\n}\n\nexport type FrameGridRenderable = {\n\ttoVirtualMedia(): VirtualMediaData;\n\trenderFrame(options: {\n\t\tframe?: number;\n\t\tatMs?: number;\n\t\tfps?: number;\n\t\trenderer?: HeadlessMediaRenderer;\n\t}): Promise<Buffer>;\n\tfps?: number;\n\tdurationMs?: number;\n\twidth?: number;\n\theight?: number;\n};\n\n/**\n * Renders a sequence of frames from a Composition or Media pipeline into a unified image grid (contact sheet).\n * Ideal for visual inspection of kinetic motion, transitions, easing, and layout stability.\n */\nexport async function renderFrameGrid(\n\ttarget: FrameGridRenderable,\n\toptions: FrameGridOptions = {},\n): Promise<Buffer> {\n\tconst defaultFps = target.fps ?? 24;\n\tconst durationMs = target.durationMs;\n\tconst { samples, fps } = resolveSamplePoints(options, defaultFps, durationMs);\n\n\tconst compWidth = target.width ?? 1920;\n\tconst compHeight = target.height ?? 1080;\n\tconst aspectRatio =\n\t\tcompWidth > 0 && compHeight > 0 ? compWidth / compHeight : 16 / 9;\n\n\tconst layout = computeGridLayout(samples.length, aspectRatio, options);\n\tconst renderer = options.renderer ?? new HeadlessMediaRenderer();\n\n\t// Render each frame sequentially to manage GPU resources cleanly\n\tconst frameBuffers: Buffer[] = [];\n\tfor (const sample of samples) {\n\t\tconst buf = await target.renderFrame({\n\t\t\tframe: sample.frame,\n\t\t\tatMs: sample.timeMs,\n\t\t\tfps,\n\t\t\trenderer,\n\t\t});\n\t\tframeBuffers.push(buf);\n\t}\n\n\t// Composite into a single grid canvas using skia-canvas\n\tconst canvas = new Canvas(layout.totalWidth, layout.totalHeight);\n\tconst ctx = canvas.getContext(\"2d\");\n\n\t// Fill background\n\tctx.fillStyle = options.backgroundColor ?? \"#090a0f\";\n\tctx.fillRect(0, 0, layout.totalWidth, layout.totalHeight);\n\n\t// Header banner\n\tif (options.showHeader !== false && layout.headerHeight > 0) {\n\t\tconst title =\n\t\t\toptions.headerText ??\n\t\t\t`FrameGrid Conformance Review | Frames ${samples[0].frame}–${samples[samples.length - 1].frame} (Count: ${samples.length})`;\n\t\tconst subtitle = `${compWidth}×${compHeight} @ ${fps} FPS | Cell: ${layout.cellWidth}×${layout.cellHeight}px | Step: ${\n\t\t\toptions.stepFrames\n\t\t\t\t? `${options.stepFrames}f`\n\t\t\t\t: options.stepMs\n\t\t\t\t\t? `${options.stepMs}ms`\n\t\t\t\t\t: \"Custom\"\n\t\t}`;\n\n\t\tctx.fillStyle = \"#f8fafc\";\n\t\tctx.font = \"bold 15px sans-serif\";\n\t\tctx.fillText(title, layout.padding, layout.padding + 18);\n\n\t\tctx.fillStyle = \"#94a3b8\";\n\t\tctx.font = \"12px sans-serif\";\n\t\tctx.fillText(subtitle, layout.padding, layout.padding + 36);\n\n\t\t// Subtle divider line\n\t\tctx.strokeStyle = \"#1e2433\";\n\t\tctx.lineWidth = 1;\n\t\tctx.beginPath();\n\t\tctx.moveTo(layout.padding, layout.padding + 46);\n\t\tctx.lineTo(layout.totalWidth - layout.padding, layout.padding + 46);\n\t\tctx.stroke();\n\t}\n\n\tconst showLabels = options.showLabels ?? true;\n\n\t// Draw each sampled cell\n\tfor (let i = 0; i < samples.length; i++) {\n\t\tconst sample = samples[i];\n\t\tconst col = i % layout.columns;\n\t\tconst row = Math.floor(i / layout.columns);\n\n\t\tconst x = layout.padding + col * (layout.cellWidth + layout.gap);\n\t\tconst y =\n\t\t\tlayout.padding +\n\t\t\tlayout.headerHeight +\n\t\t\trow * (layout.cellHeight + layout.gap);\n\n\t\tconst img = await loadImage(frameBuffers[i]);\n\t\tctx.drawImage(img, x, y, layout.cellWidth, layout.cellHeight);\n\n\t\t// Subtle cell border\n\t\tctx.strokeStyle = \"#262b3d\";\n\t\tctx.lineWidth = 1;\n\t\tctx.strokeRect(x, y, layout.cellWidth, layout.cellHeight);\n\n\t\t// Sleek metadata pill badge\n\t\tif (showLabels) {\n\t\t\tconst label = `F:${sample.frame} • ${sample.timeMs}ms`;\n\n\t\t\tctx.font = \"bold 11px sans-serif\";\n\t\t\tconst textWidth = ctx.measureText(label).width;\n\t\t\tconst badgeW = textWidth + 14;\n\t\t\tconst badgeH = 20;\n\t\t\tconst badgeX = x + 6;\n\t\t\tconst badgeY = y + 6;\n\n\t\t\t// Badge backdrop\n\t\t\tctx.fillStyle = \"#090a0fee\";\n\t\t\tctx.beginPath();\n\t\t\tctx.roundRect(badgeX, badgeY, badgeW, badgeH, 4);\n\t\t\tctx.fill();\n\n\t\t\t// Badge border\n\t\t\tctx.strokeStyle = \"#6366f155\";\n\t\t\tctx.lineWidth = 1;\n\t\t\tctx.stroke();\n\n\t\t\t// Badge text\n\t\t\tctx.fillStyle = \"#e2e8f0\";\n\t\t\tctx.fillText(label, badgeX + 7, badgeY + 14);\n\t\t}\n\t}\n\n\tconst gridBuffer = await canvas.toBuffer(\"png\");\n\n\tif (options.outputPath) {\n\t\tawait fs.writeFile(options.outputPath, gridBuffer);\n\t}\n\n\treturn gridBuffer;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,iBAAiB,KAAK;CAC3B,OAAO,OAAO,YAAY,eAAe,QAAQ,KAAK,aAAa;CACnE,WAAW,KAAK,iBAAiB;CACjC,MAAM,EAAE,WAAW,YAAY;CAC/B,CAAC;;;;;;;AAUF,eAAe,aAAa,OAAO,SAAS,MAAM;AACjD,KAAI,CAAC,MAAO;AACZ,OAAM,wBAAwB,OAAO,SAAS,KAAK,SAAS,eAAe,MAAM,KAAK,6CAA6C,OAAO,CAAC;;;;;;;;;;AAa5I,IAAI,iBAAiB,MAAM;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,cAAc;CACd,YAAY,QAAQ,SAAS;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ,QAAQ;AACrB,OAAK,SAAS,QAAQ;AACtB,OAAK,WAAW,KAAK,IAAI,GAAG,QAAQ,YAAY,EAAE;AAClD,OAAK,SAAS,QAAQ,UAAU;AAChC,OAAK,sBAAsB,KAAK,QAAQ;EACxC,MAAM,e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