d7002057d7
This PR moves the tldraw.com app into the public repo. ### Change Type - [x] `internal` — Any other changes that don't affect the published package[^2] --------- Co-authored-by: Dan Groshev <git@dgroshev.com> Co-authored-by: alex <alex@dytry.ch>
45 lines
1 KiB
JavaScript
45 lines
1 KiB
JavaScript
/* eslint-disable no-undef */
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const { spawn } = require('child_process')
|
|
const colors = require('picocolors')
|
|
|
|
class Monitor {
|
|
lastLineTime = Date.now()
|
|
nextTick = 0
|
|
|
|
size = 0
|
|
|
|
start() {
|
|
console.log('Spawning')
|
|
const proc = spawn('npx', ['esbuild', 'src/lib/worker.ts', '--bundle', '--minify', '--watch'])
|
|
// listen for lines on stdin
|
|
proc.stdout.on('data', (data) => {
|
|
this.size += data.length
|
|
this.lastLineTime = Date.now()
|
|
clearTimeout(this.nextTick)
|
|
this.nextTick = setTimeout(() => {
|
|
console.log(
|
|
colors.bold(colors.yellow('dotcom-worker')),
|
|
'is roughly',
|
|
colors.bold(colors.cyan(Math.floor(this.size / 1024) + 'kb')),
|
|
'(minified)\n'
|
|
)
|
|
this.size = 0
|
|
}, 10)
|
|
})
|
|
process.on('SIGINT', () => {
|
|
console.log('Int')
|
|
proc.kill()
|
|
})
|
|
process.on('SIGTERM', () => {
|
|
console.log('Term')
|
|
proc.kill()
|
|
})
|
|
process.on('exit', () => {
|
|
console.log('Exiting')
|
|
proc.kill()
|
|
})
|
|
}
|
|
}
|
|
|
|
new Monitor().start()
|