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

xgrn-image

v1.0.5

Published

xgrn-image is used to solve cache problems of react-native image component.

Downloads

2

Readme

XGImage 新光互联图片控件

项目背景

React Native自带的Image控件在缓存表现上存在较大的问题,基本可以认为没做什么缓存处理。为了解决这个问题,我们需要实现一个带有预期的缓存功能的图片控件: XGImage

假若我们抛开React Native,在做原生开发的时候,不论是 iOS 还是 Android 都已经有一套自己成熟的图片缓存处理方案。比如 iOS 的 SDWebImageYYWebImage等都是采用内存和硬盘两级的缓存方案对远程图片进行缓存处理。因此,我们不需要从零开始去实现所需的功能,只需要将这些现有方案桥接给React Native即可。

考虑到现有的情况,iOS 端采用YYWebImage,安卓采用Glide,而桥接方案则是参考了FastImage这个项目。为了可以快速上手使用,还有一些FastImage的功能残留,但它本身的处理做得并不好,因此并不建议使用,具体使用方案参考本文档。

已实现及后续计划实现内容

目标 | 进度 ---|--- 图片缓存 | ☑️ YYWebImage ☑️ Glide 图片格式 | ☑️ jpg☑️ png🕓 webp 可支持,但需测试覆盖🕓 更多格式根据需求进行适配 回调事件 | ☑️ 开始加载图片 onLoadStart☑️ 图片加载进度 onProgress☑️ 图片加载成功 onLoad☑️ 图片加载失败 onError☑️ 图片加载结束统一回调 onLoadEnd PlaceHolder | 🕓 支持使用本地图片作为默认图 OSS URL 处理 | 🕓 source 中支持额外的oss属性🕓 oss 支持width,height,quality,format等属性🕓 支持全局对oss进行配置🕓 针对oss对缓存策略进行优化 图片加载队列 | ⚠️ 优先级队列:不实现,只是网络请求发出先后问题,实际价值不大⚠️ 串行请求:不实现,请在业务层用回调函数自己实现 更多功能 | 🕓 请直接联系张斌或徐峰详聊

使用说明

安装
yarn add xgrn-image
react-native link xgrn-image
JS调用
import XGImage from 'xgrn-image';

// 远程图片
<XGImage
    style={styles.myImage}
    source={{uri: 'http://xxx.yyy.zzz/a.png'}}
    onLoad={(event) => console.warn(event.nativeEvent)}
    placeholderImage={img_pic}
    placeholderColor={'red'}
/>

// 本地图片
<XGImage
    style={styles.myImage}
    source={localImageID}
/>