@yuhufe/wtool-vdiff 0.0.6 → 0.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.
Files changed (42) hide show
  1. package/README.md +140 -41
  2. package/dist/DiffFiles/DiffFiles.vue.d.ts +12 -0
  3. package/dist/DiffFiles/DiffList/DiffList.vue.d.ts +94 -0
  4. package/dist/DiffFiles/FileExplore/FileExplore.vue.d.ts +510 -0
  5. package/dist/DiffFiles/FileExplore/FileSearch.vue.d.ts +11 -0
  6. package/dist/DiffFiles/FileExplore/fileTree.d.ts +17 -0
  7. package/dist/DiffFiles/createDiffFiles.d.ts +13 -0
  8. package/dist/DiffFiles/index.d.ts +3 -0
  9. package/dist/DiffFiles/types.d.ts +12 -0
  10. package/dist/DiffFiles/useDiffFiles.d.ts +23 -0
  11. package/dist/DiffViewer/DiffViewer.vue.d.ts +15 -4
  12. package/dist/DiffViewer/MonacoDiffViewer.vue.d.ts +1 -1
  13. package/dist/DiffViewer/TopBar.vue.d.ts +2 -0
  14. package/dist/DiffViewer/const.d.ts +8 -0
  15. package/dist/DiffViewer/utils/autoHeight.d.ts +4 -1
  16. package/dist/DiffViewer/utils/patch2Pair.d.ts +9 -14
  17. package/dist/index.d.ts +1 -0
  18. package/dist/types.d.ts +16 -0
  19. package/dist/utils/patch.d.ts +20 -0
  20. package/dist/wtool-vdiff.cjs.js +45 -36
  21. package/dist/wtool-vdiff.es.js +9535 -5984
  22. package/package.json +10 -9
  23. package/src/DiffFiles/DiffFiles.vue +126 -0
  24. package/src/DiffFiles/DiffList/DiffList.vue +125 -0
  25. package/src/DiffFiles/FileExplore/FileExplore.vue +181 -0
  26. package/src/DiffFiles/FileExplore/FileSearch.vue +81 -0
  27. package/src/DiffFiles/FileExplore/fileTree.ts +102 -0
  28. package/src/DiffFiles/createDiffFiles.ts +70 -0
  29. package/src/DiffFiles/index.ts +11 -0
  30. package/src/DiffFiles/types.ts +15 -0
  31. package/src/DiffFiles/useDiffFiles.ts +56 -0
  32. package/src/DiffViewer/DiffViewer.vue +28 -7
  33. package/src/DiffViewer/MonacoDiffViewer.vue +21 -2
  34. package/src/DiffViewer/TopBar.vue +25 -6
  35. package/src/DiffViewer/const.ts +11 -0
  36. package/src/DiffViewer/utils/autoHeight.ts +159 -43
  37. package/src/DiffViewer/utils/patch2Pair.ts +37 -56
  38. package/src/assets/file.svg +4 -0
  39. package/src/assets/folder.svg +4 -0
  40. package/src/index.ts +1 -0
  41. package/src/types.ts +19 -0
  42. package/src/utils/patch.ts +74 -0
@@ -3,11 +3,13 @@ type __VLS_Props = {
3
3
  filename: string;
4
4
  content: string | null;
5
5
  }[];
6
+ diffPatch?: string;
6
7
  };
7
8
  declare const _default: import('../../node_modules/vue/dist/vue.esm-bundler.js').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('../../node_modules/vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, import('../../node_modules/vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, {}, string, import('../../node_modules/vue/dist/vue.esm-bundler.js').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
9
  diffPair: {
9
10
  filename: string;
10
11
  content: string | null;
11
12
  }[];
13
+ diffPatch: string;
12
14
  }, {}, {}, {}, string, import('../../node_modules/vue/dist/vue.esm-bundler.js').ComponentProvideOptions, false, {}, HTMLDivElement>;
13
15
  export default _default;
@@ -0,0 +1,8 @@
1
+ /** 顶部工具栏的固定高度,单位:像素。 */
2
+ export declare const HEIGHT_TOP_BAR = 32;
3
+ /** Diff 编辑器中单行代码的默认高度,单位:像素。 */
4
+ export declare const HEIGHT_CODE_LINE = 18;
5
+ /** 未变更代码折叠区域占用的固定高度,单位:像素。 */
6
+ export declare const HEIGHT_HIDDEN_REGION = 24;
7
+ /** Diff 编辑器横向滚动条的默认高度,单位:像素。 */
8
+ export declare const HEIGHT_HORIZONTAL_SCROLLBAR = 8;
@@ -1,9 +1,12 @@
1
1
  import { WtoolDiffViewerProps } from '../../types';
2
- export declare const autoHeight: ({ patch, pair, maxHeight, minHeight, unchangedVisiable, unchangedCtxLineNum, }: {
2
+ export declare const height2Num: (heightStr: string) => number;
3
+ export declare const autoHeight: ({ id, patch, pair, maxHeight, minHeight, unchangedVisiable, unchangedCtxLineNum, unchangedMinLineNum, }: {
4
+ id: string;
3
5
  patch?: string;
4
6
  pair?: WtoolDiffViewerProps["diffPair"];
5
7
  maxHeight: string;
6
8
  minHeight: string;
7
9
  unchangedVisiable: boolean;
8
10
  unchangedCtxLineNum: number;
11
+ unchangedMinLineNum?: number;
9
12
  }) => number;
@@ -2,21 +2,15 @@ export interface FilePair {
2
2
  filename: string;
3
3
  content: string;
4
4
  }
5
- export interface Hunk {
6
- origStart: number;
7
- origCount: number;
8
- modStart: number;
9
- modCount: number;
10
- lines: string[];
5
+ export interface PatchChangedLineBlock {
6
+ start: number;
7
+ end: number;
8
+ }
9
+ export interface PatchPairLayout {
10
+ pair: FilePair[];
11
+ changedLineBlocks: PatchChangedLineBlock[];
12
+ totalLines: number;
11
13
  }
12
- /**
13
- * 解析 unified diff patch,提取文件名与所有 hunk
14
- */
15
- export declare function parseHunks(patch: string): {
16
- origFilename: string;
17
- modFilename: string;
18
- hunks: Hunk[];
19
- };
20
14
  /**
21
15
  * 将 unified diff patch 转换为 [original, modified] 文件对。
22
16
  *
@@ -27,4 +21,5 @@ export declare function parseHunks(patch: string): {
27
21
  * - 连续的删除('-')/ 新增('+')块:收集后成对对齐写入,
28
22
  * 行数较少的一侧补空行,使 Monaco 能在同一视觉行渲染替换关系
29
23
  */
24
+ export declare const patch2PairWithLayout: (patch: string) => PatchPairLayout;
30
25
  export declare const patch2Pair: (patch: string) => FilePair[];
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './DiffViewer';
2
+ export * from './DiffFiles';
2
3
  export { default as loader } from '@monaco-editor/loader';
package/dist/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import type * as Monaco from 'monaco-editor';
2
2
  export type DiffEditorOptions = Monaco.editor.IStandaloneDiffEditorConstructionOptions;
3
3
  export type ModelOptions = Monaco.editor.ITextModelUpdateOptions;
4
4
  export interface WtoolDiffViewerProps {
5
+ fileId?: string;
5
6
  diffPair?: {
6
7
  filename: string;
7
8
  content: string | null;
@@ -17,4 +18,19 @@ export interface WtoolDiffViewerStyle {
17
18
  height?: string;
18
19
  minHeight?: string;
19
20
  maxHeight?: string;
21
+ viewed?: boolean;
22
+ rawed?: boolean;
23
+ }
24
+ export interface DiffFile {
25
+ fullPath?: string;
26
+ diffPair?: WtoolDiffViewerProps['diffPair'];
27
+ diffPatch?: string;
28
+ viewerStyle?: WtoolDiffViewerStyle;
29
+ }
30
+ /** @deprecated Use DiffFile. Nested directory input is no longer supported. */
31
+ export type FileTree = DiffFile;
32
+ export interface WtoolDiffFilesProps {
33
+ diffFiles?: DiffFile[];
34
+ fileOverScan?: number;
35
+ viewerStyle?: WtoolDiffViewerStyle;
20
36
  }
@@ -0,0 +1,20 @@
1
+ export interface Hunk {
2
+ origStart: number;
3
+ origCount: number;
4
+ modStart: number;
5
+ modCount: number;
6
+ lines: string[];
7
+ }
8
+ export interface PatchFilenames {
9
+ origFilename: string;
10
+ modFilename: string;
11
+ }
12
+ /**
13
+ * 从 unified diff patch 解析 --- / +++ 行中的文件名。
14
+ * 文件名位于 patch 头部,遇到首个 @@ hunk 或已解析到两侧文件名后即停止扫描。
15
+ */
16
+ export declare function parsePatchFilenames(patch: string): PatchFilenames;
17
+ /**
18
+ * 从 unified diff patch 解析所有 hunk(@@ 块)
19
+ */
20
+ export declare function parsePatchHunks(patch: string): Hunk[];