service-worker

How can I append DOM elements as they stream in from the network?

試著忘記壹切 提交于 2019-11-29 11:42:24
I have an element that I want to populate as a request's HTML streams in, instead of waiting for the complete response. This turned out to be incredibly difficult. Things I've tried: 1. milestoneNode.insertAdjacentHTML('beforebegin', text) Be lovely if this worked. Unfortunately, elements with quirky parsing wreck it — such as <p> and <table> . The resulting DOM can be charitably described as Dada. 2. Using a virtual DOM/DOM update management library Google's incremental-dom seemed most promising, but its patch() operation always restarts from the beginning of the container node. Not sure how

Expected ratio of ServiceWorker instances to Geolocation Updates

一个人想着一个人 提交于 2019-11-29 11:32:32
EDIT: There is a new version of my Brotkrumen Web App in the same location. Most important design/proposed-specification change is that TravelManager subscription should now be Client specific. The TravelEvent must contain the intended Client.id (TravelEvent.source.id). This means that the UA must monitor and filter GeoLocation updates per client. I have also added new demo functionality such as a Trip Summary that is displayed when you press the "Arrive" button. The trip can also be replayed onto Google Maps by pressing "Map Trip" or "Replay". If the last and next geolocation updates for the

@angular/service-worker not working when offline

主宰稳场 提交于 2019-11-29 11:25:12
I never got the service worker from Angular Mobile Team to work properly and at this point I guess I forgot to enable something, because it never worked since the initial release. Even if it installs and run on Google Chrome (smartphone & desktop) when I go offline it doesn't work anymore, also it randomly crashes after updates. There is no documentation on how to set it up. So here is how I did it: ng new test-service-worker npm install @angular/service-worker in .angular-cli.json , I add "serviceWorker": true npm build --prod , output ngsw-manifest.json sw-register.b73048fe3d9f8a1e7ae5

Read cookies from within a Service Worker?

一世执手 提交于 2019-11-29 11:08:32
I would like to read a cookie within my service worker to use it when setting up my caches, but can't find any way of doing it. Is there any way of doing that, or will I need to duplicate cookie data into IDB or similar? Marco Currently, you can't access them. There's a discussion in the W3C ServiceWorker repo about adding methods to access them in the future. 来源: https://stackoverflow.com/questions/35447567/read-cookies-from-within-a-service-worker

Service Worker registration error: Unsupported MIME type ('text/html')

别等时光非礼了梦想. 提交于 2019-11-29 09:47:53
I'm using create-react-app with an express server. create-react-app has a pre-configured ServiceWorker that caches local assets ( https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app ). The problem I encountered when I tried to publish on my server is that the service-worker.js file was available, but I was getting errors in my browser console when it tried to register it. On Firefox, I got this error: Error during service worker registration: TypeError: ServiceWorker script at https://my-domain.com/service-worker.js

Vue pwa with firebase cloud messaging not working properly

↘锁芯ラ 提交于 2019-11-29 07:59:55
im trying the following code: navigator.serviceWorker.register('service-worker.js') .then((registration) => { const messaging = firebase.messaging().useServiceworker(registration) console.log(messaging) messaging.requestPermission().then(function () { console.log('Notification permission granted.') messaging.getToken().then(function (currentToken) { if (currentToken) { console.log(currentToken) } }) }) }) my manifest: { "name": "Herot-Eyes", "short_name": "herot-eyes", "gcm_sender_id": "103953800507", "icons": [ { "src": "/static/img/icons/herot-eyes-192x192.png", "sizes": "192x192", "type":

Progressive Web App (PWA) in standalone mode OAuth error

◇◆丶佛笑我妖孽 提交于 2019-11-29 07:09:30
After I saved my PWA (Test App) built using Create React App to homescreen and launched the app in standalone mode on android using chrome and iOS using safari. Then in the app I initiate Firebase method signInWithPopup(GoogleProvider) the device asks me if I want to open the action with Test App or other browsers installed on device i.e chrome , firefox . If I select to open with my Test App the popup opens and I select the correct Google account. Error: After the google account selection the popup closes without ever redirecting back to my Test App . If I instead to open the Firebase method

How to modify auto generated service-worker in Create-React-App

一笑奈何 提交于 2019-11-29 06:52:46
I have created a sample app from Create-React-App library. When I ran the build command then it generates a service-worker on its own using cache-first strategy. But I need some more functionality like cache some API responses n all. I don't know how to modify the script which includes my own code in auto generated service-worker. I have found some help lines for my case but these are not enough to get a whole understanding of it. By default, the generated service worker file will not intercept or cache any cross-origin traffic, like HTTP API requests, images, or embeds loaded from a different

What is the use of `self.Clients.claim()`

非 Y 不嫁゛ 提交于 2019-11-29 06:43:16
问题 To register a service worker, I can call navigator.serviceWorker.register('/worker.js') Every time the page loads it checks for an updated version of worker.js . If an update is found, the new worker won't be used until all the page's tabs are closed and then re-opened. The solution I read was: self.addEventListener('install', function(event) { event.waitUntil(self.skipWaiting()); }); self.addEventListener('activate', function(event) { event.waitUntil(self.clients.claim()); }); I can

Background Geolocation ServiceWorker - onMessage Event order when Web App regains focus [closed]

元气小坏坏 提交于 2019-11-29 05:47:10
For complete details, and a more lengthy description, please refer to this W3C Service worker issue . This is my HTML5 Web App scenario: - My Web App has been backgrounded and stuck in my pocket while I go for a ride As I clock up the KMs my Service Worker(s) is regularly receiving GPS updates and invoking postMessage() to queue them up for my App to eventually plot on the Google map At the end of the ride I order a beer and foreground the Web App so I can see where I've been, average speed, and so on. My question are these: - 1) Will the Focus event fire before or after all of the Message