@runtime-type-inspector/transpiler 2.0.6 → 2.0.8
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/index.cjs +26 -11
- package/index.mjs +26 -9
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -557,6 +557,7 @@
|
|
|
557
557
|
_defineProperty(this, "forceCurly", false);
|
|
558
558
|
_defineProperty(this, "parents", []);
|
|
559
559
|
_defineProperty(this, "numSpaces", 0);
|
|
560
|
+
_defineProperty(this, "lastCommentLineIndex", -1);
|
|
560
561
|
}
|
|
561
562
|
_createClass(Stringifier, [{
|
|
562
563
|
key: "toSource",
|
|
@@ -587,6 +588,9 @@
|
|
|
587
588
|
try {
|
|
588
589
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
589
590
|
var trailingComment = _step.value;
|
|
591
|
+
if (trailingComment.type === 'CommentBlock') {
|
|
592
|
+
out += ' ';
|
|
593
|
+
}
|
|
590
594
|
out += this.toSource(trailingComment);
|
|
591
595
|
}
|
|
592
596
|
} catch (err) {
|
|
@@ -1583,14 +1587,14 @@
|
|
|
1583
1587
|
value: function CommentBlock(node) {
|
|
1584
1588
|
var value = node.value,
|
|
1585
1589
|
loc = node.loc;
|
|
1586
|
-
var spaces = this.spaces
|
|
1587
|
-
|
|
1588
|
-
var par = parents[parents.length - 3];
|
|
1590
|
+
var spaces = this.spaces;
|
|
1591
|
+
this.parents;
|
|
1589
1592
|
var out = '';
|
|
1590
|
-
|
|
1591
|
-
|
|
1593
|
+
var dedicatedLine = spaces.length === loc.start.column;
|
|
1594
|
+
if (dedicatedLine) {
|
|
1595
|
+
out += spaces;
|
|
1592
1596
|
}
|
|
1593
|
-
out +=
|
|
1597
|
+
out += '/*';
|
|
1594
1598
|
if (value.includes('\n')) {
|
|
1595
1599
|
value = trimEndSpaces(value.replace(/^\s*\*/gm, '*')).split('\n').filter(function (_) {
|
|
1596
1600
|
return _.length;
|
|
@@ -1601,19 +1605,27 @@
|
|
|
1601
1605
|
} else {
|
|
1602
1606
|
out += "".concat(value, "*/");
|
|
1603
1607
|
}
|
|
1604
|
-
if (
|
|
1605
|
-
|
|
1608
|
+
if (dedicatedLine) {
|
|
1609
|
+
out += '\n';
|
|
1610
|
+
} else {
|
|
1611
|
+
out += ' ';
|
|
1606
1612
|
}
|
|
1607
|
-
return
|
|
1613
|
+
return out;
|
|
1608
1614
|
}
|
|
1609
1615
|
}, {
|
|
1610
1616
|
key: "CommentLine",
|
|
1611
1617
|
value: function CommentLine(node) {
|
|
1612
1618
|
var value = node.value,
|
|
1613
1619
|
loc = node.loc;
|
|
1620
|
+
if (this.lastCommentLineIndex === loc.start.index) {
|
|
1621
|
+
return '';
|
|
1622
|
+
}
|
|
1623
|
+
this.lastCommentLineIndex = loc.start.index;
|
|
1614
1624
|
var out = '';
|
|
1615
|
-
|
|
1616
|
-
|
|
1625
|
+
var spaces = this.spaces;
|
|
1626
|
+
var dedicatedLine = spaces.length === loc.start.column;
|
|
1627
|
+
if (dedicatedLine) {
|
|
1628
|
+
out += '\n' + spaces;
|
|
1617
1629
|
} else {
|
|
1618
1630
|
out += ' ';
|
|
1619
1631
|
}
|
|
@@ -1870,6 +1882,9 @@
|
|
|
1870
1882
|
if (parent.leadingComments) {
|
|
1871
1883
|
return parent;
|
|
1872
1884
|
}
|
|
1885
|
+
if (parent.type === 'CallExpression') {
|
|
1886
|
+
break;
|
|
1887
|
+
}
|
|
1873
1888
|
if (nodeIsFunction(parent)) {
|
|
1874
1889
|
break;
|
|
1875
1890
|
}
|
package/index.mjs
CHANGED
|
@@ -280,6 +280,7 @@ class Stringifier {
|
|
|
280
280
|
this.forceCurly = false;
|
|
281
281
|
this.parents = [];
|
|
282
282
|
this.numSpaces = 0;
|
|
283
|
+
this.lastCommentLineIndex = -1;
|
|
283
284
|
}
|
|
284
285
|
toSource(node) {
|
|
285
286
|
var _node$extra;
|
|
@@ -306,6 +307,9 @@ class Stringifier {
|
|
|
306
307
|
}
|
|
307
308
|
if (trailingComments) {
|
|
308
309
|
for (const trailingComment of trailingComments) {
|
|
310
|
+
if (trailingComment.type === 'CommentBlock') {
|
|
311
|
+
out += ' ';
|
|
312
|
+
}
|
|
309
313
|
out += this.toSource(trailingComment);
|
|
310
314
|
}
|
|
311
315
|
}
|
|
@@ -1287,31 +1291,41 @@ class Stringifier {
|
|
|
1287
1291
|
spaces,
|
|
1288
1292
|
parents
|
|
1289
1293
|
} = this;
|
|
1290
|
-
const par = parents[parents.length - 3];
|
|
1291
1294
|
let out = '';
|
|
1292
|
-
|
|
1293
|
-
|
|
1295
|
+
const dedicatedLine = spaces.length === loc.start.column;
|
|
1296
|
+
if (dedicatedLine) {
|
|
1297
|
+
out += spaces;
|
|
1294
1298
|
}
|
|
1295
|
-
out +=
|
|
1299
|
+
out += '/*';
|
|
1296
1300
|
if (value.includes('\n')) {
|
|
1297
1301
|
value = trimEndSpaces(value.replace(/^\s*\*/gm, '*')).split('\n').filter(_ => _.length).map((line, i) => (i ? spaces + ' ' : '') + line).join('\n');
|
|
1298
1302
|
out += `${value}\n${spaces} */`;
|
|
1299
1303
|
} else {
|
|
1300
1304
|
out += `${value}*/`;
|
|
1301
1305
|
}
|
|
1302
|
-
if (
|
|
1303
|
-
|
|
1306
|
+
if (dedicatedLine) {
|
|
1307
|
+
out += '\n';
|
|
1308
|
+
} else {
|
|
1309
|
+
out += ' ';
|
|
1304
1310
|
}
|
|
1305
|
-
return
|
|
1311
|
+
return out;
|
|
1306
1312
|
}
|
|
1307
1313
|
CommentLine(node) {
|
|
1308
1314
|
const {
|
|
1309
1315
|
value,
|
|
1310
1316
|
loc
|
|
1311
1317
|
} = node;
|
|
1318
|
+
if (this.lastCommentLineIndex === loc.start.index) {
|
|
1319
|
+
return '';
|
|
1320
|
+
}
|
|
1321
|
+
this.lastCommentLineIndex = loc.start.index;
|
|
1312
1322
|
let out = '';
|
|
1313
|
-
|
|
1314
|
-
|
|
1323
|
+
const {
|
|
1324
|
+
spaces
|
|
1325
|
+
} = this;
|
|
1326
|
+
const dedicatedLine = spaces.length === loc.start.column;
|
|
1327
|
+
if (dedicatedLine) {
|
|
1328
|
+
out += '\n' + spaces;
|
|
1315
1329
|
} else {
|
|
1316
1330
|
out += ' ';
|
|
1317
1331
|
}
|
|
@@ -1544,6 +1558,9 @@ class Asserter extends Stringifier {
|
|
|
1544
1558
|
if (parent.leadingComments) {
|
|
1545
1559
|
return parent;
|
|
1546
1560
|
}
|
|
1561
|
+
if (parent.type === 'CallExpression') {
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1547
1564
|
if (nodeIsFunction(parent)) {
|
|
1548
1565
|
break;
|
|
1549
1566
|
}
|
package/package.json
CHANGED