Skip to main content

Types

Exported by nitro-view-shot​

ViewShotViewRef​

The value a ViewShotView ref receives.

FieldTypeDescription
capture()() => Promise<Image>Captures this view and its children. Rejects when unmounted or with an empty size.

ViewShotViewProps​

type ViewShotViewProps = ViewProps & { ref?: Ref<ViewShotViewRef> }

Every NitroUI ViewProps, plus a ref typed as ViewShotViewRef.

From nitro-ui-renderer​

These come from nitro-ui-renderer/hybrids and are listed as of nitro-ui-renderer 0.3.0.

Image​

MemberTypeDescription
widthnumberWidth in pixels.
heightnumberHeight in pixels.
toRawPixelData(allowGpu?) / toRawPixelDataAsyncRawPixelDataRaw pixel bytes and their byte order.
toEncodedImageData(format, quality?) / …AsyncEncodedImageDataEncoded file bytes.
toBase64Async(format, quality?)Promise<string>Encoded bytes as padded Base64, no data-URL prefix.
saveToFileAsync(path, format, quality?)Promise<void>Writes an encoded file to path.
saveToTemporaryFileAsync(format, quality?)Promise<string>Writes a temporary file and returns its path.
resize, crop, rotate, mirrorHorizontally, renderIntoImageReturn a new Image; each has an Async variant.

RawPixelData​

FieldTypeDescription
bufferArrayBufferPixel bytes.
widthnumberWidth in pixels.
heightnumberHeight in pixels.
pixelFormatPixelFormatByte order in memory, e.g. 'BGRA'.

EncodedImageData​

FieldTypeDescription
bufferArrayBufferEncoded file bytes.
widthnumberWidth in pixels.
heightnumberHeight in pixels.
imageFormatImageFormatContainer format.

ImageFormat and PixelFormat​

type ImageFormat = 'jpg' | 'png' | 'heic'

type PixelFormat =
'ARGB' | 'BGRA' | 'ABGR' | 'RGBA' | 'XRGB' | 'BGRX' | 'XBGR' | 'RGBX' | 'RGB' | 'BGR' | 'unknown'

X marks a skipped alpha byte.