xtralab 0.14.1 → 0.15.1
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 +10 -0
- package/lib/about/icons.d.ts +0 -5
- package/lib/about/icons.js +0 -5
- package/lib/about/index.d.ts +4 -8
- package/lib/about/index.js +6 -17
- package/lib/agentSessions.d.ts +9 -29
- package/lib/agentSessions.js +2 -7
- package/lib/askAgent/editorSelection.d.ts +20 -26
- package/lib/askAgent/editorSelection.js +11 -26
- package/lib/askAgent/icons.d.ts +2 -3
- package/lib/askAgent/icons.js +2 -3
- package/lib/askAgent/index.d.ts +4 -26
- package/lib/askAgent/index.js +54 -158
- package/lib/askAgent/popup.d.ts +12 -16
- package/lib/askAgent/popup.js +18 -37
- package/lib/askAgent/prompt.d.ts +3 -5
- package/lib/askAgent/prompt.js +6 -19
- package/lib/askAgent/queue.d.ts +11 -21
- package/lib/askAgent/queue.js +9 -19
- package/lib/askAgent/queuePanel.d.ts +13 -18
- package/lib/askAgent/queuePanel.js +15 -37
- package/lib/askAgent/targetPicker.d.ts +2 -9
- package/lib/askAgent/targetPicker.js +6 -11
- package/lib/askAgent/tokens.d.ts +32 -46
- package/lib/askAgent/tokens.js +4 -6
- package/lib/commandBar/index.d.ts +4 -13
- package/lib/commandBar/index.js +21 -39
- package/lib/customPanel/index.d.ts +7 -0
- package/lib/customPanel/index.js +89 -0
- package/lib/editorBreadcrumbs/index.d.ts +3 -6
- package/lib/editorBreadcrumbs/index.js +10 -6
- package/lib/editorBreadcrumbs/widget.d.ts +17 -4
- package/lib/editorBreadcrumbs/widget.js +11 -17
- package/lib/editorIndent/index.d.ts +4 -12
- package/lib/editorIndent/index.js +8 -23
- package/lib/fileBrowser/commands.d.ts +28 -19
- package/lib/fileBrowser/commands.js +51 -98
- package/lib/fileBrowser/contents.d.ts +14 -0
- package/lib/fileBrowser/contents.js +28 -0
- package/lib/fileBrowser/dragAndDrop.d.ts +79 -0
- package/lib/fileBrowser/dragAndDrop.js +110 -0
- package/lib/fileBrowser/fileBrowser.d.ts +21 -9
- package/lib/fileBrowser/fileBrowser.js +211 -405
- package/lib/fileBrowser/gitStatus.d.ts +4 -9
- package/lib/fileBrowser/gitStatus.js +7 -17
- package/lib/fileBrowser/gitignore.d.ts +4 -17
- package/lib/fileBrowser/gitignore.js +4 -25
- package/lib/fileBrowser/icons.d.ts +7 -17
- package/lib/fileBrowser/icons.js +25 -80
- package/lib/fileBrowser/index.js +41 -10
- package/lib/fileBrowser/widget.d.ts +170 -53
- package/lib/fileBrowser/widget.js +242 -18
- package/lib/fileTypeIcons/index.js +0 -10
- package/lib/git/api.d.ts +5 -13
- package/lib/git/api.js +10 -36
- package/lib/git/askRequest.d.ts +4 -8
- package/lib/git/askRequest.js +6 -20
- package/lib/git/commands.d.ts +40 -5
- package/lib/git/commands.js +16 -10
- package/lib/git/diffModel.js +4 -0
- package/lib/git/diffSurface.d.ts +41 -55
- package/lib/git/diffSurface.js +42 -117
- package/lib/git/diffWidget.d.ts +81 -2
- package/lib/git/diffWidget.js +62 -12
- package/lib/git/imageDiff.d.ts +5 -6
- package/lib/git/imageDiff.js +18 -48
- package/lib/git/index.d.ts +0 -3
- package/lib/git/index.js +3 -8
- package/lib/git/notebookDiff.d.ts +110 -33
- package/lib/git/notebookDiff.js +52 -195
- package/lib/git/tokens.d.ts +73 -31
- package/lib/git/tokens.js +2 -3
- package/lib/highlight/index.d.ts +4 -10
- package/lib/highlight/index.js +10 -41
- package/lib/index.d.ts +0 -9
- package/lib/index.js +2 -9
- package/lib/launcher/agents.d.ts +55 -51
- package/lib/launcher/agents.js +25 -54
- package/lib/launcher/availability.d.ts +3 -9
- package/lib/launcher/availability.js +3 -9
- package/lib/launcher/commands.d.ts +7 -32
- package/lib/launcher/commands.js +14 -45
- package/lib/launcher/dashboard.d.ts +19 -24
- package/lib/launcher/dashboard.js +21 -67
- package/lib/launcher/editorRegistry.d.ts +10 -22
- package/lib/launcher/editorRegistry.js +14 -18
- package/lib/launcher/editors.d.ts +39 -45
- package/lib/launcher/editors.js +8 -34
- package/lib/launcher/icons.d.ts +0 -12
- package/lib/launcher/icons.js +14 -37
- package/lib/launcher/index.js +12 -55
- package/lib/launcher/invocation.d.ts +4 -10
- package/lib/launcher/invocation.js +7 -22
- package/lib/launcher/registry.d.ts +9 -7
- package/lib/launcher/registry.js +9 -7
- package/lib/launcher/schemaDefaults.d.ts +2 -9
- package/lib/launcher/schemaDefaults.js +37 -13
- package/lib/launcher/tokens.d.ts +10 -22
- package/lib/launcher/tokens.js +5 -8
- package/lib/menuBar/index.d.ts +3 -10
- package/lib/menuBar/index.js +11 -28
- package/lib/menus/index.d.ts +3 -9
- package/lib/menus/index.js +14 -30
- package/lib/omnibox/files.d.ts +2 -4
- package/lib/omnibox/files.js +5 -11
- package/lib/omnibox/index.d.ts +4 -14
- package/lib/omnibox/index.js +9 -27
- package/lib/omnibox/model.d.ts +38 -10
- package/lib/omnibox/model.js +15 -33
- package/lib/omnibox/recents.d.ts +15 -17
- package/lib/omnibox/recents.js +12 -17
- package/lib/omnibox/tokens.d.ts +5 -10
- package/lib/omnibox/tokens.js +2 -6
- package/lib/omnibox/widget.d.ts +11 -7
- package/lib/omnibox/widget.js +8 -16
- package/lib/searchReplace/index.d.ts +4 -20
- package/lib/searchReplace/index.js +7 -27
- package/lib/showOutput/index.d.ts +3 -12
- package/lib/showOutput/index.js +6 -22
- package/lib/sidebar/index.d.ts +4 -13
- package/lib/sidebar/index.js +73 -46
- package/lib/terminalNotifications/index.d.ts +4 -10
- package/lib/terminalNotifications/index.js +6 -20
- package/lib/terminals/agentTerminals.d.ts +12 -5
- package/lib/terminals/agentTerminals.js +25 -44
- package/lib/terminals/detection.d.ts +4 -8
- package/lib/terminals/detection.js +4 -8
- package/lib/terminals/index.d.ts +0 -33
- package/lib/terminals/index.js +24 -102
- package/lib/terminals/model.d.ts +64 -139
- package/lib/terminals/model.js +80 -220
- package/lib/terminals/tokens.d.ts +11 -22
- package/lib/terminals/tokens.js +2 -2
- package/lib/terminals/widget.d.ts +72 -38
- package/lib/terminals/widget.js +173 -73
- package/lib/topBar/icons.d.ts +3 -8
- package/lib/topBar/icons.js +3 -8
- package/lib/topBar/index.d.ts +4 -11
- package/lib/topBar/index.js +10 -38
- package/lib/walkthrough/index.d.ts +4 -9
- package/lib/walkthrough/index.js +6 -20
- package/lib/walkthrough/panel.d.ts +40 -9
- package/lib/walkthrough/panel.js +4 -10
- package/package.json +2 -2
- package/schema/launcher.json +2 -2
- package/schema/sidebar.json +47 -7
- package/src/about/icons.ts +0 -5
- package/src/about/index.tsx +6 -17
- package/src/agentSessions.ts +9 -29
- package/src/askAgent/editorSelection.ts +22 -29
- package/src/askAgent/icons.ts +2 -3
- package/src/askAgent/index.ts +54 -158
- package/src/askAgent/popup.tsx +23 -45
- package/src/askAgent/prompt.ts +6 -19
- package/src/askAgent/queue.ts +13 -24
- package/src/askAgent/queuePanel.tsx +21 -46
- package/src/askAgent/targetPicker.tsx +5 -15
- package/src/askAgent/tokens.ts +32 -46
- package/src/commandBar/index.ts +24 -39
- package/src/customPanel/index.ts +119 -0
- package/src/editorBreadcrumbs/index.ts +10 -6
- package/src/editorBreadcrumbs/widget.ts +23 -17
- package/src/editorIndent/index.ts +17 -23
- package/src/fileBrowser/commands.ts +70 -98
- package/src/fileBrowser/contents.ts +33 -0
- package/src/fileBrowser/dragAndDrop.ts +188 -0
- package/src/fileBrowser/fileBrowser.tsx +259 -440
- package/src/fileBrowser/gitStatus.ts +7 -17
- package/src/fileBrowser/gitignore.ts +4 -25
- package/src/fileBrowser/icons.ts +25 -80
- package/src/fileBrowser/index.ts +43 -10
- package/src/fileBrowser/widget.tsx +344 -64
- package/src/fileTypeIcons/index.ts +0 -10
- package/src/git/api.ts +10 -36
- package/src/git/askRequest.ts +6 -20
- package/src/git/commands.ts +70 -10
- package/src/git/diffModel.ts +25 -0
- package/src/git/diffSurface.tsx +71 -159
- package/src/git/diffWidget.tsx +104 -14
- package/src/git/imageDiff.tsx +45 -51
- package/src/git/index.ts +3 -8
- package/src/git/notebookDiff.tsx +211 -238
- package/src/git/tokens.ts +73 -31
- package/src/highlight/index.ts +10 -41
- package/src/index.ts +2 -9
- package/src/launcher/agents.ts +74 -92
- package/src/launcher/availability.ts +3 -9
- package/src/launcher/commands.ts +14 -51
- package/src/launcher/dashboard.tsx +49 -88
- package/src/launcher/editorRegistry.ts +21 -29
- package/src/launcher/editors.ts +39 -58
- package/src/launcher/icons.ts +15 -37
- package/src/launcher/index.ts +12 -55
- package/src/launcher/invocation.ts +7 -22
- package/src/launcher/registry.ts +9 -7
- package/src/launcher/schemaDefaults.ts +43 -13
- package/src/launcher/tokens.ts +10 -22
- package/src/menuBar/index.ts +11 -28
- package/src/menus/index.ts +14 -30
- package/src/omnibox/files.ts +10 -14
- package/src/omnibox/index.ts +9 -27
- package/src/omnibox/model.ts +50 -38
- package/src/omnibox/recents.ts +17 -22
- package/src/omnibox/tokens.ts +5 -10
- package/src/omnibox/widget.tsx +14 -19
- package/src/searchReplace/index.ts +7 -27
- package/src/showOutput/index.ts +6 -22
- package/src/sidebar/index.ts +103 -52
- package/src/terminalNotifications/index.ts +42 -25
- package/src/terminals/agentTerminals.ts +25 -49
- package/src/terminals/detection.ts +4 -8
- package/src/terminals/index.ts +31 -102
- package/src/terminals/model.ts +130 -246
- package/src/terminals/tokens.ts +11 -22
- package/src/terminals/widget.tsx +229 -113
- package/src/topBar/icons.ts +3 -8
- package/src/topBar/index.ts +21 -44
- package/src/walkthrough/index.ts +6 -20
- package/src/walkthrough/panel.ts +40 -10
- package/style/about.css +2 -7
- package/style/askAgent.css +8 -40
- package/style/base.css +25 -73
- package/style/chrome.css +108 -308
- package/style/commandBar.css +4 -20
- package/style/customPanel.css +6 -0
- package/style/git.css +22 -184
- package/style/highlight.css +1 -3
- package/style/index.js +1 -0
- package/style/launcher.css +6 -70
- package/style/omnibox.css +2 -14
- package/style/showOutput.css +0 -6
- package/style/sidebar.css +29 -9
- package/style/tabs.css +5 -13
- package/style/terminals.css +18 -123
- package/style/topBar.css +2 -22
- package/style/walkthrough.css +0 -8
package/src/git/api.ts
CHANGED
|
@@ -9,29 +9,15 @@ import {
|
|
|
9
9
|
IGitStatusResult
|
|
10
10
|
} from './tokens';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Root URL segment used by the `jupyterlab_git` server extension. Every
|
|
14
|
-
* endpoint hangs off this prefix; the `<repoPath>` between it and the
|
|
15
|
-
* endpoint suffix is the JupyterLab server-relative path of the git
|
|
16
|
-
* repository (URL-encoded). For an empty `repoPath` the URL collapses to
|
|
17
|
-
* `/git/<endpoint>` — a shape git's URL routing also accepts.
|
|
18
|
-
*/
|
|
19
12
|
const GIT_NAMESPACE = 'git';
|
|
20
13
|
|
|
21
|
-
/**
|
|
22
|
-
* Issue a `POST` against a `jupyterlab_git` endpoint that takes a `<path>`
|
|
23
|
-
* prefix (e.g. `/git/<path>/status`). The response body is decoded as JSON;
|
|
24
|
-
* non-2xx responses are surfaced via the JupyterLab `ServerConnection`
|
|
25
|
-
* machinery so callers can show their `message` field as-is.
|
|
26
|
-
*/
|
|
27
14
|
async function postWithPath<T>(
|
|
28
15
|
endpoint: string,
|
|
29
16
|
repoPath: string,
|
|
30
17
|
body: unknown
|
|
31
18
|
): Promise<T> {
|
|
32
19
|
const settings = ServerConnection.makeSettings();
|
|
33
|
-
//
|
|
34
|
-
// between them — the server expects the path to look like a posix path.
|
|
20
|
+
// encodeParts keeps the slashes the server's posix-path routing expects.
|
|
35
21
|
const encodedPath = repoPath.length > 0 ? URLExt.encodeParts(repoPath) : '';
|
|
36
22
|
const url = URLExt.join(
|
|
37
23
|
settings.baseUrl,
|
|
@@ -50,7 +36,7 @@ async function postWithPath<T>(
|
|
|
50
36
|
try {
|
|
51
37
|
data = JSON.parse(text) as T;
|
|
52
38
|
} catch {
|
|
53
|
-
//
|
|
39
|
+
// Non-JSON bodies still surface via the ResponseError below.
|
|
54
40
|
}
|
|
55
41
|
}
|
|
56
42
|
if (!response.ok) {
|
|
@@ -62,18 +48,16 @@ async function postWithPath<T>(
|
|
|
62
48
|
}
|
|
63
49
|
|
|
64
50
|
/**
|
|
65
|
-
* Fetch `git status --porcelain` for the
|
|
66
|
-
*
|
|
67
|
-
* from the JupyterLab server's root directory.
|
|
51
|
+
* Fetch `git status --porcelain` for the repo at `repoPath` (empty string
|
|
52
|
+
* resolves from the server's root directory).
|
|
68
53
|
*/
|
|
69
54
|
export async function status(repoPath: string): Promise<IGitStatusResult> {
|
|
70
55
|
return postWithPath<IGitStatusResult>('status', repoPath, {});
|
|
71
56
|
}
|
|
72
57
|
|
|
73
58
|
/**
|
|
74
|
-
* Fetch a file's contents at a
|
|
75
|
-
*
|
|
76
|
-
* of {@link status}'s response).
|
|
59
|
+
* Fetch a file's contents at a git reference; `filename` is relative to the
|
|
60
|
+
* git repository root.
|
|
77
61
|
*/
|
|
78
62
|
export async function content(
|
|
79
63
|
repoPath: string,
|
|
@@ -88,13 +72,7 @@ export async function content(
|
|
|
88
72
|
|
|
89
73
|
/**
|
|
90
74
|
* Expand the porcelain `files` array into one entry per logical change.
|
|
91
|
-
*
|
|
92
|
-
* both staged and modified again in the worktree); callers that just want
|
|
93
|
-
* a flat list of all changes — without any staged-vs-unstaged grouping —
|
|
94
|
-
* can use this helper.
|
|
95
|
-
*
|
|
96
|
-
* Provided as a manual concat rather than `Array.prototype.flatMap` so we
|
|
97
|
-
* don't pin our `tsconfig.lib` to ES2019.
|
|
75
|
+
* Manual concat rather than `flatMap` so `tsconfig.lib` need not be ES2019.
|
|
98
76
|
*/
|
|
99
77
|
export function expandStatusFiles(files: IGitStatusFile[]): IFileChange[] {
|
|
100
78
|
const result: IFileChange[] = [];
|
|
@@ -107,16 +85,12 @@ export function expandStatusFiles(files: IGitStatusFile[]): IFileChange[] {
|
|
|
107
85
|
}
|
|
108
86
|
|
|
109
87
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* per non-empty side, so a "modified-staged-and-then-modified-again" file
|
|
114
|
-
* shows up twice in the panel — once under "Staged Changes" and once under
|
|
115
|
-
* "Changes" — matching the layout the user sees in VS Code.
|
|
88
|
+
* Map one porcelain entry to up to two {@link IFileChange} rows — one per
|
|
89
|
+
* non-empty index/worktree side — so a staged-then-modified-again file
|
|
90
|
+
* appears under both groups, as in VS Code.
|
|
116
91
|
*/
|
|
117
92
|
function porcelainToFileChanges(file: IGitStatusFile): IFileChange[] {
|
|
118
93
|
const result: IFileChange[] = [];
|
|
119
|
-
// Untracked files are reported with `??` and only appear under "Changes".
|
|
120
94
|
if (file.x === '?' && file.y === '?') {
|
|
121
95
|
return [
|
|
122
96
|
{
|
package/src/git/askRequest.ts
CHANGED
|
@@ -9,10 +9,8 @@ import type { IXtralabDiffModel } from './diffWidget';
|
|
|
9
9
|
type DiffSide = 'deletions' | 'additions';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Agent-facing name of a diff content source
|
|
13
|
-
*
|
|
14
|
-
* side name. English on purpose — this ends up in the agent prompt, not in
|
|
15
|
-
* the UI.
|
|
12
|
+
* Agent-facing name of a diff content source. English on purpose — this
|
|
13
|
+
* ends up in the agent prompt, not in the UI.
|
|
16
14
|
*/
|
|
17
15
|
function describeSource(source: unknown, fallback: string): string {
|
|
18
16
|
if (source === Git.Diff.SpecialRef.WORKING) {
|
|
@@ -34,9 +32,6 @@ function sideName(side: DiffSide): string {
|
|
|
34
32
|
return side === 'deletions' ? 'old side' : 'new side';
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
/**
|
|
38
|
-
* Extract lines `startLine`–`endLine` (1-indexed, inclusive) from `text`.
|
|
39
|
-
*/
|
|
40
35
|
function sliceLines(text: string, startLine: number, endLine: number): string {
|
|
41
36
|
return text
|
|
42
37
|
.split('\n')
|
|
@@ -46,14 +41,10 @@ function sliceLines(text: string, startLine: number, endLine: number): string {
|
|
|
46
41
|
|
|
47
42
|
/**
|
|
48
43
|
* Build the ask-agent request for a line range selected in a git diff.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* whose gutter shows new-side numbers — reads from the challenger text. A
|
|
54
|
-
* gutter drag that crosses the two split columns has endpoints in different
|
|
55
|
-
* line-number spaces, so it is described textually instead of as a numeric
|
|
56
|
-
* range.
|
|
44
|
+
* `deletions` ranges index the reference text; other ranges — including
|
|
45
|
+
* sideless unified context rows, whose gutter shows new-side numbers —
|
|
46
|
+
* index the challenger. A drag across the two split columns mixes
|
|
47
|
+
* line-number spaces, so it is described textually instead of numerically.
|
|
57
48
|
*/
|
|
58
49
|
export function buildDiffAskRequest(options: {
|
|
59
50
|
model: IXtralabDiffModel;
|
|
@@ -97,15 +88,10 @@ export function buildDiffAskRequest(options: {
|
|
|
97
88
|
...base,
|
|
98
89
|
startLine,
|
|
99
90
|
endLine,
|
|
100
|
-
// Only new-side lines of a working-tree diff index the file on disk;
|
|
101
|
-
// old-side and historical line numbers must not be used to highlight
|
|
102
|
-
// the working file.
|
|
103
91
|
linesInWorkingFile:
|
|
104
92
|
!isOld && model.challenger.source === Git.Diff.SpecialRef.WORKING,
|
|
105
93
|
text: sliceLines(isOld ? oldText : newText, startLine, endLine),
|
|
106
94
|
location: `the ${sideName(startSide)} (${ref}) of the current git diff`,
|
|
107
|
-
// New-side lines read as the file's current content, so only old-side
|
|
108
|
-
// ranges need a clarifying tag in the popup header.
|
|
109
95
|
...(isOld ? { note: trans.__('old version') } : {})
|
|
110
96
|
},
|
|
111
97
|
anchor
|
package/src/git/commands.ts
CHANGED
|
@@ -28,16 +28,25 @@ export namespace CommandIDs {
|
|
|
28
28
|
* Argument shapes used by {@link CommandIDs.openDiff}.
|
|
29
29
|
*/
|
|
30
30
|
export namespace CommandArguments {
|
|
31
|
+
/**
|
|
32
|
+
* The arguments for the open-diff command.
|
|
33
|
+
*/
|
|
31
34
|
export interface IOpenDiff {
|
|
35
|
+
/**
|
|
36
|
+
* The server-relative path of the repository containing the change.
|
|
37
|
+
*/
|
|
32
38
|
repoPath: string;
|
|
39
|
+
/**
|
|
40
|
+
* The file change to show.
|
|
41
|
+
*/
|
|
33
42
|
change: IFileChange;
|
|
43
|
+
/**
|
|
44
|
+
* Whether to open the diff as a pinned tab instead of the shared preview.
|
|
45
|
+
*/
|
|
34
46
|
pin?: boolean;
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
/**
|
|
39
|
-
* Widget id of the single, reused preview diff tab.
|
|
40
|
-
*/
|
|
41
50
|
export const PREVIEW_DIFF_WIDGET_ID = 'xtralab:diff:preview';
|
|
42
51
|
|
|
43
52
|
/**
|
|
@@ -70,14 +79,23 @@ export class DiffMainAreaWidget extends MainAreaWidget<XtralabDiffWidget> {
|
|
|
70
79
|
this._trans = trans;
|
|
71
80
|
}
|
|
72
81
|
|
|
82
|
+
/**
|
|
83
|
+
* The file change currently displayed.
|
|
84
|
+
*/
|
|
73
85
|
get change(): IFileChange {
|
|
74
86
|
return this._change;
|
|
75
87
|
}
|
|
76
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Whether the widget is pinned rather than the shared preview.
|
|
91
|
+
*/
|
|
77
92
|
get pinned(): boolean {
|
|
78
93
|
return this._pinned;
|
|
79
94
|
}
|
|
80
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Pin the widget; a no-op when already pinned.
|
|
98
|
+
*/
|
|
81
99
|
pin(): void {
|
|
82
100
|
if (this._pinned) {
|
|
83
101
|
return;
|
|
@@ -86,10 +104,16 @@ export class DiffMainAreaWidget extends MainAreaWidget<XtralabDiffWidget> {
|
|
|
86
104
|
this._pinnedChanged.emit(true);
|
|
87
105
|
}
|
|
88
106
|
|
|
107
|
+
/**
|
|
108
|
+
* A signal emitted when the widget becomes pinned.
|
|
109
|
+
*/
|
|
89
110
|
get pinnedChanged(): ISignal<this, boolean> {
|
|
90
111
|
return this._pinnedChanged;
|
|
91
112
|
}
|
|
92
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Display a new file change and update the tab title, caption, and icon.
|
|
116
|
+
*/
|
|
93
117
|
setChange(repoPath: string, change: IFileChange): void {
|
|
94
118
|
this._change = change;
|
|
95
119
|
this.content.setModel(fileChangeToDiffModel(repoPath, change));
|
|
@@ -104,21 +128,48 @@ export class DiffMainAreaWidget extends MainAreaWidget<XtralabDiffWidget> {
|
|
|
104
128
|
private _pinnedChanged = new Signal<this, boolean>(this);
|
|
105
129
|
}
|
|
106
130
|
|
|
131
|
+
/**
|
|
132
|
+
* The options used to create a diff main area widget.
|
|
133
|
+
*/
|
|
107
134
|
interface ICreateDiffWidgetOptions {
|
|
135
|
+
/**
|
|
136
|
+
* The server-relative path of the repository containing the change.
|
|
137
|
+
*/
|
|
108
138
|
repoPath: string;
|
|
139
|
+
/**
|
|
140
|
+
* The file change to display.
|
|
141
|
+
*/
|
|
109
142
|
change: IFileChange;
|
|
143
|
+
/**
|
|
144
|
+
* Theme manager the diff view follows; may be `null`.
|
|
145
|
+
*/
|
|
110
146
|
themeManager: IThemeManager | null;
|
|
147
|
+
/**
|
|
148
|
+
* Contents manager used to write hunk-discard results.
|
|
149
|
+
*/
|
|
111
150
|
contentsManager: Contents.IManager;
|
|
151
|
+
/**
|
|
152
|
+
* Rendermime registry used by notebook diffs; may be `null`.
|
|
153
|
+
*/
|
|
112
154
|
rendermime: IRenderMimeRegistry | null;
|
|
155
|
+
/**
|
|
156
|
+
* Ask-agent popup for prompting an agent about diff lines; may be `null`.
|
|
157
|
+
*/
|
|
113
158
|
askAgent: IAskAgent | null;
|
|
159
|
+
/**
|
|
160
|
+
* Translation bundle for user-facing strings.
|
|
161
|
+
*/
|
|
114
162
|
trans: TranslationBundle;
|
|
163
|
+
/**
|
|
164
|
+
* Whether the widget opens pinned instead of as the shared preview.
|
|
165
|
+
*/
|
|
115
166
|
pinned?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Callback invoked when the widget becomes pinned.
|
|
169
|
+
*/
|
|
116
170
|
onPinned?: (widget: DiffMainAreaWidget) => void;
|
|
117
171
|
}
|
|
118
172
|
|
|
119
|
-
/**
|
|
120
|
-
* Build the launcher's diff tab around the shared diff widget.
|
|
121
|
-
*/
|
|
122
173
|
function createDiffWidget(
|
|
123
174
|
options: ICreateDiffWidgetOptions
|
|
124
175
|
): DiffMainAreaWidget {
|
|
@@ -158,7 +209,6 @@ function createDiffWidget(
|
|
|
158
209
|
widget.toolbar.addItem('pin', pinButton);
|
|
159
210
|
addDiffToolbarItems(widget.toolbar, content);
|
|
160
211
|
|
|
161
|
-
// Keep chrome visible only while there is a relevant toolbar control.
|
|
162
212
|
const syncToolbarVisibility = (): void => {
|
|
163
213
|
if (widget.isDisposed) {
|
|
164
214
|
return;
|
|
@@ -186,7 +236,6 @@ function createDiffWidget(
|
|
|
186
236
|
}
|
|
187
237
|
syncToolbarVisibility();
|
|
188
238
|
};
|
|
189
|
-
// Auto-close once a discard leaves nothing to show.
|
|
190
239
|
const onEmptied = (): void => {
|
|
191
240
|
if (!widget.isDisposed) {
|
|
192
241
|
widget.close();
|
|
@@ -206,8 +255,17 @@ function createDiffWidget(
|
|
|
206
255
|
return widget;
|
|
207
256
|
}
|
|
208
257
|
|
|
258
|
+
/**
|
|
259
|
+
* The options for {@link registerGitCommands}.
|
|
260
|
+
*/
|
|
209
261
|
interface IRegisterGitCommandsOptions {
|
|
262
|
+
/**
|
|
263
|
+
* The JupyterLab application, providing the commands registry and shell.
|
|
264
|
+
*/
|
|
210
265
|
app: JupyterFrontEnd;
|
|
266
|
+
/**
|
|
267
|
+
* Theme manager the diff views follow; may be `null`.
|
|
268
|
+
*/
|
|
211
269
|
themeManager: IThemeManager | null;
|
|
212
270
|
/**
|
|
213
271
|
* Contents manager used to write hunk-discard results.
|
|
@@ -233,12 +291,14 @@ interface IRegisterGitCommandsOptions {
|
|
|
233
291
|
* Look up an already-open diff widget for a file change.
|
|
234
292
|
*/
|
|
235
293
|
findDiff(change: IFileChange, pin?: boolean): DiffMainAreaWidget | undefined;
|
|
294
|
+
/**
|
|
295
|
+
* Callback invoked when a preview diff widget becomes pinned.
|
|
296
|
+
*/
|
|
236
297
|
onPinned(widget: DiffMainAreaWidget): void;
|
|
237
298
|
}
|
|
238
299
|
|
|
239
300
|
/**
|
|
240
|
-
* Register the launcher's git diff command
|
|
241
|
-
* registry.
|
|
301
|
+
* Register the launcher's git diff command.
|
|
242
302
|
*/
|
|
243
303
|
export function registerGitCommands(
|
|
244
304
|
options: IRegisterGitCommandsOptions
|
package/src/git/diffModel.ts
CHANGED
|
@@ -80,14 +80,39 @@ class FileChangeDiffModel implements IXtralabDiffModel {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A signal emitted when the reference or challenger changes; this static
|
|
85
|
+
* model never emits it.
|
|
86
|
+
*/
|
|
83
87
|
readonly changed: ISignal<Git.Diff.IModel, Git.Diff.IModelChange> =
|
|
84
88
|
new Signal<Git.Diff.IModel, Git.Diff.IModelChange>(this);
|
|
89
|
+
/**
|
|
90
|
+
* The reference (old) side of the diff.
|
|
91
|
+
*/
|
|
85
92
|
reference: Git.Diff.IContent;
|
|
93
|
+
/**
|
|
94
|
+
* The challenger (new) side of the diff.
|
|
95
|
+
*/
|
|
86
96
|
challenger: Git.Diff.IContent;
|
|
97
|
+
/**
|
|
98
|
+
* Repo-relative path of the changed file.
|
|
99
|
+
*/
|
|
87
100
|
readonly filename: string;
|
|
101
|
+
/**
|
|
102
|
+
* The rename source path; `undefined` for non-renames.
|
|
103
|
+
*/
|
|
88
104
|
readonly oldFilename: string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Path of the git repository, relative to the server root.
|
|
107
|
+
*/
|
|
89
108
|
readonly repositoryPath: string;
|
|
109
|
+
/**
|
|
110
|
+
* Whether the file content is binary.
|
|
111
|
+
*/
|
|
90
112
|
readonly isBinary: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Whether hunks can be discarded through a working-tree save.
|
|
115
|
+
*/
|
|
91
116
|
readonly canDiscard: boolean;
|
|
92
117
|
}
|
|
93
118
|
|