-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompute.js
More file actions
36 lines (30 loc) · 1023 Bytes
/
compute.js
File metadata and controls
36 lines (30 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as BareMux from './matrix/index.mjs'
import './shader.bundle.mjs'
import './shader.config.mjs'
import './shader.kernel.mjs'
self.BareMux = BareMux
const uv = new self.UVServiceWorker()
const connection = new BareMux.BareMuxConnection('./matrix/worker.js?raw=true')
let transportReady = false
async function setupTransport() {
const wispUrl = self.__uv$config.wisp
try {
const transportUrl = new URL('./vector/index.mjs', self.location.href).href
await connection.setTransport(transportUrl, [{ wisp: wispUrl }])
console.log('[SW] Vector transport configured (Remote):', wispUrl)
transportReady = true
} catch (err) {
console.error('[SW] Failed to set Wisp transport:', err)
}
}
const transportPromise = setupTransport()
self.addEventListener('fetch', (event) => {
if (event.request.url.startsWith(location.origin + self.__uv$config.prefix)) {
event.respondWith(
(async () => {
await transportPromise
return await uv.fetch(event)
})()
)
}
})