@pierre/diffs 1.5.1 → 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.
Files changed (60) hide show
  1. package/dist/components/CodeView.d.ts +2 -1
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +21 -11
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts.map +1 -1
  6. package/dist/components/File.js +3 -1
  7. package/dist/components/File.js.map +1 -1
  8. package/dist/components/FileDiff.d.ts +7 -4
  9. package/dist/components/FileDiff.d.ts.map +1 -1
  10. package/dist/components/FileDiff.js +4 -2
  11. package/dist/components/FileDiff.js.map +1 -1
  12. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  13. package/dist/components/VirtualizedFile.js +10 -5
  14. package/dist/components/VirtualizedFile.js.map +1 -1
  15. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  16. package/dist/components/VirtualizedFileDiff.js +3 -4
  17. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  18. package/dist/editor/editor.d.ts.map +1 -1
  19. package/dist/editor/editor.js +5 -2
  20. package/dist/editor/editor.js.map +1 -1
  21. package/dist/editor/getChangedDocumentLines.d.ts +6 -0
  22. package/dist/editor/getChangedDocumentLines.d.ts.map +1 -0
  23. package/dist/editor/getChangedDocumentLines.js +35 -0
  24. package/dist/editor/getChangedDocumentLines.js.map +1 -0
  25. package/dist/renderers/DiffHunksRenderer.d.ts +1 -1
  26. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  27. package/dist/renderers/DiffHunksRenderer.js +19 -2
  28. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  29. package/dist/types.d.ts +3 -2
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/utils/computeVirtualFileMetrics.d.ts +2 -1
  32. package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -1
  33. package/dist/utils/computeVirtualFileMetrics.js +5 -3
  34. package/dist/utils/computeVirtualFileMetrics.js.map +1 -1
  35. package/dist/utils/getDiffHunksRendererOptions.js +1 -0
  36. package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
  37. package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
  38. package/dist/utils/getFiletypeFromFileName.js +21 -3
  39. package/dist/utils/getFiletypeFromFileName.js.map +1 -1
  40. package/dist/utils/platform.d.ts +2 -1
  41. package/dist/utils/platform.d.ts.map +1 -1
  42. package/dist/utils/platform.js +6 -1
  43. package/dist/utils/platform.js.map +1 -1
  44. package/dist/worker/WorkerPoolManager.d.ts +8 -0
  45. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  46. package/dist/worker/WorkerPoolManager.js +29 -14
  47. package/dist/worker/WorkerPoolManager.js.map +1 -1
  48. package/dist/worker/errors.d.ts +35 -0
  49. package/dist/worker/errors.d.ts.map +1 -0
  50. package/dist/worker/errors.js +52 -0
  51. package/dist/worker/errors.js.map +1 -0
  52. package/dist/worker/index.d.ts +2 -1
  53. package/dist/worker/index.js +2 -1
  54. package/dist/worker/types.d.ts +13 -0
  55. package/dist/worker/types.d.ts.map +1 -1
  56. package/dist/worker/worker-portable.js +21 -3
  57. package/dist/worker/worker-portable.js.map +1 -1
  58. package/dist/worker/worker.js +21 -3
  59. package/dist/worker/worker.js.map +1 -1
  60. package/package.json +1 -1
@@ -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[fileName] != null) return EXTENSION_TO_FILE_FORMAT[fileName];
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[compoundMatch[1]] != null) return EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] ?? "text";
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;