ether-code 0.8.9 → 0.9.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/cli/ether.js +1 -1
- package/package.json +1 -1
- package/parsers/ether-parser-css.js +19 -15
- package/parsers/ether-parser-php.js +10 -10
package/cli/ether.js
CHANGED
package/package.json
CHANGED
|
@@ -68,7 +68,7 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
68
68
|
if (!current || current.type === TokenType.EOF) break
|
|
69
69
|
|
|
70
70
|
if (current.type === TokenType.IDENTIFIER) {
|
|
71
|
-
const value = current.value.toLowerCase()
|
|
71
|
+
const value = String(current.value || '').toLowerCase()
|
|
72
72
|
|
|
73
73
|
if (value.startsWith('au ') || value === 'au survol' || value === 'au clic' ||
|
|
74
74
|
value === 'au focus' || value === 'actif' || value === 'visite' ||
|
|
@@ -188,6 +188,9 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
188
188
|
|
|
189
189
|
translateCSSSelector(selector) {
|
|
190
190
|
const map = this.reverseMaps.css || {}
|
|
191
|
+
if (typeof selector !== 'string') {
|
|
192
|
+
selector = String(selector || '')
|
|
193
|
+
}
|
|
191
194
|
const lower = selector.toLowerCase()
|
|
192
195
|
|
|
193
196
|
const selectorTranslations = {
|
|
@@ -248,7 +251,7 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
248
251
|
'alignement': ['texte'],
|
|
249
252
|
'decoration': ['texte'],
|
|
250
253
|
'transformation': ['texte'],
|
|
251
|
-
'ombre': ['texte', 'boite', '
|
|
254
|
+
'ombre': ['texte', 'boite', 'boîte'],
|
|
252
255
|
'espacement': ['lettres'],
|
|
253
256
|
'bordure': ['haut', 'bas', 'gauche', 'droite', 'couleur', 'style', 'largeur', 'arrondi'],
|
|
254
257
|
'couleur': ['bordure', 'fond', 'texte', 'remplissage'],
|
|
@@ -259,19 +262,19 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
259
262
|
'direction': ['flex'],
|
|
260
263
|
'enveloppe': ['flex'],
|
|
261
264
|
'justifier': ['contenu'],
|
|
262
|
-
'aligner': ['elements', '
|
|
265
|
+
'aligner': ['elements', 'éléments', 'contenu'],
|
|
263
266
|
'colonnes': ['grille'],
|
|
264
267
|
'lignes': ['grille'],
|
|
265
268
|
'espace': ['ligne', 'colonne', 'blanc'],
|
|
266
|
-
'
|
|
269
|
+
'débordement': ['x', 'y'],
|
|
267
270
|
'debordement': ['x', 'y'],
|
|
268
|
-
'
|
|
271
|
+
'événements': ['pointeur'],
|
|
269
272
|
'evenements': ['pointeur'],
|
|
270
|
-
'
|
|
271
|
-
'modele': ['boite', '
|
|
273
|
+
'modèle': ['boite', 'boîte'],
|
|
274
|
+
'modele': ['boite', 'boîte'],
|
|
272
275
|
'filtre': ['fond'],
|
|
273
276
|
'decoupe': ['fond'],
|
|
274
|
-
'
|
|
277
|
+
'découpe': ['fond'],
|
|
275
278
|
'origine': ['transformation', 'perspective'],
|
|
276
279
|
'liste': ['style', 'type', 'position', 'image'],
|
|
277
280
|
}
|
|
@@ -281,8 +284,9 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
281
284
|
|
|
282
285
|
let nextToken = this.current()
|
|
283
286
|
while (nextToken && nextToken.type === TokenType.IDENTIFIER) {
|
|
284
|
-
const propLower = property.toLowerCase()
|
|
285
|
-
|
|
287
|
+
const propLower = String(property || '').toLowerCase()
|
|
288
|
+
const nextVal = String(nextToken.value || '').toLowerCase()
|
|
289
|
+
if (compoundProperties[propLower] && compoundProperties[propLower].includes(nextVal)) {
|
|
286
290
|
property = property + ' ' + nextToken.value
|
|
287
291
|
this.advance()
|
|
288
292
|
nextToken = this.current()
|
|
@@ -321,7 +325,7 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
321
325
|
if (lastType === TokenType.NUMBER || lastType === TokenType.INTEGER || lastType === TokenType.FLOAT) {
|
|
322
326
|
if (current.type === TokenType.IDENTIFIER) {
|
|
323
327
|
const units = ['px', 'em', 'rem', '%', 'vw', 'vh', 'vmin', 'vmax', 'ch', 'ex', 'cm', 'mm', 'in', 'pt', 'pc', 'deg', 'rad', 'turn', 'ms', 's', 'fr', 'cqw', 'cqh']
|
|
324
|
-
if (units.includes(current.value.toLowerCase())) {
|
|
328
|
+
if (units.includes(String(current.value || '').toLowerCase())) {
|
|
325
329
|
needsSpace = false
|
|
326
330
|
}
|
|
327
331
|
}
|
|
@@ -460,7 +464,7 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
460
464
|
'marqueur': '::marker'
|
|
461
465
|
}
|
|
462
466
|
|
|
463
|
-
const lower = value.toLowerCase()
|
|
467
|
+
const lower = String(value || '').toLowerCase()
|
|
464
468
|
return map[lower] || ':' + lower.replace(/\s+/g, '-')
|
|
465
469
|
}
|
|
466
470
|
|
|
@@ -470,7 +474,7 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
470
474
|
|
|
471
475
|
if (!nameToken) return null
|
|
472
476
|
|
|
473
|
-
const name = nameToken.value.toLowerCase()
|
|
477
|
+
const name = String(nameToken.value || '').toLowerCase()
|
|
474
478
|
this.advance()
|
|
475
479
|
|
|
476
480
|
if (name === 'media' || name === 'requete media' || name === 'ecran' || name === 'si') {
|
|
@@ -615,7 +619,7 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
615
619
|
'vers': 'to'
|
|
616
620
|
}
|
|
617
621
|
|
|
618
|
-
selector = selectorMap[selector.toLowerCase()] || selector
|
|
622
|
+
selector = typeof selector === 'string' ? (selectorMap[selector.toLowerCase()] || selector) : String(selector || '')
|
|
619
623
|
this.advance()
|
|
620
624
|
|
|
621
625
|
this.skipNewlines()
|
|
@@ -742,4 +746,4 @@ class EtherParserCSS extends EtherParserBase {
|
|
|
742
746
|
}
|
|
743
747
|
}
|
|
744
748
|
|
|
745
|
-
module.exports = { EtherParserCSS }
|
|
749
|
+
module.exports = { EtherParserCSS }
|
|
@@ -278,16 +278,6 @@ class EtherParserPHP extends EtherParserBase {
|
|
|
278
278
|
|
|
279
279
|
const value = token.value != null ? this.normalizeAccents(String(token.value).toLowerCase()) : ''
|
|
280
280
|
|
|
281
|
-
if (token.type === TokenType.IDENTIFIER) {
|
|
282
|
-
const multiWordCall = this.tryParseMultiWordCallFromStart(lang)
|
|
283
|
-
if (multiWordCall) {
|
|
284
|
-
return {
|
|
285
|
-
type: 'ExpressionStatement',
|
|
286
|
-
expression: multiWordCall
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
281
|
if (this.isDeclare(value)) {
|
|
292
282
|
return this.parseDeclare(lang)
|
|
293
283
|
}
|
|
@@ -336,6 +326,16 @@ class EtherParserPHP extends EtherParserBase {
|
|
|
336
326
|
return this.parseSwitch(lang)
|
|
337
327
|
}
|
|
338
328
|
|
|
329
|
+
if (token.type === TokenType.IDENTIFIER) {
|
|
330
|
+
const multiWordCall = this.tryParseMultiWordCallFromStart(lang)
|
|
331
|
+
if (multiWordCall) {
|
|
332
|
+
return {
|
|
333
|
+
type: 'ExpressionStatement',
|
|
334
|
+
expression: multiWordCall
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
339
|
if (this.isTry(value)) {
|
|
340
340
|
return this.parseTryStatement(lang)
|
|
341
341
|
}
|