@runtime-type-inspector/transpiler 2.0.6 → 2.0.7
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 +27 -11
- package/index.mjs +27 -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,28 @@
|
|
|
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
|
+
console.log("CommentLine> ignore double");
|
|
1622
|
+
return '';
|
|
1623
|
+
}
|
|
1624
|
+
this.lastCommentLineIndex = loc.start.index;
|
|
1614
1625
|
var out = '';
|
|
1615
|
-
|
|
1616
|
-
|
|
1626
|
+
var spaces = this.spaces;
|
|
1627
|
+
var dedicatedLine = spaces.length === loc.start.column;
|
|
1628
|
+
if (dedicatedLine) {
|
|
1629
|
+
out += '\n' + spaces;
|
|
1617
1630
|
} else {
|
|
1618
1631
|
out += ' ';
|
|
1619
1632
|
}
|
|
@@ -1870,6 +1883,9 @@
|
|
|
1870
1883
|
if (parent.leadingComments) {
|
|
1871
1884
|
return parent;
|
|
1872
1885
|
}
|
|
1886
|
+
if (parent.type === 'CallExpression') {
|
|
1887
|
+
break;
|
|
1888
|
+
}
|
|
1873
1889
|
if (nodeIsFunction(parent)) {
|
|
1874
1890
|
break;
|
|
1875
1891
|
}
|
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,42 @@ 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
|
+
console.log("CommentLine> ignore double");
|
|
1320
|
+
return '';
|
|
1321
|
+
}
|
|
1322
|
+
this.lastCommentLineIndex = loc.start.index;
|
|
1312
1323
|
let out = '';
|
|
1313
|
-
|
|
1314
|
-
|
|
1324
|
+
const {
|
|
1325
|
+
spaces
|
|
1326
|
+
} = this;
|
|
1327
|
+
const dedicatedLine = spaces.length === loc.start.column;
|
|
1328
|
+
if (dedicatedLine) {
|
|
1329
|
+
out += '\n' + spaces;
|
|
1315
1330
|
} else {
|
|
1316
1331
|
out += ' ';
|
|
1317
1332
|
}
|
|
@@ -1544,6 +1559,9 @@ class Asserter extends Stringifier {
|
|
|
1544
1559
|
if (parent.leadingComments) {
|
|
1545
1560
|
return parent;
|
|
1546
1561
|
}
|
|
1562
|
+
if (parent.type === 'CallExpression') {
|
|
1563
|
+
break;
|
|
1564
|
+
}
|
|
1547
1565
|
if (nodeIsFunction(parent)) {
|
|
1548
1566
|
break;
|
|
1549
1567
|
}
|
package/package.json
CHANGED