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

hoodie-plugin-appcache

v1.0.2

Published

Auto Updates and more for Offline First Applications

Downloads

23

Readme

appCache Hoodie Plugin

Auto Updates and more for Offline First Applications

Hoodie has offline-support built in—for data. If you want to make your app work offline as well, you have work with Application Cache – and it's a douchebag.

Until now.

The appCache Hoodie Plugin gives you a JavaScript API that gives you full control on whether you want to make your app work offline or not. It provides a beautiful JavaScript API for the initial caching, for updating, and much more.

The appCache Hoodie Plugin is basically a wrapper around The appCache Nanny, with the addition that it serves an auto-generated manifest.appcache file and appCacheNanny's appcache-loader.html.

No extra setup needed, you can make your app work offline with a single line of JavaScript.

Installation

hoodie install appcache
# this is needed as temporary workaround for
# https://github.com/hoodiehq/hoodie-plugin-appcache/issues/7
npm install -S appcache-nanny

Usage

First thing to learn is that you won't add manifest="path/to/manifest.appcache" properties to <html> tags any more. Your app doesn't get cached automatically, you have to start the caching explicitely:

hoodie.appCache.start().then(showAppIsCachedNotification)
// NOTE: start() does not yet return a promise: #5

That's it. Not only does your app work without internet connection now, it also automatically starts to check for update with an interval of 30 seconds.

Here's a list of all avialable methods:

// start initial caching & auto-updating, returns promise
hoodie.appCache.start({
  // in ms, defaults to 30000
  checkInterval: 10000,

  // in ms, defaults to 30000
  offlineCheckInterval: 5000,

  // set a path to your custom manifest loader,
  // defaults to /_api/_plugins/appcache/_api/loader
  loaderPath: '/appcache-loder.html',
});
// manually check for updates, returns promise
hoodie.appCache.update()
// stops auto-updating, returns promise
hoodie.appCache.stop()
// returns true / false
hoodie.appCache.hasUpdate()
// returns true / false
hoodie.appCache.isSupported()
// returns true / false
hoodie.appCache.isCheckingForUpdates()
// get / change settings
hoodie.appCache.set('checkInterval', 20000)
hoodie.appCache.set('offlineCheckInterval', 10000)
hoodie.appCache.set('loaderPath', '/new/appcache-loader.html')
var checkInterval = hoodie.appCache.get('checkInterval')
var offlineCheckInterval = hoodie.appCache.get('offlineCheckInterval')
var loaderPath = hoodie.appCache.get('loaderPath')

The appCache comes also with a list of events that you can react on

hoodie.appCache.on('update', handleUpdate)
hoodie.appCache.on('error', handleError)
hoodie.appCache.on('noupdate', handleNoUpdate)
hoodie.appCache.on('downloading', handleDownloading)
hoodie.appCache.on('progress', handleProgress)
hoodie.appCache.on('cached', handleCached)
hoodie.appCache.on('updateready', handleUpdateReady)
hoodie.appCache.on('start', handleStart)
hoodie.appCache.on('stop', handleStop)
hoodie.appCache.on('init:downloading', handleInitialDownloading)
hoodie.appCache.on('init:progress', handleInitialProgress)
hoodie.appCache.on('init:cached', handleInitialCached)

How it works

The appCache Hoodie Plugin automatically scans your app's www/ folder and adds all assets to the manifest.appcache to make them available offline. Each time an asset changes the manifest.appcache gets changed to trigger an update.

hoodie.appCache.start() add's a hidden <iframe> to the page that loads appcache-loader.html. That's an empty HTML file has the manifest property on its <html> tag to start or update the local cache. Both files are served from the appCache Hoodie Plugin's hook API.

Fine Print

appCache Hoodie Plugin has been authored by Gregor Martynus, proud member of The Hoodie Community, with help from Michael Oneppo. Please support our work: gittip us.

License: MIT