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

expo-play-asset-delivery

v1.2.3

Published

Play Asset Delivery integration for Expo

Downloads

4

Readme

expo-play-asset-delivery

Play Asset Delivery integration for Expo

npm

Installation

  • Install the package expo-play-asset-delivery from NPM

  • Configure Expo Plugin in app.config.js

    module.exports = {
        // ...
        plugins: [
            // ...
            [
                'expo-play-asset-delivery',
                [
                    {
                        // Internal name of the asset pack
                        name: 'asset-pack',
                        // Path of the assets directory relative to the (Expo) project root folder
                        path: 'assets',
                        // Delivery mode (see https://developer.android.com/guide/playcore/asset-delivery#delivery-modes)
                        deliveryMode: 'fast-follow',
                    },
                ],
            ],
        ],
    };
  • :warning: If you are using bare workflow (if you don't know what it is you aren't):

    • Run npx expo prebuild --clean to regenerate the build files (this must be done after every change to the plugin configuration)
  • :warning: If you are using expo-dev-client (if you don't know what it is you aren't):

    • The dev client must be rebuilt every time the plugin configuration changes or the assets are changed

Usage

If you are using fast-follow or on-demand delivery modes, you must check the status of the asset pack before trying to access the assets:

import { getAssetPackStates, requestAssetPackFetch, AssetPackStatus } from 'expo-play-asset-delivery';

const state = await getAssetPackStates(['asset-pack'])['asset-pack']
if (state.status !== AssetPackStatus.COMPLETED) {
    await requestAssetPackFetch(['asset-pack']);
    // ...
}

After requesting the download of the asset pack, you can add an event listener to monitor the download progress:

import { addAssetPackProgressListener, AssetPackState } from 'expo-play-asset-delivery';

addAssetPackProgressListener((state: AssetPackState) => {
    // ...
});

Regardless of the delivery mode, you can load the assets by their filename:

import { loadPackedAssetAsBase64 } from 'expo-play-asset-delivery';

const base64 = await loadPackedAssetAsBase64('asset-pack', 'assets/image.png');
const uri = `data:image/png;base64,${base64}`;

// ...

return (
  <Image source={{ uri }} />
)

If you have issues loading larger files, see this issue.

Development

In order to access the asset packs during development, you must install expo-dev-client and configure it to build as AAB:

{
  "build": {
    "development": {
      "android": {
        "gradleCommand": ":app:bundleDebug"
      }
    }
  }
}

You can then use bundletool to create and install the APK including the asset packs (you can download the keystore with the alias/passwords from Expo):

java -jar bundletool-all-*.jar build-apks --bundle=build-1674208169858.aab --output output.apks --local-testing --ks=keystore.jks --ks-key-alias=<keyalias>
java -jar bundletool-all-*.jar install-apks --apks=output.apks