{"id":15351105,"url":"https://github.com/realityforge/gwt-serviceworker-linker","last_synced_at":"2025-04-14T23:37:11.394Z","repository":{"id":57739983,"uuid":"246172321","full_name":"realityforge/gwt-serviceworker-linker","owner":"realityforge","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-26T02:53:55.000Z","size":175,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T11:42:51.722Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/realityforge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-03-10T00:35:47.000Z","updated_at":"2024-07-26T02:53:58.000Z","dependencies_parsed_at":"2024-01-18T07:50:19.794Z","dependency_job_id":"09f13baa-af52-40e2-a5c9-972f98ccf535","html_url":"https://github.com/realityforge/gwt-serviceworker-linker","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fgwt-serviceworker-linker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fgwt-serviceworker-linker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fgwt-serviceworker-linker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realityforge%2Fgwt-serviceworker-linker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realityforge","download_url":"https://codeload.github.com/realityforge/gwt-serviceworker-linker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248980942,"owners_count":21193142,"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-10-01T12:01:06.113Z","updated_at":"2025-04-14T23:37:11.374Z","avatar_url":"https://github.com/realityforge.png","language":"Java","funding_links":[],"categories":["Web Worker"],"sub_categories":[],"readme":"# gwt-serviceworker-linker\n\n[![Build Status](https://api.travis-ci.com/realityforge/gwt-serviceworker-linker.svg?branch=master)](http://travis-ci.com/realityforge/gwt-serviceworker-linker)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.realityforge.gwt.serviceworker/gwt-serviceworker-linker.svg?label=latest%20release\"/\u003e](https://search.maven.org/search?q=g:org.realityforge.gwt.serviceworker)\n\nThe [ServiceWorkers](https://www.w3.org/TR/service-workers/) specification enables applications\nto take advantage of persistent background processing, including hooks to enable bootstrapping\nof web applications while offline. This project attempts to basic AppCache behaviour using\nServiceWorkers.\n\n## Quick Start\n\nThe simplest way to serviceworker enable a GWT application is to;\n\n* add the following dependencies into the build system. i.e.\n\n```xml\n\u003cdependency\u003e\n   \u003cgroupId\u003eorg.realityforge.gwt.serviceworker\u003c/groupId\u003e\n   \u003cartifactId\u003egwt-serviceworker-linker\u003c/artifactId\u003e\n   \u003cversion\u003e0.02\u003c/version\u003e\n   \u003cscope\u003eprovided\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n* add the following snippet into the .gwt.xml file.\n\n```xml\n\u003cmodule rename-to='myapp'\u003e\n  ...\n\n  \u003cinherits name=\"org.realityforge.gwt.serviceworker.Linker\"/\u003e\n\n  \u003c!-- enable the linker that generates the serviceworker javascript --\u003e\n  \u003cadd-linker name=\"serviceworker\"/\u003e\n\n  \u003c!-- configure all the static files not managed by the GWT compiler --\u003e\n  \u003cextend-configuration-property name=\"serviceworker_static_files\" value=\"./\"/\u003e\n  \u003cextend-configuration-property name=\"serviceworker_static_files\" value=\"index.html\"/\u003e\n\u003c/module\u003e\n```\n\n* launch the service worker from within the application using [Elemental2](https://github.com/google/elemental2).\n\n```java\nimport static elemental2.dom.DomGlobal.*;\n\n...\n\nif ( null != navigator.serviceWorker )\n{\n  navigator.serviceWorker\n    .register( GWT.getModuleName() + \"-sw.js\" )\n    .then( registration -\u003e {\n      console.log( \"ServiceWorker registration successful with scope: \" + registration.getScope() );\n\n      // Every minute attempt to update the serviceWorker. If it does update\n      // then the \"controllerchange\" event will fire.\n      DomGlobal.setInterval( v -\u003e registration.update(), 60000 );\n\n      return null;\n    }, error -\u003e {\n      console.log( \"ServiceWorker registration failed: \", error );\n      return null;\n    } );\n\n  navigator.serviceWorker.addEventListener( \"controllerchange\", e -\u003e {\n    // This fires when the service worker controlling this page\n    // changes, eg a new worker has skipped waiting and become\n    // the new active worker.\n    console.log( \"ServiceWorker updated \", e );\n  } );\n}\n  ...\n```\n\nThis should be sufficient to get your application using a serviceworker to cache static assets.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealityforge%2Fgwt-serviceworker-linker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealityforge%2Fgwt-serviceworker-linker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealityforge%2Fgwt-serviceworker-linker/lists"}