Skip to content

Commit d39f280

Browse files
committed
examples/web: Remove browser-stdout dependency
1 parent bf40423 commit d39f280

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

examples/web/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"start": "concurrently 'rsbuild dev' 'websockify 80 irc.libera.chat 6697'"
44
},
55
"dependencies": {
6-
"browser-stdout": "^1.3.1",
76
"slate-irc": "workspace:*",
87
"websocket-stream": "^5.5.2",
98
"websockify": "workspace:*"

examples/web/src/index.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
import BrowserStdout from 'browser-stdout'
1+
import { Writable } from 'node:stream'
2+
23
import irc from 'slate-irc'
34
import websocket from 'websocket-stream'
45

5-
const stream = new websocket('ws://localhost', 'binary')
6-
stream.on('error', (error) => {
6+
document.head.insertAdjacentHTML(
7+
'beforeend',
8+
`<style>
9+
#root {
10+
white-space: pre;
11+
font-family: monospace;
12+
}
13+
</style>`,
14+
)
15+
16+
const root = document.getElementById('root')
17+
18+
const browser = new Writable({
19+
write(chunk, _encoding, callback) {
20+
root.textContent += chunk.toString()
21+
callback()
22+
},
23+
})
24+
25+
const ws = new websocket('ws://localhost', 'binary')
26+
ws.on('error', (error) => {
727
throw error
828
})
929

10-
const client = irc(stream)
11-
client.use((irc) => irc.stream.pipe(BrowserStdout())) // Pipe to browser log.
30+
const client = irc(ws)
31+
client.use((irc) => irc.stream.pipe(browser))
1232
client.pass('pass')
1333
client.nick(`slate-${(Math.random() * 100000) | 0}`)
1434
client.user('tobi', 'Tobi Ferret')
15-
16-
const root = document.getElementById('root')
17-
root.textContent = 'Open your console and see the irc log!'

pnpm-lock.yaml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)