ether-code 0.1.8 → 0.1.9
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/ether-compiler.js +190 -0
- package/ether-parser.js +3059 -0
- package/package.json +3 -2
- package/cli/ether.js +0 -700
- package/cli/watcher.js +0 -106
- package/i18n/i18n-css.json +0 -743
- package/i18n/i18n-graphql.json +0 -1531
- package/i18n/i18n-html.json +0 -572
- package/i18n/i18n-js.json +0 -2790
- package/i18n/i18n-node.json +0 -2442
- package/i18n/i18n-php.json +0 -4306
- package/i18n/i18n-python.json +0 -3080
- package/i18n/i18n-react.json +0 -1784
- package/i18n/i18n-ruby.json +0 -1858
- package/i18n/i18n-sql.json +0 -3466
- package/i18n/i18n-ts.json +0 -442
- package/lexer/ether-lexer.js +0 -869
- package/lexer/tokens.js +0 -292
package/cli/watcher.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const EventEmitter = require('events')
|
|
4
|
-
|
|
5
|
-
class Watcher extends EventEmitter {
|
|
6
|
-
constructor(dir, options = {}) {
|
|
7
|
-
super()
|
|
8
|
-
this.dir = dir
|
|
9
|
-
this.options = {
|
|
10
|
-
ignored: ['node_modules', '.git', 'dist'],
|
|
11
|
-
debounce: 100,
|
|
12
|
-
...options
|
|
13
|
-
}
|
|
14
|
-
this.watchers = new Map()
|
|
15
|
-
this.debounceTimers = new Map()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
start() {
|
|
19
|
-
this.watchDir(this.dir)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
stop() {
|
|
23
|
-
for (const watcher of this.watchers.values()) {
|
|
24
|
-
watcher.close()
|
|
25
|
-
}
|
|
26
|
-
this.watchers.clear()
|
|
27
|
-
|
|
28
|
-
for (const timer of this.debounceTimers.values()) {
|
|
29
|
-
clearTimeout(timer)
|
|
30
|
-
}
|
|
31
|
-
this.debounceTimers.clear()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
watchDir(dir) {
|
|
35
|
-
if (this.isIgnored(dir)) return
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const watcher = fs.watch(dir, { persistent: true }, (eventType, filename) => {
|
|
39
|
-
if (!filename) return
|
|
40
|
-
|
|
41
|
-
const fullPath = path.join(dir, filename)
|
|
42
|
-
this.handleEvent(eventType, fullPath)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
watcher.on('error', (err) => {
|
|
46
|
-
this.emit('error', err)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
this.watchers.set(dir, watcher)
|
|
50
|
-
|
|
51
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true })
|
|
52
|
-
for (const entry of entries) {
|
|
53
|
-
if (entry.isDirectory() && !this.isIgnored(entry.name)) {
|
|
54
|
-
this.watchDir(path.join(dir, entry.name))
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} catch (err) {
|
|
58
|
-
this.emit('error', err)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
handleEvent(eventType, filePath) {
|
|
63
|
-
const existing = this.debounceTimers.get(filePath)
|
|
64
|
-
if (existing) {
|
|
65
|
-
clearTimeout(existing)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const timer = setTimeout(() => {
|
|
69
|
-
this.debounceTimers.delete(filePath)
|
|
70
|
-
this.processEvent(filePath)
|
|
71
|
-
}, this.options.debounce)
|
|
72
|
-
|
|
73
|
-
this.debounceTimers.set(filePath, timer)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
processEvent(filePath) {
|
|
77
|
-
try {
|
|
78
|
-
const exists = fs.existsSync(filePath)
|
|
79
|
-
|
|
80
|
-
if (!exists) {
|
|
81
|
-
this.emit('unlink', filePath)
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const stat = fs.statSync(filePath)
|
|
86
|
-
|
|
87
|
-
if (stat.isDirectory()) {
|
|
88
|
-
if (!this.watchers.has(filePath)) {
|
|
89
|
-
this.watchDir(filePath)
|
|
90
|
-
this.emit('addDir', filePath)
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
this.emit('change', filePath)
|
|
94
|
-
}
|
|
95
|
-
} catch (err) {
|
|
96
|
-
this.emit('error', err)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
isIgnored(name) {
|
|
101
|
-
const baseName = path.basename(name)
|
|
102
|
-
return this.options.ignored.includes(baseName) || baseName.startsWith('.')
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
module.exports = { Watcher }
|