ether-code 0.1.9 → 0.2.3
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 +1 -1
- package/README.md +27 -89
- package/cli/compiler.js +11 -25
- package/cli/ether.js +1095 -0
- package/cli/watcher.js +106 -0
- package/ether-compiler.js +1 -1
- package/ether-parser.js +9 -3
- package/generators/html-generator.js +1 -0
- package/i18n/i18n-css.json +743 -0
- package/i18n/i18n-graphql.json +1531 -0
- package/i18n/i18n-html.json +572 -0
- package/i18n/i18n-js.json +2790 -0
- package/i18n/i18n-node.json +2442 -0
- package/i18n/i18n-php.json +4306 -0
- package/i18n/i18n-python.json +3080 -0
- package/i18n/i18n-react.json +1784 -0
- package/i18n/i18n-ruby.json +1858 -0
- package/i18n/i18n-sql.json +3466 -0
- package/i18n/i18n-ts.json +442 -0
- package/lexer/ether-lexer.js +869 -0
- package/lexer/tokens.js +292 -0
- package/package.json +1 -1
package/cli/watcher.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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 }
|
package/ether-compiler.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
-
const { EtherLexer, TokenType } = require('./ether-lexer')
|
|
3
|
+
const { EtherLexer, TokenType } = require('./lexer/ether-lexer')
|
|
4
4
|
const { EtherParser } = require('./ether-parser')
|
|
5
5
|
const { CSSGenerator } = require('./generators/css-generator')
|
|
6
6
|
const { HTMLGenerator } = require('./generators/html-generator')
|
package/ether-parser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
|
-
const { EtherLexer, Token, TokenType } = require('./ether-lexer')
|
|
2
|
+
const { EtherLexer, Token, TokenType } = require('./lexer/ether-lexer')
|
|
3
3
|
|
|
4
4
|
class EtherParser {
|
|
5
5
|
constructor(options = {}) {
|
|
@@ -349,7 +349,13 @@ class EtherParser {
|
|
|
349
349
|
'html': 'html',
|
|
350
350
|
'document': 'html',
|
|
351
351
|
'tete': 'head',
|
|
352
|
-
'titre': '
|
|
352
|
+
'titre': 'title',
|
|
353
|
+
'titre1': 'h1',
|
|
354
|
+
'titre2': 'h2',
|
|
355
|
+
'titre3': 'h3',
|
|
356
|
+
'titre4': 'h4',
|
|
357
|
+
'titre5': 'h5',
|
|
358
|
+
'titre6': 'h6',
|
|
353
359
|
'paragraphe': 'p',
|
|
354
360
|
'lien': 'a',
|
|
355
361
|
'image': 'img',
|
|
@@ -871,7 +877,7 @@ class EtherParser {
|
|
|
871
877
|
'section': 'section',
|
|
872
878
|
'article': 'article',
|
|
873
879
|
'cote': 'aside',
|
|
874
|
-
'titre': '
|
|
880
|
+
'titre': 'title',
|
|
875
881
|
'titre1': 'h1',
|
|
876
882
|
'titre2': 'h2',
|
|
877
883
|
'titre3': 'h3',
|