coffeehaml 0.7.1 → 0.7.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/dist/prettier/printer.js +4 -4
- package/package.json +2 -2
- package/dist/src/ast.js +0 -338
- package/dist/src/cli.js +0 -430
- package/dist/src/compiler.js +0 -132
- package/dist/src/emitter.js +0 -791
- package/dist/src/errors.js +0 -5
- package/dist/src/expressions.js +0 -223
- package/dist/src/index.js +0 -22
- package/dist/src/lexer.js +0 -504
- package/dist/src/parser.js +0 -575
- package/dist/src/types.js +0 -122
- package/dist/src/vite-plugin.js +0 -78
package/dist/prettier/printer.js
CHANGED
|
@@ -293,7 +293,7 @@ printElement = function(path, o, printFn) {
|
|
|
293
293
|
}
|
|
294
294
|
childDocs = (ref3 = path.map(printFn, 'children')) != null ? ref3 : [];
|
|
295
295
|
joined = joinChildrenWithBlanks(children, childDocs, o);
|
|
296
|
-
return
|
|
296
|
+
return [header, indent([hardline, joined])];
|
|
297
297
|
};
|
|
298
298
|
|
|
299
299
|
// ─── ImplicitDiv ───────────────────────────────────────────
|
|
@@ -317,7 +317,7 @@ printImplicitDiv = function(path, o, printFn) {
|
|
|
317
317
|
}
|
|
318
318
|
childDocs = (ref3 = path.map(printFn, 'children')) != null ? ref3 : [];
|
|
319
319
|
joined = joinChildrenWithBlanks(children, childDocs, o);
|
|
320
|
-
return
|
|
320
|
+
return [header, indent([hardline, joined])];
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
// ─── Output ────────────────────────────────────────────────
|
|
@@ -335,7 +335,7 @@ printOutput = function(path, o, printFn) {
|
|
|
335
335
|
}
|
|
336
336
|
childDocs = (ref2 = path.map(printFn, 'children')) != null ? ref2 : [];
|
|
337
337
|
joined = joinChildrenWithBlanks(children, childDocs, o);
|
|
338
|
-
return
|
|
338
|
+
return [`${marker} ${expr}`, indent([hardline, joined])];
|
|
339
339
|
};
|
|
340
340
|
|
|
341
341
|
// ─── Control Flow ──────────────────────────────────────────
|
|
@@ -403,7 +403,7 @@ printFlow = function(path, o, printFn) {
|
|
|
403
403
|
});
|
|
404
404
|
return join(hardline, ['-', childLines.join('\n')]);
|
|
405
405
|
}
|
|
406
|
-
return
|
|
406
|
+
return [header, indent([hardline, join(hardline, (ref2 = path.map(printFn, 'children')) != null ? ref2 : [])])];
|
|
407
407
|
};
|
|
408
408
|
|
|
409
409
|
printMergedFlow = function(path, o, printFn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coffeehaml",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Haml structure. CoffeeScript semantics. React runtime. Zero runtime. Vite-native.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -91,4 +91,4 @@
|
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"source-map": "^0.7.4"
|
|
93
93
|
}
|
|
94
|
-
}
|
|
94
|
+
}
|
package/dist/src/ast.js
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
// Generated by CoffeeScript 2.7.0
|
|
2
|
-
// ast.coffee — CoffeeHaml AST node types
|
|
3
|
-
// Mirrors src/ast.ts with CoffeeScript idioms
|
|
4
|
-
import {
|
|
5
|
-
SourceLocation
|
|
6
|
-
} from './types.js';
|
|
7
|
-
|
|
8
|
-
// ─── Node Kinds ────────────────────────────────────────────
|
|
9
|
-
export var NodeKind = ['Document', 'Element', 'ImplicitDiv', 'Text', 'Output', 'ControlFlow', 'Comment', 'Filter', 'Doctype'];
|
|
10
|
-
|
|
11
|
-
export var ControlFlowKind = ['if', 'unless', 'for', 'while', 'else', 'statement'];
|
|
12
|
-
|
|
13
|
-
export var CommentKind = ['haml', 'html'];
|
|
14
|
-
|
|
15
|
-
export var OutputKind = ['escaped', 'unescaped'];
|
|
16
|
-
|
|
17
|
-
export var Node = (function() {
|
|
18
|
-
// ─── Base Node ─────────────────────────────────────────────
|
|
19
|
-
class Node {
|
|
20
|
-
constructor(location1) {
|
|
21
|
-
this.location = location1;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
Node.prototype.kind = null; // set by subclasses
|
|
27
|
-
|
|
28
|
-
Node.prototype.location = null;
|
|
29
|
-
|
|
30
|
-
return Node;
|
|
31
|
-
|
|
32
|
-
}).call(this);
|
|
33
|
-
|
|
34
|
-
export var Expression = (function() {
|
|
35
|
-
// ─── Expression ────────────────────────────────────────────
|
|
36
|
-
class Expression {
|
|
37
|
-
constructor(source, parsed = null) {
|
|
38
|
-
this.source = source;
|
|
39
|
-
this.parsed = parsed;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
toString() {
|
|
43
|
-
return this.source;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
Expression.prototype.source = '';
|
|
49
|
-
|
|
50
|
-
Expression.prototype.parsed = null;
|
|
51
|
-
|
|
52
|
-
return Expression;
|
|
53
|
-
|
|
54
|
-
}).call(this);
|
|
55
|
-
|
|
56
|
-
export var Document = (function() {
|
|
57
|
-
// ─── Document ──────────────────────────────────────────────
|
|
58
|
-
class Document extends Node {
|
|
59
|
-
constructor(children, prologue = [], location = null) {
|
|
60
|
-
super(location);
|
|
61
|
-
this.children = children;
|
|
62
|
-
this.prologue = prologue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
Document.prototype.kind = 'Document';
|
|
68
|
-
|
|
69
|
-
Document.prototype.prologue = [];
|
|
70
|
-
|
|
71
|
-
Document.prototype.children = [];
|
|
72
|
-
|
|
73
|
-
return Document;
|
|
74
|
-
|
|
75
|
-
}).call(this);
|
|
76
|
-
|
|
77
|
-
export var Attribute = (function() {
|
|
78
|
-
// ─── Attribute types ───────────────────────────────────────
|
|
79
|
-
class Attribute {
|
|
80
|
-
constructor(name, value, shorthand = false) {
|
|
81
|
-
this.name = name;
|
|
82
|
-
this.value = value;
|
|
83
|
-
this.shorthand = shorthand;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
Attribute.prototype.spread = void 0;
|
|
89
|
-
|
|
90
|
-
Attribute.prototype.name = '';
|
|
91
|
-
|
|
92
|
-
Attribute.prototype.value = null; // Expression
|
|
93
|
-
|
|
94
|
-
Attribute.prototype.shorthand = false;
|
|
95
|
-
|
|
96
|
-
return Attribute;
|
|
97
|
-
|
|
98
|
-
}).call(this);
|
|
99
|
-
|
|
100
|
-
export var SpreadAttribute = (function() {
|
|
101
|
-
class SpreadAttribute {
|
|
102
|
-
constructor(expression) {
|
|
103
|
-
this.expression = expression;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
SpreadAttribute.prototype.spread = true;
|
|
109
|
-
|
|
110
|
-
SpreadAttribute.prototype.expression = null; // Expression
|
|
111
|
-
|
|
112
|
-
return SpreadAttribute;
|
|
113
|
-
|
|
114
|
-
}).call(this);
|
|
115
|
-
|
|
116
|
-
export var AnyAttribute = null; // Attribute | SpreadAttribute (union, runtime only)
|
|
117
|
-
|
|
118
|
-
export var Element = (function() {
|
|
119
|
-
|
|
120
|
-
// ─── Element ───────────────────────────────────────────────
|
|
121
|
-
class Element extends Node {
|
|
122
|
-
constructor(tag, opts = {}) {
|
|
123
|
-
var ref, ref1, ref2, ref3, ref4, ref5, ref6;
|
|
124
|
-
super(opts.location);
|
|
125
|
-
this.tag = tag;
|
|
126
|
-
this.classes = (ref = opts.classes) != null ? ref : [];
|
|
127
|
-
this.id = (ref1 = opts.id) != null ? ref1 : null;
|
|
128
|
-
this.attributes = (ref2 = opts.attributes) != null ? ref2 : [];
|
|
129
|
-
this.children = (ref3 = opts.children) != null ? ref3 : [];
|
|
130
|
-
this.isComponent = (ref4 = opts.isComponent) != null ? ref4 : false;
|
|
131
|
-
this.isSelfClosing = (ref5 = opts.isSelfClosing) != null ? ref5 : false;
|
|
132
|
-
this.attrStyle = (ref6 = opts.attrStyle) != null ? ref6 : null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
Element.prototype.kind = 'Element';
|
|
138
|
-
|
|
139
|
-
Element.prototype.tag = null; // string | Expression
|
|
140
|
-
|
|
141
|
-
Element.prototype.classes = [];
|
|
142
|
-
|
|
143
|
-
Element.prototype.id = null;
|
|
144
|
-
|
|
145
|
-
Element.prototype.attributes = [];
|
|
146
|
-
|
|
147
|
-
Element.prototype.children = [];
|
|
148
|
-
|
|
149
|
-
Element.prototype.isComponent = false;
|
|
150
|
-
|
|
151
|
-
Element.prototype.isSelfClosing = false;
|
|
152
|
-
|
|
153
|
-
Element.prototype.attrStyle = null; // 'braces' | 'parens' | 'bare' | null
|
|
154
|
-
|
|
155
|
-
return Element;
|
|
156
|
-
|
|
157
|
-
}).call(this);
|
|
158
|
-
|
|
159
|
-
export var ImplicitDiv = (function() {
|
|
160
|
-
// ─── ImplicitDiv ───────────────────────────────────────────
|
|
161
|
-
class ImplicitDiv extends Node {
|
|
162
|
-
constructor(opts = {}) {
|
|
163
|
-
var ref, ref1, ref2, ref3, ref4;
|
|
164
|
-
super(opts.location);
|
|
165
|
-
this.classes = (ref = opts.classes) != null ? ref : [];
|
|
166
|
-
this.id = (ref1 = opts.id) != null ? ref1 : null;
|
|
167
|
-
this.attributes = (ref2 = opts.attributes) != null ? ref2 : [];
|
|
168
|
-
this.children = (ref3 = opts.children) != null ? ref3 : [];
|
|
169
|
-
this.attrStyle = (ref4 = opts.attrStyle) != null ? ref4 : null;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
ImplicitDiv.prototype.kind = 'ImplicitDiv';
|
|
175
|
-
|
|
176
|
-
ImplicitDiv.prototype.classes = [];
|
|
177
|
-
|
|
178
|
-
ImplicitDiv.prototype.id = null;
|
|
179
|
-
|
|
180
|
-
ImplicitDiv.prototype.attributes = [];
|
|
181
|
-
|
|
182
|
-
ImplicitDiv.prototype.children = [];
|
|
183
|
-
|
|
184
|
-
ImplicitDiv.prototype.attrStyle = null;
|
|
185
|
-
|
|
186
|
-
return ImplicitDiv;
|
|
187
|
-
|
|
188
|
-
}).call(this);
|
|
189
|
-
|
|
190
|
-
export var Text = (function() {
|
|
191
|
-
// ─── Text ──────────────────────────────────────────────────
|
|
192
|
-
class Text extends Node {
|
|
193
|
-
constructor(value, location = null) {
|
|
194
|
-
super(location);
|
|
195
|
-
this.value = value;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
Text.prototype.kind = 'Text';
|
|
201
|
-
|
|
202
|
-
Text.prototype.value = '';
|
|
203
|
-
|
|
204
|
-
return Text;
|
|
205
|
-
|
|
206
|
-
}).call(this);
|
|
207
|
-
|
|
208
|
-
export var Output = (function() {
|
|
209
|
-
// ─── Output ────────────────────────────────────────────────
|
|
210
|
-
class Output extends Node {
|
|
211
|
-
constructor(expression, outputKind, location = null, children = []) {
|
|
212
|
-
super(location);
|
|
213
|
-
this.expression = expression;
|
|
214
|
-
this.outputKind = outputKind;
|
|
215
|
-
this.children = children;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
Output.prototype.kind = 'Output';
|
|
221
|
-
|
|
222
|
-
Output.prototype.expression = null; // Expression
|
|
223
|
-
|
|
224
|
-
Output.prototype.outputKind = 'escaped';
|
|
225
|
-
|
|
226
|
-
Output.prototype.children = [];
|
|
227
|
-
|
|
228
|
-
return Output;
|
|
229
|
-
|
|
230
|
-
}).call(this);
|
|
231
|
-
|
|
232
|
-
export var ControlFlow = (function() {
|
|
233
|
-
// ─── ControlFlow ───────────────────────────────────────────
|
|
234
|
-
class ControlFlow extends Node {
|
|
235
|
-
constructor(controlKind, expression, children = [], next = null, location = null) {
|
|
236
|
-
super(location);
|
|
237
|
-
this.controlKind = controlKind;
|
|
238
|
-
this.expression = expression;
|
|
239
|
-
this.children = children;
|
|
240
|
-
this.next = next;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
isLoop() {
|
|
244
|
-
var ref;
|
|
245
|
-
return (ref = this.controlKind) === 'for' || ref === 'while';
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
isConditional() {
|
|
249
|
-
var ref;
|
|
250
|
-
return (ref = this.controlKind) === 'if' || ref === 'unless';
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
chainLength() {
|
|
254
|
-
var count, n;
|
|
255
|
-
count = 0;
|
|
256
|
-
n = this;
|
|
257
|
-
while (n) {
|
|
258
|
-
count++;
|
|
259
|
-
n = n.next;
|
|
260
|
-
}
|
|
261
|
-
return count;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
ControlFlow.prototype.kind = 'ControlFlow';
|
|
267
|
-
|
|
268
|
-
ControlFlow.prototype.controlKind = 'if';
|
|
269
|
-
|
|
270
|
-
ControlFlow.prototype.expression = null;
|
|
271
|
-
|
|
272
|
-
ControlFlow.prototype.children = [];
|
|
273
|
-
|
|
274
|
-
ControlFlow.prototype.next = null;
|
|
275
|
-
|
|
276
|
-
return ControlFlow;
|
|
277
|
-
|
|
278
|
-
}).call(this);
|
|
279
|
-
|
|
280
|
-
export var Comment = (function() {
|
|
281
|
-
// ─── Comment ───────────────────────────────────────────────
|
|
282
|
-
class Comment extends Node {
|
|
283
|
-
constructor(commentKind, text, location = null) {
|
|
284
|
-
super(location);
|
|
285
|
-
this.commentKind = commentKind;
|
|
286
|
-
this.text = text;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
Comment.prototype.kind = 'Comment';
|
|
292
|
-
|
|
293
|
-
Comment.prototype.commentKind = 'haml';
|
|
294
|
-
|
|
295
|
-
Comment.prototype.text = '';
|
|
296
|
-
|
|
297
|
-
return Comment;
|
|
298
|
-
|
|
299
|
-
}).call(this);
|
|
300
|
-
|
|
301
|
-
export var Filter = (function() {
|
|
302
|
-
// ─── Filter ────────────────────────────────────────────────
|
|
303
|
-
class Filter extends Node {
|
|
304
|
-
constructor(filterName, content, location = null) {
|
|
305
|
-
super(location);
|
|
306
|
-
this.filterName = filterName;
|
|
307
|
-
this.content = content;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
Filter.prototype.kind = 'Filter';
|
|
313
|
-
|
|
314
|
-
Filter.prototype.filterName = '';
|
|
315
|
-
|
|
316
|
-
Filter.prototype.content = '';
|
|
317
|
-
|
|
318
|
-
return Filter;
|
|
319
|
-
|
|
320
|
-
}).call(this);
|
|
321
|
-
|
|
322
|
-
export var Doctype = (function() {
|
|
323
|
-
// ─── Doctype ───────────────────────────────────────────────
|
|
324
|
-
class Doctype extends Node {
|
|
325
|
-
constructor(value, location = null) {
|
|
326
|
-
super(location);
|
|
327
|
-
this.value = value;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
Doctype.prototype.kind = 'Doctype';
|
|
333
|
-
|
|
334
|
-
Doctype.prototype.value = '';
|
|
335
|
-
|
|
336
|
-
return Doctype;
|
|
337
|
-
|
|
338
|
-
}).call(this);
|