@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/imagesNo 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#
| Import | Key exports |
|---|---|
@solidnative-dev/images | createImageService, ImageService, ImageRequest, ImageDimensions, ImageCacheEntry, ImagePrefetchCancelledError |
@solidnative-dev/images/react-native | createReactNativeImageService, ImagePrefetchCancelledError |
@solidnative-dev/images/solid | createImageController, SolidImageController, ImageOwnerDisposedError, ImagePrefetchCancelledError |
Behavior & platform notes#
- Normalized native ABI: Smooths over Android vs iOS
ImageLoaderdifferences (object vs width/height tuple fromgetSize, 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 iOSImageLoaderhas no native cancellation primitive, iOS cancellation rejects immediately withImagePrefetchCancelledErrorand 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.
queryCachededuplicates 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.