xtralab 0.8.0 → 0.10.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 +30 -6
- package/lib/fileBrowser/commands.d.ts +7 -0
- package/lib/fileBrowser/commands.js +74 -1
- package/lib/fileBrowser/fileBrowser.js +4 -1
- package/lib/fileBrowser/icons.d.ts +5 -9
- package/lib/fileBrowser/icons.js +97 -13
- package/lib/fileBrowser/index.js +5 -3
- package/lib/fileTypeIcons/index.d.ts +6 -0
- package/lib/fileTypeIcons/index.js +144 -0
- package/lib/git/commands.d.ts +34 -33
- package/lib/git/commands.js +132 -10
- package/lib/git/diffModel.d.ts +14 -0
- package/lib/git/diffModel.js +75 -0
- package/lib/git/diffProvider.d.ts +0 -5
- package/lib/git/diffProvider.js +6 -376
- package/lib/git/diffSurface.d.ts +36 -26
- package/lib/git/diffSurface.js +13 -20
- package/lib/git/diffTheme.d.ts +9 -0
- package/lib/git/diffTheme.js +31 -0
- package/lib/git/diffWidget.d.ts +54 -91
- package/lib/git/diffWidget.js +184 -361
- package/lib/git/index.d.ts +1 -6
- package/lib/git/index.js +7 -23
- package/lib/git/notebookDiff.d.ts +6 -1
- package/lib/git/notebookDiff.js +4 -3
- package/lib/index.js +4 -0
- package/lib/terminalNotifications/index.d.ts +15 -0
- package/lib/terminalNotifications/index.js +213 -0
- package/lib/terminals/model.d.ts +1 -1
- package/lib/terminals/model.js +1 -1
- package/lib/terminals/widget.d.ts +1 -1
- package/lib/terminals/widget.js +1 -1
- package/package.json +3 -3
- package/schema/plugin.json +6 -0
- package/schema/terminal-notifications.json +21 -0
- package/src/fileBrowser/commands.ts +91 -2
- package/src/fileBrowser/fileBrowser.tsx +4 -1
- package/src/fileBrowser/icons.ts +103 -13
- package/src/fileBrowser/index.ts +9 -3
- package/src/fileTypeIcons/index.ts +174 -0
- package/src/git/commands.ts +177 -43
- package/src/git/diffModel.ts +102 -0
- package/src/git/diffProvider.tsx +8 -540
- package/src/git/diffSurface.tsx +44 -28
- package/src/git/diffTheme.ts +40 -0
- package/src/git/diffWidget.tsx +256 -448
- package/src/git/index.ts +14 -28
- package/src/git/notebookDiff.tsx +10 -3
- package/src/index.ts +4 -0
- package/src/terminalNotifications/index.ts +295 -0
- package/src/terminals/model.ts +1 -1
- package/src/terminals/widget.tsx +1 -1
- package/style/git.css +12 -9
- package/style/index.css +1 -0
- package/style/index.js +1 -0
- package/style/launcher.css +46 -18
- package/style/sidebar.css +14 -0
package/src/git/diffSurface.tsx
CHANGED
|
@@ -18,22 +18,7 @@ import {
|
|
|
18
18
|
NotebookDiffView,
|
|
19
19
|
type INotebookDiffResult
|
|
20
20
|
} from './notebookDiff';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Shared diff rendering surface used by both diff hosts in this extension:
|
|
24
|
-
*
|
|
25
|
-
* - the launcher dashboard's own `xtralab:git:open-diff` command
|
|
26
|
-
* (via {@link DiffContentWidget} in `diffWidget.tsx`), and
|
|
27
|
-
* - the `jupyterlab-git` diff providers registered into the upstream git
|
|
28
|
-
* panel (via `XtralabDiffWidget` in `diffProvider.tsx`).
|
|
29
|
-
*
|
|
30
|
-
* The surface is deliberately content-source agnostic: callers resolve the
|
|
31
|
-
* old/new text however they like (xtralab's REST helper, or a
|
|
32
|
-
* `Git.Diff.IModel`'s `content()` getters) and hand the resolved strings in.
|
|
33
|
-
* Everything visual — the `@pierre/diffs` split view, the cell-by-cell
|
|
34
|
-
* notebook view, the draggable column resizer, and the per-hunk discard
|
|
35
|
-
* affordance — lives here so the two hosts stay pixel-identical.
|
|
36
|
-
*/
|
|
21
|
+
import { resolveDiffTheme } from './diffTheme';
|
|
37
22
|
|
|
38
23
|
/**
|
|
39
24
|
* The CSS class added to the diff main-area widget. The selectors that
|
|
@@ -196,6 +181,14 @@ export function isDarkTheme(themeManager: IThemeManager | null): boolean {
|
|
|
196
181
|
return document.body.dataset.jpThemeLight === 'false';
|
|
197
182
|
}
|
|
198
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Whether the active JupyterLab theme should keep Pierre diff highlighting.
|
|
186
|
+
*/
|
|
187
|
+
export function isPierreTheme(themeManager: IThemeManager | null): boolean {
|
|
188
|
+
const theme = themeManager?.theme ?? null;
|
|
189
|
+
return theme !== null && theme.toLowerCase().includes('pierre');
|
|
190
|
+
}
|
|
191
|
+
|
|
199
192
|
/**
|
|
200
193
|
* Optional per-hunk discard wiring. When supplied and `enabled`, each hunk
|
|
201
194
|
* in a plain-text/code diff gets an inline "discard" button; clicking it
|
|
@@ -211,15 +204,25 @@ export interface IHunkDiscard {
|
|
|
211
204
|
}
|
|
212
205
|
|
|
213
206
|
export interface IDiffSurfaceProps {
|
|
214
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* Whether the host is still resolving the file contents.
|
|
209
|
+
*/
|
|
215
210
|
loading: boolean;
|
|
216
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* Fatal error message to show instead of a diff, or `null`.
|
|
213
|
+
*/
|
|
217
214
|
error: string | null;
|
|
218
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* Whether the file is binary (no textual diff is rendered).
|
|
217
|
+
*/
|
|
219
218
|
isBinary: boolean;
|
|
220
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Resolved old/reference text. Ignored while loading/binary/errored.
|
|
221
|
+
*/
|
|
221
222
|
oldText: string;
|
|
222
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* Resolved new/challenger text. Ignored while loading/binary/errored.
|
|
225
|
+
*/
|
|
223
226
|
newText: string;
|
|
224
227
|
/**
|
|
225
228
|
* New-side path. Drives notebook detection and the `@pierre/diffs` file
|
|
@@ -231,17 +234,27 @@ export interface IDiffSurfaceProps {
|
|
|
231
234
|
* to {@link newName} when the host does not track a previous path.
|
|
232
235
|
*/
|
|
233
236
|
oldName?: string;
|
|
234
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Whether to render with the dark `@pierre/diffs` theme.
|
|
239
|
+
*/
|
|
235
240
|
dark: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Whether the diff should keep Pierre's own syntax palette.
|
|
243
|
+
*/
|
|
244
|
+
pierreTheme: boolean;
|
|
236
245
|
/**
|
|
237
246
|
* Rendermime registry used by the notebook view to render outputs and
|
|
238
247
|
* markdown cells. May be `null` in stripped-down hosts; the notebook
|
|
239
248
|
* diff falls back to a textual representation in that case.
|
|
240
249
|
*/
|
|
241
250
|
rendermime: IRenderMimeRegistry | null;
|
|
242
|
-
/**
|
|
251
|
+
/**
|
|
252
|
+
* Current rendered-vs-JSON choice for notebook diffs (host-controlled).
|
|
253
|
+
*/
|
|
243
254
|
notebookViewMode: NotebookDiffViewMode;
|
|
244
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Split vs unified layout for the textual/code file diff (host-controlled).
|
|
257
|
+
*/
|
|
245
258
|
diffStyle: DiffStyle;
|
|
246
259
|
/**
|
|
247
260
|
* Called whenever the availability of a rendered notebook view changes,
|
|
@@ -261,13 +274,14 @@ export interface IDiffSurfaceProps {
|
|
|
261
274
|
* post-discard behaviors such as auto-closing an emptied diff.
|
|
262
275
|
*/
|
|
263
276
|
onMetadataChange?: (info: { hunkCount: number | null }) => void;
|
|
264
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* Optional per-hunk discard wiring; omit for a read-only diff.
|
|
279
|
+
*/
|
|
265
280
|
hunkDiscard?: IHunkDiscard;
|
|
266
281
|
}
|
|
267
282
|
|
|
268
283
|
/**
|
|
269
|
-
*
|
|
270
|
-
* docstring for the division of labor between this surface and its hosts.
|
|
284
|
+
* Shared renderer for text, notebook and image diffs.
|
|
271
285
|
*/
|
|
272
286
|
export function DiffSurface(props: IDiffSurfaceProps): React.ReactElement {
|
|
273
287
|
const {
|
|
@@ -279,6 +293,7 @@ export function DiffSurface(props: IDiffSurfaceProps): React.ReactElement {
|
|
|
279
293
|
newName,
|
|
280
294
|
oldName,
|
|
281
295
|
dark,
|
|
296
|
+
pierreTheme,
|
|
282
297
|
rendermime,
|
|
283
298
|
notebookViewMode,
|
|
284
299
|
diffStyle,
|
|
@@ -539,6 +554,7 @@ export function DiffSurface(props: IDiffSurfaceProps): React.ReactElement {
|
|
|
539
554
|
<NotebookDiffView
|
|
540
555
|
diff={notebookDiff}
|
|
541
556
|
dark={dark}
|
|
557
|
+
pierreTheme={pierreTheme}
|
|
542
558
|
rendermime={rendermime}
|
|
543
559
|
/>
|
|
544
560
|
) : showFileDiff && metadata !== null ? (
|
|
@@ -560,7 +576,7 @@ export function DiffSurface(props: IDiffSurfaceProps): React.ReactElement {
|
|
|
560
576
|
// file name and the panel header carries the change
|
|
561
577
|
// context.
|
|
562
578
|
disableFileHeader: true,
|
|
563
|
-
theme: dark
|
|
579
|
+
theme: resolveDiffTheme(dark, pierreTheme),
|
|
564
580
|
themeType: dark ? 'dark' : 'light',
|
|
565
581
|
// Inject the column-resize override into the shadow root
|
|
566
582
|
// via the library's `@layer unsafe` channel. Keeping the
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerCustomCSSVariableTheme,
|
|
3
|
+
type DiffsThemeNames
|
|
4
|
+
} from '@pierre/diffs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shiki CSS-variable theme used for non-Pierre JupyterLab themes.
|
|
8
|
+
*/
|
|
9
|
+
export const JUPYTERLAB_DIFF_THEME: DiffsThemeNames = 'jupyterlab';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Register a Shiki theme whose token colors read JupyterLab's editor
|
|
13
|
+
* variables. The values are CSS variables, so theme changes recolor the diff.
|
|
14
|
+
*/
|
|
15
|
+
registerCustomCSSVariableTheme(JUPYTERLAB_DIFF_THEME, {
|
|
16
|
+
foreground: 'var(--jp-content-font-color1)',
|
|
17
|
+
background: 'var(--jp-layout-color1)',
|
|
18
|
+
'token-keyword': 'var(--jp-mirror-editor-keyword-color)',
|
|
19
|
+
'token-string': 'var(--jp-mirror-editor-string-color)',
|
|
20
|
+
'token-string-expression': 'var(--jp-mirror-editor-string-2-color)',
|
|
21
|
+
'token-comment': 'var(--jp-mirror-editor-comment-color)',
|
|
22
|
+
'token-constant': 'var(--jp-mirror-editor-number-color)',
|
|
23
|
+
'token-function': 'var(--jp-mirror-editor-def-color)',
|
|
24
|
+
'token-parameter': 'var(--jp-mirror-editor-variable-color)',
|
|
25
|
+
'token-punctuation': 'var(--jp-mirror-editor-punctuation-color)',
|
|
26
|
+
'token-link': 'var(--jp-mirror-editor-link-color)'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Choose Pierre's palette or the JupyterLab CSS-variable theme.
|
|
31
|
+
*/
|
|
32
|
+
export function resolveDiffTheme(
|
|
33
|
+
dark: boolean,
|
|
34
|
+
pierreTheme: boolean
|
|
35
|
+
): DiffsThemeNames {
|
|
36
|
+
if (pierreTheme) {
|
|
37
|
+
return dark ? 'pierre-dark' : 'pierre-light';
|
|
38
|
+
}
|
|
39
|
+
return JUPYTERLAB_DIFF_THEME;
|
|
40
|
+
}
|