espolar 0.1.4 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +9 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1346,8 +1346,14 @@ function pushMapping(mappings, mapping, combineMappingData) {
1346
1346
  }
1347
1347
  mappings.push(mapping);
1348
1348
  }
1349
+ /**
1350
+ * Two adjacent mappings with identical lengths can be merged into one mapping.
1351
+ * @param left
1352
+ * @param right
1353
+ * @returns
1354
+ */
1349
1355
  function canMerge(left, right) {
1350
- return left.sourceStart + left.sourceEnd === right.sourceStart && left.generatedStart + left.generatedEnd === right.generatedStart;
1356
+ return left.sourceEnd - left.sourceStart === left.generatedEnd - left.generatedStart && right.sourceEnd - right.sourceStart === right.generatedEnd - right.generatedStart && left.sourceEnd === right.sourceStart && left.generatedEnd === right.generatedStart;
1351
1357
  }
1352
1358
  function toVolarMapping(mapping) {
1353
1359
  const sourceLength = mapping.sourceEnd - mapping.sourceStart;
@@ -1415,7 +1421,7 @@ function createPrinterContext(options) {
1415
1421
  generatedOffset += text.length;
1416
1422
  },
1417
1423
  writeMapped(text, sourceStart, sourceEnd, data) {
1418
- if (text.length === 0 || sourceEnd <= sourceStart) return;
1424
+ if (text.length === 0 || sourceEnd < sourceStart) return;
1419
1425
  const generatedStart = generatedOffset;
1420
1426
  context.write(text);
1421
1427
  appendMapping({
@@ -1472,7 +1478,7 @@ function createPrinterContext(options) {
1472
1478
  }
1473
1479
  },
1474
1480
  writeSource(start, end, data) {
1475
- if (end <= start) return;
1481
+ if (end < start) return;
1476
1482
  const generatedStart = generatedOffset;
1477
1483
  context.write(options.source.slice(start, end));
1478
1484
  appendMapping({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "espolar",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {