{"id":15862119,"url":"https://github.com/afeiship/sw-runtime","last_synced_at":"2025-04-01T20:35:32.320Z","repository":{"id":217969818,"uuid":"745247327","full_name":"afeiship/sw-runtime","owner":"afeiship","description":"Service worker runtime for workbox.","archived":false,"fork":false,"pushed_at":"2024-09-16T04:40:40.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-07T13:24:29.198Z","etag":null,"topics":["active","cache","cli","install","pwa","service-worker","sw","workbox"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/afeiship.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-18T23:33:34.000Z","updated_at":"2024-09-16T04:40:43.000Z","dependencies_parsed_at":"2024-01-31T16:57:01.319Z","dependency_job_id":"b5260dae-b9c3-4121-8714-84dd135e90bd","html_url":"https://github.com/afeiship/sw-runtime","commit_stats":null,"previous_names":["afeiship/sw-runtime"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fsw-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fsw-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fsw-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fsw-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afeiship","download_url":"https://codeload.github.com/afeiship/sw-runtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709935,"owners_count":20821298,"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":["active","cache","cli","install","pwa","service-worker","sw","workbox"],"created_at":"2024-10-05T22:25:16.588Z","updated_at":"2025-04-01T20:35:32.292Z","avatar_url":"https://github.com/afeiship.png","language":"TypeScript","readme":"# sw-runtime\n\u003e Service worker runtime for workbox.\n\n[![version][version-image]][version-url]\n[![license][license-image]][license-url]\n[![size][size-image]][size-url]\n[![download][download-image]][download-url]\n\n## installation\n```shell\nnpm install @jswork/sw-runtime\n```\n\n## skipWaiting\n```js\n// case1: skipWaiting true: will be update immediately\nmodule.exports = {\n  maximumFileSizeToCacheInBytes: 100 * 1024 * 1024,\n  globDirectory: 'build/',\n  globPatterns: ['**/*.{js,png,json,txt,css,map}'],\n  globIgnores: ['*/fallback.js'],\n  skipWaiting: true,\n  clientsClaim: true,\n  //...\n};\n\n// case2: skipWaiting false: will be update when you click sw-tips `reload` button\nmodule.exports = {\n  maximumFileSizeToCacheInBytes: 100 * 1024 * 1024,\n  globDirectory: 'build/',\n  globPatterns: ['**/*.{js,png,json,txt,css,map}'],\n  globIgnores: ['*/fallback.js'],\n  skipWaiting: false,\n  clientsClaim: false,\n  //...\n};\n```\n\n## usage\n```js\nimport SwRuntime from '@jswork/sw-runtime';\n\n// App Did Mount, config sw\nwindow.onload = function () {\n  SwRuntime.install({\n    autoUpdate: true,\n    autoUpdateInterval: 5 * 1000,\n    onAutoUpdate: function () {\n      console.log('SW Event:', 'onAutoUpdate');\n    },\n    onUpdateReady: function ({ context }) {\n      console.log('SW Event:', 'onUpdateReady');\n      setTimeout(function () {\n        console.log('SW Event:', 'do applyUpdate');\n        // Need to reload page, or it will be pending.\n        context.applyUpdate().then(()=\u003e{\n          window.location.reload();\n        });\n      }, 1000);\n    },\n  });\n};\n```\n\n## todos\n1. unpkg/jsdelivr cdn zero cache?(not ok)\n2. auto update interval(ok)\n\n## license\nCode released under [the MIT license](https://github.com/afeiship/sw-runtime/blob/master/LICENSE.txt).\n\n[version-image]: https://img.shields.io/npm/v/@jswork/sw-runtime\n[version-url]: https://npmjs.org/package/@jswork/sw-runtime\n\n[license-image]: https://img.shields.io/npm/l/@jswork/sw-runtime\n[license-url]: https://github.com/afeiship/sw-runtime/blob/master/LICENSE.txt\n\n[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/sw-runtime\n[size-url]: https://github.com/afeiship/sw-runtime/blob/master/dist/index.min.js\n\n[download-image]: https://img.shields.io/npm/dm/@jswork/sw-runtime\n[download-url]: https://www.npmjs.com/package/@jswork/sw-runtime\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafeiship%2Fsw-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafeiship%2Fsw-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafeiship%2Fsw-runtime/lists"}