MCPcopy
hub / github.com/d3george/slash-admin / resolveMainClient

Function resolveMainClient

public/mockServiceWorker.js:160–185  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

158// that registered the worker. It's with the latter the worker should
159// communicate with during the response resolving phase.
160async function resolveMainClient(event) {
161 const client = await self.clients.get(event.clientId)
162
163 if (activeClientIds.has(event.clientId)) {
164 return client
165 }
166
167 if (client?.frameType === 'top-level') {
168 return client
169 }
170
171 const allClients = await self.clients.matchAll({
172 type: 'window',
173 })
174
175 return allClients
176 .filter((client) => {
177 // Get only those clients that are currently visible.
178 return client.visibilityState === 'visible'
179 })
180 .find((client) => {
181 // Find the client ID that's recorded in the
182 // set of clients that have registered the worker.
183 return activeClientIds.has(client.id)
184 })
185}
186
187async function getResponse(event, client, requestId) {
188 const { request } = event

Callers 1

handleRequestFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected