Files
RecipesCam/modules/recipescam-export/index.ts
T

77 lines
2.9 KiB
TypeScript

import { requireNativeModule } from 'expo-modules-core';
export interface DecodeEncodeTimings {
decodeMs: number;
encodeWriteMs: number;
totalMs: number;
}
export interface ColorTimings {
decodeMs: number;
toneMs?: number;
cinemaMs?: number;
colorMs: number;
clarityMs?: number;
grainMs?: number;
encodeWriteMs: number;
totalMs: number;
}
/** Rect (pixel coords) of the center-largest aspect crop, computed in JS. */
export interface CropRect {
x: number;
y: number;
width: number;
height: number;
}
/** ToneUniforms from toneShader.ts (0/0/0 = skip tone pass). */
export interface ToneUniforms {
dr: number;
hl: number;
sh: number;
}
/** Optional pipeline params passed as a map (native Coroutine arity cap = 8). */
export interface PhotoAdjust {
/** ToneUniforms from toneShader.ts; default 0/0/0 = skip tone pass. */
toneDr?: number;
toneHl?: number;
toneSh?: number;
/** 16 flat floats from cinemaShader.ts getCinemaUniforms(season).flat; null/omitted or flat[0]=0 = skip. */
cinema?: number[] | null;
/** ColorAdjustments.denoise 0..10 (0 = skip). */
denoise?: number;
/** ColorAdjustments.clarity -10..10; >0 conv sharpen, <0 mist blur (0 = skip). */
clarity?: number;
/** ColorAdjustments.grain 0..10 (0 = skip). */
grain?: number;
/** JPEG quality 0..100; default 95. */
quality?: number;
}
export interface RecipescamExportModule {
/** Decode JPEG/PNG at srcPath (plain absolute path), re-encode JPEG q and write dstPath. All native, background. Returns stage timings in ms. */
decodeEncodeAsync(srcPath: string, dstPath: string, quality: number): Promise<DecodeEncodeTimings>;
/**
* Native pipeline mirroring exportEngine.ts filter order — decode, optional
* center-largest crop, optional tone pass (TONE_SKSL port), optional cinema
* seasonal grade (CINEMA_SKSL port), row-major 4x5 color matrix (translate
* column in 0..1 Skia space), optional denoise blur / clarity conv / mist
* blur / grain Overlay, then JPEG-encode to dstPath. All native, off the
* JS/main threads. Stage order mirrors exportEngine: crop -> tone -> cinema
* -> matrix -> denoise/clarity -> grain -> encode.
*/
processPhotoAsync(srcPath: string, dstPath: string, matrix: number[], crop: CropRect | null, adjust?: PhotoAdjust): Promise<ColorTimings>;
/** P1 alias: matrix + crop, no tone/cinema/enhance passes. */
processColorAsync(srcPath: string, dstPath: string, matrix: number[], crop: CropRect | null, quality: number): Promise<ColorTimings>;
/** P0 probe helpers — removed before ship. */
ping(): Promise<string>;
materializeBenchAsset(assetName: string): Promise<string>;
materializeSolidAsset(r: number, g: number, b: number): Promise<string>;
materializeRampAsset(): Promise<string>;
materializeStepAsset(): Promise<string>;
}
export default requireNativeModule('RecipesCamExport') as RecipescamExportModule;