coffeehaml 0.7.5 → 0.7.6
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/expressions.js +119 -36
- package/dist/prettier/options.js +1 -1
- package/package.json +1 -1
package/dist/expressions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
|
2
2
|
// expressions.coffee — CoffeeScript expression compilation bridge
|
|
3
|
-
var _coffeeScriptAvailable, _coffeeScriptUnavailableReason, _require, checkCoffeeScript, loadCoffeeScript, stripCoffeeWrapper, stripToConst;
|
|
3
|
+
var _coffeeScriptAvailable, _coffeeScriptUnavailableReason, _require, checkCoffeeScript, collapseWs, loadCoffeeScript, splitTopLevelStatements, stripCoffeeWrapper, stripToConst;
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
createRequire
|
|
@@ -110,11 +110,11 @@ stripCoffeeWrapper = function(js, _original) {
|
|
|
110
110
|
result = js.trim();
|
|
111
111
|
result = result.replace(/;\s*$/, '');
|
|
112
112
|
lines = (function() {
|
|
113
|
-
var
|
|
113
|
+
var j, len, ref, results;
|
|
114
114
|
ref = result.split('\n');
|
|
115
115
|
results = [];
|
|
116
|
-
for (
|
|
117
|
-
l = ref[
|
|
116
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
|
117
|
+
l = ref[j];
|
|
118
118
|
if (l.trim() !== '') {
|
|
119
119
|
results.push(l);
|
|
120
120
|
}
|
|
@@ -123,10 +123,10 @@ stripCoffeeWrapper = function(js, _original) {
|
|
|
123
123
|
})();
|
|
124
124
|
if (lines.length > 0) {
|
|
125
125
|
varLines = (function() {
|
|
126
|
-
var
|
|
126
|
+
var j, len, results;
|
|
127
127
|
results = [];
|
|
128
|
-
for (
|
|
129
|
-
l = lines[
|
|
128
|
+
for (j = 0, len = lines.length; j < len; j++) {
|
|
129
|
+
l = lines[j];
|
|
130
130
|
if (/^\s*var\b/.test(l)) {
|
|
131
131
|
results.push(l);
|
|
132
132
|
}
|
|
@@ -134,10 +134,10 @@ stripCoffeeWrapper = function(js, _original) {
|
|
|
134
134
|
return results;
|
|
135
135
|
})();
|
|
136
136
|
meaningful = (function() {
|
|
137
|
-
var
|
|
137
|
+
var j, len, results;
|
|
138
138
|
results = [];
|
|
139
|
-
for (
|
|
140
|
-
l = lines[
|
|
139
|
+
for (j = 0, len = lines.length; j < len; j++) {
|
|
140
|
+
l = lines[j];
|
|
141
141
|
if (!/^\s*var\b/.test(l)) {
|
|
142
142
|
results.push(l);
|
|
143
143
|
}
|
|
@@ -180,44 +180,127 @@ export var compileStatement = function(source, location = null) {
|
|
|
180
180
|
|
|
181
181
|
// ─── Convert var → const/let ───────────────────────────────
|
|
182
182
|
stripToConst = function(js) {
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (l.trim() !== '') {
|
|
191
|
-
results.push(l);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return results;
|
|
195
|
-
})();
|
|
196
|
-
varLine = lines.find(function(l) {
|
|
197
|
-
return /^\s*var\b/.test(l);
|
|
183
|
+
var assign, assignments, body, idx, j, len, name, stmts, varIdx, varNames;
|
|
184
|
+
stmts = splitTopLevelStatements(js);
|
|
185
|
+
if (stmts.length === 0) {
|
|
186
|
+
return js.replace(/;\s*$/, '');
|
|
187
|
+
}
|
|
188
|
+
varIdx = stmts.findIndex(function(s) {
|
|
189
|
+
return /^\s*var\b/.test(s);
|
|
198
190
|
});
|
|
199
|
-
if (
|
|
191
|
+
if (varIdx < 0) {
|
|
200
192
|
return js.replace(/;\s*$/, '');
|
|
201
193
|
}
|
|
202
|
-
varNames =
|
|
194
|
+
varNames = stmts[varIdx].replace(/^\s*var\s+/, '').replace(/;\s*$/, '').split(',').map(function(s) {
|
|
203
195
|
return s.trim();
|
|
204
196
|
}).filter(Boolean);
|
|
197
|
+
body = stmts.filter(function(s, i) {
|
|
198
|
+
return i !== varIdx;
|
|
199
|
+
});
|
|
205
200
|
assignments = [];
|
|
206
|
-
for (
|
|
207
|
-
name = varNames[
|
|
208
|
-
|
|
201
|
+
for (j = 0, len = varNames.length; j < len; j++) {
|
|
202
|
+
name = varNames[j];
|
|
203
|
+
idx = body.findIndex(function(s) {
|
|
209
204
|
var t;
|
|
210
|
-
t =
|
|
205
|
+
t = s.trim();
|
|
211
206
|
return t.startsWith(`${name} =`) || t.startsWith(`${name}=`);
|
|
212
207
|
});
|
|
213
|
-
if (
|
|
214
|
-
|
|
208
|
+
if (idx >= 0) {
|
|
209
|
+
assign = collapseWs(body[idx]).replace(/;\s*$/, '');
|
|
210
|
+
assignments.push('const ' + assign);
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
if (assignments.length > 0) {
|
|
218
214
|
return assignments.join('; ');
|
|
219
215
|
}
|
|
220
|
-
return
|
|
221
|
-
return
|
|
222
|
-
}).join(' ')
|
|
216
|
+
return body.map(function(s) {
|
|
217
|
+
return collapseWs(s);
|
|
218
|
+
}).join(' ');
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// Split compiled JS into top-level statements, respecting string literals
|
|
222
|
+
// and bracket nesting so multiline object/array/call literals stay intact.
|
|
223
|
+
splitTopLevelStatements = function(js) {
|
|
224
|
+
var ch, depth, i, inString, last, start, stmts;
|
|
225
|
+
stmts = [];
|
|
226
|
+
depth = 0;
|
|
227
|
+
inString = null;
|
|
228
|
+
start = 0;
|
|
229
|
+
i = 0;
|
|
230
|
+
while (i < js.length) {
|
|
231
|
+
ch = js[i];
|
|
232
|
+
if (inString) {
|
|
233
|
+
if (ch === '\\') {
|
|
234
|
+
i += 2;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (ch === inString) {
|
|
238
|
+
inString = null;
|
|
239
|
+
}
|
|
240
|
+
i++;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (ch === "'" || ch === '"' || ch === '`') {
|
|
244
|
+
inString = ch;
|
|
245
|
+
} else if (ch === '{' || ch === '[' || ch === '(') {
|
|
246
|
+
depth++;
|
|
247
|
+
} else if (ch === '}' || ch === ']' || ch === ')') {
|
|
248
|
+
depth--;
|
|
249
|
+
} else if (ch === ';' && depth === 0) {
|
|
250
|
+
stmts.push(js.slice(start, i).trim());
|
|
251
|
+
start = i + 1;
|
|
252
|
+
}
|
|
253
|
+
i++;
|
|
254
|
+
}
|
|
255
|
+
last = js.slice(start).trim();
|
|
256
|
+
if (last) {
|
|
257
|
+
stmts.push(last);
|
|
258
|
+
}
|
|
259
|
+
return stmts;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Collapse runs of whitespace to single spaces, preserving string contents.
|
|
263
|
+
collapseWs = function(s) {
|
|
264
|
+
var ch, i, inString, out, pendingSpace;
|
|
265
|
+
out = '';
|
|
266
|
+
inString = null;
|
|
267
|
+
pendingSpace = false;
|
|
268
|
+
i = 0;
|
|
269
|
+
while (i < s.length) {
|
|
270
|
+
ch = s[i];
|
|
271
|
+
if (inString) {
|
|
272
|
+
out += ch;
|
|
273
|
+
if (ch === '\\' && i + 1 < s.length) {
|
|
274
|
+
out += s[i + 1];
|
|
275
|
+
i += 2;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (ch === inString) {
|
|
279
|
+
inString = null;
|
|
280
|
+
}
|
|
281
|
+
i++;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (ch === "'" || ch === '"' || ch === '`') {
|
|
285
|
+
if (pendingSpace && out.length) {
|
|
286
|
+
out += ' ';
|
|
287
|
+
}
|
|
288
|
+
pendingSpace = false;
|
|
289
|
+
inString = ch;
|
|
290
|
+
out += ch;
|
|
291
|
+
i++;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (/\s/.test(ch)) {
|
|
295
|
+
pendingSpace = true;
|
|
296
|
+
} else {
|
|
297
|
+
if (pendingSpace && out.length) {
|
|
298
|
+
out += ' ';
|
|
299
|
+
}
|
|
300
|
+
pendingSpace = false;
|
|
301
|
+
out += ch;
|
|
302
|
+
}
|
|
303
|
+
i++;
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
223
306
|
};
|
package/dist/prettier/options.js
CHANGED
|
@@ -216,7 +216,7 @@ export var defaultOptions = {
|
|
|
216
216
|
implicitDivExpansion: false,
|
|
217
217
|
maxChainLength: 4,
|
|
218
218
|
inlineThreshold: -1,
|
|
219
|
-
voidElementStyle: '
|
|
219
|
+
voidElementStyle: 'explicit',
|
|
220
220
|
attributeStyle: 'preserve',
|
|
221
221
|
attributeMultilineThreshold: 1,
|
|
222
222
|
attributeSort: 'none',
|