@pierre/diffs 1.5.0 → 1.5.2
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/components/CodeView.d.ts +2 -1
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +21 -11
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +3 -1
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +7 -4
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +4 -2
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +10 -5
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +3 -4
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +7 -4
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/getChangedDocumentLines.d.ts +6 -0
- package/dist/editor/getChangedDocumentLines.d.ts.map +1 -0
- package/dist/editor/getChangedDocumentLines.js +35 -0
- package/dist/editor/getChangedDocumentLines.js.map +1 -0
- package/dist/renderers/DiffHunksRenderer.d.ts +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +19 -2
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/types.d.ts +4 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.d.ts +2 -1
- package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.js +5 -3
- package/dist/utils/computeVirtualFileMetrics.js.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.js +21 -3
- package/dist/utils/getFiletypeFromFileName.js.map +1 -1
- package/dist/utils/platform.d.ts +2 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +6 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +39 -0
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +8 -0
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +29 -14
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/errors.d.ts +35 -0
- package/dist/worker/errors.d.ts.map +1 -0
- package/dist/worker/errors.js +52 -0
- package/dist/worker/errors.js.map +1 -0
- package/dist/worker/index.d.ts +2 -1
- package/dist/worker/index.js +2 -1
- package/dist/worker/types.d.ts +13 -0
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +60 -3
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +60 -3
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/worker/worker.js
CHANGED
|
@@ -281,6 +281,7 @@ const EXTENSION_TO_FILE_FORMAT = {
|
|
|
281
281
|
mli: "ocaml",
|
|
282
282
|
mll: "ocaml",
|
|
283
283
|
mly: "ocaml",
|
|
284
|
+
odin: "odin",
|
|
284
285
|
pas: "pascal",
|
|
285
286
|
p: "pascal",
|
|
286
287
|
pl: "prolog",
|
|
@@ -313,6 +314,17 @@ const EXTENSION_TO_FILE_FORMAT = {
|
|
|
313
314
|
py: "python",
|
|
314
315
|
pyw: "python",
|
|
315
316
|
pyi: "python",
|
|
317
|
+
BUCK: "python",
|
|
318
|
+
BUILD: "python",
|
|
319
|
+
PACKAGE: "python",
|
|
320
|
+
WORKSPACE: "python",
|
|
321
|
+
Tiltfile: "python",
|
|
322
|
+
bazel: "python",
|
|
323
|
+
bxl: "python",
|
|
324
|
+
bzl: "python",
|
|
325
|
+
bzlmod: "python",
|
|
326
|
+
star: "python",
|
|
327
|
+
sky: "python",
|
|
316
328
|
qml: "qml",
|
|
317
329
|
qmldir: "qmldir",
|
|
318
330
|
qss: "qss",
|
|
@@ -423,16 +435,22 @@ const EXTENSION_TO_FILE_FORMAT = {
|
|
|
423
435
|
sty: "tex"
|
|
424
436
|
};
|
|
425
437
|
function getFiletypeFromFileName(fileName) {
|
|
438
|
+
const format = matchFiletypeFromName(fileName);
|
|
439
|
+
if (format != null) return format;
|
|
440
|
+
const baseName = fileName.split(/[/\\]/).pop() ?? fileName;
|
|
441
|
+
return baseName === fileName ? "text" : matchFiletypeFromName(baseName) ?? "text";
|
|
442
|
+
}
|
|
443
|
+
function matchFiletypeFromName(fileName) {
|
|
426
444
|
if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(fileName)) return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(fileName) ?? "text";
|
|
427
|
-
if (EXTENSION_TO_FILE_FORMAT
|
|
445
|
+
if (Object.hasOwn(EXTENSION_TO_FILE_FORMAT, fileName)) return EXTENSION_TO_FILE_FORMAT[fileName] ?? null;
|
|
428
446
|
const compoundMatch = fileName.match(/\.([^/\\]+\.[^/\\]+)$/);
|
|
429
447
|
if (compoundMatch != null) {
|
|
430
448
|
if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(compoundMatch[1])) return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(compoundMatch[1]) ?? "text";
|
|
431
|
-
if (EXTENSION_TO_FILE_FORMAT
|
|
449
|
+
if (Object.hasOwn(EXTENSION_TO_FILE_FORMAT, compoundMatch[1])) return EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] ?? "text";
|
|
432
450
|
}
|
|
433
451
|
const simpleMatch = fileName.match(/\.([^.]+)$/)?.[1] ?? "";
|
|
434
452
|
if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(simpleMatch)) return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(simpleMatch) ?? "text";
|
|
435
|
-
return EXTENSION_TO_FILE_FORMAT[simpleMatch] ?? "text";
|
|
453
|
+
return Object.hasOwn(EXTENSION_TO_FILE_FORMAT, simpleMatch) ? EXTENSION_TO_FILE_FORMAT[simpleMatch] ?? "text" : null;
|
|
436
454
|
}
|
|
437
455
|
function replaceCustomExtensions(version, map) {
|
|
438
456
|
if (version <= customExtensionsVersion) return false;
|
|
@@ -1432,12 +1450,51 @@ function renderDiffWithHighlighter(diff, highlighter, options, { forcePlainText,
|
|
|
1432
1450
|
baseThemeType
|
|
1433
1451
|
};
|
|
1434
1452
|
}
|
|
1453
|
+
function pushWordLineDecorations(lineDiff, { deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations }) {
|
|
1454
|
+
let deletionOffset = 0;
|
|
1455
|
+
let additionOffset = 0;
|
|
1456
|
+
let deletionStart = -1;
|
|
1457
|
+
let deletionEnd = 0;
|
|
1458
|
+
let additionStart = -1;
|
|
1459
|
+
let additionEnd = 0;
|
|
1460
|
+
for (const { value, added, removed } of lineDiff) if (removed) {
|
|
1461
|
+
if (deletionStart === -1) deletionStart = deletionOffset;
|
|
1462
|
+
deletionOffset += value.length;
|
|
1463
|
+
deletionEnd = deletionOffset;
|
|
1464
|
+
} else if (added) {
|
|
1465
|
+
if (additionStart === -1) additionStart = additionOffset;
|
|
1466
|
+
additionOffset += value.length;
|
|
1467
|
+
additionEnd = additionOffset;
|
|
1468
|
+
} else {
|
|
1469
|
+
deletionOffset += value.length;
|
|
1470
|
+
additionOffset += value.length;
|
|
1471
|
+
}
|
|
1472
|
+
if (deletionStart !== -1) deletionDecorations.push(createDiffSpanDecoration({
|
|
1473
|
+
line: deletionLineIndex,
|
|
1474
|
+
spanStart: deletionStart,
|
|
1475
|
+
spanLength: deletionEnd - deletionStart
|
|
1476
|
+
}));
|
|
1477
|
+
if (additionStart !== -1) additionDecorations.push(createDiffSpanDecoration({
|
|
1478
|
+
line: additionLineIndex,
|
|
1479
|
+
spanStart: additionStart,
|
|
1480
|
+
spanLength: additionEnd - additionStart
|
|
1481
|
+
}));
|
|
1482
|
+
}
|
|
1435
1483
|
function computeLineDiffDecorations({ deletionLine, additionLine, deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations, lineDiffType, maxLineDiffLength }) {
|
|
1436
1484
|
if (deletionLine == null || additionLine == null || lineDiffType === "none") return;
|
|
1437
1485
|
deletionLine = cleanLastNewline(deletionLine);
|
|
1438
1486
|
additionLine = cleanLastNewline(additionLine);
|
|
1439
1487
|
if (deletionLine.length > maxLineDiffLength || additionLine.length > maxLineDiffLength) return;
|
|
1440
1488
|
const lineDiff = lineDiffType === "char" ? diffChars(deletionLine, additionLine) : diffWordsWithSpace(deletionLine, additionLine);
|
|
1489
|
+
if (lineDiffType === "word-line") {
|
|
1490
|
+
pushWordLineDecorations(lineDiff, {
|
|
1491
|
+
deletionLineIndex,
|
|
1492
|
+
additionLineIndex,
|
|
1493
|
+
deletionDecorations,
|
|
1494
|
+
additionDecorations
|
|
1495
|
+
});
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1441
1498
|
const deletionSpans = [];
|
|
1442
1499
|
const additionSpans = [];
|
|
1443
1500
|
const enableJoin = lineDiffType === "word-alt";
|