@singapore-editor/diff 0.2.0
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/README.md +158 -0
- package/dist/diffGutter.d.ts +37 -0
- package/dist/diffGutter.d.ts.map +1 -0
- package/dist/diffGutter.js +189 -0
- package/dist/diffGutter.js.map +1 -0
- package/dist/diffRows.d.ts +5 -0
- package/dist/diffRows.d.ts.map +1 -0
- package/dist/diffRows.js +40 -0
- package/dist/diffRows.js.map +1 -0
- package/dist/diffSyntax.d.ts +124 -0
- package/dist/diffSyntax.d.ts.map +1 -0
- package/dist/diffSyntax.js +491 -0
- package/dist/diffSyntax.js.map +1 -0
- package/dist/editorDiffPlugin.d.ts +74 -0
- package/dist/editorDiffPlugin.d.ts.map +1 -0
- package/dist/editorDiffPlugin.js +546 -0
- package/dist/editorDiffPlugin.js.map +1 -0
- package/dist/editorOptions.d.ts +15 -0
- package/dist/editorOptions.d.ts.map +1 -0
- package/dist/editorOptions.js +33 -0
- package/dist/editorOptions.js.map +1 -0
- package/dist/gutters.d.ts +53 -0
- package/dist/gutters.d.ts.map +1 -0
- package/dist/gutters.js +122 -0
- package/dist/gutters.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/inline.d.ts +3 -0
- package/dist/inline.d.ts.map +1 -0
- package/dist/inline.js +72 -0
- package/dist/inline.js.map +1 -0
- package/dist/lines.d.ts +8 -0
- package/dist/lines.d.ts.map +1 -0
- package/dist/lines.js +49 -0
- package/dist/lines.js.map +1 -0
- package/dist/liveProjection.d.ts +11 -0
- package/dist/liveProjection.d.ts.map +1 -0
- package/dist/liveProjection.js +152 -0
- package/dist/liveProjection.js.map +1 -0
- package/dist/model.d.ts +4 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +247 -0
- package/dist/model.js.map +1 -0
- package/dist/projection.d.ts +18 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +281 -0
- package/dist/projection.js.map +1 -0
- package/dist/regions.d.ts +28 -0
- package/dist/regions.d.ts.map +1 -0
- package/dist/regions.js +0 -0
- package/dist/regions.js.map +1 -0
- package/dist/style.css +145 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +43 -0
- package/dist/theme.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.d.ts","sourceRoot":"","sources":["../src/regions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;IACzC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IAChC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAA;IACpC,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,gBAAgB,CAAA;CACpD,CAAA;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CA6BvD"}
|
package/dist/regions.js
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.js","names":[],"sources":["../src/regions.ts"],"sourcesContent":["import type { EditorDisposable } from '@singapore-editor/core/extensions'\nimport type { DiffFile } from './types'\n\n/**\n * Which collapsed regions are expanded, and who owns that answer.\n *\n * Split mode is two editors holding two documents, which means two plugin instances — and a\n * separator row is one region shown twice, once per side. If each instance kept its own expansion\n * set, one gutter click would expand the left pane and leave the right where it was, and every row\n * below would be misaligned. That is the single property split mode exists to hold (§C7).\n *\n * So expansion is a store the sides *share* rather than state each side owns. A host building a\n * split view creates one store and passes it to both plugins; a stacked host passes nothing and\n * gets a private one. This is not the mirroring §C5 forbids — nobody is keeping a second copy in\n * sync. There is one copy, and both sides read it.\n */\nexport type DiffRegionStore = {\n getExpandedRegions(): ReadonlySet<string>\n isExpanded(key: string): boolean\n toggleRegion(key: string): void\n /**\n * Points the store at a diff. Expansion is per *diff*, not per path — see the note below — so\n * this drops the current set whenever the identity changes.\n */\n setFile(file: DiffFile | null): void\n onDidChange(listener: () => void): EditorDisposable\n}\n\nexport function createDiffRegionStore(): DiffRegionStore {\n const listeners = new Set<() => void>()\n let expanded = new Set<string>()\n let identity: string | null = null\n\n const notify = (): void => {\n for (const listener of listeners) listener()\n }\n\n return {\n getExpandedRegions: () => expanded,\n isExpanded: (key) => expanded.has(key),\n toggleRegion(key) {\n if (!expanded.delete(key)) expanded.add(key)\n notify()\n },\n setFile(file) {\n const next = diffIdentity(file)\n if (next === identity) return\n\n identity = next\n expanded = new Set()\n notify()\n },\n onDidChange(listener) {\n listeners.add(listener)\n return { dispose: () => listeners.delete(listener) }\n },\n }\n}\n\n/**\n * What counts as \"the same diff\" for the purpose of keeping regions open.\n *\n * Deliberately content-sensitive, and this is a behaviour decision worth stating plainly rather\n * than leaving to be discovered. A region's key is `\"{oldStart}:{newStart}\"` (projection.ts) —\n * absolute line numbers — so any edit *above* a collapsed region renumbers it and the retained key\n * matches nothing. Keeping the set across a content change therefore does not keep regions open;\n * it just means the set quietly stops applying, and a region the reader expanded closes under them\n * on the next refetch.\n *\n * Resetting on a content change gives the same visible outcome and is at least honest about it. It\n * also removes the worse case, where a stale key happens to collide with a region the reader never\n * touched.\n *\n * Making expansion actually survive a refetch needs region identity that does not move with line\n * numbers, which is a design change rather than a fix; it is not attempted here. The comment at\n * projection.ts is careful to claim only that a key cannot land on the *wrong* region — it does\n * not claim survival, and neither does this.\n */\nfunction diffIdentity(file: DiffFile | null): string | null {\n if (!file) return null\n if (file.cacheKey !== undefined) return `${file.path}\u0000${file.cacheKey}`\n\n return `${file.path}\u0000${file.oldLines.length}:${file.newLines.length}:${file.hunks.length}`\n}\n"],"mappings":";AA4BA,SAAgB,wBAAyC;CACvD,MAAM,4BAAY,IAAI,IAAgB;CACtC,IAAI,2BAAW,IAAI,IAAY;CAC/B,IAAI,WAA0B;CAE9B,MAAM,eAAqB;EACzB,KAAK,MAAM,YAAY,WAAW,SAAS;CAC7C;CAEA,OAAO;EACL,0BAA0B;EAC1B,aAAa,QAAQ,SAAS,IAAI,GAAG;EACrC,aAAa,KAAK;GAChB,IAAI,CAAC,SAAS,OAAO,GAAG,GAAG,SAAS,IAAI,GAAG;GAC3C,OAAO;EACT;EACA,QAAQ,MAAM;GACZ,MAAM,OAAO,aAAa,IAAI;GAC9B,IAAI,SAAS,UAAU;GAEvB,WAAW;GACX,2BAAW,IAAI,IAAI;GACnB,OAAO;EACT;EACA,YAAY,UAAU;GACpB,UAAU,IAAI,QAAQ;GACtB,OAAO,EAAE,eAAe,UAAU,OAAO,QAAQ,EAAE;EACrD;CACF;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,aAAa,MAAsC;CAC1D,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,KAAK,aAAa,KAAA,GAAW,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK;CAE7D,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK,SAAS,OAAO,GAAG,KAAK,SAAS,OAAO,GAAG,KAAK,MAAM;AACpF"}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* No caret. A diff is a real `Editor`, so it brings one — and a caret is an insertion point, which
|
|
3
|
+
* a diff does not have: the document is a synthetic projection, `editability` is readonly and the
|
|
4
|
+
* host's keymap is empty, so a blinking bar claims an affordance that is not there.
|
|
5
|
+
*
|
|
6
|
+
* `display: none` on the layer rather than a transparent caret, so the blink animation stops
|
|
7
|
+
* running rather than animating something invisible. Selection is untouched — it paints from its
|
|
8
|
+
* own range highlight, so a reader can still select and copy.
|
|
9
|
+
*
|
|
10
|
+
* Scoped to the host's `.editor-diff-view` class. Base colors come from EditorTheme;
|
|
11
|
+
* `createDiffPlugin` registers the `diff.*` palette used below.
|
|
12
|
+
*/
|
|
13
|
+
.editor-diff-view .editor-virtualized-caret-layer {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.editor-diff-row-addition {
|
|
18
|
+
background: var(--editor-diff-added-bg);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.editor-diff-row-deletion {
|
|
22
|
+
background: var(--editor-diff-deleted-bg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.editor-diff-row-placeholder {
|
|
26
|
+
background: var(--editor-diff-placeholder-bg);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.editor-diff-row-hunk {
|
|
30
|
+
background: var(--editor-diff-hunk-bg);
|
|
31
|
+
color: var(--editor-diff-hunk-foreground);
|
|
32
|
+
user-select: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.editor-diff-row-expandable {
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.editor-diff-row-empty {
|
|
40
|
+
color: var(--editor-diff-muted);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* The gutter cell. `grid-template-columns` comes from `diffGutterLayout`, published as a custom
|
|
45
|
+
* property on the scroll element every time the geometry is recomputed, so the DOM lanes sit
|
|
46
|
+
* exactly where the canvas used to paint them. Hardcoding `1fr 1fr 12px` here would drift, because
|
|
47
|
+
* the lane widths are `ceil(characters * characterWidth + 6)` and the indicator is a fixed 12px
|
|
48
|
+
* (gutters.ts:19-21, :142) — §3.3, trap 1.
|
|
49
|
+
*
|
|
50
|
+
* Deliberately no padding on this element. Its tracks are fixed px summing to exactly the cell's
|
|
51
|
+
* border-box width — which the core also writes inline on the same element — so padding here is
|
|
52
|
+
* inert, and having it *look* effective is how the indicator ended up flush against the code text
|
|
53
|
+
* with no gap. The 4px the canvas inset every lane by (`GUTTER_PADDING_RIGHT`) belongs on the
|
|
54
|
+
* lanes, indicator included.
|
|
55
|
+
*/
|
|
56
|
+
.editor-diff-gutter {
|
|
57
|
+
align-items: center;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
/* The diff's own hook first, then the editor colour theme, then the package default — rather
|
|
60
|
+
than forcing `--editor-gutter-foreground` above, which would outrank the theme's inline value
|
|
61
|
+
and leave the numbers a fixed grey. */
|
|
62
|
+
color: var(--editor-diff-gutter-foreground, var(--editor-gutter-foreground, #71717a));
|
|
63
|
+
display: grid;
|
|
64
|
+
font-variant-numeric: tabular-nums;
|
|
65
|
+
grid-template-columns: var(--editor-diff-gutter-columns, minmax(0, 1fr) minmax(0, 1fr) 12px);
|
|
66
|
+
height: 100%;
|
|
67
|
+
width: 100%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.editor-diff-gutter-lane {
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
min-width: 0;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
padding-right: 4px;
|
|
75
|
+
text-align: right;
|
|
76
|
+
white-space: pre;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* The number lanes carry the plain gutter's left inset; the indicator lane is a fixed 12px track
|
|
80
|
+
that a left pad would squeeze. */
|
|
81
|
+
.editor-diff-gutter-lane-old,
|
|
82
|
+
.editor-diff-gutter-lane-new {
|
|
83
|
+
padding-left: 2px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
* Per-lane tones, not per-row: in stacked mode a single addition row leaves the old lane at
|
|
88
|
+
* foreground and turns the new lane green, which a row-level class cannot express (§3.3, trap 2).
|
|
89
|
+
* `diffGutterLaneTone` decides; this only paints.
|
|
90
|
+
*/
|
|
91
|
+
.editor-diff-gutter-lane[data-diff-tone='added'] {
|
|
92
|
+
color: var(--editor-diff-added);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.editor-diff-gutter-lane[data-diff-tone='deleted'] {
|
|
96
|
+
color: var(--editor-diff-deleted);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.editor-diff-gutter-lane[data-diff-tone='hunk'] {
|
|
100
|
+
color: var(--editor-diff-hunk-foreground);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* The gutter band's own tint, which the canvas used to fill. This *is* per pane — a split old pane
|
|
105
|
+
* shows no tint behind an addition, because that row is a placeholder there.
|
|
106
|
+
*
|
|
107
|
+
* In document mode the diff gutter is the pane's whole gutter, so the tint is the gutter row's own
|
|
108
|
+
* background (`editor-diff-gutter-band-*`, from the row decoration). The row spans the gutter's
|
|
109
|
+
* leading inset as well as the lanes, so a tinted row runs from the pane's edge to its text.
|
|
110
|
+
*/
|
|
111
|
+
.editor-diff-gutter-band-addition {
|
|
112
|
+
background: var(--editor-diff-added-bg);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.editor-diff-gutter-band-deletion {
|
|
116
|
+
background: var(--editor-diff-deleted-bg);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.editor-diff-gutter-band-hunk {
|
|
120
|
+
background: var(--editor-diff-hunk-bg);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.editor-diff-gutter-band-placeholder {
|
|
124
|
+
background: var(--editor-diff-placeholder-bg);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
* In overlay mode the diff lane shares the gutter with the host's own lanes, so only its cell is
|
|
129
|
+
* tinted. The tone comes from `diffGutterRowTone`.
|
|
130
|
+
*/
|
|
131
|
+
.editor-diff-gutter-tinted[data-diff-row-tone='added'] {
|
|
132
|
+
background: var(--editor-diff-added-bg);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.editor-diff-gutter-tinted[data-diff-row-tone='deleted'] {
|
|
136
|
+
background: var(--editor-diff-deleted-bg);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.editor-diff-gutter-tinted[data-diff-row-tone='hunk'] {
|
|
140
|
+
background: var(--editor-diff-hunk-bg);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.editor-diff-gutter-tinted[data-diff-row-type='placeholder'] {
|
|
144
|
+
background: var(--editor-diff-placeholder-bg);
|
|
145
|
+
}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAqBA,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { registerEditorColor } from "@singapore-editor/core/rendering";
|
|
2
|
+
//#region src/theme.ts
|
|
3
|
+
var colors = {
|
|
4
|
+
added: {
|
|
5
|
+
dark: "#5ecc71",
|
|
6
|
+
light: "#166534"
|
|
7
|
+
},
|
|
8
|
+
deleted: {
|
|
9
|
+
dark: "#ff6762",
|
|
10
|
+
light: "#991b1b"
|
|
11
|
+
},
|
|
12
|
+
modified: {
|
|
13
|
+
dark: "#69b1ff",
|
|
14
|
+
light: "#0369a1"
|
|
15
|
+
},
|
|
16
|
+
"added.bg": "color-mix(in srgb, var(--editor-background, #1e1e1e) 78%, var(--editor-diff-added))",
|
|
17
|
+
"deleted.bg": "color-mix(in srgb, var(--editor-background, #1e1e1e) 78%, var(--editor-diff-deleted))",
|
|
18
|
+
"hunk.bg": "color-mix(in srgb, var(--editor-background, #1e1e1e) 84%, var(--editor-diff-modified))",
|
|
19
|
+
"placeholder.bg": {
|
|
20
|
+
dark: "color-mix(in srgb, var(--editor-background, #1e1e1e) 92%, #ffffff)",
|
|
21
|
+
light: "color-mix(in srgb, var(--editor-background, #ffffff) 92%, #000000)"
|
|
22
|
+
},
|
|
23
|
+
border: {
|
|
24
|
+
dark: "#3f3f46",
|
|
25
|
+
light: "#d4d4d8"
|
|
26
|
+
},
|
|
27
|
+
"split.handle": "#71717a",
|
|
28
|
+
muted: {
|
|
29
|
+
dark: "#a1a1aa",
|
|
30
|
+
light: "#52525b"
|
|
31
|
+
},
|
|
32
|
+
"hunk.foreground": {
|
|
33
|
+
dark: "#9cdcfe",
|
|
34
|
+
light: "#0369a1"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function registerDiffColors() {
|
|
38
|
+
for (const [id, fallback] of Object.entries(colors)) registerEditorColor(`diff.${id}`, fallback);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { registerDiffColors };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../src/theme.ts"],"sourcesContent":["import { registerEditorColor, type EditorColorDefaults } from '@singapore-editor/core/rendering'\n\nconst colors = {\n added: { dark: '#5ecc71', light: '#166534' },\n deleted: { dark: '#ff6762', light: '#991b1b' },\n modified: { dark: '#69b1ff', light: '#0369a1' },\n 'added.bg': 'color-mix(in srgb, var(--editor-background, #1e1e1e) 78%, var(--editor-diff-added))',\n 'deleted.bg':\n 'color-mix(in srgb, var(--editor-background, #1e1e1e) 78%, var(--editor-diff-deleted))',\n 'hunk.bg':\n 'color-mix(in srgb, var(--editor-background, #1e1e1e) 84%, var(--editor-diff-modified))',\n 'placeholder.bg': {\n dark: 'color-mix(in srgb, var(--editor-background, #1e1e1e) 92%, #ffffff)',\n light: 'color-mix(in srgb, var(--editor-background, #ffffff) 92%, #000000)',\n },\n border: { dark: '#3f3f46', light: '#d4d4d8' },\n 'split.handle': '#71717a',\n muted: { dark: '#a1a1aa', light: '#52525b' },\n 'hunk.foreground': { dark: '#9cdcfe', light: '#0369a1' },\n} satisfies Record<string, EditorColorDefaults>\n\nexport function registerDiffColors(): void {\n for (const [id, fallback] of Object.entries(colors)) registerEditorColor(`diff.${id}`, fallback)\n}\n"],"mappings":";;AAEA,IAAM,SAAS;CACb,OAAO;EAAE,MAAM;EAAW,OAAO;CAAU;CAC3C,SAAS;EAAE,MAAM;EAAW,OAAO;CAAU;CAC7C,UAAU;EAAE,MAAM;EAAW,OAAO;CAAU;CAC9C,YAAY;CACZ,cACE;CACF,WACE;CACF,kBAAkB;EAChB,MAAM;EACN,OAAO;CACT;CACA,QAAQ;EAAE,MAAM;EAAW,OAAO;CAAU;CAC5C,gBAAgB;CAChB,OAAO;EAAE,MAAM;EAAW,OAAO;CAAU;CAC3C,mBAAmB;EAAE,MAAM;EAAW,OAAO;CAAU;AACzD;AAEA,SAAgB,qBAA2B;CACzC,KAAK,MAAM,CAAC,IAAI,aAAa,OAAO,QAAQ,MAAM,GAAG,oBAAoB,QAAQ,MAAM,QAAQ;AACjG"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { EditorSyntaxLanguageId, EditorSyntaxProvider } from '@singapore-editor/core/syntax';
|
|
2
|
+
import type { EditorHighlighterProvider } from '@singapore-editor/core/extensions';
|
|
3
|
+
export type DiffFileChangeType = 'change' | 'add' | 'delete' | 'rename' | 'rename-change';
|
|
4
|
+
export type DiffLineType = 'context' | 'addition' | 'deletion';
|
|
5
|
+
export type DiffRenderRowType = 'context' | 'addition' | 'deletion' | 'placeholder' | 'hunk' | 'empty';
|
|
6
|
+
export type DiffInlineRange = {
|
|
7
|
+
readonly start: number;
|
|
8
|
+
readonly end: number;
|
|
9
|
+
};
|
|
10
|
+
export type DiffHunkLine = {
|
|
11
|
+
readonly type: DiffLineType;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
readonly oldLineNumber?: number;
|
|
14
|
+
readonly newLineNumber?: number;
|
|
15
|
+
readonly oldInlineRanges?: readonly DiffInlineRange[];
|
|
16
|
+
readonly newInlineRanges?: readonly DiffInlineRange[];
|
|
17
|
+
};
|
|
18
|
+
export type DiffHunk = {
|
|
19
|
+
readonly oldStart: number;
|
|
20
|
+
readonly oldLines: number;
|
|
21
|
+
readonly newStart: number;
|
|
22
|
+
readonly newLines: number;
|
|
23
|
+
readonly header: string;
|
|
24
|
+
readonly lines: readonly DiffHunkLine[];
|
|
25
|
+
};
|
|
26
|
+
export type DiffFile = {
|
|
27
|
+
readonly path: string;
|
|
28
|
+
readonly oldPath?: string;
|
|
29
|
+
readonly newPath: string;
|
|
30
|
+
readonly changeType: DiffFileChangeType;
|
|
31
|
+
readonly oldObjectId?: string;
|
|
32
|
+
readonly newObjectId?: string;
|
|
33
|
+
readonly oldMode?: string;
|
|
34
|
+
readonly newMode?: string;
|
|
35
|
+
readonly oldLines: readonly string[];
|
|
36
|
+
readonly newLines: readonly string[];
|
|
37
|
+
readonly hunks: readonly DiffHunk[];
|
|
38
|
+
readonly isPartial: boolean;
|
|
39
|
+
readonly languageId?: EditorSyntaxLanguageId | null;
|
|
40
|
+
readonly cacheKey?: string;
|
|
41
|
+
};
|
|
42
|
+
export type DiffTextFile = {
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly text: string;
|
|
45
|
+
readonly languageId?: EditorSyntaxLanguageId | null;
|
|
46
|
+
readonly objectId?: string;
|
|
47
|
+
readonly mode?: string;
|
|
48
|
+
};
|
|
49
|
+
export type CreateTextDiffOptions = {
|
|
50
|
+
readonly oldFile?: DiffTextFile | null;
|
|
51
|
+
readonly newFile?: DiffTextFile | null;
|
|
52
|
+
readonly contextLines?: number;
|
|
53
|
+
readonly ignoreWhitespace?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export type ParseGitPatchOptions = {
|
|
56
|
+
readonly cacheKey?: string;
|
|
57
|
+
};
|
|
58
|
+
export type DiffRenderRow = {
|
|
59
|
+
readonly type: DiffRenderRowType;
|
|
60
|
+
readonly text: string;
|
|
61
|
+
readonly oldLineNumber?: number;
|
|
62
|
+
readonly newLineNumber?: number;
|
|
63
|
+
readonly hunkIndex?: number;
|
|
64
|
+
readonly expanded?: boolean;
|
|
65
|
+
readonly expandable?: boolean;
|
|
66
|
+
/** Stable identity of the collapsed region a `hunk` row stands for. */
|
|
67
|
+
readonly expandKey?: string;
|
|
68
|
+
readonly skippedLines?: number;
|
|
69
|
+
readonly inlineRanges?: readonly DiffInlineRange[];
|
|
70
|
+
};
|
|
71
|
+
export type DiffSyntaxBackend = {
|
|
72
|
+
readonly kind: 'highlighter';
|
|
73
|
+
readonly provider?: EditorHighlighterProvider | null;
|
|
74
|
+
} | {
|
|
75
|
+
readonly kind: 'tree-sitter';
|
|
76
|
+
readonly provider?: EditorSyntaxProvider | null;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACjG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAElF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAA;AAEzF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;AAE9D,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,UAAU,GACV,aAAa,GACb,MAAM,GACN,OAAO,CAAA;AAEX,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;I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ACnD,CAAA;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAA;CACrD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAA;CAChD,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@singapore-editor/diff",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"README.md",
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/style.css"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./style.css": "./dist/style.css"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "bun ../../scripts/build-package.ts",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"typecheck": "tsgo --noEmit",
|
|
28
|
+
"lint": "oxlint .",
|
|
29
|
+
"format": "oxfmt --write .",
|
|
30
|
+
"format:check": "oxfmt --check ."
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@singapore-editor/core": "0.1.2",
|
|
34
|
+
"diff": "^9.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
38
|
+
"happy-dom": "^20.14.5",
|
|
39
|
+
"oxfmt": "0.70.0",
|
|
40
|
+
"oxlint": "1.85.0",
|
|
41
|
+
"typescript": "~6.0.3",
|
|
42
|
+
"vitest": "^5.0.2"
|
|
43
|
+
}
|
|
44
|
+
}
|