Skip to content
/ butler Public

A small, elegant and friendly library to deal elegantly with Service Workers (experimental)

Notifications You must be signed in to change notification settings

h2non/butler

Repository files navigation

butler Build Status Version Code Climate Stories in Ready

Work in progress!

An elegant, friendly and courteous butler to avoid headaches with ServiceWorkers in a clean, elegant and simple programmatic in order to provide a better approach for insanely great use of ServiceWorker features underling ugly implementation details

ServiceWorker introduces interesting, reliable and powerful ways to do awesome things in the browsers which will evolve the Web to the next-level

Note that ServiceWorker is still an experimental technology and its standard is under active discussion and it is not currently supported by latest production browsers

Aditionally you should consider that this library is very much a work in progress, as it is a hacking-driven implementation, therefore important changes can be done in a near future and API retrocompatibility is not premise

If you are new with ServiceWorker, before getting started you could take a look to the explainer document, HTML5rocks introduction or the draft specification

Installation

Via Bower

bower install butler

Via Component

component install h2non/butler

Or loading the script remotely

<script src="//cdn.rawgit.com/h2non/butler/0.1.0/butler.js"></script>

Setup

Due to ServiceWorkers security limitations, it's required to copy the butler.worker.js source in the root directory of your application (although, you could use the HTTP server rewrite rules to do the same in remote servers) in order to be enable the Service Worker control into the desired page scope (defaults to /)

Example command if you are using Bower as package manager

cp ./bower_components/butler/butler.worker.js .

Chrome Canary setup

To start hacking with ServiceWorker you should enable the "experimental Web Platform features" flag in Canary. You can do it opening chrome://flags. Then you should restart the browser

How to debug

Open chrome://serviceworker-internals/, or alternatively use chrome://inspect/#service-workers

Browser Support

Chrome Firefox IE Opera Safari
Canary ✔ Nightly ✔ No ? No

For more information about browsers support see "is ServiceWorker ready?" site

Basic usage

To Do

API

butler([ path, options ])

Create a new butler instance

path argument points to the butler.worker.js. Default to /butler.worker.js

Supported options are:

  • scope string - Worker control path scope. Default to /

butler.workerPath

Type: string

Bock worker file path. Default to /butler.worker.js. Be aware with the scope security limitation

butler.VERSION

Type: string

Current library semantic version

Contributing

Wanna help? Cool! It will be appreciated :)

You must add new test cases for any new feature or refactor you do, always following the same design/code patterns that already exist

Development

Only node.js is required for development

Clone the repository

$ git clone https://github.com/h2non/butler.git && cd butler

Install dependencies

$ npm install

Generate browser bundle source

$ make browser

Run tests

$ make test

See the examples

$ ./node_modules/.bin/http-server

License

MIT - Tomas Aparicio

About

A small, elegant and friendly library to deal elegantly with Service Workers (experimental)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published