2017-03-29 03:02:08 +02:00
|
|
|
const ParentStream = require('iframe-stream').ParentStream
|
2017-04-03 07:01:44 +02:00
|
|
|
const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
|
2017-03-29 03:02:08 +02:00
|
|
|
const SwStream = require('sw-stream/lib/sw-stream.js')
|
|
|
|
const SetupUntrustedComunication = ('./lib/setup-untrusted-connection.js')
|
2017-04-03 07:01:44 +02:00
|
|
|
|
2017-03-29 03:02:08 +02:00
|
|
|
const background = new SWcontroller({
|
2017-04-05 07:45:39 +02:00
|
|
|
fileName: '/background.js',
|
2017-03-29 03:02:08 +02:00
|
|
|
})
|
|
|
|
|
2017-03-29 20:02:50 +02:00
|
|
|
const pageStream = new ParentStream()
|
2017-03-29 19:53:43 +02:00
|
|
|
background.on('ready', (_) => {
|
2017-03-30 00:19:46 +02:00
|
|
|
let swStream = SwStream({
|
|
|
|
serviceWorker: background.controller,
|
|
|
|
context: 'dapp',
|
|
|
|
})
|
2017-03-29 03:02:08 +02:00
|
|
|
pageStream.pipe(swStream).pipe(pageStream)
|
2017-03-30 20:28:22 +02:00
|
|
|
|
2017-03-29 03:02:08 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
background.on('error', console.error)
|
|
|
|
background.startWorker()
|