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

isomorphic-pkg-reader

v1.1.21

Published

Read IOS/Android pkg's(.apk/.ipa ) manifest info, for NodeJS/Webpack/Browserify.

Downloads

76

Readme

isomorphic-pkg-reader

Read IOS/Android package's(.apk/.ipa ) manifest info, for NodeJS/Webpack/Browserify.

Introduction

For .apk, parse the AndroidManifest.xml and resources.arsc files, read all values listed in AndroidManifest.xml(both primitive and reference type), also you can get and show the icon of the apk file directly from the parsed result.

For .ipa, parse the info.plist and embedded.mobileprovision files, read all basic information in info.plist file, including the icon of the ipa file(already handled the crushed pngs).

Install

npm i isomorphic-pkg-reader

Example


npm i;
npm run start;

Then open http://localhost:3000 to try the DEMO. You can find the basic usage for browser and NodeJS in the /example folder.

Constructor

PkgReader(pkgFile, Extensions, options)

var PkgReader = require('isomorphic-pkg-reader');

// in browser, it received a file object or a blob object.
var reader = new PkgReader(blob/file, 'apk', { withIcon: true, iconType: 'base64', searchResource: true });
pkgFile {Blob/File/String}

In browser, you can pass a File object that you can get from a <input type=file>, or you can pass a Blob directly.

In NodeJS, you need to pass the path or the file (Don't support passing a Buffer in here).

Extensions {String}

The extensions of your file, like 'apk' or 'ipa', because we need to make sure what type of the package is before we start to parse, and it's not reliable by detecting the extensions by the file name.

Options {Object}
Options.withIcon {Boolean}

Default: false.

Do you need the icon for showing. If it's true, we will find out the icon from the package and turn it into a BlobUrl or Base64, so you can directly use it for show like:

var reader = new PkgReader(file, 'apk', {withIcon: true});
reader.parse(function(err, pkgInfo) {
  document.querySelector('img').src = pkgInfo.icon; // It's a base64 DataUrl or a BlobUrl depending on another options: iconType
});

This options only works for browser.

Options.iconType {String}

Default: 'base64'

What type of icon you need to show, this can be either 'base64' or 'blob'.

This options only works for browser too.

Options.searchResource {Boolean}

Default: true

This options only works for .apk files. Whether parse the resources.arsc or not, if it's false, it won't parse the resources.arsc file and will return the information in the AndroidManifest.xml directly (So you can't read all reference type values).

APIs

reader.parse(callback)

The basic method, unzip the package file, read the information of the package.

The callback function received two parameters: error and pkgInfo: callback(error, pkgInfo)

What's the pkgInfo like is totally different from .apk to .ipa, also if you set the options.withIcon=true, you can access the icon from pkgInfo.icon, it'll be a BlobUrl or a DataUrl.

reader.getEntries(whatYouNeed, [options], callback)

Basically this method just calling the unzip.getBuffer function which you can find the docs here.

whatYouNeed {Array}

An array of String/RegExp/Function that contains the entry name you want to access.

options {Object}

Emm...currently we don't have any options here, forget it.

options.callback {Function}

Will be called like: callback(error, buffers).

buffers is a object that use the entry name as key, Buffer object as value.

reader.getEntry(entryName, options, callback)

This function works just like getEntries, but this will only search for one entry a time.

reader.parseIcon(buffer, callback)

This method repair the crushed pngs from ipa, turing a buffer/blob into a Png Object, then you can call the reader.redraw(png, function(err, base64Icon)) to get the repaired icon.

buffer {Buffer/Blob}

Buffer/Blob of your icon

callback(error, png)

Notice:

You can access this method only when you're parsing an ipa package, because for apk there is no need to use it.

Sometimes when you set options.withIcon=true, but we can't find out the icon from a ipa file in our search rules(In which you can read the source from /lib/utils -> findOutIcon function), so in this situation(maybe rare), you can also find out the icon yourself and use this to repair a curshed png.

reader.redraw(png, [type,] callback)

png {Object}

A Png Object that you get from calling reader.parseIcon.

type {String}

What type of data you need to show an icon, can be either 'base64' or 'blob', default to be 'base64'.

callback(error, icon)

When you set type=base64, the icon is an base64 format image, if type=blob, the icon is an BlobUrl.

Additional

Basically this pkg reader can get everything the other readers could get, and it can run both on browser and NodeJS.

Don't worried about the efficiency in browser, it's all async by using WebWorkers(That means it required IE10+, and currently it's only async in the unzipping process).

It's now working fine on our production environment, if you have any issue when using this, please make us know.

CHANGE LOG

2016.6.13 1.1.15

Fix some range error when parsing .apk resource map.