@solidnative-dev/images

Validated image dimensions, prefetching, and cache inspection for Solid Native. The React Native adapter calls the ImageLoader TurboModule directly without loading React Native's Image JS facade.

Installation#

sh
pnpm add @solidnative-dev/images

No extra native dependency is required—uses React Native's built-in ImageLoader TurboModule.

Usage#

ts
import { createReactNativeImageService } from "@solidnative-dev/images/react-native";
import { createImageController } from "@solidnative-dev/images/solid";

const images = createImageController(createReactNativeImageService());

const dimensions = await images.getDimensions({
  uri: "https://images.example/hero.png",
  headers: { Authorization: "Bearer …" },
});

const prefetch = images.prefetch("https://images.example/hero.png");
await prefetch.result;

const cache = await images.queryCache(["https://images.example/hero.png"]);
// [{ uri: "https://images.example/hero.png", location: "disk/memory" | "memory" | "disk" | "none" }]

Entrypoints#

ImportKey exports
@solidnative-dev/imagescreateImageService, ImageService, ImageRequest, ImageDimensions, ImageCacheEntry, ImagePrefetchCancelledError
@solidnative-dev/images/react-nativecreateReactNativeImageService, ImagePrefetchCancelledError
@solidnative-dev/images/solidcreateImageController, SolidImageController, ImageOwnerDisposedError, ImagePrefetchCancelledError

Behavior & platform notes#

  • Normalized native ABI: Smooths over Android vs iOS ImageLoader differences (object vs width/height tuple from getSize, signed 32-bit prefetch request IDs on Android vs no ID on iOS).
  • Cancellation: prefetch.cancel() cancels native work on Android. Because React Native's iOS ImageLoader has no native cancellation primitive, iOS cancellation rejects immediately with ImagePrefetchCancelledError and ignores late settlements.
  • Bounds & deduplication: URIs (up to 8,192 chars), headers (up to 128 headers / 64 Ki chars total), cache query cardinality (up to 256 URIs), and dimensions are bounded and validated. queryCache deduplicates native lookups while preserving caller order.
  • Owner disposal & privacy: Disposing the Solid owner rejects pending work with ImageOwnerDisposedError (and cancels active Android prefetches). Causal traces omit URIs and request headers.