@bendyline/docblocks-react 2.0.0 → 2.1.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 +18 -3
- package/dist/ExportDialog-VYATD5UC.js +9 -0
- package/dist/{ExportToolbarControls-D2YDWOXW.js → ExportToolbarControls-5HUE3LSX.js} +206 -42
- package/dist/{GitToolbarControl-LMIR4R7I.js → GitToolbarControl-FW3BZFXV.js} +62 -44
- package/dist/{GitUI-KGF5MSNV.js → GitUI-GMH3PAYL.js} +225 -141
- package/dist/{LazyEditorShell-EF2BWRXU.js → LazyEditorShell-RF54B5UD.js} +0 -1
- package/dist/ShareDialog-PAMOQQFB.js +212 -0
- package/dist/chunk-3CZ27FOA.js +359 -0
- package/dist/chunk-3QSZY74C.js +255 -0
- package/{src/Export/export-destination.ts → dist/chunk-BI7NVU6T.js} +16 -15
- package/dist/{chunk-VHDP4IPL.js → chunk-BPGEBGAN.js} +0 -1
- package/dist/{chunk-DD4VFJQI.js → chunk-EBWYGTN7.js} +2 -1
- package/dist/{chunk-ZI56BNB7.js → chunk-GHQ4X7KM.js} +27 -7
- package/dist/{chunk-5A4KEWKT.js → chunk-HFYPTTCH.js} +0 -1
- package/dist/chunk-LG6HAWCK.js +109 -0
- package/dist/chunk-TFMO7EVO.js +88 -0
- package/dist/{chunk-4XXSWN3T.js → chunk-YBEYTVU2.js} +0 -1
- package/dist/editor.d.ts +5 -4
- package/dist/editor.js +8 -70
- package/dist/export/index.d.ts +24 -8
- package/dist/export/index.js +10 -6
- package/dist/index.d.ts +355 -21
- package/dist/index.js +6419 -21
- package/dist/run-export-Z5BVFLIR.js +9 -0
- package/dist/settings/index.d.ts +9 -1
- package/dist/settings/index.js +6 -5
- package/package.json +18 -13
- package/src/styles/docblocks.css +985 -35
- package/dist/AppMenu/AppMenu.d.ts +0 -53
- package/dist/AppMenu/AppMenu.d.ts.map +0 -1
- package/dist/AppMenu/AppMenu.js +0 -67
- package/dist/AppMenu/AppMenu.js.map +0 -1
- package/dist/AppMenu/index.d.ts +0 -3
- package/dist/AppMenu/index.d.ts.map +0 -1
- package/dist/AppMenu/index.js +0 -2
- package/dist/AppMenu/index.js.map +0 -1
- package/dist/DocBlocksShell/DocBlocksShell.d.ts +0 -49
- package/dist/DocBlocksShell/DocBlocksShell.d.ts.map +0 -1
- package/dist/DocBlocksShell/DocBlocksShell.js +0 -2730
- package/dist/DocBlocksShell/DocBlocksShell.js.map +0 -1
- package/dist/DocBlocksShell/LazyEditorShell.d.ts +0 -3
- package/dist/DocBlocksShell/LazyEditorShell.d.ts.map +0 -1
- package/dist/DocBlocksShell/LazyEditorShell.js +0 -3
- package/dist/DocBlocksShell/LazyEditorShell.js.map +0 -1
- package/dist/DocBlocksShell/UpdateAvailableNotice.d.ts +0 -13
- package/dist/DocBlocksShell/UpdateAvailableNotice.d.ts.map +0 -1
- package/dist/DocBlocksShell/UpdateAvailableNotice.js +0 -16
- package/dist/DocBlocksShell/UpdateAvailableNotice.js.map +0 -1
- package/dist/DocBlocksShell/document-title.d.ts +0 -3
- package/dist/DocBlocksShell/document-title.d.ts.map +0 -1
- package/dist/DocBlocksShell/document-title.js +0 -17
- package/dist/DocBlocksShell/document-title.js.map +0 -1
- package/dist/DocBlocksShell/index.d.ts +0 -3
- package/dist/DocBlocksShell/index.d.ts.map +0 -1
- package/dist/DocBlocksShell/index.js +0 -2
- package/dist/DocBlocksShell/index.js.map +0 -1
- package/dist/DocBlocksShell/workspace-authority-barrier.d.ts +0 -14
- package/dist/DocBlocksShell/workspace-authority-barrier.d.ts.map +0 -1
- package/dist/DocBlocksShell/workspace-authority-barrier.js +0 -23
- package/dist/DocBlocksShell/workspace-authority-barrier.js.map +0 -1
- package/dist/Export/DeferredExportToolbarControls.d.ts +0 -5
- package/dist/Export/DeferredExportToolbarControls.d.ts.map +0 -1
- package/dist/Export/DeferredExportToolbarControls.js +0 -10
- package/dist/Export/DeferredExportToolbarControls.js.map +0 -1
- package/dist/Export/ExportDialog.d.ts +0 -25
- package/dist/Export/ExportDialog.d.ts.map +0 -1
- package/dist/Export/ExportDialog.js +0 -160
- package/dist/Export/ExportDialog.js.map +0 -1
- package/dist/Export/ExportToolbarControls.d.ts +0 -37
- package/dist/Export/ExportToolbarControls.d.ts.map +0 -1
- package/dist/Export/ExportToolbarControls.js +0 -285
- package/dist/Export/ExportToolbarControls.js.map +0 -1
- package/dist/Export/export-destination.d.ts +0 -3
- package/dist/Export/export-destination.d.ts.map +0 -1
- package/dist/Export/export-destination.js +0 -32
- package/dist/Export/export-destination.js.map +0 -1
- package/dist/Export/export-options.d.ts +0 -53
- package/dist/Export/export-options.d.ts.map +0 -1
- package/dist/Export/export-options.js +0 -49
- package/dist/Export/export-options.js.map +0 -1
- package/dist/Export/index.d.ts +0 -10
- package/dist/Export/index.d.ts.map +0 -1
- package/dist/Export/index.js +0 -6
- package/dist/Export/index.js.map +0 -1
- package/dist/Export/public-api.d.ts +0 -12
- package/dist/Export/public-api.d.ts.map +0 -1
- package/dist/Export/public-api.js +0 -9
- package/dist/Export/public-api.js.map +0 -1
- package/dist/Export/run-export.d.ts +0 -10
- package/dist/Export/run-export.d.ts.map +0 -1
- package/dist/Export/run-export.js +0 -313
- package/dist/Export/run-export.js.map +0 -1
- package/dist/Export/transform-summaries.d.ts +0 -7
- package/dist/Export/transform-summaries.d.ts.map +0 -1
- package/dist/Export/transform-summaries.js +0 -6
- package/dist/Export/transform-summaries.js.map +0 -1
- package/dist/ExportDialog-MEUISWZX.js +0 -9
- package/dist/ExportDialog-MEUISWZX.js.map +0 -1
- package/dist/ExportToolbarControls-D2YDWOXW.js.map +0 -1
- package/dist/FileExplorer/FileExplorer.d.ts +0 -43
- package/dist/FileExplorer/FileExplorer.d.ts.map +0 -1
- package/dist/FileExplorer/FileExplorer.js +0 -315
- package/dist/FileExplorer/FileExplorer.js.map +0 -1
- package/dist/FileExplorer/FileTreeNode.d.ts +0 -39
- package/dist/FileExplorer/FileTreeNode.d.ts.map +0 -1
- package/dist/FileExplorer/FileTreeNode.js +0 -131
- package/dist/FileExplorer/FileTreeNode.js.map +0 -1
- package/dist/FileExplorer/index.d.ts +0 -6
- package/dist/FileExplorer/index.d.ts.map +0 -1
- package/dist/FileExplorer/index.js +0 -4
- package/dist/FileExplorer/index.js.map +0 -1
- package/dist/FileExplorer/useFileTree.d.ts +0 -37
- package/dist/FileExplorer/useFileTree.d.ts.map +0 -1
- package/dist/FileExplorer/useFileTree.js +0 -284
- package/dist/FileExplorer/useFileTree.js.map +0 -1
- package/dist/Git/GitAuthGuidanceDialog.d.ts +0 -18
- package/dist/Git/GitAuthGuidanceDialog.d.ts.map +0 -1
- package/dist/Git/GitAuthGuidanceDialog.js +0 -27
- package/dist/Git/GitAuthGuidanceDialog.js.map +0 -1
- package/dist/Git/GitBranchesDialog.d.ts +0 -13
- package/dist/Git/GitBranchesDialog.d.ts.map +0 -1
- package/dist/Git/GitBranchesDialog.js +0 -59
- package/dist/Git/GitBranchesDialog.js.map +0 -1
- package/dist/Git/GitCloneDialog.d.ts +0 -14
- package/dist/Git/GitCloneDialog.d.ts.map +0 -1
- package/dist/Git/GitCloneDialog.js +0 -79
- package/dist/Git/GitCloneDialog.js.map +0 -1
- package/dist/Git/GitCommitDialog.d.ts +0 -12
- package/dist/Git/GitCommitDialog.d.ts.map +0 -1
- package/dist/Git/GitCommitDialog.js +0 -38
- package/dist/Git/GitCommitDialog.js.map +0 -1
- package/dist/Git/GitConflictsDialog.d.ts +0 -12
- package/dist/Git/GitConflictsDialog.d.ts.map +0 -1
- package/dist/Git/GitConflictsDialog.js +0 -17
- package/dist/Git/GitConflictsDialog.js.map +0 -1
- package/dist/Git/GitContext.d.ts +0 -89
- package/dist/Git/GitContext.d.ts.map +0 -1
- package/dist/Git/GitContext.js +0 -15
- package/dist/Git/GitContext.js.map +0 -1
- package/dist/Git/GitDiffDialog.d.ts +0 -20
- package/dist/Git/GitDiffDialog.d.ts.map +0 -1
- package/dist/Git/GitDiffDialog.js +0 -100
- package/dist/Git/GitDiffDialog.js.map +0 -1
- package/dist/Git/GitDiffView.d.ts +0 -23
- package/dist/Git/GitDiffView.d.ts.map +0 -1
- package/dist/Git/GitDiffView.js +0 -77
- package/dist/Git/GitDiffView.js.map +0 -1
- package/dist/Git/GitHistoryDialog.d.ts +0 -15
- package/dist/Git/GitHistoryDialog.d.ts.map +0 -1
- package/dist/Git/GitHistoryDialog.js +0 -107
- package/dist/Git/GitHistoryDialog.js.map +0 -1
- package/dist/Git/GitStatusBar.d.ts +0 -8
- package/dist/Git/GitStatusBar.d.ts.map +0 -1
- package/dist/Git/GitStatusBar.js +0 -49
- package/dist/Git/GitStatusBar.js.map +0 -1
- package/dist/Git/GitToolbarControl.d.ts +0 -15
- package/dist/Git/GitToolbarControl.d.ts.map +0 -1
- package/dist/Git/GitToolbarControl.js +0 -51
- package/dist/Git/GitToolbarControl.js.map +0 -1
- package/dist/Git/GitUI.d.ts +0 -14
- package/dist/Git/GitUI.d.ts.map +0 -1
- package/dist/Git/GitUI.js +0 -21
- package/dist/Git/GitUI.js.map +0 -1
- package/dist/Git/commit-selection.d.ts +0 -22
- package/dist/Git/commit-selection.d.ts.map +0 -1
- package/dist/Git/commit-selection.js +0 -47
- package/dist/Git/commit-selection.js.map +0 -1
- package/dist/Git/git-clone-utils.d.ts +0 -8
- package/dist/Git/git-clone-utils.d.ts.map +0 -1
- package/dist/Git/git-clone-utils.js +0 -26
- package/dist/Git/git-clone-utils.js.map +0 -1
- package/dist/Git/git-status.d.ts +0 -24
- package/dist/Git/git-status.d.ts.map +0 -1
- package/dist/Git/git-status.js +0 -105
- package/dist/Git/git-status.js.map +0 -1
- package/dist/Git/useGit.d.ts +0 -15
- package/dist/Git/useGit.d.ts.map +0 -1
- package/dist/Git/useGit.js +0 -206
- package/dist/Git/useGit.js.map +0 -1
- package/dist/Git/useGitStatus.d.ts +0 -17
- package/dist/Git/useGitStatus.d.ts.map +0 -1
- package/dist/Git/useGitStatus.js +0 -63
- package/dist/Git/useGitStatus.js.map +0 -1
- package/dist/GitToolbarControl-LMIR4R7I.js.map +0 -1
- package/dist/GitUI-KGF5MSNV.js.map +0 -1
- package/dist/LazyEditorShell-EF2BWRXU.js.map +0 -1
- package/dist/Settings/Settings.d.ts +0 -23
- package/dist/Settings/Settings.d.ts.map +0 -1
- package/dist/Settings/Settings.js +0 -22
- package/dist/Settings/Settings.js.map +0 -1
- package/dist/Settings/public-api.d.ts +0 -3
- package/dist/Settings/public-api.d.ts.map +0 -1
- package/dist/Settings/public-api.js +0 -2
- package/dist/Settings/public-api.js.map +0 -1
- package/dist/WorkspacePicker/WorkspacePicker.d.ts +0 -22
- package/dist/WorkspacePicker/WorkspacePicker.d.ts.map +0 -1
- package/dist/WorkspacePicker/WorkspacePicker.js +0 -74
- package/dist/WorkspacePicker/WorkspacePicker.js.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsButton.d.ts +0 -11
- package/dist/WorkspacePicker/WorkspaceSettingsButton.d.ts.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsButton.js +0 -27
- package/dist/WorkspacePicker/WorkspaceSettingsButton.js.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.d.ts +0 -20
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.d.ts.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.js +0 -36
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.js.map +0 -1
- package/dist/WorkspacePicker/index.d.ts +0 -3
- package/dist/WorkspacePicker/index.d.ts.map +0 -1
- package/dist/WorkspacePicker/index.js +0 -2
- package/dist/WorkspacePicker/index.js.map +0 -1
- package/dist/chunk-3SAXDU2U.js +0 -157
- package/dist/chunk-3SAXDU2U.js.map +0 -1
- package/dist/chunk-4XXSWN3T.js.map +0 -1
- package/dist/chunk-5A4KEWKT.js.map +0 -1
- package/dist/chunk-AOVTHZU7.js +0 -321
- package/dist/chunk-AOVTHZU7.js.map +0 -1
- package/dist/chunk-DD4VFJQI.js.map +0 -1
- package/dist/chunk-GSNZSCIK.js +0 -55
- package/dist/chunk-GSNZSCIK.js.map +0 -1
- package/dist/chunk-VHDP4IPL.js.map +0 -1
- package/dist/chunk-ZI56BNB7.js.map +0 -1
- package/dist/components/Dialog.d.ts +0 -22
- package/dist/components/Dialog.d.ts.map +0 -1
- package/dist/components/Dialog.js +0 -33
- package/dist/components/Dialog.js.map +0 -1
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.js.map +0 -1
- package/dist/export/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -2
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useDocumentSession.d.ts +0 -16
- package/dist/hooks/useDocumentSession.d.ts.map +0 -1
- package/dist/hooks/useDocumentSession.js +0 -18
- package/dist/hooks/useDocumentSession.js.map +0 -1
- package/dist/icons.d.ts +0 -12
- package/dist/icons.d.ts.map +0 -1
- package/dist/icons.js +0 -28
- package/dist/icons.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/preferences/theme.d.ts +0 -18
- package/dist/preferences/theme.d.ts.map +0 -1
- package/dist/preferences/theme.js +0 -63
- package/dist/preferences/theme.js.map +0 -1
- package/dist/preferences/versioning.d.ts +0 -27
- package/dist/preferences/versioning.d.ts.map +0 -1
- package/dist/preferences/versioning.js +0 -62
- package/dist/preferences/versioning.js.map +0 -1
- package/dist/provider-lease.d.ts +0 -10
- package/dist/provider-lease.d.ts.map +0 -1
- package/dist/provider-lease.js +0 -42
- package/dist/provider-lease.js.map +0 -1
- package/dist/run-export-ICTZITXC.js +0 -10
- package/dist/run-export-ICTZITXC.js.map +0 -1
- package/dist/settings/index.js.map +0 -1
- package/src/AppMenu/AppMenu.tsx +0 -334
- package/src/AppMenu/index.ts +0 -2
- package/src/DocBlocksShell/DocBlocksShell.tsx +0 -3398
- package/src/DocBlocksShell/LazyEditorShell.ts +0 -2
- package/src/DocBlocksShell/UpdateAvailableNotice.tsx +0 -60
- package/src/DocBlocksShell/document-title.ts +0 -19
- package/src/DocBlocksShell/index.ts +0 -2
- package/src/DocBlocksShell/workspace-authority-barrier.ts +0 -26
- package/src/Export/DeferredExportToolbarControls.tsx +0 -23
- package/src/Export/ExportDialog.tsx +0 -437
- package/src/Export/ExportToolbarControls.tsx +0 -511
- package/src/Export/export-options.ts +0 -99
- package/src/Export/index.ts +0 -19
- package/src/Export/public-api.ts +0 -17
- package/src/Export/run-export.ts +0 -374
- package/src/Export/transform-summaries.ts +0 -14
- package/src/FileExplorer/FileExplorer.tsx +0 -528
- package/src/FileExplorer/FileTreeNode.tsx +0 -306
- package/src/FileExplorer/index.ts +0 -5
- package/src/FileExplorer/useFileTree.ts +0 -352
- package/src/Git/GitAuthGuidanceDialog.tsx +0 -84
- package/src/Git/GitBranchesDialog.tsx +0 -144
- package/src/Git/GitCloneDialog.tsx +0 -200
- package/src/Git/GitCommitDialog.tsx +0 -119
- package/src/Git/GitConflictsDialog.tsx +0 -62
- package/src/Git/GitContext.tsx +0 -88
- package/src/Git/GitDiffDialog.tsx +0 -147
- package/src/Git/GitDiffView.tsx +0 -105
- package/src/Git/GitHistoryDialog.tsx +0 -195
- package/src/Git/GitStatusBar.tsx +0 -157
- package/src/Git/GitToolbarControl.tsx +0 -123
- package/src/Git/GitUI.tsx +0 -68
- package/src/Git/commit-selection.ts +0 -63
- package/src/Git/git-clone-utils.ts +0 -23
- package/src/Git/git-status.ts +0 -113
- package/src/Git/useGit.ts +0 -279
- package/src/Git/useGitStatus.ts +0 -78
- package/src/Settings/Settings.tsx +0 -118
- package/src/Settings/public-api.ts +0 -8
- package/src/WorkspacePicker/WorkspacePicker.tsx +0 -191
- package/src/WorkspacePicker/WorkspaceSettingsButton.tsx +0 -88
- package/src/WorkspacePicker/WorkspaceSettingsDialog.tsx +0 -121
- package/src/WorkspacePicker/index.ts +0 -2
- package/src/components/Dialog.tsx +0 -81
- package/src/editor.ts +0 -72
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useDocumentSession.ts +0 -37
- package/src/icons.tsx +0 -48
- package/src/index.ts +0 -61
- package/src/preferences/theme.ts +0 -67
- package/src/preferences/versioning.ts +0 -69
- package/src/provider-lease.ts +0 -52
- package/src/types/pwa-dom.d.ts +0 -31
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useFileTree — hook that reads from a FileSystemProvider,
|
|
3
|
-
* maintains expanded/collapsed state, and provides CRUD operations.
|
|
4
|
-
*/
|
|
5
|
-
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
6
|
-
import { getFileSystemProviderV2, moveFileSystemEntry, parseWorkspacePath, } from '@bendyline/docblocks/filesystem';
|
|
7
|
-
function normalisePath(path) {
|
|
8
|
-
return parseWorkspacePath(path);
|
|
9
|
-
}
|
|
10
|
-
function relocatePath(path, oldPath, newPath) {
|
|
11
|
-
const current = normalisePath(path);
|
|
12
|
-
const oldNormalised = normalisePath(oldPath);
|
|
13
|
-
if (current !== oldNormalised && !current.startsWith(`${oldNormalised}/`))
|
|
14
|
-
return path;
|
|
15
|
-
const suffix = current.slice(oldNormalised.length);
|
|
16
|
-
return `${newPath.replace(/\/+$/, '')}${suffix}`;
|
|
17
|
-
}
|
|
18
|
-
function ancestorPaths(path) {
|
|
19
|
-
const canonical = normalisePath(path);
|
|
20
|
-
if (!canonical)
|
|
21
|
-
return [];
|
|
22
|
-
const segments = canonical.split('/');
|
|
23
|
-
const prefix = /^[\\/]/u.test(path) ? '/' : '';
|
|
24
|
-
return segments
|
|
25
|
-
.slice(0, -1)
|
|
26
|
-
.map((_, index) => `${prefix}${segments.slice(0, index + 1).join('/')}`);
|
|
27
|
-
}
|
|
28
|
-
function equivalentPathKeys(path) {
|
|
29
|
-
const canonical = normalisePath(path);
|
|
30
|
-
return canonical ? [path, canonical, `/${canonical}`] : [path, canonical];
|
|
31
|
-
}
|
|
32
|
-
function hasEquivalentPath(paths, path) {
|
|
33
|
-
return equivalentPathKeys(path).some((candidate) => paths.has(candidate));
|
|
34
|
-
}
|
|
35
|
-
async function readProviderDirectory(provider, path) {
|
|
36
|
-
const providerV2 = getFileSystemProviderV2(provider);
|
|
37
|
-
if (!providerV2)
|
|
38
|
-
return provider.readDirectory(path);
|
|
39
|
-
const entries = await providerV2.readDirectory(parseWorkspacePath(path));
|
|
40
|
-
return entries.map((entry) => ({ kind: entry.kind, name: entry.name, path: entry.path }));
|
|
41
|
-
}
|
|
42
|
-
export function useFileTree(provider) {
|
|
43
|
-
const [entries, setEntries] = useState([]);
|
|
44
|
-
const [expanded, setExpanded] = useState(new Set());
|
|
45
|
-
const [selectedPath, setSelectedPath] = useState(null);
|
|
46
|
-
const [selectedKind, setSelectedKind] = useState(null);
|
|
47
|
-
const [loading, setLoading] = useState(false);
|
|
48
|
-
// Track child entries for expanded directories
|
|
49
|
-
const [childEntries, setChildEntries] = useState(new Map());
|
|
50
|
-
const providerRef = useRef(provider);
|
|
51
|
-
providerRef.current = provider;
|
|
52
|
-
const loadRoot = useCallback(async () => {
|
|
53
|
-
if (!providerRef.current) {
|
|
54
|
-
setEntries([]);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
setLoading(true);
|
|
58
|
-
try {
|
|
59
|
-
const root = await readProviderDirectory(providerRef.current, '');
|
|
60
|
-
setEntries(root);
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
63
|
-
setLoading(false);
|
|
64
|
-
}
|
|
65
|
-
}, []);
|
|
66
|
-
const loadChildren = useCallback(async (dirPath) => {
|
|
67
|
-
if (!providerRef.current)
|
|
68
|
-
return;
|
|
69
|
-
const children = await readProviderDirectory(providerRef.current, dirPath);
|
|
70
|
-
setChildEntries((prev) => {
|
|
71
|
-
const next = new Map(prev);
|
|
72
|
-
next.set(dirPath, children);
|
|
73
|
-
return next;
|
|
74
|
-
});
|
|
75
|
-
}, []);
|
|
76
|
-
// Load root on provider change
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
setExpanded(new Set());
|
|
79
|
-
setChildEntries(new Map());
|
|
80
|
-
setSelectedPath(null);
|
|
81
|
-
setSelectedKind(null);
|
|
82
|
-
loadRoot();
|
|
83
|
-
}, [provider, loadRoot]);
|
|
84
|
-
const toggleExpand = useCallback((path) => {
|
|
85
|
-
setExpanded((prev) => {
|
|
86
|
-
const next = new Set(prev);
|
|
87
|
-
if (hasEquivalentPath(next, path)) {
|
|
88
|
-
for (const candidate of equivalentPathKeys(path))
|
|
89
|
-
next.delete(candidate);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
next.add(path);
|
|
93
|
-
// Load children when expanding
|
|
94
|
-
loadChildren(path);
|
|
95
|
-
}
|
|
96
|
-
return next;
|
|
97
|
-
});
|
|
98
|
-
}, [loadChildren]);
|
|
99
|
-
const select = useCallback((path, kind) => {
|
|
100
|
-
setSelectedPath(path);
|
|
101
|
-
setSelectedKind(kind);
|
|
102
|
-
}, []);
|
|
103
|
-
const reveal = useCallback((path, kind) => {
|
|
104
|
-
const ancestors = ancestorPaths(path);
|
|
105
|
-
setSelectedPath(path);
|
|
106
|
-
setSelectedKind(kind);
|
|
107
|
-
setExpanded((prev) => {
|
|
108
|
-
const next = new Set(prev);
|
|
109
|
-
for (const ancestor of ancestors) {
|
|
110
|
-
if (!hasEquivalentPath(next, ancestor))
|
|
111
|
-
next.add(ancestor);
|
|
112
|
-
}
|
|
113
|
-
return next;
|
|
114
|
-
});
|
|
115
|
-
for (const ancestor of ancestors) {
|
|
116
|
-
void loadChildren(ancestor);
|
|
117
|
-
}
|
|
118
|
-
}, [loadChildren]);
|
|
119
|
-
const refresh = useCallback(async () => {
|
|
120
|
-
await loadRoot();
|
|
121
|
-
// Reload all expanded directories
|
|
122
|
-
const expandedPaths = [...expanded];
|
|
123
|
-
for (const dirPath of expandedPaths) {
|
|
124
|
-
await loadChildren(dirPath);
|
|
125
|
-
}
|
|
126
|
-
}, [loadRoot, loadChildren, expanded]);
|
|
127
|
-
const refreshRef = useRef(refresh);
|
|
128
|
-
refreshRef.current = refresh;
|
|
129
|
-
// Keep the explorer synchronized with provider changes. Watch-capable
|
|
130
|
-
// providers (including Electron's chokidar-backed provider) update in real
|
|
131
|
-
// time. Calls are serialized and coalesced so event bursts cannot publish
|
|
132
|
-
// directory reads out of order.
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
if (!provider)
|
|
135
|
-
return;
|
|
136
|
-
const providerV2 = getFileSystemProviderV2(provider);
|
|
137
|
-
if (!providerV2?.capabilities.watch)
|
|
138
|
-
return;
|
|
139
|
-
let disposed = false;
|
|
140
|
-
let refreshing = false;
|
|
141
|
-
let refreshAgain = false;
|
|
142
|
-
const requestRefresh = () => {
|
|
143
|
-
if (disposed)
|
|
144
|
-
return;
|
|
145
|
-
if (refreshing) {
|
|
146
|
-
refreshAgain = true;
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
refreshing = true;
|
|
150
|
-
void (async () => {
|
|
151
|
-
try {
|
|
152
|
-
do {
|
|
153
|
-
refreshAgain = false;
|
|
154
|
-
await refreshRef.current();
|
|
155
|
-
} while (refreshAgain && !disposed);
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// A later watcher event or window resume will retry the read.
|
|
159
|
-
}
|
|
160
|
-
finally {
|
|
161
|
-
refreshing = false;
|
|
162
|
-
if (refreshAgain && !disposed)
|
|
163
|
-
requestRefresh();
|
|
164
|
-
}
|
|
165
|
-
})();
|
|
166
|
-
};
|
|
167
|
-
const subscription = providerV2.watch(requestRefresh, { onError: requestRefresh });
|
|
168
|
-
void subscription.ready.catch(() => undefined);
|
|
169
|
-
return () => {
|
|
170
|
-
disposed = true;
|
|
171
|
-
void subscription.dispose();
|
|
172
|
-
};
|
|
173
|
-
}, [provider]);
|
|
174
|
-
// File System Access and IndexedDB do not expose a dependable external
|
|
175
|
-
// watcher. Refreshing on resume catches changes made while this surface was
|
|
176
|
-
// in the background without continuously polling the filesystem.
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
if (!provider)
|
|
179
|
-
return;
|
|
180
|
-
const refreshOnFocus = () => {
|
|
181
|
-
void refreshRef.current().catch(() => undefined);
|
|
182
|
-
};
|
|
183
|
-
const refreshOnVisibility = () => {
|
|
184
|
-
if (document.visibilityState === 'visible')
|
|
185
|
-
refreshOnFocus();
|
|
186
|
-
};
|
|
187
|
-
window.addEventListener('focus', refreshOnFocus);
|
|
188
|
-
document.addEventListener('visibilitychange', refreshOnVisibility);
|
|
189
|
-
return () => {
|
|
190
|
-
window.removeEventListener('focus', refreshOnFocus);
|
|
191
|
-
document.removeEventListener('visibilitychange', refreshOnVisibility);
|
|
192
|
-
};
|
|
193
|
-
}, [provider]);
|
|
194
|
-
const createFile = useCallback(async (path, content = '') => {
|
|
195
|
-
if (!providerRef.current)
|
|
196
|
-
return;
|
|
197
|
-
const providerV2 = getFileSystemProviderV2(providerRef.current);
|
|
198
|
-
if (providerV2) {
|
|
199
|
-
await providerV2.writeFile(parseWorkspacePath(path), new TextEncoder().encode(content), {
|
|
200
|
-
mode: 'create',
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
await providerRef.current.writeFile(path, content);
|
|
205
|
-
}
|
|
206
|
-
await refresh();
|
|
207
|
-
}, [refresh]);
|
|
208
|
-
const createDirectory = useCallback(async (path) => {
|
|
209
|
-
if (!providerRef.current)
|
|
210
|
-
return;
|
|
211
|
-
const providerV2 = getFileSystemProviderV2(providerRef.current);
|
|
212
|
-
if (providerV2) {
|
|
213
|
-
await providerV2.createDirectory(parseWorkspacePath(path), { mode: 'create' });
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
await providerRef.current.createDirectory(path);
|
|
217
|
-
}
|
|
218
|
-
await refresh();
|
|
219
|
-
}, [refresh]);
|
|
220
|
-
const deleteEntry = useCallback(async (path) => {
|
|
221
|
-
if (!providerRef.current)
|
|
222
|
-
return;
|
|
223
|
-
const providerV2 = getFileSystemProviderV2(providerRef.current);
|
|
224
|
-
if (providerV2) {
|
|
225
|
-
const canonical = parseWorkspacePath(path);
|
|
226
|
-
const entry = await providerV2.stat(canonical);
|
|
227
|
-
if (entry) {
|
|
228
|
-
await providerV2.remove(canonical, {
|
|
229
|
-
recursive: entry.kind === 'directory',
|
|
230
|
-
missing: 'error',
|
|
231
|
-
expectedVersion: entry.version,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
await providerRef.current.delete(path);
|
|
237
|
-
}
|
|
238
|
-
if (selectedPath === path) {
|
|
239
|
-
setSelectedPath(null);
|
|
240
|
-
setSelectedKind(null);
|
|
241
|
-
}
|
|
242
|
-
await refresh();
|
|
243
|
-
}, [refresh, selectedPath]);
|
|
244
|
-
const renameEntry = useCallback(async (oldPath, newPath, kind) => {
|
|
245
|
-
if (!providerRef.current)
|
|
246
|
-
return;
|
|
247
|
-
const oldNormalised = normalisePath(oldPath);
|
|
248
|
-
const knownEntry = [...entries, ...childEntries.values()]
|
|
249
|
-
.flat()
|
|
250
|
-
.find((entry) => normalisePath(entry.path) === oldNormalised);
|
|
251
|
-
const entryKind = kind ?? knownEntry?.kind ?? 'file';
|
|
252
|
-
await moveFileSystemEntry(providerRef.current, oldPath, newPath, entryKind);
|
|
253
|
-
if (selectedPath) {
|
|
254
|
-
setSelectedPath(relocatePath(selectedPath, oldPath, newPath));
|
|
255
|
-
}
|
|
256
|
-
const nextExpanded = new Set([...expanded].map((path) => relocatePath(path, oldPath, newPath)));
|
|
257
|
-
setExpanded(nextExpanded);
|
|
258
|
-
setChildEntries(new Map());
|
|
259
|
-
await loadRoot();
|
|
260
|
-
for (const dirPath of nextExpanded) {
|
|
261
|
-
await loadChildren(dirPath);
|
|
262
|
-
}
|
|
263
|
-
}, [selectedPath, entries, childEntries, expanded, loadRoot, loadChildren]);
|
|
264
|
-
// Merge root entries with child entries for a flat tree representation
|
|
265
|
-
// (consumers use `expanded` and `childEntries` to render recursively)
|
|
266
|
-
return {
|
|
267
|
-
entries,
|
|
268
|
-
expanded,
|
|
269
|
-
selectedPath,
|
|
270
|
-
selectedKind,
|
|
271
|
-
loading,
|
|
272
|
-
toggleExpand,
|
|
273
|
-
select,
|
|
274
|
-
reveal,
|
|
275
|
-
createFile,
|
|
276
|
-
createDirectory,
|
|
277
|
-
deleteEntry,
|
|
278
|
-
renameEntry,
|
|
279
|
-
refresh,
|
|
280
|
-
// Expose child entries for rendering
|
|
281
|
-
...{ childEntries },
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
//# sourceMappingURL=useFileTree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFileTree.js","sourceRoot":"","sources":["../../src/FileExplorer/useFileTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GAGnB,MAAM,iCAAiC,CAAC;AAEzC,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,OAAe,EAAE,OAAe;IAClE,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,aAAa,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,aAAa,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACvF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;AACnD,CAAC;AAED,SAAS,aA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Y,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAC1B,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAClE,CAAC;QACF,WAAW,CAAC,YAAY,CAAC,CAAC;QAC1B,eAAe,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAC3B,MAAM,QAAQ,EAAE,CAAC;QACjB,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACnC,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,EACD,CAAC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CACxE,CAAC;IAEF,uEAAuE;IACvE,sEAAsE;IAEtE,OAAO;QACL,OAAO;QACP,QAAQ;QACR,YAAY;QACZ,YAAY;QACZ,OAAO;QACP,YAAY;QACZ,MAAM;QACN,MAAM;QACN,UAAU;QACV,eAAe;QACf,WAAW;QACX,WAAW;QACX,OAAO;QACP,qCAAqC;QACrC,GAAG,EAAE,YAAY,EAAE;KACkE,CAAC;AAC1F,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitAuthGuidanceDialog — shown when a git operation fails to authenticate.
|
|
3
|
-
*
|
|
4
|
-
* DocBlocks deliberately never collects or stores credentials, so this
|
|
5
|
-
* dialog only explains the three supported sign-in routes (credential
|
|
6
|
-
* helper, GitHub CLI, SSH key). The copy is exported as a standalone
|
|
7
|
-
* component so the clone dialog can embed it after an auth failure.
|
|
8
|
-
*/
|
|
9
|
-
/** The credential guidance copy, reusable outside this dialog (clone flow). */
|
|
10
|
-
export declare function GitCredentialGuidance({ detail }: {
|
|
11
|
-
detail?: string;
|
|
12
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare function GitAuthGuidanceDialog({ operation, detail, onClose, }: {
|
|
14
|
-
operation: 'push' | 'pull' | 'fetch' | 'clone' | 'pr';
|
|
15
|
-
detail?: string;
|
|
16
|
-
onClose: () => void;
|
|
17
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
//# sourceMappingURL=GitAuthGuidanceDialog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitAuthGuidanceDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitAuthGuidanceDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,2CAuBpE;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,MAAM,EACN,OAAO,GACR,EAAE;IACD,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CA0BA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* GitAuthGuidanceDialog — shown when a git operation fails to authenticate.
|
|
4
|
-
*
|
|
5
|
-
* DocBlocks deliberately never collects or stores credentials, so this
|
|
6
|
-
* dialog only explains the three supported sign-in routes (credential
|
|
7
|
-
* helper, GitHub CLI, SSH key). The copy is exported as a standalone
|
|
8
|
-
* component so the clone dialog can embed it after an auth failure.
|
|
9
|
-
*/
|
|
10
|
-
import { maybeGetDocBlocksHost } from '@bendyline/docblocks/host';
|
|
11
|
-
import { Dialog } from '../components/Dialog.js';
|
|
12
|
-
const LEARN_MORE_URL = 'https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git';
|
|
13
|
-
const OPERATION_LABELS = {
|
|
14
|
-
push: 'push',
|
|
15
|
-
pull: 'pull',
|
|
16
|
-
fetch: 'fetch',
|
|
17
|
-
clone: 'clone',
|
|
18
|
-
pr: 'create the pull request',
|
|
19
|
-
};
|
|
20
|
-
/** The credential guidance copy, reusable outside this dialog (clone flow). */
|
|
21
|
-
export function GitCredentialGuidance({ detail }) {
|
|
22
|
-
return (_jsxs(_Fragment, { children: [_jsx("p", { className: "db-settings-hint", children: "DocBlocks never stores Git credentials. Sign in with one of these, then try again:" }), _jsxs("ul", { className: "db-git-hint", children: [_jsxs("li", { children: ["A git credential helper (", _jsx("code", { children: "git config credential.helper" }), ")"] }), _jsxs("li", { children: ["The GitHub CLI (", _jsx("code", { children: "gh auth login" }), ")"] }), _jsx("li", { children: "An SSH key registered with your remote" })] }), detail && (_jsxs("details", { children: [_jsx("summary", { children: "Details" }), _jsx("p", { className: "db-git-hint", children: detail })] }))] }));
|
|
23
|
-
}
|
|
24
|
-
export function GitAuthGuidanceDialog({ operation, detail, onClose, }) {
|
|
25
|
-
return (_jsxs(Dialog, { title: "Git needs credentials", onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: () => void maybeGetDocBlocksHost()?.shell.openExternal(LEARN_MORE_URL), children: "Learn more" }), _jsx("button", { type: "button", className: "db-git-primary-btn", onClick: onClose, children: "Close" })] }), children: [_jsxs("p", { className: "db-settings-hint", children: ["Git could not authenticate with the remote while trying to ", OPERATION_LABELS[operation], "."] }), _jsx(GitCredentialGuidance, { detail: detail })] }));
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=GitAuthGuidanceDialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitAuthGuidanceDialog.js","sourceRoot":"","sources":["../../src/Git/GitAuthGuidanceDialog.tsx"],"names":[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MAAM,GAAI,IAClC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitBranchesDialog — switch between local branches or create a new one.
|
|
3
|
-
*
|
|
4
|
-
* Loads the branch list once from the host git API on mount. Remote
|
|
5
|
-
* branches are display-only in v1 (a collapsed disclosure); switching and
|
|
6
|
-
* creating go through the GitValue actions so errors (e.g. uncommitted
|
|
7
|
-
* changes blocking a checkout) surface inline via lastResult.
|
|
8
|
-
*/
|
|
9
|
-
export declare function GitBranchesDialog({ createFocus, onClose, }: {
|
|
10
|
-
createFocus?: boolean;
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
-
//# sourceMappingURL=GitBranchesDialog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitBranchesDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitBranchesDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,OAAO,GACR,EAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,kDA2HA"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* GitBranchesDialog — switch between local branches or create a new one.
|
|
4
|
-
*
|
|
5
|
-
* Loads the branch list once from the host git API on mount. Remote
|
|
6
|
-
* branches are display-only in v1 (a collapsed disclosure); switching and
|
|
7
|
-
* creating go through the GitValue actions so errors (e.g. uncommitted
|
|
8
|
-
* changes blocking a checkout) surface inline via lastResult.
|
|
9
|
-
*/
|
|
10
|
-
import { useEffect, useRef, useState } from 'react';
|
|
11
|
-
import { Dialog } from '../components/Dialog.js';
|
|
12
|
-
import { useGitContext } from './GitContext.js';
|
|
13
|
-
export function GitBranchesDialog({ createFocus, onClose, }) {
|
|
14
|
-
const git = useGitContext();
|
|
15
|
-
const gitApi = git?.gitApi ?? null;
|
|
16
|
-
const repositoryId = git?.repositoryId ?? null;
|
|
17
|
-
const [branches, setBranches] = useState(null);
|
|
18
|
-
const [loadError, setLoadError] = useState(null);
|
|
19
|
-
const [newName, setNewName] = useState('');
|
|
20
|
-
const createInputRef = useRef(null);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!gitApi || !repositoryId)
|
|
23
|
-
return;
|
|
24
|
-
let cancelled = false;
|
|
25
|
-
void gitApi.listBranches(repositoryId).then((result) => {
|
|
26
|
-
if (cancelled)
|
|
27
|
-
return;
|
|
28
|
-
if (result.ok)
|
|
29
|
-
setBranches(result.value);
|
|
30
|
-
else
|
|
31
|
-
setLoadError(result.error.message || 'Could not list branches');
|
|
32
|
-
});
|
|
33
|
-
return () => {
|
|
34
|
-
cancelled = true;
|
|
35
|
-
};
|
|
36
|
-
}, [gitApi, repositoryId]);
|
|
37
|
-
if (!git)
|
|
38
|
-
return null;
|
|
39
|
-
const locals = branches?.filter((b) => b.kind === 'local') ?? [];
|
|
40
|
-
const remotes = branches?.filter((b) => b.kind === 'remote') ?? [];
|
|
41
|
-
const canCreate = newName.trim().length > 0 && git.busy === null;
|
|
42
|
-
const handleSwitch = async (name) => {
|
|
43
|
-
const ok = await git.switchBranch(name);
|
|
44
|
-
if (ok)
|
|
45
|
-
onClose();
|
|
46
|
-
};
|
|
47
|
-
const handleCreate = async () => {
|
|
48
|
-
if (!canCreate)
|
|
49
|
-
return;
|
|
50
|
-
const ok = await git.createBranch(newName.trim());
|
|
51
|
-
if (ok)
|
|
52
|
-
onClose();
|
|
53
|
-
};
|
|
54
|
-
return (_jsxs(Dialog, { title: "Branches", onClose: onClose, initialFocusRef: createFocus ? createInputRef : undefined, children: [branches === null && loadError === null && _jsx("p", { className: "db-git-hint", children: "Loading branches\u2026" }), loadError !== null && (_jsx("p", { className: "db-git-form-error", role: "alert", children: loadError })), branches !== null && (_jsx("div", { className: "db-git-branch-list", children: locals.map((branch) => branch.current ? (_jsx("span", { className: "db-git-branch-row db-git-branch-row--current", "aria-current": "true", children: branch.name }, branch.name)) : (_jsx("button", { type: "button", className: "db-git-branch-row", disabled: git.busy !== null, onClick: () => void handleSwitch(branch.name), children: branch.name }, branch.name))) })), git.lastResult?.tone === 'error' && (_jsx("p", { className: "db-git-form-error", role: "alert", children: git.lastResult.message })), _jsx("hr", {}), _jsxs("div", { className: "db-git-form-row", children: [_jsx("label", { className: "db-git-form-label", htmlFor: "db-git-new-branch-name", children: "New branch" }), _jsx("input", { id: "db-git-new-branch-name", ref: createInputRef, className: "db-git-form-input", type: "text", value: newName, onChange: (e) => setNewName(e.target.value), onKeyDown: (e) => {
|
|
55
|
-
if (e.key === 'Enter')
|
|
56
|
-
void handleCreate();
|
|
57
|
-
}, placeholder: "feature/my-branch", spellCheck: false }), _jsx("button", { type: "button", className: "db-git-primary-btn", disabled: !canCreate, onClick: () => void handleCreate(), children: "Create" })] }), remotes.length > 0 && (_jsxs("details", { children: [_jsxs("summary", { children: ["Remote branches (", remotes.length, ")"] }), _jsx("div", { className: "db-git-branch-list", children: remotes.map((branch) => (_jsx("span", { className: "db-git-branch-row", children: branch.name }, branch.name))) })] }))] }));
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=GitBranchesDialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitBranchesDialog.js","sourceRoot":"","sources":["../../src/Git/GitBranchesDialog.tsx"],"names":[],"mappings":";AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,iBAAiB,CAAC,EAChC,WAAW,EACX,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,cAAK,SAAS,EAAC,oBAAoB,YAChC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,eAAwB,SAAS,EAAC,mBAAmB,YAClD,MAAM,CAAC,IAAI,IADH,MAAM,CAAC,IAAI,CAEf,CACR,CAAC,GACE,IACE,CACX,IACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitCloneDialog — clone a remote repository into a new local workspace.
|
|
3
|
-
*
|
|
4
|
-
* The renderer only collects the URL; the main process shows the native
|
|
5
|
-
* destination picker, streams progress back, and registers the clone as a
|
|
6
|
-
* workspace. An auth failure swaps the body to the shared credential
|
|
7
|
-
* guidance copy (no credentials are ever collected here).
|
|
8
|
-
*/
|
|
9
|
-
import type { ElectronWorkspaceInfo } from '@bendyline/docblocks/host';
|
|
10
|
-
export declare function GitCloneDialog({ onClose, onCloned, }: {
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
onCloned: (info: ElectronWorkspaceInfo) => void;
|
|
13
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
-
//# sourceMappingURL=GitCloneDialog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitCloneDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitCloneDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,qBAAqB,EAGtB,MAAM,2BAA2B,CAAC;AAMnC,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACjD,kDA6KA"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* GitCloneDialog — clone a remote repository into a new local workspace.
|
|
4
|
-
*
|
|
5
|
-
* The renderer only collects the URL; the main process shows the native
|
|
6
|
-
* destination picker, streams progress back, and registers the clone as a
|
|
7
|
-
* workspace. An auth failure swaps the body to the shared credential
|
|
8
|
-
* guidance copy (no credentials are ever collected here).
|
|
9
|
-
*/
|
|
10
|
-
import { useEffect, useRef, useState } from 'react';
|
|
11
|
-
import { Dialog } from '../components/Dialog.js';
|
|
12
|
-
import { useGitContext } from './GitContext.js';
|
|
13
|
-
import { deriveCloneFolderName, isLikelyGitUrl } from './git-clone-utils.js';
|
|
14
|
-
import { GitCredentialGuidance } from './GitAuthGuidanceDialog.js';
|
|
15
|
-
export function GitCloneDialog({ onClose, onCloned, }) {
|
|
16
|
-
const git = useGitContext();
|
|
17
|
-
const gitApi = git?.gitApi ?? null;
|
|
18
|
-
const [url, setUrl] = useState('');
|
|
19
|
-
const [cloning, setCloning] = useState(false);
|
|
20
|
-
const [progress, setProgress] = useState(null);
|
|
21
|
-
const [error, setError] = useState(null);
|
|
22
|
-
/** Non-null → show embedded credential guidance instead of the form. */
|
|
23
|
-
const [authDetail, setAuthDetail] = useState(null);
|
|
24
|
-
const handleRef = useRef(null);
|
|
25
|
-
const urlInputRef = useRef(null);
|
|
26
|
-
// Closing the dialog mid-clone abandons it — kill git and clean up.
|
|
27
|
-
useEffect(() => () => {
|
|
28
|
-
handleRef.current?.cancel();
|
|
29
|
-
}, []);
|
|
30
|
-
if (!gitApi || typeof gitApi.clone !== 'function')
|
|
31
|
-
return null;
|
|
32
|
-
const canClone = isLikelyGitUrl(url) && !cloning;
|
|
33
|
-
const handleClone = async () => {
|
|
34
|
-
if (!canClone)
|
|
35
|
-
return;
|
|
36
|
-
setCloning(true);
|
|
37
|
-
setError(null);
|
|
38
|
-
setProgress(null);
|
|
39
|
-
const handle = gitApi.clone(url.trim(), (p) => setProgress(p));
|
|
40
|
-
handleRef.current = handle;
|
|
41
|
-
const result = await handle.result;
|
|
42
|
-
handleRef.current = null;
|
|
43
|
-
setCloning(false);
|
|
44
|
-
setProgress(null);
|
|
45
|
-
if (!result.ok) {
|
|
46
|
-
switch (result.error.code) {
|
|
47
|
-
case 'invalid-url':
|
|
48
|
-
setError('That doesn’t look like a valid repository URL.');
|
|
49
|
-
break;
|
|
50
|
-
case 'destination-exists':
|
|
51
|
-
setError('A folder with that name already exists there. Pick a different location.');
|
|
52
|
-
break;
|
|
53
|
-
case 'auth-failed':
|
|
54
|
-
setAuthDetail({ detail: result.error.message });
|
|
55
|
-
break;
|
|
56
|
-
case 'cancelled':
|
|
57
|
-
break; // user cancelled — just return to the form
|
|
58
|
-
default:
|
|
59
|
-
setError(result.error.message);
|
|
60
|
-
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (result.value === null)
|
|
64
|
-
return; // user cancelled the destination picker
|
|
65
|
-
onCloned(result.value);
|
|
66
|
-
};
|
|
67
|
-
const progressPercent = progress?.percent ?? null;
|
|
68
|
-
const progressText = progress !== null
|
|
69
|
-
? `${progress.phase}…${progressPercent !== null ? ` ${Math.round(progressPercent)}%` : ''}`
|
|
70
|
-
: 'Starting clone…';
|
|
71
|
-
if (authDetail !== null) {
|
|
72
|
-
return (_jsxs(Dialog, { title: "Clone repository", onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: () => setAuthDetail(null), children: "Back" }), _jsx("button", { type: "button", className: "db-git-primary-btn", onClick: onClose, children: "Close" })] }), children: [_jsx("p", { className: "db-settings-hint", children: "Git could not authenticate with that remote." }), _jsx(GitCredentialGuidance, { detail: authDetail.detail })] }));
|
|
73
|
-
}
|
|
74
|
-
return (_jsxs(Dialog, { title: "Clone repository", onClose: onClose, closeOnBackdrop: !cloning, initialFocusRef: urlInputRef, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: onClose, disabled: cloning, children: "Cancel" }), _jsx("button", { type: "button", className: "db-git-primary-btn", disabled: !canClone, onClick: () => void handleClone(), children: "Clone" })] }), children: [_jsxs("div", { className: "db-git-form-row", children: [_jsx("label", { className: "db-git-form-label", htmlFor: "db-git-clone-url", children: "Repository URL" }), _jsx("input", { id: "db-git-clone-url", ref: urlInputRef, className: "db-git-form-input", type: "text", value: url, onChange: (e) => setUrl(e.target.value), onKeyDown: (e) => {
|
|
75
|
-
if (e.key === 'Enter')
|
|
76
|
-
void handleClone();
|
|
77
|
-
}, placeholder: "https://github.com/owner/repo.git", disabled: cloning, spellCheck: false })] }), isLikelyGitUrl(url) && (_jsxs("p", { className: "db-git-hint", children: ["Will clone into: ", _jsx("b", { children: deriveCloneFolderName(url) }), " \u2014 you\u2019ll pick where next"] })), _jsx("p", { className: "db-git-hint", children: "HTTPS and SSH URLs both work. You\u2019ll choose the destination folder in the next step." }), error !== null && (_jsx("p", { className: "db-git-form-error", role: "alert", children: error })), cloning && (_jsxs("div", { className: "db-git-progress", children: [progressPercent !== null && (_jsx("div", { className: "db-git-progress-bar", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(progressPercent), style: { width: `${progressPercent}%` } })), _jsx("p", { className: "db-git-progress-text", children: progressText }), _jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: () => handleRef.current?.cancel(), children: "Cancel" })] }))] }));
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=GitCloneDialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitCloneDialog.js","sourceRoot":"","sources":["../../src/Git/GitCloneDialog.tsx"],"names":[],"mappings":";AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMpD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,cAAc,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changed files are included by default; while a merge is being
|
|
5
|
-
* concluded, conflicted files are force-included (locked) because a commit
|
|
6
|
-
* that omits them would not resolve the merge. Selection logic lives in
|
|
7
|
-
* commit-selection.ts so it stays unit-testable.
|
|
8
|
-
*/
|
|
9
|
-
export declare function GitCommitDialog({ onClose }: {
|
|
10
|
-
onClose: () => void;
|
|
11
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
-
//# sourceMappingURL=GitCommitDialog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitCommitDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitCommitDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,kDA+FnE"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* GitCommitDialog — message + per-file selection for committing changes.
|
|
4
|
-
*
|
|
5
|
-
* All changed files are included by default; while a merge is being
|
|
6
|
-
* concluded, conflicted files are force-included (locked) because a commit
|
|
7
|
-
* that omits them would not resolve the merge. Selection logic lives in
|
|
8
|
-
* commit-selection.ts so it stays unit-testable.
|
|
9
|
-
*/
|
|
10
|
-
import { useRef, useState } from 'react';
|
|
11
|
-
import { Dialog } from '../components/Dialog.js';
|
|
12
|
-
import { useGitContext } from './GitContext.js';
|
|
13
|
-
import { BADGE_LABELS, badgeKindFor } from './git-status.js';
|
|
14
|
-
import { canCommit, initSelection, isMergeCommit, selectedPaths, setAllSelected, toggleSelection, } from './commit-selection.js';
|
|
15
|
-
export function GitCommitDialog({ onClose }) {
|
|
16
|
-
const git = useGitContext();
|
|
17
|
-
const status = git?.status ?? null;
|
|
18
|
-
const merging = isMergeCommit(status);
|
|
19
|
-
const [message, setMessage] = useState('');
|
|
20
|
-
const [selection, setSelection] = useState(() => initSelection(status?.changes ?? [], merging));
|
|
21
|
-
const messageRef = useRef(null);
|
|
22
|
-
if (!git || !status)
|
|
23
|
-
return null;
|
|
24
|
-
const allOn = [...selection.included.values()].every(Boolean);
|
|
25
|
-
const commitDisabled = !canCommit(message, selection) || git.busy !== null;
|
|
26
|
-
const handleCommit = async () => {
|
|
27
|
-
const ok = await git.commit(message, selectedPaths(selection));
|
|
28
|
-
if (ok)
|
|
29
|
-
onClose();
|
|
30
|
-
};
|
|
31
|
-
return (_jsxs(Dialog, { title: merging ? 'Commit merge' : 'Commit changes', onClose: onClose, size: "wide", closeOnBackdrop: false, initialFocusRef: messageRef, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: onClose, children: "Cancel" }), _jsx("button", { type: "button", className: "db-git-primary-btn", disabled: commitDisabled, onClick: () => void handleCommit(), children: "Commit" })] }), children: [merging && (_jsx("p", { className: "db-settings-hint", children: "You\u2019re completing a merge. Committing will conclude it." })), _jsx("textarea", { ref: messageRef, className: "db-git-commit-message", value: message, onChange: (e) => setMessage(e.target.value), placeholder: "Commit message", "aria-label": "Commit message", rows: 3 }), _jsx("div", { className: "db-git-form-row", children: _jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: () => setSelection((s) => setAllSelected(s, !allOn)), children: allOn ? 'Select none' : 'Select all' }) }), _jsx("ul", { className: "db-git-file-list", children: status.changes.map((change) => {
|
|
32
|
-
const kind = badgeKindFor(change);
|
|
33
|
-
const locked = selection.locked.has(change.path);
|
|
34
|
-
const checked = locked || (selection.included.get(change.path) ?? true);
|
|
35
|
-
return (_jsxs("li", { className: "db-git-file-row", children: [_jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: checked, disabled: locked, onChange: () => setSelection((s) => toggleSelection(s, change.path)) }), _jsx("span", { children: change.path.replace(/^\/+/, '') })] }), _jsx("span", { className: "db-git-file-kind", children: BADGE_LABELS[kind] })] }, change.path));
|
|
36
|
-
}) }), git.lastResult?.tone === 'error' && (_jsx("p", { className: "db-git-form-error", role: "alert", children: git.lastResult.message }))] }));
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=GitCommitDialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GitCommitDialog.js","sourceRoot":"","sources":["../../src/Git/GitCommitDialog.tsx"],"names":[],"mappings":";AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,UAAU,eAAe,CAAC,EAAE,OAAO,EAA2B;IAClE,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC;IACnC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAEtC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAkB,GAAG,EAAE,CAC/D,aAAa,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC,CAC9C,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IAErD,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,C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