xtralab 0.1.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.
Files changed (56) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +69 -0
  3. package/lib/fileBrowser/commands.d.ts +62 -0
  4. package/lib/fileBrowser/commands.js +418 -0
  5. package/lib/fileBrowser/contents.d.ts +28 -0
  6. package/lib/fileBrowser/contents.js +48 -0
  7. package/lib/fileBrowser/fileBrowser.d.ts +24 -0
  8. package/lib/fileBrowser/fileBrowser.js +535 -0
  9. package/lib/fileBrowser/icons.d.ts +37 -0
  10. package/lib/fileBrowser/icons.js +153 -0
  11. package/lib/fileBrowser/index.d.ts +7 -0
  12. package/lib/fileBrowser/index.js +38 -0
  13. package/lib/fileBrowser/widget.d.ts +97 -0
  14. package/lib/fileBrowser/widget.js +95 -0
  15. package/lib/git/api.d.ts +39 -0
  16. package/lib/git/api.js +164 -0
  17. package/lib/git/commands.d.ts +69 -0
  18. package/lib/git/commands.js +67 -0
  19. package/lib/git/diffWidget.d.ts +108 -0
  20. package/lib/git/diffWidget.js +624 -0
  21. package/lib/git/icons.d.ts +14 -0
  22. package/lib/git/icons.js +19 -0
  23. package/lib/git/index.d.ts +11 -0
  24. package/lib/git/index.js +74 -0
  25. package/lib/git/notebookDiff.d.ts +176 -0
  26. package/lib/git/notebookDiff.js +805 -0
  27. package/lib/git/panel.d.ts +29 -0
  28. package/lib/git/panel.js +42 -0
  29. package/lib/git/panelComponent.d.ts +26 -0
  30. package/lib/git/panelComponent.js +300 -0
  31. package/lib/git/tokens.d.ts +78 -0
  32. package/lib/git/tokens.js +6 -0
  33. package/lib/index.d.ts +10 -0
  34. package/lib/index.js +14 -0
  35. package/package.json +216 -0
  36. package/schema/plugin.json +67 -0
  37. package/src/fileBrowser/commands.ts +507 -0
  38. package/src/fileBrowser/contents.ts +66 -0
  39. package/src/fileBrowser/fileBrowser.tsx +635 -0
  40. package/src/fileBrowser/icons.ts +172 -0
  41. package/src/fileBrowser/index.ts +56 -0
  42. package/src/fileBrowser/widget.tsx +202 -0
  43. package/src/git/api.ts +207 -0
  44. package/src/git/commands.ts +143 -0
  45. package/src/git/diffWidget.tsx +903 -0
  46. package/src/git/icons.ts +20 -0
  47. package/src/git/index.ts +109 -0
  48. package/src/git/notebookDiff.tsx +1294 -0
  49. package/src/git/panel.tsx +56 -0
  50. package/src/git/panelComponent.tsx +558 -0
  51. package/src/git/tokens.ts +91 -0
  52. package/src/index.ts +18 -0
  53. package/style/base.css +175 -0
  54. package/style/git.css +770 -0
  55. package/style/index.css +2 -0
  56. package/style/index.js +2 -0
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+ import { ReactWidget } from '@jupyterlab/ui-components';
3
+ import { ISignal } from '@lumino/signaling';
4
+ import { IGitPanelHandlers } from './panelComponent';
5
+ /**
6
+ * The id and CSS class used for the git panel widget. The id ends up as the
7
+ * sidebar tab id (so layout restoration can find the widget) and the CSS
8
+ * class lets per-panel styles attach without leaking to other widgets.
9
+ */
10
+ export declare const GIT_PANEL_ID = "xtralab:git-panel";
11
+ export declare const GIT_PANEL_CSS_CLASS = "jp-xtralab-GitPanel";
12
+ /**
13
+ * The lumino host widget for the git changes panel. Owns the `refresh`
14
+ * signal that the React component listens to, and exposes a typed callback
15
+ * surface (`handlers`) the React component uses to react to user actions.
16
+ */
17
+ export declare class GitPanel extends ReactWidget {
18
+ constructor(handlers: IGitPanelHandlers);
19
+ /**
20
+ * Public refresh hook called by the plugin when something happened that
21
+ * invalidates the current view (the user clicked the toolbar refresh, the
22
+ * file browser refreshed, a focused notebook saved, …).
23
+ */
24
+ refresh(): void;
25
+ get refreshRequested(): ISignal<this, void>;
26
+ protected render(): React.ReactElement;
27
+ private _handlers;
28
+ private _refreshRequested;
29
+ }
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { ReactWidget } from '@jupyterlab/ui-components';
3
+ import { Signal } from '@lumino/signaling';
4
+ import { gitIcon } from './icons';
5
+ import { GitPanelComponent } from './panelComponent';
6
+ /**
7
+ * The id and CSS class used for the git panel widget. The id ends up as the
8
+ * sidebar tab id (so layout restoration can find the widget) and the CSS
9
+ * class lets per-panel styles attach without leaking to other widgets.
10
+ */
11
+ export const GIT_PANEL_ID = 'xtralab:git-panel';
12
+ export const GIT_PANEL_CSS_CLASS = 'jp-xtralab-GitPanel';
13
+ /**
14
+ * The lumino host widget for the git changes panel. Owns the `refresh`
15
+ * signal that the React component listens to, and exposes a typed callback
16
+ * surface (`handlers`) the React component uses to react to user actions.
17
+ */
18
+ export class GitPanel extends ReactWidget {
19
+ constructor(handlers) {
20
+ super();
21
+ this._refreshRequested = new Signal(this);
22
+ this.id = GIT_PANEL_ID;
23
+ this.title.icon = gitIcon;
24
+ this.title.caption = 'Git Changes';
25
+ this.addClass(GIT_PANEL_CSS_CLASS);
26
+ this._handlers = handlers;
27
+ }
28
+ /**
29
+ * Public refresh hook called by the plugin when something happened that
30
+ * invalidates the current view (the user clicked the toolbar refresh, the
31
+ * file browser refreshed, a focused notebook saved, …).
32
+ */
33
+ refresh() {
34
+ this._refreshRequested.emit();
35
+ }
36
+ get refreshRequested() {
37
+ return this._refreshRequested;
38
+ }
39
+ render() {
40
+ return (React.createElement(GitPanelComponent, { handlers: this._handlers, refreshSignal: this._refreshRequested }));
41
+ }
42
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { ISignal } from '@lumino/signaling';
3
+ import { IFileChange } from './tokens';
4
+ /**
5
+ * Callbacks the panel needs to delegate to (so the React component stays
6
+ * free of any JupyterLab application coupling). The plugin wires these up
7
+ * with the actual `JupyterFrontEnd` reference.
8
+ */
9
+ export interface IGitPanelHandlers {
10
+ /** Open a diff viewer for the given file in the main area. */
11
+ openDiff(change: IFileChange): void;
12
+ /** Show a confirmation dialog. Returns true when the user accepted. */
13
+ confirm(title: string, body: string, accept: string): Promise<boolean>;
14
+ /** Show an error dialog. */
15
+ showError(title: string, error: Error): Promise<void>;
16
+ }
17
+ /**
18
+ * Top-level React component rendered inside the {@link GitPanel} widget.
19
+ * Owns the polling + refresh wiring around the `/git/status` endpoint and
20
+ * the small bit of UI state that controls section collapse and the
21
+ * in-flight per-file action spinners.
22
+ */
23
+ export declare function GitPanelComponent(props: {
24
+ handlers: IGitPanelHandlers;
25
+ refreshSignal: ISignal<unknown, void>;
26
+ }): React.ReactElement;
@@ -0,0 +1,300 @@
1
+ import * as React from 'react';
2
+ import { add, addAll, checkout, porcelainToFileChanges, reset, resetAll, showTopLevel, status } from './api';
3
+ /**
4
+ * The polling interval for the panel. We refresh the status periodically so
5
+ * out-of-band changes (e.g. the user runs `git add` from a terminal) become
6
+ * visible without requiring a manual refresh.
7
+ */
8
+ const STATUS_POLL_INTERVAL_MS = 5000;
9
+ /**
10
+ * Top-level React component rendered inside the {@link GitPanel} widget.
11
+ * Owns the polling + refresh wiring around the `/git/status` endpoint and
12
+ * the small bit of UI state that controls section collapse and the
13
+ * in-flight per-file action spinners.
14
+ */
15
+ export function GitPanelComponent(props) {
16
+ const { handlers, refreshSignal } = props;
17
+ const [state, setState] = React.useState({
18
+ loading: true,
19
+ result: null,
20
+ error: null
21
+ });
22
+ // The absolute filesystem path of the resolved git top-level. Used purely
23
+ // for display in the panel header.
24
+ const [topLevel, setTopLevel] = React.useState(null);
25
+ // Per-action spinner gating: keyed by `${group}:${path}`, value is the
26
+ // action currently in flight. Lets the row render a disabled state on
27
+ // exactly the file that is being mutated, without locking the whole panel.
28
+ const [pendingActions, setPendingActions] = React.useState({});
29
+ const [stagedCollapsed, setStagedCollapsed] = React.useState(false);
30
+ const [changesCollapsed, setChangesCollapsed] = React.useState(false);
31
+ // The repo path passed to every API call. We use the JupyterLab server's
32
+ // root (the empty string) and let `git` resolve the enclosing repo on the
33
+ // server side. This works as long as the server was started inside a git
34
+ // repo — the common case.
35
+ const repoPath = '';
36
+ const refresh = React.useCallback(async () => {
37
+ var _a;
38
+ try {
39
+ const [topLevelResult, statusResult] = await Promise.all([
40
+ showTopLevel(repoPath),
41
+ status(repoPath)
42
+ ]);
43
+ setTopLevel(topLevelResult);
44
+ if (statusResult.code !== 0) {
45
+ setState({
46
+ loading: false,
47
+ result: null,
48
+ error: (_a = statusResult.message) !== null && _a !== void 0 ? _a : 'Failed to load git status'
49
+ });
50
+ return;
51
+ }
52
+ setState({ loading: false, result: statusResult, error: null });
53
+ }
54
+ catch (err) {
55
+ setState({
56
+ loading: false,
57
+ result: null,
58
+ error: err instanceof Error ? err.message : String(err)
59
+ });
60
+ }
61
+ }, [repoPath]);
62
+ // Initial load + polling. `refresh` is stable for a given `repoPath`, so
63
+ // the polling interval is only re-created when the repo path changes.
64
+ React.useEffect(() => {
65
+ void refresh();
66
+ const interval = window.setInterval(() => void refresh(), STATUS_POLL_INTERVAL_MS);
67
+ return () => {
68
+ window.clearInterval(interval);
69
+ };
70
+ }, [refresh]);
71
+ // External refresh triggers (toolbar button, plugin-level events).
72
+ React.useEffect(() => {
73
+ const handler = () => {
74
+ void refresh();
75
+ };
76
+ refreshSignal.connect(handler);
77
+ return () => {
78
+ refreshSignal.disconnect(handler);
79
+ };
80
+ }, [refresh, refreshSignal]);
81
+ const runAction = React.useCallback(async (change, action, run) => {
82
+ const key = `${change.group}:${change.path}`;
83
+ setPendingActions(prev => ({ ...prev, [key]: action }));
84
+ try {
85
+ await run();
86
+ await refresh();
87
+ }
88
+ catch (err) {
89
+ await handlers.showError('Git operation failed', err instanceof Error ? err : new Error(String(err)));
90
+ }
91
+ finally {
92
+ setPendingActions(prev => {
93
+ const next = { ...prev };
94
+ delete next[key];
95
+ return next;
96
+ });
97
+ }
98
+ }, [handlers, refresh]);
99
+ const onStage = React.useCallback((change) => runAction(change, 'stage', () => add(repoPath, change.path)), [repoPath, runAction]);
100
+ const onUnstage = React.useCallback((change) => runAction(change, 'unstage', () => reset(repoPath, change.path)), [repoPath, runAction]);
101
+ const onDiscard = React.useCallback(async (change) => {
102
+ const verb = change.status === 'untracked' ? 'remove' : 'restore';
103
+ const accepted = await handlers.confirm(verb === 'remove' ? 'Remove file' : 'Discard changes', verb === 'remove'
104
+ ? `Permanently remove ${change.path}? This cannot be undone.`
105
+ : `Discard all changes to ${change.path}? This will revert the file to its last staged version and cannot be undone.`, verb === 'remove' ? 'Remove' : 'Discard');
106
+ if (!accepted) {
107
+ return;
108
+ }
109
+ // The git extension's `checkout` endpoint without a branch reverts the
110
+ // working tree copy of the file to the index. For untracked files we
111
+ // can't checkout, so the user is told the action is unsupported and we
112
+ // bail out — they can delete the file via the file browser instead.
113
+ if (change.status === 'untracked') {
114
+ await handlers.showError('Cannot discard untracked file', new Error('Untracked files cannot be discarded from the git panel — delete them from the file browser instead.'));
115
+ return;
116
+ }
117
+ await runAction(change, 'discard', () => checkout(repoPath, change.path));
118
+ }, [handlers, repoPath, runAction]);
119
+ const onStageAll = React.useCallback(async () => {
120
+ try {
121
+ await addAll(repoPath);
122
+ await refresh();
123
+ }
124
+ catch (err) {
125
+ await handlers.showError('Stage all failed', err instanceof Error ? err : new Error(String(err)));
126
+ }
127
+ }, [handlers, refresh, repoPath]);
128
+ const onUnstageAll = React.useCallback(async () => {
129
+ try {
130
+ await resetAll(repoPath);
131
+ await refresh();
132
+ }
133
+ catch (err) {
134
+ await handlers.showError('Unstage all failed', err instanceof Error ? err : new Error(String(err)));
135
+ }
136
+ }, [handlers, refresh, repoPath]);
137
+ // Categorize the porcelain entries into the two visible groups. Because
138
+ // `porcelainToFileChanges` may emit two changes per file (one staged, one
139
+ // unstaged), the same file can show up in both lists when it has been
140
+ // partially staged.
141
+ const { staged, unstaged } = React.useMemo(() => {
142
+ const stagedAcc = [];
143
+ const unstagedAcc = [];
144
+ if (state.result === null) {
145
+ return { staged: stagedAcc, unstaged: unstagedAcc };
146
+ }
147
+ for (const file of state.result.files) {
148
+ for (const change of porcelainToFileChanges(file)) {
149
+ if (change.group === 'staged') {
150
+ stagedAcc.push(change);
151
+ }
152
+ else {
153
+ unstagedAcc.push(change);
154
+ }
155
+ }
156
+ }
157
+ stagedAcc.sort((a, b) => a.path.localeCompare(b.path));
158
+ unstagedAcc.sort((a, b) => a.path.localeCompare(b.path));
159
+ return { staged: stagedAcc, unstaged: unstagedAcc };
160
+ }, [state.result]);
161
+ return (React.createElement("div", { className: "jp-xtralab-GitPanel-content" },
162
+ React.createElement(PanelHeader, { topLevel: topLevel, result: state.result, loading: state.loading, error: state.error, onRefresh: () => void refresh() }),
163
+ state.error !== null ? (React.createElement("div", { className: "jp-xtralab-GitPanel-error" }, state.error)) : (React.createElement(React.Fragment, null,
164
+ React.createElement(ChangeSection, { label: "Staged Changes", count: staged.length, collapsed: stagedCollapsed, onToggleCollapsed: () => setStagedCollapsed(c => !c), actions: staged.length > 0
165
+ ? [
166
+ {
167
+ label: 'Unstage all changes',
168
+ symbol: '−',
169
+ onClick: onUnstageAll
170
+ }
171
+ ]
172
+ : undefined }, staged.map(change => (React.createElement(ChangeRow, { key: `${change.group}:${change.path}`, change: change, pendingAction: pendingActions[`${change.group}:${change.path}`], onClick: () => handlers.openDiff(change), actions: [
173
+ {
174
+ label: 'Unstage changes',
175
+ symbol: '−',
176
+ onClick: () => void onUnstage(change)
177
+ }
178
+ ] })))),
179
+ React.createElement(ChangeSection, { label: "Changes", count: unstaged.length, collapsed: changesCollapsed, onToggleCollapsed: () => setChangesCollapsed(c => !c), actions: unstaged.length > 0
180
+ ? [
181
+ {
182
+ label: 'Stage all changes',
183
+ symbol: '+',
184
+ onClick: onStageAll
185
+ }
186
+ ]
187
+ : undefined }, unstaged.map(change => (React.createElement(ChangeRow, { key: `${change.group}:${change.path}`, change: change, pendingAction: pendingActions[`${change.group}:${change.path}`], onClick: () => handlers.openDiff(change), actions: [
188
+ {
189
+ label: 'Discard changes',
190
+ symbol: '⟲',
191
+ onClick: () => void onDiscard(change)
192
+ },
193
+ {
194
+ label: 'Stage changes',
195
+ symbol: '+',
196
+ onClick: () => void onStage(change)
197
+ }
198
+ ] })))),
199
+ staged.length === 0 && unstaged.length === 0 && !state.loading ? (React.createElement("div", { className: "jp-xtralab-GitPanel-empty" }, "No changes detected.")) : null))));
200
+ }
201
+ function PanelHeader(props) {
202
+ var _a;
203
+ const { topLevel, result, loading, error, onRefresh } = props;
204
+ const repoName = topLevel !== null
205
+ ? ((_a = topLevel
206
+ .split('/')
207
+ .filter(s => s.length > 0)
208
+ .pop()) !== null && _a !== void 0 ? _a : topLevel)
209
+ : null;
210
+ return (React.createElement("div", { className: "jp-xtralab-GitPanel-header" },
211
+ React.createElement("div", { className: "jp-xtralab-GitPanel-headerInfo" },
212
+ React.createElement("div", { className: "jp-xtralab-GitPanel-title" }, "Source Control"),
213
+ repoName !== null ? (React.createElement("div", { className: "jp-xtralab-GitPanel-repo", title: topLevel !== null && topLevel !== void 0 ? topLevel : '' }, repoName)) : null,
214
+ (result === null || result === void 0 ? void 0 : result.branch) !== undefined && (result === null || result === void 0 ? void 0 : result.branch) !== null ? (React.createElement("div", { className: "jp-xtralab-GitPanel-branch" },
215
+ result.branch,
216
+ result.ahead > 0 ? React.createElement("span", null,
217
+ " \u2191",
218
+ result.ahead) : null,
219
+ result.behind > 0 ? React.createElement("span", null,
220
+ " \u2193",
221
+ result.behind) : null)) : null),
222
+ React.createElement("button", { type: "button", className: "jp-xtralab-GitPanel-iconButton", title: "Refresh", disabled: loading && error === null, onClick: onRefresh }, "\u27F3")));
223
+ }
224
+ function ChangeSection(props) {
225
+ const { label, count, collapsed, onToggleCollapsed, actions, children } = props;
226
+ return (React.createElement("div", { className: "jp-xtralab-GitPanel-section" },
227
+ React.createElement("div", { className: "jp-xtralab-GitPanel-sectionHeader", onClick: onToggleCollapsed },
228
+ React.createElement("span", { className: "jp-xtralab-GitPanel-sectionChevron" }, collapsed ? '▸' : '▾'),
229
+ React.createElement("span", { className: "jp-xtralab-GitPanel-sectionLabel" }, label),
230
+ actions !== undefined ? (React.createElement("span", { className: "jp-xtralab-GitPanel-sectionActions" }, actions.map(action => (React.createElement("button", { key: action.label, type: "button", className: "jp-xtralab-GitPanel-iconButton", title: action.label, onClick: event => {
231
+ event.stopPropagation();
232
+ action.onClick();
233
+ } }, action.symbol))))) : null,
234
+ React.createElement("span", { className: "jp-xtralab-GitPanel-sectionCount" }, count)),
235
+ !collapsed ? (React.createElement("div", { className: "jp-xtralab-GitPanel-sectionBody" }, children)) : null));
236
+ }
237
+ function ChangeRow(props) {
238
+ const { change, pendingAction, onClick, actions } = props;
239
+ const filename = basename(change.path);
240
+ const dirname = dirnameOrEmpty(change.path);
241
+ return (React.createElement("div", { className: "jp-xtralab-GitPanel-row", "data-status": change.status, title: change.from !== undefined
242
+ ? `${change.from} → ${change.path}`
243
+ : change.path, onClick: onClick },
244
+ React.createElement("span", { className: "jp-xtralab-GitPanel-rowLabel" },
245
+ React.createElement("span", { className: "jp-xtralab-GitPanel-rowName" }, filename),
246
+ dirname !== '' ? (React.createElement("span", { className: "jp-xtralab-GitPanel-rowPath" }, dirname)) : null),
247
+ React.createElement("span", { className: "jp-xtralab-GitPanel-rowActions", "data-pending": pendingAction !== undefined }, actions.map(action => (React.createElement("button", { key: action.label, type: "button", className: "jp-xtralab-GitPanel-iconButton", title: action.label, disabled: pendingAction !== undefined, onClick: event => {
248
+ event.stopPropagation();
249
+ action.onClick();
250
+ } }, action.symbol)))),
251
+ React.createElement("span", { className: "jp-xtralab-GitPanel-rowBadge", "data-status": change.status, title: statusTooltip(change.status) }, statusBadge(change.status))));
252
+ }
253
+ function statusBadge(status) {
254
+ switch (status) {
255
+ case 'modified':
256
+ return 'M';
257
+ case 'added':
258
+ return 'A';
259
+ case 'deleted':
260
+ return 'D';
261
+ case 'renamed':
262
+ return 'R';
263
+ case 'untracked':
264
+ return 'U';
265
+ case 'unmerged':
266
+ return '!';
267
+ case 'typechange':
268
+ return 'T';
269
+ default:
270
+ return '?';
271
+ }
272
+ }
273
+ function statusTooltip(status) {
274
+ switch (status) {
275
+ case 'modified':
276
+ return 'Modified';
277
+ case 'added':
278
+ return 'Added';
279
+ case 'deleted':
280
+ return 'Deleted';
281
+ case 'renamed':
282
+ return 'Renamed';
283
+ case 'untracked':
284
+ return 'Untracked';
285
+ case 'unmerged':
286
+ return 'Unmerged (conflict)';
287
+ case 'typechange':
288
+ return 'Type changed';
289
+ default:
290
+ return 'Unknown';
291
+ }
292
+ }
293
+ function basename(path) {
294
+ const idx = path.lastIndexOf('/');
295
+ return idx < 0 ? path : path.slice(idx + 1);
296
+ }
297
+ function dirnameOrEmpty(path) {
298
+ const idx = path.lastIndexOf('/');
299
+ return idx < 0 ? '' : path.slice(0, idx);
300
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Types shared by the git plugin. Mirror the response shapes returned by the
3
+ * `jupyterlab_git` server extension's REST API so the frontend can stay
4
+ * tightly coupled to a single version of those endpoints.
5
+ */
6
+ /**
7
+ * A single entry in the `files` array returned by `POST /git/<path>/status`.
8
+ * `x` and `y` are the porcelain-format index/worktree status codes (see
9
+ * `git status --porcelain`); `to` is the file's current path relative to the
10
+ * git repository root, `from` is the source path for renames (and equal to
11
+ * `to` for any other status).
12
+ */
13
+ export interface IGitStatusFile {
14
+ x: string;
15
+ y: string;
16
+ to: string;
17
+ from: string;
18
+ is_binary: boolean | null;
19
+ }
20
+ /** Response shape of `POST /git/<path>/status`. */
21
+ export interface IGitStatusResult {
22
+ code: number;
23
+ branch: string | null;
24
+ remote: string | null;
25
+ ahead: number;
26
+ behind: number;
27
+ files: IGitStatusFile[];
28
+ state?: number;
29
+ message?: string;
30
+ }
31
+ /**
32
+ * Reference accepted by `POST /git/<path>/content` to identify which version
33
+ * of a file to fetch. `WORKING` is the on-disk copy, `INDEX` is the staged
34
+ * copy, and a `git` value is any commit-ish (`HEAD`, a SHA, …).
35
+ */
36
+ export type GitReference = {
37
+ special: 'WORKING' | 'INDEX' | 'BASE';
38
+ } | {
39
+ git: string;
40
+ };
41
+ /**
42
+ * Response shape of `POST /git/<path>/content`. The server only returns text
43
+ * content here; binary files are reported as binary in the status response,
44
+ * and we surface them in the UI without attempting to render their diff.
45
+ */
46
+ export interface IGitContentResult {
47
+ code: number;
48
+ content: string;
49
+ message?: string;
50
+ }
51
+ /**
52
+ * Where a file's change lives relative to the index.
53
+ *
54
+ * - `staged` → present in the index, may differ from HEAD
55
+ * - `unstaged` → present in the worktree, differs from the index
56
+ *
57
+ * A single file can appear in both groups when the worktree has further
58
+ * changes on top of an already-staged version. The panel models that as two
59
+ * separate entries, one per group.
60
+ */
61
+ export type FileChangeGroup = 'staged' | 'unstaged';
62
+ /**
63
+ * The user-facing status of a file change. Drives the single-letter badge
64
+ * (M/A/D/R/U/?) shown next to each entry in the panel.
65
+ */
66
+ export type FileChangeStatus = 'modified' | 'added' | 'deleted' | 'renamed' | 'untracked' | 'unmerged' | 'typechange' | 'unknown';
67
+ /**
68
+ * One row in the changes panel. `path` is the file's path relative to the
69
+ * git repository root. `from` is non-`undefined` only for renames, in which
70
+ * case it carries the original path.
71
+ */
72
+ export interface IFileChange {
73
+ path: string;
74
+ from?: string;
75
+ group: FileChangeGroup;
76
+ status: FileChangeStatus;
77
+ isBinary: boolean | null;
78
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Types shared by the git plugin. Mirror the response shapes returned by the
3
+ * `jupyterlab_git` server extension's REST API so the frontend can stay
4
+ * tightly coupled to a single version of those endpoints.
5
+ */
6
+ export {};
package/lib/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ /**
3
+ * Every plugin contributed by `xtralab`. The entry point of the
4
+ * labextension is an array because the package bundles several independent
5
+ * enhancements (file browser, git changes panel, …) — JupyterLab activates
6
+ * each plugin individually and only the ones whose required tokens are
7
+ * available end up running.
8
+ */
9
+ declare const plugins: JupyterFrontEndPlugin<unknown>[];
10
+ export default plugins;
package/lib/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import fileBrowserPlugin from './fileBrowser';
2
+ import gitPlugin from './git';
3
+ /**
4
+ * Every plugin contributed by `xtralab`. The entry point of the
5
+ * labextension is an array because the package bundles several independent
6
+ * enhancements (file browser, git changes panel, …) — JupyterLab activates
7
+ * each plugin individually and only the ones whose required tokens are
8
+ * available end up running.
9
+ */
10
+ const plugins = [
11
+ fileBrowserPlugin,
12
+ gitPlugin
13
+ ];
14
+ export default plugins;