npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-turbo-image

v1.21.0

Published

Performant image for React native

Downloads

47,358

Readme

You can find more examples in example folder

Performant image component for React Native. Powered by Nuke and Coil

Features

  • Support New Architecture. see the example
  • Support authorization headers
  • Support thumbhash, blurhash and memoryCacheKey for placeholder
  • Memory cache, aggressive LRU disk cache and HTTP disk cache
  • Prefetch, dispose, cleanMemoryCache and cleanDiskCache
  • Written in TypeScript, Swift and Kotlin
  • Support special formats (SVG, Gif, APNG)

Installation

npm install react-native-turbo-image

cd ios && pod install

Usage

import TurboImage from 'react-native-turbo-image';

<TurboImage
  source={{ uri: "https://github.com/duguyihou/react-native-turbo-image/assets/9347790/7955aa00-0b53-44d1-88bd-9b5e320db21e" }}
  style={{ width: 300, height: 300 }}
/>;

Properties

| Name | Type | Description | Default | | --------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | source | Source | (Required) an object containing a uri string | - | | style | ImageStyle | Styles to be applied to the image. | - | | placeholder | Placeholder | show placeholder while loading | - | | cachePolicy | CachePolicy | Determines how to cache the image | urlCache | | resizeMode | String | Resize the image with one of the options: contain cover stretch center | contain | | indicator | object | style: medium(default) or largecolor: number / ColorValue | - | | fadeDuration | number | The transition duration of the image. Note: To avoid flicking, it will be set to 0 when a placeholder is provided | 300(iOS) / 100(Android) | | resize | number | Scales an image to the given width preserving aspect ratio | - | | blur | number | The blur radius of the blur filter added to the image | - | | monochrome | number / ColorValue | The color applied to the image. note: For iOS and Android Q+, it works with any color. For Android Q-, it only supports grayscale | - | | tint | number / ColorValue | The color is applied to every non-transparent pixel, causing the image’s shape to adopt that color. This effect is not applied to placeholders | - | | showPlaceholderOnFailure | boolean | Show the placeholder image in the case of a failure | false | | rounded | boolean | Round the image into a circle | false | | enableLiveTextInteraction | boolean | Enables Live Text interaction with the image (iOS 16+ only) | false | | allowHardware | boolean | Setting this to false will reduce performance on API 26 and above. Only disable this if necessary. Coil's docs (Android only) | true | | format | string | Specify the format for special image, e.g. svg, gif and apng. In general, TurboImage will determine the decoder automatically. | - | | onStart | Function | Gets called when the request is started. | - | | onProgress | Function | Gets called when the request progress is updated. | - | | onSuccess | Function | Gets called when the requests finished successfully. | - | | onFailure | Function | Gets called when the requests fails. | - | | onCompletion | Function | Gets called when the request is completed. | - |

Methods

prefetch

await TurboImage.prefetch([Source]);

dispose

await TurboImage.dispose([Source]);

clearMemoryCache

await TurboImage.clearMemoryCache();

clearDiskCache

await TurboImage.clearDiskCache();

Types

Source

| Name | Type | Description | | ---------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------- | | uri | string | the url of the image | | headers | Record<string, string> | An object representing the HTTP headers to send along with the request for a remote image | | cacheKey | string | The cache key used to query and store this specific image. If not provided, the uri is used also as the cache key |

Placeholder

| Name | Type | Description | | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | thumbhash | string | A string used to generate the image placeholder. For more information, see thumbhash | | blurhash | string | A string used to generate the image placeholder. For more information, see woltapp/blurhash. | | memoryCacheKey | string | Using the key of previous request as placeholder. For more information, see Memory Cache Key |

| thumbhash | blurhash | memoryCacheKey | | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | | | |

CachePolicy

| Name | Type | Description | | ----------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | urlCache | string | Allows the server to manage caching precisely through cache-control HTTP headers. You can determine which images to cache and caching duration | | dataCache | string | Ignores HTTP cache control |

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

TurboImage is released under the MIT license. Some of the dependencies are licensed differently, with the Apache-2.0 license, for example.