{"id":13605311,"url":"https://github.com/choojs/choo-service-worker","last_synced_at":"2025-07-21T06:35:05.443Z","repository":{"id":57198225,"uuid":"96717672","full_name":"choojs/choo-service-worker","owner":"choojs","description":"👷 - Service worker loader for choo","archived":false,"fork":false,"pushed_at":"2019-06-09T08:32:21.000Z","size":33,"stargazers_count":25,"open_issues_count":0,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-08T22:39:42.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/choojs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-09T23:32:15.000Z","updated_at":"2024-11-30T13:05:22.000Z","dependencies_parsed_at":"2022-09-16T13:12:32.808Z","dependency_job_id":null,"html_url":"https://github.com/choojs/choo-service-worker","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/choojs/choo-service-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fchoo-service-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fchoo-service-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fchoo-service-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fchoo-service-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choojs","download_url":"https://codeload.github.com/choojs/choo-service-worker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fchoo-service-worker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264677831,"owners_count":23648131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:00:57.292Z","updated_at":"2025-07-21T06:35:05.426Z","avatar_url":"https://github.com/choojs.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# choo-service-worker [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nService worker loader for choo. Only runs in the browser, and emits events.\nDoes not include the worker code itself, you'll need to serve it using a tool\nlike `bankai`.\n\n## Usage\n```js\nvar choo = require('choo')\n\nvar app = choo()\nif (process.env.NODE_ENV !== 'production') {\n  app.use(require('choo-service-worker/clear')())\n}\napp.use(require('choo-service-worker')())\napp.mount('body')\n```\nThe above example will install your service worker, and add the events and state \nproperties documented below. For a complete example on how to use them check the \n[example.js](./example.js) file.\n\n## Events\n### `log:error` | `sw.events.ERROR`\nEmitted if the worker fails to register.\n\n### `sw:installed` | `sw.events.INSTALLED`\nEmitted when the worker correctly registers for the first time.\n\n### `sw:updated` | `sw.events.UPDATED`\nEmitted when an already saved worker register or update its content.\n\n### `sw:redundant` | `sw.events.REDUNDANT`\nEmitted when an existing worker become redundant.\n\n### `sw:postMessage` | `sw.events.POST_MESSAGE`\nEmit this to post a message to the current service worker. This event is not \nmeant to be handled by choo (or any client).\n\n### `sw:message` | `sw.events.MESSAGE`\nListen to this event to hadle messages from the worker. This event is not meant \nto be sent by choo (or any client).\n\n### `sw:sync` | `sw.events.SYNC`\nEmit this to register a sync tag to the service worker. This event is not \nmeant to be handled by choo (or any client).\n\n### `sw:notificationRequest` | `sw.events.NOTIFICATION_REQUEST`\nEmit this to ask for authorization to send notifications. This event is not \nmeant to be handled by choo (or any client).\n\n## API\n### `plugin = sw([route], [opts])`\nRegister a new service worker if possible. Route defaults to `/sw.js`. \nAn optional `opts` object can be passed, you can add a `electron` \nBoolean property to the options object, to enable registration in electron, \nthe rest of the options are passed directly to the registration method of \nthe service worker. Note that, if you enable electron with `opts.electron`, \nthe scope property will be forced to  the root path of your app. Emits \nevents when the worker is registered. The plugin also add a few properties \nto the app state.\n\n- `state.syncTags`: `array` - an array of registered tags for background \nsyncronization.\n\n### `clear = sw/clear()`\nClear all service workers.\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/choo-service-worker.svg?style=flat-square\n[3]: https://npmjs.org/package/choo-service-worker\n[4]: https://img.shields.io/travis/yoshuawuyts/choo-service-worker/master.svg?style=flat-square\n[5]: https://travis-ci.org/yoshuawuyts/choo-service-worker\n[6]: https://img.shields.io/codecov/c/github/yoshuawuyts/choo-service-worker/master.svg?style=flat-square\n[7]: https://codecov.io/github/yoshuawuyts/choo-service-worker\n[8]: http://img.shields.io/npm/dm/choo-service-worker.svg?style=flat-square\n[9]: https://npmjs.org/package/choo-service-worker\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fchoo-service-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoojs%2Fchoo-service-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fchoo-service-worker/lists"}