numux 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +292 -0
- package/package.json +42 -4
- package/src/cli.ts +207 -0
- package/src/completions.ts +119 -0
- package/src/config/interpolate.ts +50 -0
- package/src/config/loader.ts +76 -0
- package/src/config/resolver.ts +67 -0
- package/src/config/validator.ts +140 -0
- package/src/config.ts +8 -0
- package/src/index.ts +229 -0
- package/src/process/manager.ts +377 -0
- package/src/process/ready.ts +45 -0
- package/src/process/runner.ts +243 -0
- package/src/types.ts +45 -0
- package/src/ui/app.ts +424 -0
- package/src/ui/pane.ts +125 -0
- package/src/ui/prefix.ts +199 -0
- package/src/ui/status-bar.ts +119 -0
- package/src/ui/tabs.ts +90 -0
- package/src/utils/color.ts +85 -0
- package/src/utils/env-file.ts +58 -0
- package/src/utils/log-writer.ts +48 -0
- package/src/utils/logger.ts +32 -0
- package/src/utils/shutdown.ts +39 -0
- package/src/utils/watcher.ts +53 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type FSWatcher, watch } from 'node:fs'
|
|
2
|
+
import { log } from './logger'
|
|
3
|
+
|
|
4
|
+
const DEBOUNCE_MS = 300
|
|
5
|
+
const IGNORED_SEGMENTS = new Set(['node_modules', '.git'])
|
|
6
|
+
|
|
7
|
+
export class FileWatcher {
|
|
8
|
+
private watchers: FSWatcher[] = []
|
|
9
|
+
private debounceTimers = new Map<string, ReturnType<typeof setTimeout>>()
|
|
10
|
+
|
|
11
|
+
watch(name: string, patterns: string[], cwd: string, onChanged: (path: string) => void): void {
|
|
12
|
+
const globs = patterns.map(p => new Bun.Glob(p))
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const watcher = watch(cwd, { recursive: true }, (_event, filename) => {
|
|
16
|
+
if (!filename) return
|
|
17
|
+
|
|
18
|
+
// Skip node_modules, .git, etc.
|
|
19
|
+
const segments = filename.split('/')
|
|
20
|
+
if (segments.some(s => IGNORED_SEGMENTS.has(s))) return
|
|
21
|
+
|
|
22
|
+
// Check if changed file matches any pattern
|
|
23
|
+
if (!globs.some(g => g.match(filename))) return
|
|
24
|
+
|
|
25
|
+
// Debounce per process
|
|
26
|
+
const existing = this.debounceTimers.get(name)
|
|
27
|
+
if (existing) clearTimeout(existing)
|
|
28
|
+
this.debounceTimers.set(
|
|
29
|
+
name,
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
this.debounceTimers.delete(name)
|
|
32
|
+
onChanged(filename)
|
|
33
|
+
}, DEBOUNCE_MS)
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
this.watchers.push(watcher)
|
|
37
|
+
log(`[${name}] Watching: ${patterns.join(', ')}`)
|
|
38
|
+
} catch (err) {
|
|
39
|
+
log(`[${name}] Failed to set up file watcher: ${err}`)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
close(): void {
|
|
44
|
+
for (const timer of this.debounceTimers.values()) {
|
|
45
|
+
clearTimeout(timer)
|
|
46
|
+
}
|
|
47
|
+
this.debounceTimers.clear()
|
|
48
|
+
for (const watcher of this.watchers) {
|
|
49
|
+
watcher.close()
|
|
50
|
+
}
|
|
51
|
+
this.watchers = []
|
|
52
|
+
}
|
|
53
|
+
}
|