rough-native
Version:
Create graphics using HTML Canvas or SVG with a hand-drawn, sketchy, appearance. Features comprehensive React hooks, memory management, and React 18 concurrent rendering support.
73 lines (72 loc) • 2.98 kB
TypeScript
/// <reference types="react" />
import { RoughReactNativeSVG } from './react-native-svg';
import { Config, Options } from './core';
import { Point } from './geometry';
export declare function useDeepMemoWithDebug<T>(value: T, deps?: React.DependencyList, debugName?: string): T;
export declare const debugUtils: {
getDeepEqualStats: () => {
hits: number;
misses: number;
hitRate: number;
memoryPressure: "high" | "low" | "medium";
maxCacheSize: number;
currentCacheCount: number;
};
clearDeepEqualCache: () => void;
getRoughInstanceCount: () => number;
getShapeCacheSize: () => number;
clearRoughInstances: () => void;
clearShapeCache: () => void;
getMemoryPressure: () => "high" | "low" | "medium";
getRecommendedCacheSize: () => number;
forceMemoryCleanup: () => void;
clearAllCaches: () => void;
};
/**
* React hook that provides a RoughReactNativeSVG instance with automatic cleanup
* Concurrent rendering safe with useSyncExternalStore
* @param config - Optional configuration for the rough instance
* @returns RoughReactNativeSVG instance that will be automatically disposed on unmount
*/
export declare function useRough(config?: Config): RoughReactNativeSVG;
/**
* React hook for creating shapes with automatic lifecycle management
* Concurrent rendering safe with cached shape generation
* @param shapeType - Type of shape to create
* @param params - Parameters for the shape
* @param options - Rough.js options
* @param config - Optional configuration for the rough instance
* @returns Rendered shape element
*/
export declare function useRoughShape<T extends keyof ShapeParams>(shapeType: T, params: ShapeParams[T], options?: Options, config?: Config): any;
/**
* React hook for batch creating multiple shapes with shared configuration
* Concurrent rendering safe with batch shape generation
* @param shapes - Array of shape definitions
* @param config - Optional configuration for the rough instance
* @returns Array of rendered shape elements
*/
export declare function useRoughShapes(shapes: ShapeDefinition[], config?: Config): any;
/**
* React hook that provides a stable rough instance that only recreates when config changes deeply
* @param config - Configuration for the rough instance
* @returns RoughReactNativeSVG instance
*/
export declare function useStableRough(config?: Config): RoughReactNativeSVG;
interface ShapeParams {
line: [number, number, number, number];
rectangle: [number, number, number, number];
ellipse: [number, number, number, number];
circle: [number, number, number];
linearPath: Point[];
polygon: Point[];
arc: [number, number, number, number, number, number, boolean?];
curve: Point[] | Point[][];
path: string;
}
interface ShapeDefinition {
type: keyof ShapeParams;
params: ShapeParams[keyof ShapeParams];
options?: Options;
}
export type { ShapeParams, ShapeDefinition };