Frame recording types
PibblFrameRecordingOptions
Section titled “PibblFrameRecordingOptions”PibblFrameRecordingOptions requires duration in milliseconds and accepts
frameRate, memoryHeadroom, and an optional cancellation signal. The optional
onRenderComplete callback observes each root render after render-owned state has
published. It receives a committed event with a committed generation or a
failed event for an attempted generation. Failed attempts never yield pixel
frames; a failed capture rejects. onFrameCaptured observes the exact generation
after its RGBA bytes are copied, which can occur later than the render-completion
callback when capture coalesces renders.
PibblRenderCompletion
Section titled “PibblRenderCompletion”PibblRenderCompletion distinguishes committed generations from failed attempts.
Only committed generations can identify recorded pixel evidence.
PibblFrameRecordingSession
Section titled “PibblFrameRecordingSession”PibblFrameRecordingSession exposes ready, finished, stop(), and cancel().
Stop preserves captured frames. Cancel discards an active session.
PibblFrameRecording
Section titled “PibblFrameRecording”PibblFrameRecording exposes actual duration, immutable frames metadata,
readFrame(index), and idempotent dispose(). Each read returns a caller-owned
copy; disposal releases worker-owned pixels and cancels pending operations.
PibblRecordedFrameInfo
Section titled “PibblRecordedFrameInfo”PibblRecordedFrameInfo contains renderGeneration, the committed root render
generation whose pixels were copied; timestamp in milliseconds from capture
start; and physical backing width and height. Timestamps measure wall-clock
capture time, can coalesce multiple renders, and are not generation identifiers.
PibblRecordedFrame
Section titled “PibblRecordedFrame”PibblRecordedFrame adds data, a
Uint8ClampedArray of RGBA8 bytes.
PibblGifExportOptions
Section titled “PibblGifExportOptions”PibblGifExportOptions accepts frameRate (default 25, maximum 100), repeatCount
(omitted plays once, zero loops forever, positive values repeat), an opaque CSS
background, an abort signal, and onProgress(progress) from zero to one.
Export quality and size controls:
widthandheight: integer output dimensions from 1 to 65535. One dimension preserves aspect ratio; both specify the exact size. Omitted dimensions keep the original bitmap size. Resizing uses premultiplied-alpha bilinear sampling.maxColors: integer 2–256, default 256. Includes the transparency entry whenbackgroundis omitted. GIF color tables round up to a power of two.palette: optional array of opaque CSS colors, used exactly instead of an automatically selected palette. Its length must fitmaxColors, allowing one extra entry for transparent export. Unrepresented pixels use the nearest RGB palette color. Partial-alpha colors are rejected.dithering: boolean, default false. Enables Floyd–Steinberg error diffusion.quantizationSampleFactor: integer 1–30, default 10. One spends most NeuQuant training effort; larger factors sample less and run faster.paletteSampleCount: integer 1–16777216, default 262144. Caps pixels sampled across up to 32 representative output frames for palette selection.
A supplied palette bypasses both automatic sampling controls. All exports keep recorded pixels unchanged, so a recording can be exported repeatedly with different settings. GIF compression itself is lossless over the resulting palette indexes; color reduction, binary transparency, resizing and frame sampling may lose detail.
See recordFrames and exportGif.
API details from source
Section titled “API details from source”
PibblFrameRecordingOptions
Section titled “PibblFrameRecordingOptions”Options for capturing committed renders of one live Pibbl root.
interface PibblFrameRecordingOptionsRelated API: PibblFrameRecordingOptions.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:4
Properties and methods
Section titled “Properties and methods”
duration
duration: numberRecording length in milliseconds, measured after initialization.
frameRate (optional)
frameRate?: number | undefinedMaximum capture frequency; defaults to 60 frames per second.
memoryHeadroom (optional)
memoryHeadroom?: number | undefinedInitial estimated memory multiplier; defaults to 1.15. Memory may grow.
signal (optional)
signal?: AbortSignal | undefinedRelated API: signal.
Aborting discards the recording, including during initialization.
onRenderComplete (optional)
onRenderComplete?: ((completion: PibblRenderCompletion) => void) | undefinedRelated API: PibblRenderCompletion.
Observe each root render after its committed application state is published. Failed attempts are reported separately and never produce recorded frames.
Parameters
Section titled “Parameters”completion— The committed or failed root render attempt.
onFrameCaptured (optional)
onFrameCaptured?: ((frame: PibblRecordedFrameInfo) => void) | undefinedRelated API: PibblRecordedFrameInfo.
Observe the exact committed generation after its RGBA pixels were copied.
Parameters
Section titled “Parameters”frame— Metadata identifying the captured root bitmap.
PibblFrameRecordingSession
Section titled “PibblFrameRecordingSession”An active capture; stop keeps frames and cancel discards them.
interface PibblFrameRecordingSessionRelated API: PibblFrameRecordingSession.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:46
Properties and methods
Section titled “Properties and methods”
ready
readonly ready: Promise<void>Resolves after frame zero has been captured and capture has started.
finished
readonly finished: Promise<PibblFrameRecording>Related API: PibblFrameRecording.
Resolves when retained frames are ready, or rejects on cancellation/failure.
stop
stop: () => voidFinish at the current elapsed time, retaining captured frames. Idempotent.
cancel
cancel: () => voidDiscard an active recording and release its resources. Idempotent.
PibblRecordedFrameInfo
Section titled “PibblRecordedFrameInfo”Metadata for one immutable RGBA bitmap in physical backing pixels.
interface PibblRecordedFrameInfoRelated API: PibblRecordedFrameInfo.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:60
Properties and methods
Section titled “Properties and methods”
renderGeneration
readonly renderGeneration: numberRoot render generation whose committed bitmap was copied.
timestamp
readonly timestamp: numberMilliseconds since capture began; the initial frame is timestamp zero.
width
readonly width: numberBitmap width in physical backing pixels.
height
readonly height: numberBitmap height in physical backing pixels.
PibblRecordedFrame
Section titled “PibblRecordedFrame”A caller-owned copy of one frame’s RGBA8 bytes.
interface PibblRecordedFrame extends PibblRecordedFrameInfoRelated API: PibblRecordedFrame, PibblRecordedFrameInfo.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:74
Properties and methods
Section titled “Properties and methods”
data
readonly data: Uint8ClampedArray<ArrayBuffer>Independent RGBA8 bytes; mutations never affect retained pixels.
renderGeneration
readonly renderGeneration: numberRoot render generation whose committed bitmap was copied.
timestamp
readonly timestamp: numberMilliseconds since capture began; the initial frame is timestamp zero.
width
readonly width: numberBitmap width in physical backing pixels.
height
readonly height: numberBitmap height in physical backing pixels.
PibblFrameRecording
Section titled “PibblFrameRecording”Retained worker-owned frames; explicitly dispose after use.
interface PibblFrameRecordingRelated API: PibblFrameRecording.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:82
Properties and methods
Section titled “Properties and methods”
duration
readonly duration: numberActual recording length in milliseconds, including the final still hold.
frames
readonly frames: readonly PibblRecordedFrameInfo[]Related API: PibblRecordedFrameInfo.
Immutable metadata ordered by ascending timestamp.
readFrame
readFrame: (index: number) => Promise<PibblRecordedFrame>Related API: PibblRecordedFrame.
Copy one frame without transferring ownership of stored pixels.
Parameters
Section titled “Parameters”index— Zero-based recorded frame index.
Returns
Section titled “Returns”A caller-owned pixel copy and its metadata.
dispose
dispose: () => voidRelease the worker, stored pixels, and pending reads/exports. Idempotent.
PibblGifExportOptions
Section titled “PibblGifExportOptions”GIF encoding options; encoding never changes the retained recording.
interface PibblGifExportOptionsRelated API: PibblGifExportOptions.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:99
Properties and methods
Section titled “Properties and methods”
width (optional)
width?: number | undefinedOutput width in pixels; omitted preserves source width or the specified height’s aspect ratio.
height (optional)
height?: number | undefinedOutput height in pixels; omitted preserves source height or the specified width’s aspect ratio.
maxColors (optional)
maxColors?: number | undefinedMaximum palette entries, including transparency when no background is supplied; integer 2–256, default 256.
palette (optional)
palette?: readonly string[] | undefinedExact opaque CSS palette colors. Replaces automatic palette selection; must fit maxColors.
dithering (optional)
dithering?: boolean | undefinedApply Floyd–Steinberg error diffusion; defaults to false.
quantizationSampleFactor (optional)
quantizationSampleFactor?: number | undefinedNeuQuant sampling factor, integer 1–30; 1 spends most effort, default 10. Ignored with a supplied palette.
paletteSampleCount (optional)
paletteSampleCount?: number | undefinedMaximum pixels sampled for automatic palette selection across up to 32 frames; default 262144. Ignored with a supplied palette.
frameRate (optional)
frameRate?: number | undefinedOutput sampling frequency; defaults to 25. Must be at most 100.
repeatCount (optional)
repeatCount?: number | undefinedZero loops forever; omitted plays once; positive values repeat that many times.
background (optional)
background?: string | undefinedOptional opaque CSS color used to flatten partial alpha before quantization.
signal (optional)
signal?: AbortSignal | undefinedRelated API: signal.
Abort encoding while preserving the recording for another export.
onProgress (optional)
onProgress?: ((progress: number) => void) | undefinedProgress from zero to one, delivered between bounded worker batches.
Parameters
Section titled “Parameters”progress— Fraction of output frames encoded.
PibblRenderCompletion
Section titled “PibblRenderCompletion”A completed root-render attempt. Failed generations were attempted, not committed. Generations identify renders of one mounted root; they are not global IDs.
type PibblRenderCompletion = | { /** The root bitmap and render-owned state committed successfully. */ readonly status: "committed"; /** Monotonically increasing generation of this root's committed render. */ readonly generation: number; } | { /** The attempted render failed and supplies no committed pixel evidence. */ readonly status: "failed"; /** Attempted generation of this root; it must not identify recorded pixels. */ readonly generation: number; }Related API: PibblRenderCompletion.
See also
Section titled “See also”View source — packages/core/src/lib/recording/types.ts:29
Properties and methods
Section titled “Properties and methods”
status
readonly status: "committed" | "failed"The root bitmap and render-owned state committed successfully. The attempted render failed and supplies no committed pixel evidence.
generation
readonly generation: numberMonotonically increasing generation of this root’s committed render. Attempted generation of this root; it must not identify recorded pixels.
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Record committed frames and export a GIF: Capture a live Canvas color change, read frame metadata and pixels, export a GIF and release owned resources. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.