kopia lustrzana https://gitlab.com/rysiekpl/libresilient
libresilient test deploy: Request() init cannot have "mode: navigate", it seems
rodzic
a8707f758b
commit
67f178924d
|
@ -233,9 +233,13 @@ let decrementActiveFetches = (clientId) => {
|
|||
// got fetched) or not
|
||||
self.clients.get(clientId).then((client)=>{
|
||||
if (client !== null) {
|
||||
try {
|
||||
client.postMessage({
|
||||
allFetched: true
|
||||
})
|
||||
} catch(err) {
|
||||
self.log("service-worker", `postMessage failed for client: ${client}\n- Error message: ${err}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(()=>{
|
||||
|
@ -314,7 +318,11 @@ let LibResilientResourceInfo = class {
|
|||
this.client = client
|
||||
// Send a message to the client
|
||||
if (this.client !== null) {
|
||||
try {
|
||||
this.client.postMessage(this.values);
|
||||
} catch(err) {
|
||||
self.log("service-worker", `postMessage failed for client: ${this.client}\n- Error message: ${err}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -347,7 +355,11 @@ let LibResilientResourceInfo = class {
|
|||
self.log('service-worker', msg)
|
||||
// send the message to the client
|
||||
if (this.client && changed && (this.client !== null)) {
|
||||
try {
|
||||
this.client.postMessage(this.values);
|
||||
} catch(err) {
|
||||
self.log("service-worker", `postMessage failed for client: ${this.client}\n- Error message: ${err}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +419,7 @@ let initFromRequest = (req) => {
|
|||
return {
|
||||
method: req.method,
|
||||
headers: req.headers,
|
||||
mode: req.mode,
|
||||
mode: "cors", // req.mode, TODO: commented out because mode: navigate is haram in service worker, it seems
|
||||
credentials: req.credentials,
|
||||
cache: req.cache,
|
||||
redirect: req.redirect,
|
||||
|
@ -586,10 +598,14 @@ let getResourceThroughLibResilient = (request, clientId, useStashed=true, doStas
|
|||
self.log('service-worker', 'fetched version method or ETag differs from stashed for:', url)
|
||||
self.clients.get(reqInfo.clientId).then((client)=>{
|
||||
if (client !== null) {
|
||||
try {
|
||||
client.postMessage({
|
||||
url: url,
|
||||
fetchedDiffers: true
|
||||
})
|
||||
} catch(err) {
|
||||
self.log("service-worker", `postMessage failed for client: ${client}\n- Error message: ${err}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
// TODO: this should probably modify doStash?
|
||||
|
@ -687,11 +703,15 @@ self.addEventListener('fetch', event => {
|
|||
.get(clientId)
|
||||
.then((client)=>{
|
||||
if (client !== null) {
|
||||
try {
|
||||
client.postMessage({
|
||||
clientId: clientId,
|
||||
plugins: self.LibResilientPlugins.map((p)=>{return p.name}),
|
||||
serviceWorker: 'COMMIT_UNKNOWN'
|
||||
})
|
||||
} catch(err) {
|
||||
self.log("service-worker", `postMessage failed for client: ${client}\n- Error message: ${err}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue