xtralab 0.15.0 → 0.15.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/README.md +65 -30
- 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.js +15 -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 +29 -19
- package/lib/fileBrowser/commands.js +83 -97
- package/lib/fileBrowser/contents.d.ts +3 -0
- package/lib/fileBrowser/dragAndDrop.d.ts +17 -4
- package/lib/fileBrowser/dragAndDrop.js +2 -7
- package/lib/fileBrowser/fileBrowser.d.ts +19 -9
- package/lib/fileBrowser/fileBrowser.js +70 -222
- package/lib/fileBrowser/gitStatus.d.ts +16 -10
- package/lib/fileBrowser/gitStatus.js +31 -30
- 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 +2 -4
- package/lib/fileBrowser/widget.d.ts +141 -48
- package/lib/fileBrowser/widget.js +102 -4
- 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 +45 -5
- package/lib/git/commands.js +20 -13
- package/lib/git/diffModel.js +4 -0
- package/lib/git/diffPreferences.d.ts +90 -0
- package/lib/git/diffPreferences.js +107 -0
- package/lib/git/diffProvider.js +10 -2
- package/lib/git/diffSurface.d.ts +64 -63
- package/lib/git/diffSurface.js +72 -213
- package/lib/git/diffTheme.d.ts +7 -0
- package/lib/git/diffTheme.js +23 -0
- package/lib/git/diffWidget.d.ts +70 -14
- package/lib/git/diffWidget.js +100 -94
- package/lib/git/imageDiff.d.ts +14 -6
- package/lib/git/imageDiff.js +19 -75
- package/lib/git/index.d.ts +0 -3
- package/lib/git/index.js +44 -10
- package/lib/git/notebookDiff.d.ts +110 -33
- package/lib/git/notebookDiff.js +55 -197
- 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 +0 -9
- package/lib/launcher/agents.d.ts +55 -51
- package/lib/launcher/agents.js +15 -57
- 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 +5 -39
- 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/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 -7
- package/lib/sidebar/index.js +5 -12
- 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 -35
- package/lib/terminals/index.js +12 -101
- 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 +43 -13
- package/lib/terminals/widget.js +33 -18
- 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 +5 -3
- package/schema/git-diff-preferences.json +42 -0
- 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 +15 -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 +119 -96
- package/src/fileBrowser/contents.ts +3 -0
- package/src/fileBrowser/dragAndDrop.ts +17 -7
- package/src/fileBrowser/fileBrowser.tsx +86 -230
- package/src/fileBrowser/gitStatus.ts +36 -33
- package/src/fileBrowser/gitignore.ts +4 -25
- package/src/fileBrowser/icons.ts +25 -80
- package/src/fileBrowser/index.ts +2 -4
- package/src/fileBrowser/widget.tsx +171 -50
- 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 +83 -11
- package/src/git/diffModel.ts +25 -0
- package/src/git/diffPreferences.ts +192 -0
- package/src/git/diffProvider.tsx +11 -2
- package/src/git/diffSurface.tsx +165 -286
- package/src/git/diffTheme.ts +24 -0
- package/src/git/diffWidget.tsx +194 -134
- package/src/git/imageDiff.tsx +56 -84
- package/src/git/index.ts +54 -10
- package/src/git/notebookDiff.tsx +214 -240
- package/src/git/tokens.ts +73 -31
- package/src/highlight/index.ts +10 -41
- package/src/index.ts +0 -9
- package/src/launcher/agents.ts +64 -95
- 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 +5 -39
- package/src/launcher/index.ts +12 -55
- package/src/launcher/invocation.ts +7 -22
- package/src/launcher/registry.ts +9 -7
- 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 +20 -12
- 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 +12 -101
- package/src/terminals/model.ts +130 -246
- package/src/terminals/tokens.ts +11 -22
- package/src/terminals/widget.tsx +48 -31
- 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 +9 -45
- package/style/chrome.css +108 -308
- package/style/commandBar.css +4 -20
- package/style/customPanel.css +1 -4
- package/style/git.css +26 -186
- package/style/highlight.css +1 -3
- 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 +6 -53
- package/style/topBar.css +2 -22
- package/style/walkthrough.css +0 -8
package/lib/git/diffModel.js
CHANGED
|
@@ -40,6 +40,10 @@ function referenceSource(ref) {
|
|
|
40
40
|
class FileChangeDiffModel {
|
|
41
41
|
constructor(repoPath, change) {
|
|
42
42
|
var _a;
|
|
43
|
+
/**
|
|
44
|
+
* A signal emitted when the reference or challenger changes; this static
|
|
45
|
+
* model never emits it.
|
|
46
|
+
*/
|
|
43
47
|
this.changed = new Signal(this);
|
|
44
48
|
const { oldRef, newRef } = resolveReferences(change);
|
|
45
49
|
// Renames compare the new path against the old path's previous content.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
2
|
+
import type { IStateDB } from '@jupyterlab/statedb';
|
|
3
|
+
import { Token } from '@lumino/coreutils';
|
|
4
|
+
import { ISignal } from '@lumino/signaling';
|
|
5
|
+
export type DiffStyle = 'split' | 'unified';
|
|
6
|
+
export type DiffStyleControlMode = 'buttons' | 'toggle';
|
|
7
|
+
export type NotebookDiffViewMode = 'notebook' | 'json';
|
|
8
|
+
export type ImageDiffViewMode = '2-up' | 'swipe' | 'onion';
|
|
9
|
+
export declare const MIN_SPLIT_RATIO = 0.1;
|
|
10
|
+
export declare const MAX_SPLIT_RATIO = 0.9;
|
|
11
|
+
export declare const DEFAULT_SPLIT_RATIO = 0.5;
|
|
12
|
+
/**
|
|
13
|
+
* Display choices shared by every diff view. The toggles live in the
|
|
14
|
+
* plugin settings; the split width lives in the state database.
|
|
15
|
+
*/
|
|
16
|
+
export interface IDiffPreferences {
|
|
17
|
+
/**
|
|
18
|
+
* The current values; a new object after each change.
|
|
19
|
+
*/
|
|
20
|
+
readonly values: IDiffPreferences.IValues;
|
|
21
|
+
/**
|
|
22
|
+
* A signal emitted when any value changes.
|
|
23
|
+
*/
|
|
24
|
+
readonly changed: ISignal<IDiffPreferences, void>;
|
|
25
|
+
/**
|
|
26
|
+
* Change some values and persist them.
|
|
27
|
+
*/
|
|
28
|
+
update(values: Partial<IDiffPreferences.IValues>): void;
|
|
29
|
+
}
|
|
30
|
+
export declare namespace IDiffPreferences {
|
|
31
|
+
/**
|
|
32
|
+
* The diff display values.
|
|
33
|
+
*/
|
|
34
|
+
interface IValues {
|
|
35
|
+
/**
|
|
36
|
+
* Split or unified layout for textual file diffs.
|
|
37
|
+
*/
|
|
38
|
+
diffStyle: DiffStyle;
|
|
39
|
+
/**
|
|
40
|
+
* Two toolbar buttons for the layout, or one button that toggles it.
|
|
41
|
+
*/
|
|
42
|
+
diffStyleControl: DiffStyleControlMode;
|
|
43
|
+
/**
|
|
44
|
+
* Whether long lines wrap instead of scrolling horizontally.
|
|
45
|
+
*/
|
|
46
|
+
lineWrap: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Rendered or JSON view for notebook diffs.
|
|
49
|
+
*/
|
|
50
|
+
notebookViewMode: NotebookDiffViewMode;
|
|
51
|
+
/**
|
|
52
|
+
* Comparison mode for image diffs.
|
|
53
|
+
*/
|
|
54
|
+
imageViewMode: ImageDiffViewMode;
|
|
55
|
+
/**
|
|
56
|
+
* Width of the left pane in split view, as a fraction of the diff width.
|
|
57
|
+
*/
|
|
58
|
+
splitRatio: number;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export declare const IDiffPreferences: Token<IDiffPreferences>;
|
|
62
|
+
/**
|
|
63
|
+
* {@link IDiffPreferences} backed by the settings registry and the state
|
|
64
|
+
* database. Without them it keeps the values in memory only.
|
|
65
|
+
*/
|
|
66
|
+
export declare class DiffPreferences implements IDiffPreferences {
|
|
67
|
+
get values(): IDiffPreferences.IValues;
|
|
68
|
+
get changed(): ISignal<this, void>;
|
|
69
|
+
update(values: Partial<IDiffPreferences.IValues>): void;
|
|
70
|
+
/**
|
|
71
|
+
* Read the toggles from the plugin settings and follow their changes.
|
|
72
|
+
*/
|
|
73
|
+
connectSettings(settings: ISettingRegistry.ISettings): void;
|
|
74
|
+
/**
|
|
75
|
+
* Restore the split width from the state database and save it there.
|
|
76
|
+
*/
|
|
77
|
+
connectState(state: IStateDB): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Merge values without persisting them; return whether one changed.
|
|
80
|
+
*/
|
|
81
|
+
private _apply;
|
|
82
|
+
private _values;
|
|
83
|
+
private _changed;
|
|
84
|
+
private _settings;
|
|
85
|
+
private _state;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Re-render on every preference change and return the current values.
|
|
89
|
+
*/
|
|
90
|
+
export declare function useDiffPreferences(preferences: IDiffPreferences): IDiffPreferences.IValues;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Token } from '@lumino/coreutils';
|
|
3
|
+
import { Signal } from '@lumino/signaling';
|
|
4
|
+
export const MIN_SPLIT_RATIO = 0.1;
|
|
5
|
+
export const MAX_SPLIT_RATIO = 0.9;
|
|
6
|
+
export const DEFAULT_SPLIT_RATIO = 0.5;
|
|
7
|
+
const SPLIT_RATIO_STATE_KEY = 'xtralab:git-diff:split-ratio';
|
|
8
|
+
export const IDiffPreferences = new Token('xtralab:IDiffPreferences', 'Display choices shared by the git diff views.');
|
|
9
|
+
const SETTING_KEYS = [
|
|
10
|
+
'diffStyle',
|
|
11
|
+
'diffStyleControl',
|
|
12
|
+
'lineWrap',
|
|
13
|
+
'notebookViewMode',
|
|
14
|
+
'imageViewMode'
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* {@link IDiffPreferences} backed by the settings registry and the state
|
|
18
|
+
* database. Without them it keeps the values in memory only.
|
|
19
|
+
*/
|
|
20
|
+
export class DiffPreferences {
|
|
21
|
+
constructor() {
|
|
22
|
+
this._values = {
|
|
23
|
+
diffStyle: 'split',
|
|
24
|
+
diffStyleControl: 'buttons',
|
|
25
|
+
lineWrap: false,
|
|
26
|
+
notebookViewMode: 'notebook',
|
|
27
|
+
imageViewMode: '2-up',
|
|
28
|
+
splitRatio: DEFAULT_SPLIT_RATIO
|
|
29
|
+
};
|
|
30
|
+
this._changed = new Signal(this);
|
|
31
|
+
this._settings = null;
|
|
32
|
+
this._state = null;
|
|
33
|
+
}
|
|
34
|
+
get values() {
|
|
35
|
+
return this._values;
|
|
36
|
+
}
|
|
37
|
+
get changed() {
|
|
38
|
+
return this._changed;
|
|
39
|
+
}
|
|
40
|
+
update(values) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if (!this._apply(values)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const key of SETTING_KEYS) {
|
|
46
|
+
if (key in values) {
|
|
47
|
+
(_a = this._settings) === null || _a === void 0 ? void 0 : _a.set(key, this._values[key]).catch(reason => {
|
|
48
|
+
console.error(`xtralab: failed to save the diff ${key}`, reason);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if ('splitRatio' in values) {
|
|
53
|
+
(_b = this._state) === null || _b === void 0 ? void 0 : _b.save(SPLIT_RATIO_STATE_KEY, this._values.splitRatio).catch(reason => {
|
|
54
|
+
console.error('xtralab: failed to save the diff split', reason);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read the toggles from the plugin settings and follow their changes.
|
|
60
|
+
*/
|
|
61
|
+
connectSettings(settings) {
|
|
62
|
+
this._settings = settings;
|
|
63
|
+
const sync = () => {
|
|
64
|
+
this._apply(settings.composite);
|
|
65
|
+
};
|
|
66
|
+
sync();
|
|
67
|
+
settings.changed.connect(sync);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Restore the split width from the state database and save it there.
|
|
71
|
+
*/
|
|
72
|
+
async connectState(state) {
|
|
73
|
+
this._state = state;
|
|
74
|
+
const ratio = await state.fetch(SPLIT_RATIO_STATE_KEY);
|
|
75
|
+
if (typeof ratio === 'number' &&
|
|
76
|
+
ratio >= MIN_SPLIT_RATIO &&
|
|
77
|
+
ratio <= MAX_SPLIT_RATIO) {
|
|
78
|
+
this._apply({ splitRatio: ratio });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Merge values without persisting them; return whether one changed.
|
|
83
|
+
*/
|
|
84
|
+
_apply(values) {
|
|
85
|
+
const next = { ...this._values, ...values };
|
|
86
|
+
const keys = Object.keys(next);
|
|
87
|
+
if (keys.every(key => next[key] === this._values[key])) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
this._values = next;
|
|
91
|
+
this._changed.emit();
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Re-render on every preference change and return the current values.
|
|
97
|
+
*/
|
|
98
|
+
export function useDiffPreferences(preferences) {
|
|
99
|
+
const subscribe = React.useCallback((onChange) => {
|
|
100
|
+
const slot = () => onChange();
|
|
101
|
+
preferences.changed.connect(slot);
|
|
102
|
+
return () => {
|
|
103
|
+
preferences.changed.disconnect(slot);
|
|
104
|
+
};
|
|
105
|
+
}, [preferences]);
|
|
106
|
+
return React.useSyncExternalStore(subscribe, () => preferences.values);
|
|
107
|
+
}
|
package/lib/git/diffProvider.js
CHANGED
|
@@ -3,6 +3,7 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
|
3
3
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
4
4
|
import { IGitExtension } from '@jupyterlab/git';
|
|
5
5
|
import { IAskAgent } from '../askAgent/tokens';
|
|
6
|
+
import { DiffPreferences, IDiffPreferences } from './diffPreferences';
|
|
6
7
|
import { XtralabDiffWidget, addDiffToolbarItems } from './diffWidget';
|
|
7
8
|
import { IMAGE_DIFF_EXTENSIONS } from './imageDiff';
|
|
8
9
|
/**
|
|
@@ -22,14 +23,21 @@ const diffProviderPlugin = {
|
|
|
22
23
|
description: "Replaces jupyterlab-git's notebook, text and image diff plugins with xtralab's renderer.",
|
|
23
24
|
autoStart: true,
|
|
24
25
|
requires: [IGitExtension],
|
|
25
|
-
optional: [
|
|
26
|
-
|
|
26
|
+
optional: [
|
|
27
|
+
IRenderMimeRegistry,
|
|
28
|
+
IThemeManager,
|
|
29
|
+
ITranslator,
|
|
30
|
+
IAskAgent,
|
|
31
|
+
IDiffPreferences
|
|
32
|
+
],
|
|
33
|
+
activate: (app, gitExtension, rendermime, themeManager, translator, askAgent, preferences) => {
|
|
27
34
|
const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
|
|
28
35
|
const factory = makeXtralabDiffFactory({
|
|
29
36
|
contentsManager: app.serviceManager.contents,
|
|
30
37
|
rendermime,
|
|
31
38
|
themeManager,
|
|
32
39
|
askAgent,
|
|
40
|
+
preferences: preferences !== null && preferences !== void 0 ? preferences : new DiffPreferences(),
|
|
33
41
|
trans
|
|
34
42
|
});
|
|
35
43
|
// Use one shared factory; the surface detects notebooks/images by filename.
|
package/lib/git/diffSurface.d.ts
CHANGED
|
@@ -3,33 +3,11 @@ import { IThemeManager } from '@jupyterlab/apputils';
|
|
|
3
3
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
4
4
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
5
5
|
import { type SelectedLineRange } from '@pierre/diffs';
|
|
6
|
-
|
|
7
|
-
* The CSS class added to the diff main-area widget. The selectors that
|
|
8
|
-
* style the embedded `@pierre/diffs` viewer hang off this class.
|
|
9
|
-
*/
|
|
6
|
+
import { type DiffStyle, type DiffStyleControlMode, type ImageDiffViewMode, type NotebookDiffViewMode } from './diffPreferences';
|
|
10
7
|
export declare const DIFF_WIDGET_CSS_CLASS = "jp-xtralab-DiffWidget";
|
|
11
8
|
/**
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
* is the single-column inline view (what diffs.com calls "stacked").
|
|
15
|
-
*/
|
|
16
|
-
export type DiffStyle = 'split' | 'unified';
|
|
17
|
-
export declare function readStoredDiffStyle(): DiffStyle;
|
|
18
|
-
export declare function writeStoredDiffStyle(style: DiffStyle): void;
|
|
19
|
-
/**
|
|
20
|
-
* View modes available for `.ipynb` diffs. `notebook` is the cell-by-cell
|
|
21
|
-
* rendered view; `json` is the raw nbformat JSON file diff, for inspecting
|
|
22
|
-
* exactly which bytes changed.
|
|
23
|
-
*/
|
|
24
|
-
export type NotebookDiffViewMode = 'notebook' | 'json';
|
|
25
|
-
export declare function readStoredNotebookViewMode(): NotebookDiffViewMode;
|
|
26
|
-
export declare function writeStoredNotebookViewMode(mode: NotebookDiffViewMode): void;
|
|
27
|
-
/**
|
|
28
|
-
* Decide whether the active JupyterLab theme is a dark theme. Prefers the
|
|
29
|
-
* `IThemeManager` token when available, and falls back to sniffing the
|
|
30
|
-
* `data-jp-theme-light` attribute that JupyterLab sets on `<body>` so the
|
|
31
|
-
* component still works in stripped-down hosts where the token isn't
|
|
32
|
-
* provided (lite, certain notebook configurations, …).
|
|
9
|
+
* Dark-theme check via `IThemeManager`, falling back to the
|
|
10
|
+
* `data-jp-theme-light` body attribute for hosts without the token.
|
|
33
11
|
*/
|
|
34
12
|
export declare function isDarkTheme(themeManager: IThemeManager | null): boolean;
|
|
35
13
|
/**
|
|
@@ -37,18 +15,26 @@ export declare function isDarkTheme(themeManager: IThemeManager | null): boolean
|
|
|
37
15
|
*/
|
|
38
16
|
export declare function isPierreTheme(themeManager: IThemeManager | null): boolean;
|
|
39
17
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* reverts that hunk and hands the rebuilt full-file text back to the host
|
|
43
|
-
* via {@link IHunkDiscard.save}. The host owns the actual write (it knows
|
|
44
|
-
* the on-disk path) and triggers any follow-up refresh in
|
|
45
|
-
* {@link IHunkDiscard.onAfterSave}.
|
|
18
|
+
* Per-hunk discard wiring: discarding rebuilds the full file text and the
|
|
19
|
+
* host owns the write via `save`, then refreshes in `onAfterSave`.
|
|
46
20
|
*/
|
|
47
21
|
interface IHunkDiscard {
|
|
22
|
+
/**
|
|
23
|
+
* Whether hunk discarding is available.
|
|
24
|
+
*/
|
|
48
25
|
enabled: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Persist the full post-discard file text.
|
|
28
|
+
*/
|
|
49
29
|
save: (fullText: string) => Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Called after a successful save so the host can refresh the diff.
|
|
32
|
+
*/
|
|
50
33
|
onAfterSave: () => void;
|
|
51
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The props for the {@link DiffSurface} component.
|
|
37
|
+
*/
|
|
52
38
|
interface IDiffSurfaceProps {
|
|
53
39
|
/**
|
|
54
40
|
* Whether the host is still resolving the file contents.
|
|
@@ -71,13 +57,11 @@ interface IDiffSurfaceProps {
|
|
|
71
57
|
*/
|
|
72
58
|
newText: string;
|
|
73
59
|
/**
|
|
74
|
-
* New-side path
|
|
75
|
-
* name on the additions side.
|
|
60
|
+
* New-side path; drives notebook detection and the highlighting filename.
|
|
76
61
|
*/
|
|
77
62
|
newName: string;
|
|
78
63
|
/**
|
|
79
|
-
* Old-side path
|
|
80
|
-
* to {@link newName} when the host does not track a previous path.
|
|
64
|
+
* Old-side path; differs from {@link newName} only for renames.
|
|
81
65
|
*/
|
|
82
66
|
oldName?: string;
|
|
83
67
|
/**
|
|
@@ -89,35 +73,48 @@ interface IDiffSurfaceProps {
|
|
|
89
73
|
*/
|
|
90
74
|
pierreTheme: boolean;
|
|
91
75
|
/**
|
|
92
|
-
*
|
|
93
|
-
* markdown cells. May be `null` in stripped-down hosts; the notebook
|
|
94
|
-
* diff falls back to a textual representation in that case.
|
|
76
|
+
* Used by the notebook view; `null` in stripped-down hosts, which forces a textual fallback.
|
|
95
77
|
*/
|
|
96
78
|
rendermime: IRenderMimeRegistry | null;
|
|
97
79
|
/**
|
|
98
|
-
*
|
|
80
|
+
* Rendered-vs-JSON choice for notebook diffs (host-controlled).
|
|
99
81
|
*/
|
|
100
82
|
notebookViewMode: NotebookDiffViewMode;
|
|
101
83
|
/**
|
|
102
|
-
* Split vs unified layout for the textual
|
|
84
|
+
* Split vs unified layout for the textual file diff (host-controlled).
|
|
103
85
|
*/
|
|
104
86
|
diffStyle: DiffStyle;
|
|
105
87
|
/**
|
|
106
|
-
*
|
|
107
|
-
|
|
88
|
+
* Whether long lines wrap instead of scrolling horizontally (host-controlled).
|
|
89
|
+
*/
|
|
90
|
+
lineWrap: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Left pane width in split view, as a fraction of the diff width (host-controlled).
|
|
93
|
+
*/
|
|
94
|
+
splitRatio: number;
|
|
95
|
+
/**
|
|
96
|
+
* Called when the user finishes resizing the split panes.
|
|
97
|
+
*/
|
|
98
|
+
onSplitRatioChange: (ratio: number) => void;
|
|
99
|
+
/**
|
|
100
|
+
* 2-up, swipe or onion view for image diffs (host-controlled).
|
|
101
|
+
*/
|
|
102
|
+
imageViewMode: ImageDiffViewMode;
|
|
103
|
+
/**
|
|
104
|
+
* Called when the user picks another image view mode.
|
|
105
|
+
*/
|
|
106
|
+
onImageViewModeChange: (mode: ImageDiffViewMode) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Fires when rendered-notebook availability changes so the host can toggle its Notebook/JSON control.
|
|
108
109
|
*/
|
|
109
110
|
onNotebookAvailabilityChange?: (available: boolean) => void;
|
|
110
111
|
/**
|
|
111
|
-
*
|
|
112
|
-
* unified choice affects) becomes the active view, so the host can
|
|
113
|
-
* show/hide its Split/Unified toolbar toggle. False for image, binary,
|
|
114
|
-
* rendered-notebook, loading and error states.
|
|
112
|
+
* Fires when the textual file diff becomes (in)active — the only view the split/unified choice affects.
|
|
115
113
|
*/
|
|
116
114
|
onFileDiffActiveChange?: (active: boolean) => void;
|
|
117
115
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* post-discard behaviors such as auto-closing an emptied diff.
|
|
116
|
+
* Fires after each diff computation with the hunk count (`null` when no
|
|
117
|
+
* textual diff); hosts use it to auto-close emptied diffs.
|
|
121
118
|
*/
|
|
122
119
|
onMetadataChange?: (info: {
|
|
123
120
|
hunkCount: number | null;
|
|
@@ -127,11 +124,8 @@ interface IDiffSurfaceProps {
|
|
|
127
124
|
*/
|
|
128
125
|
hunkDiscard?: IHunkDiscard;
|
|
129
126
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* button appears on the hovered/selected lines. Clicking that button
|
|
133
|
-
* invokes this callback with the selected range and the button's viewport
|
|
134
|
-
* rectangle (to anchor a popup to), `null` when it cannot be measured.
|
|
127
|
+
* Enables line selection and the gutter "+" button; called with the
|
|
128
|
+
* selected range and the button's viewport rect (`null` when unmeasurable).
|
|
135
129
|
*/
|
|
136
130
|
onLineAsk?: (range: SelectedLineRange, anchor: DOMRect | null) => void;
|
|
137
131
|
/**
|
|
@@ -144,10 +138,8 @@ interface IDiffSurfaceProps {
|
|
|
144
138
|
*/
|
|
145
139
|
export declare function DiffSurface(props: IDiffSurfaceProps): React.ReactElement;
|
|
146
140
|
/**
|
|
147
|
-
* Segmented Notebook/JSON selector. Hosts mount
|
|
148
|
-
*
|
|
149
|
-
* `jupyterlab-git`-provided diff toolbar) and drive its value/visibility
|
|
150
|
-
* from the same state they pass to {@link DiffSurface}.
|
|
141
|
+
* Segmented Notebook/JSON selector. Hosts mount it into their own toolbar
|
|
142
|
+
* and drive value/visibility from the state they pass to {@link DiffSurface}.
|
|
151
143
|
*/
|
|
152
144
|
export declare function NotebookViewModeControl(props: {
|
|
153
145
|
mode: NotebookDiffViewMode;
|
|
@@ -156,16 +148,25 @@ export declare function NotebookViewModeControl(props: {
|
|
|
156
148
|
trans: TranslationBundle;
|
|
157
149
|
}): React.ReactElement;
|
|
158
150
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* textual/code file diff is the active view, so `available` mirrors the
|
|
163
|
-
* surface's `onFileDiffActiveChange`.
|
|
151
|
+
* Split/Unified selector: two segmented buttons, or with `control: 'toggle'`
|
|
152
|
+
* one button that shows the layout it switches to.
|
|
153
|
+
* `available` mirrors the surface's `onFileDiffActiveChange`.
|
|
164
154
|
*/
|
|
165
155
|
export declare function DiffStyleControl(props: {
|
|
166
156
|
diffStyle: DiffStyle;
|
|
157
|
+
control: DiffStyleControlMode;
|
|
167
158
|
available: boolean;
|
|
168
159
|
onChange: (style: DiffStyle) => void;
|
|
169
160
|
trans: TranslationBundle;
|
|
170
161
|
}): React.ReactElement;
|
|
162
|
+
/**
|
|
163
|
+
* Line-wrap toggle styled as a one-button segmented control.
|
|
164
|
+
* `available` mirrors the surface's `onFileDiffActiveChange`.
|
|
165
|
+
*/
|
|
166
|
+
export declare function LineWrapControl(props: {
|
|
167
|
+
lineWrap: boolean;
|
|
168
|
+
available: boolean;
|
|
169
|
+
onChange: (wrap: boolean) => void;
|
|
170
|
+
trans: TranslationBundle;
|
|
171
|
+
}): React.ReactElement;
|
|
171
172
|
export {};
|