@bendyline/docblocks-react 1.1.1 → 2.0.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 +50 -15
- package/dist/AppMenu/AppMenu.d.ts +29 -2
- package/dist/AppMenu/AppMenu.d.ts.map +1 -1
- package/dist/AppMenu/AppMenu.js +41 -2
- package/dist/AppMenu/AppMenu.js.map +1 -1
- package/dist/AppMenu/index.d.ts +1 -1
- package/dist/AppMenu/index.d.ts.map +1 -1
- package/dist/DocBlocksShell/DocBlocksShell.d.ts +17 -4
- package/dist/DocBlocksShell/DocBlocksShell.d.ts.map +1 -1
- package/dist/DocBlocksShell/DocBlocksShell.js +1710 -299
- package/dist/DocBlocksShell/DocBlocksShell.js.map +1 -1
- package/dist/DocBlocksShell/LazyEditorShell.d.ts +3 -0
- package/dist/DocBlocksShell/LazyEditorShell.d.ts.map +1 -0
- package/dist/DocBlocksShell/LazyEditorShell.js +3 -0
- package/dist/DocBlocksShell/LazyEditorShell.js.map +1 -0
- package/dist/DocBlocksShell/UpdateAvailableNotice.d.ts +13 -0
- package/dist/DocBlocksShell/UpdateAvailableNotice.d.ts.map +1 -0
- package/dist/DocBlocksShell/UpdateAvailableNotice.js +16 -0
- package/dist/DocBlocksShell/UpdateAvailableNotice.js.map +1 -0
- package/dist/DocBlocksShell/document-title.d.ts +3 -0
- package/dist/DocBlocksShell/document-title.d.ts.map +1 -0
- package/dist/DocBlocksShell/document-title.js +17 -0
- package/dist/DocBlocksShell/document-title.js.map +1 -0
- package/dist/DocBlocksShell/workspace-authority-barrier.d.ts +14 -0
- package/dist/DocBlocksShell/workspace-authority-barrier.d.ts.map +1 -0
- package/dist/DocBlocksShell/workspace-authority-barrier.js +23 -0
- package/dist/DocBlocksShell/workspace-authority-barrier.js.map +1 -0
- package/dist/Export/DeferredExportToolbarControls.d.ts +5 -0
- package/dist/Export/DeferredExportToolbarControls.d.ts.map +1 -0
- package/dist/Export/DeferredExportToolbarControls.js +10 -0
- package/dist/Export/DeferredExportToolbarControls.js.map +1 -0
- package/dist/Export/ExportDialog.d.ts +10 -1
- package/dist/Export/ExportDialog.d.ts.map +1 -1
- package/dist/Export/ExportDialog.js +39 -20
- package/dist/Export/ExportDialog.js.map +1 -1
- package/dist/Export/ExportToolbarControls.d.ts +21 -1
- package/dist/Export/ExportToolbarControls.d.ts.map +1 -1
- package/dist/Export/ExportToolbarControls.js +161 -26
- package/dist/Export/ExportToolbarControls.js.map +1 -1
- package/dist/Export/export-destination.d.ts +3 -0
- package/dist/Export/export-destination.d.ts.map +1 -0
- package/dist/Export/export-destination.js +32 -0
- package/dist/Export/export-destination.js.map +1 -0
- package/dist/Export/index.d.ts +8 -4
- package/dist/Export/index.d.ts.map +1 -1
- package/dist/Export/index.js +4 -1
- package/dist/Export/index.js.map +1 -1
- package/dist/Export/public-api.d.ts +12 -0
- package/dist/Export/public-api.d.ts.map +1 -0
- package/dist/Export/public-api.js +9 -0
- package/dist/Export/public-api.js.map +1 -0
- package/dist/Export/run-export.d.ts +3 -1
- package/dist/Export/run-export.d.ts.map +1 -1
- package/dist/Export/run-export.js +58 -25
- package/dist/Export/run-export.js.map +1 -1
- package/dist/Export/transform-summaries.d.ts +7 -0
- package/dist/Export/transform-summaries.d.ts.map +1 -0
- package/dist/Export/transform-summaries.js +6 -0
- package/dist/Export/transform-summaries.js.map +1 -0
- package/dist/ExportDialog-MEUISWZX.js +9 -0
- package/dist/ExportDialog-MEUISWZX.js.map +1 -0
- package/dist/ExportToolbarControls-D2YDWOXW.js +373 -0
- package/dist/ExportToolbarControls-D2YDWOXW.js.map +1 -0
- package/dist/FileExplorer/FileExplorer.d.ts +26 -4
- package/dist/FileExplorer/FileExplorer.d.ts.map +1 -1
- package/dist/FileExplorer/FileExplorer.js +204 -29
- package/dist/FileExplorer/FileExplorer.js.map +1 -1
- package/dist/FileExplorer/FileTreeNode.d.ts +24 -3
- package/dist/FileExplorer/FileTreeNode.d.ts.map +1 -1
- package/dist/FileExplorer/FileTreeNode.js +27 -8
- package/dist/FileExplorer/FileTreeNode.js.map +1 -1
- package/dist/FileExplorer/index.d.ts +1 -1
- package/dist/FileExplorer/index.d.ts.map +1 -1
- package/dist/FileExplorer/useFileTree.d.ts +5 -3
- package/dist/FileExplorer/useFileTree.d.ts.map +1 -1
- package/dist/FileExplorer/useFileTree.js +173 -13
- package/dist/FileExplorer/useFileTree.js.map +1 -1
- package/dist/Git/GitAuthGuidanceDialog.d.ts +18 -0
- package/dist/Git/GitAuthGuidanceDialog.d.ts.map +1 -0
- package/dist/Git/GitAuthGuidanceDialog.js +27 -0
- package/dist/Git/GitAuthGuidanceDialog.js.map +1 -0
- package/dist/Git/GitBranchesDialog.d.ts +13 -0
- package/dist/Git/GitBranchesDialog.d.ts.map +1 -0
- package/dist/Git/GitBranchesDialog.js +59 -0
- package/dist/Git/GitBranchesDialog.js.map +1 -0
- package/dist/Git/GitCloneDialog.d.ts +14 -0
- package/dist/Git/GitCloneDialog.d.ts.map +1 -0
- package/dist/Git/GitCloneDialog.js +79 -0
- package/dist/Git/GitCloneDialog.js.map +1 -0
- package/dist/Git/GitCommitDialog.d.ts +12 -0
- package/dist/Git/GitCommitDialog.d.ts.map +1 -0
- package/dist/Git/GitCommitDialog.js +38 -0
- package/dist/Git/GitCommitDialog.js.map +1 -0
- package/dist/Git/GitConflictsDialog.d.ts +12 -0
- package/dist/Git/GitConflictsDialog.d.ts.map +1 -0
- package/dist/Git/GitConflictsDialog.js +17 -0
- package/dist/Git/GitConflictsDialog.js.map +1 -0
- package/dist/Git/GitContext.d.ts +89 -0
- package/dist/Git/GitContext.d.ts.map +1 -0
- package/dist/Git/GitContext.js +15 -0
- package/dist/Git/GitContext.js.map +1 -0
- package/dist/Git/GitDiffDialog.d.ts +20 -0
- package/dist/Git/GitDiffDialog.d.ts.map +1 -0
- package/dist/Git/GitDiffDialog.js +100 -0
- package/dist/Git/GitDiffDialog.js.map +1 -0
- package/dist/Git/GitDiffView.d.ts +23 -0
- package/dist/Git/GitDiffView.d.ts.map +1 -0
- package/dist/Git/GitDiffView.js +77 -0
- package/dist/Git/GitDiffView.js.map +1 -0
- package/dist/Git/GitHistoryDialog.d.ts +15 -0
- package/dist/Git/GitHistoryDialog.d.ts.map +1 -0
- package/dist/Git/GitHistoryDialog.js +107 -0
- package/dist/Git/GitHistoryDialog.js.map +1 -0
- package/dist/Git/GitStatusBar.d.ts +8 -0
- package/dist/Git/GitStatusBar.d.ts.map +1 -0
- package/dist/Git/GitStatusBar.js +49 -0
- package/dist/Git/GitStatusBar.js.map +1 -0
- package/dist/Git/GitToolbarControl.d.ts +15 -0
- package/dist/Git/GitToolbarControl.d.ts.map +1 -0
- package/dist/Git/GitToolbarControl.js +51 -0
- package/dist/Git/GitToolbarControl.js.map +1 -0
- package/dist/Git/GitUI.d.ts +14 -0
- package/dist/Git/GitUI.d.ts.map +1 -0
- package/dist/Git/GitUI.js +21 -0
- package/dist/Git/GitUI.js.map +1 -0
- package/dist/Git/commit-selection.d.ts +22 -0
- package/dist/Git/commit-selection.d.ts.map +1 -0
- package/dist/Git/commit-selection.js +47 -0
- package/dist/Git/commit-selection.js.map +1 -0
- package/dist/Git/git-clone-utils.d.ts +8 -0
- package/dist/Git/git-clone-utils.d.ts.map +1 -0
- package/dist/Git/git-clone-utils.js +26 -0
- package/dist/Git/git-clone-utils.js.map +1 -0
- package/dist/Git/git-status.d.ts +24 -0
- package/dist/Git/git-status.d.ts.map +1 -0
- package/dist/Git/git-status.js +105 -0
- package/dist/Git/git-status.js.map +1 -0
- package/dist/Git/useGit.d.ts +15 -0
- package/dist/Git/useGit.d.ts.map +1 -0
- package/dist/Git/useGit.js +206 -0
- package/dist/Git/useGit.js.map +1 -0
- package/dist/Git/useGitStatus.d.ts +17 -0
- package/dist/Git/useGitStatus.d.ts.map +1 -0
- package/dist/Git/useGitStatus.js +63 -0
- package/dist/Git/useGitStatus.js.map +1 -0
- package/dist/GitToolbarControl-LMIR4R7I.js +117 -0
- package/dist/GitToolbarControl-LMIR4R7I.js.map +1 -0
- package/dist/GitUI-KGF5MSNV.js +1048 -0
- package/dist/GitUI-KGF5MSNV.js.map +1 -0
- package/dist/LazyEditorShell-EF2BWRXU.js +6 -0
- package/dist/LazyEditorShell-EF2BWRXU.js.map +1 -0
- package/dist/Settings/Settings.d.ts +23 -0
- package/dist/Settings/Settings.d.ts.map +1 -0
- package/dist/Settings/Settings.js +22 -0
- package/dist/Settings/Settings.js.map +1 -0
- package/dist/Settings/public-api.d.ts +3 -0
- package/dist/Settings/public-api.d.ts.map +1 -0
- package/dist/Settings/public-api.js +2 -0
- package/dist/Settings/public-api.js.map +1 -0
- package/dist/WorkspacePicker/WorkspacePicker.d.ts +6 -1
- package/dist/WorkspacePicker/WorkspacePicker.d.ts.map +1 -1
- package/dist/WorkspacePicker/WorkspacePicker.js +16 -5
- package/dist/WorkspacePicker/WorkspacePicker.js.map +1 -1
- package/dist/chunk-3SAXDU2U.js +157 -0
- package/dist/chunk-3SAXDU2U.js.map +1 -0
- package/dist/chunk-4XXSWN3T.js +13 -0
- package/dist/chunk-4XXSWN3T.js.map +1 -0
- package/dist/chunk-5A4KEWKT.js +97 -0
- package/dist/chunk-5A4KEWKT.js.map +1 -0
- package/dist/chunk-AOVTHZU7.js +321 -0
- package/dist/chunk-AOVTHZU7.js.map +1 -0
- package/dist/chunk-DD4VFJQI.js +51 -0
- package/dist/chunk-DD4VFJQI.js.map +1 -0
- package/dist/chunk-GSNZSCIK.js +55 -0
- package/dist/chunk-GSNZSCIK.js.map +1 -0
- package/dist/chunk-VHDP4IPL.js +70 -0
- package/dist/chunk-VHDP4IPL.js.map +1 -0
- package/dist/chunk-ZI56BNB7.js +270 -0
- package/dist/chunk-ZI56BNB7.js.map +1 -0
- package/dist/components/Dialog.d.ts +22 -0
- package/dist/components/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog.js +33 -0
- package/dist/components/Dialog.js.map +1 -0
- package/dist/editor.d.ts +10 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +70 -0
- package/dist/editor.js.map +1 -0
- package/dist/export/index.d.ts +87 -0
- package/dist/export/index.js +26 -0
- package/dist/export/index.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useDocumentSession.d.ts +16 -0
- package/dist/hooks/useDocumentSession.d.ts.map +1 -0
- package/dist/hooks/useDocumentSession.js +18 -0
- package/dist/hooks/useDocumentSession.js.map +1 -0
- package/dist/icons.d.ts +11 -6
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +21 -20
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/preferences/theme.d.ts +18 -0
- package/dist/preferences/theme.d.ts.map +1 -0
- package/dist/preferences/theme.js +63 -0
- package/dist/preferences/theme.js.map +1 -0
- package/dist/provider-lease.d.ts +10 -0
- package/dist/provider-lease.d.ts.map +1 -0
- package/dist/provider-lease.js +42 -0
- package/dist/provider-lease.js.map +1 -0
- package/dist/run-export-ICTZITXC.js +10 -0
- package/dist/run-export-ICTZITXC.js.map +1 -0
- package/dist/settings/index.d.ts +28 -0
- package/dist/settings/index.js +12 -0
- package/dist/settings/index.js.map +1 -0
- package/package.json +27 -10
- package/src/AppMenu/AppMenu.tsx +169 -99
- package/src/AppMenu/index.ts +1 -1
- package/src/DocBlocksShell/DocBlocksShell.tsx +2183 -516
- package/src/DocBlocksShell/LazyEditorShell.ts +2 -0
- package/src/DocBlocksShell/UpdateAvailableNotice.tsx +60 -0
- package/src/DocBlocksShell/document-title.ts +19 -0
- package/src/DocBlocksShell/workspace-authority-barrier.ts +26 -0
- package/src/Export/DeferredExportToolbarControls.tsx +23 -0
- package/src/Export/ExportDialog.tsx +102 -27
- package/src/Export/ExportToolbarControls.tsx +343 -57
- package/src/Export/export-destination.ts +30 -0
- package/src/Export/index.ts +18 -4
- package/src/Export/public-api.ts +17 -0
- package/src/Export/run-export.ts +66 -29
- package/src/Export/transform-summaries.ts +14 -0
- package/src/FileExplorer/FileExplorer.tsx +284 -38
- package/src/FileExplorer/FileTreeNode.tsx +100 -8
- package/src/FileExplorer/index.ts +1 -1
- package/src/FileExplorer/useFileTree.ts +190 -16
- package/src/Git/GitAuthGuidanceDialog.tsx +84 -0
- package/src/Git/GitBranchesDialog.tsx +144 -0
- package/src/Git/GitCloneDialog.tsx +200 -0
- package/src/Git/GitCommitDialog.tsx +119 -0
- package/src/Git/GitConflictsDialog.tsx +62 -0
- package/src/Git/GitContext.tsx +88 -0
- package/src/Git/GitDiffDialog.tsx +147 -0
- package/src/Git/GitDiffView.tsx +105 -0
- package/src/Git/GitHistoryDialog.tsx +195 -0
- package/src/Git/GitStatusBar.tsx +157 -0
- package/src/Git/GitToolbarControl.tsx +123 -0
- package/src/Git/GitUI.tsx +68 -0
- package/src/Git/commit-selection.ts +63 -0
- package/src/Git/git-clone-utils.ts +23 -0
- package/src/Git/git-status.ts +113 -0
- package/src/Git/useGit.ts +279 -0
- package/src/Git/useGitStatus.ts +78 -0
- package/src/Settings/Settings.tsx +118 -0
- package/src/Settings/public-api.ts +8 -0
- package/src/WorkspacePicker/WorkspacePicker.tsx +62 -8
- package/src/components/Dialog.tsx +81 -0
- package/src/editor.ts +72 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useDocumentSession.ts +37 -0
- package/src/icons.tsx +33 -55
- package/src/index.ts +35 -5
- package/src/preferences/theme.ts +67 -0
- package/src/provider-lease.ts +52 -0
- package/src/styles/docblocks.css +2247 -77
- package/src/types/pwa-dom.d.ts +31 -0
- package/dist/hooks/useAutoSave.d.ts +0 -15
- package/dist/hooks/useAutoSave.d.ts.map +0 -1
- package/dist/hooks/useAutoSave.js +0 -83
- package/dist/hooks/useAutoSave.js.map +0 -1
- package/src/fonts/fonts.css +0 -362
- package/src/fonts/licenses/LICENSE-cormorant-garamond.txt +0 -93
- package/src/fonts/licenses/LICENSE-crimson-text.txt +0 -93
- package/src/fonts/licenses/LICENSE-dm-sans.txt +0 -93
- package/src/fonts/licenses/LICENSE-dm-serif-display.txt +0 -93
- package/src/fonts/licenses/LICENSE-hanken-grotesk.txt +0 -94
- package/src/fonts/licenses/LICENSE-ibm-plex-sans.txt +0 -93
- package/src/fonts/licenses/LICENSE-inter.txt +0 -93
- package/src/fonts/licenses/LICENSE-jetbrains-mono.txt +0 -93
- package/src/fonts/licenses/LICENSE-lora.txt +0 -93
- package/src/fonts/licenses/LICENSE-merriweather.txt +0 -93
- package/src/fonts/licenses/LICENSE-oswald.txt +0 -93
- package/src/fonts/licenses/LICENSE-playfair-display.txt +0 -93
- package/src/fonts/licenses/LICENSE-pt-serif.txt +0 -93
- package/src/fonts/licenses/LICENSE-roboto.txt +0 -93
- package/src/fonts/licenses/LICENSE-source-serif-4.txt +0 -93
- package/src/fonts/woff2/cormorant-garamond-400.woff2 +0 -0
- package/src/fonts/woff2/cormorant-garamond-700.woff2 +0 -0
- package/src/fonts/woff2/crimson-text-400.woff2 +0 -0
- package/src/fonts/woff2/crimson-text-400i.woff2 +0 -0
- package/src/fonts/woff2/crimson-text-700.woff2 +0 -0
- package/src/fonts/woff2/dm-sans-400.woff2 +0 -0
- package/src/fonts/woff2/dm-sans-400i.woff2 +0 -0
- package/src/fonts/woff2/dm-sans-500.woff2 +0 -0
- package/src/fonts/woff2/dm-sans-700.woff2 +0 -0
- package/src/fonts/woff2/dm-serif-display-400.woff2 +0 -0
- package/src/fonts/woff2/hanken-grotesk-400.woff2 +0 -0
- package/src/fonts/woff2/hanken-grotesk-400i.woff2 +0 -0
- package/src/fonts/woff2/hanken-grotesk-500.woff2 +0 -0
- package/src/fonts/woff2/hanken-grotesk-600.woff2 +0 -0
- package/src/fonts/woff2/hanken-grotesk-700.woff2 +0 -0
- package/src/fonts/woff2/ibm-plex-sans-400.woff2 +0 -0
- package/src/fonts/woff2/ibm-plex-sans-400i.woff2 +0 -0
- package/src/fonts/woff2/ibm-plex-sans-500.woff2 +0 -0
- package/src/fonts/woff2/ibm-plex-sans-600.woff2 +0 -0
- package/src/fonts/woff2/ibm-plex-sans-700.woff2 +0 -0
- package/src/fonts/woff2/inter-400.woff2 +0 -0
- package/src/fonts/woff2/inter-400i.woff2 +0 -0
- package/src/fonts/woff2/inter-500.woff2 +0 -0
- package/src/fonts/woff2/inter-600.woff2 +0 -0
- package/src/fonts/woff2/inter-700.woff2 +0 -0
- package/src/fonts/woff2/jetbrains-mono-400.woff2 +0 -0
- package/src/fonts/woff2/jetbrains-mono-400i.woff2 +0 -0
- package/src/fonts/woff2/jetbrains-mono-700.woff2 +0 -0
- package/src/fonts/woff2/lora-400.woff2 +0 -0
- package/src/fonts/woff2/lora-400i.woff2 +0 -0
- package/src/fonts/woff2/lora-700.woff2 +0 -0
- package/src/fonts/woff2/merriweather-400.woff2 +0 -0
- package/src/fonts/woff2/merriweather-700.woff2 +0 -0
- package/src/fonts/woff2/oswald-400.woff2 +0 -0
- package/src/fonts/woff2/oswald-700.woff2 +0 -0
- package/src/fonts/woff2/playfair-display-400.woff2 +0 -0
- package/src/fonts/woff2/playfair-display-700.woff2 +0 -0
- package/src/fonts/woff2/pt-serif-400.woff2 +0 -0
- package/src/fonts/woff2/pt-serif-700.woff2 +0 -0
- package/src/fonts/woff2/roboto-400.woff2 +0 -0
- package/src/fonts/woff2/roboto-400i.woff2 +0 -0
- package/src/fonts/woff2/roboto-700.woff2 +0 -0
- package/src/fonts/woff2/source-serif-4-400.woff2 +0 -0
- package/src/fonts/woff2/source-serif-4-400i.woff2 +0 -0
- package/src/fonts/woff2/source-serif-4-700.woff2 +0 -0
- package/src/hooks/useAutoSave.ts +0 -116
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitConflictsDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitConflictsDialog.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,UAAU,EACV,OAAO,GACR,EAAE;IACD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CA2CA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GitConflictsDialog — lists conflicted files after a pull hits a merge
|
|
4
|
+
* conflict. Each row opens the file in the editor so the user can resolve
|
|
5
|
+
* the markers; the primary action hands off to the commit dialog, which
|
|
6
|
+
* concludes the merge.
|
|
7
|
+
*/
|
|
8
|
+
import { Dialog } from '../components/Dialog.js';
|
|
9
|
+
import { useGitContext } from './GitContext.js';
|
|
10
|
+
export function GitConflictsDialog({ paths, onOpenFile, onClose, }) {
|
|
11
|
+
const git = useGitContext();
|
|
12
|
+
return (_jsxs(Dialog, { title: "Merge conflicts", onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "db-git-secondary-btn", onClick: onClose, children: "Close" }), _jsx("button", { type: "button", className: "db-git-primary-btn", onClick: () => git?.openDialog({ kind: 'commit' }), children: "Open commit dialog" })] }), children: [_jsx("p", { className: "db-settings-hint", children: "These files contain conflict markers. Edit each one to resolve the conflicts, then commit to complete the merge." }), _jsx("ul", { className: "db-git-file-list", children: paths.map((path) => (_jsx("li", { className: "db-git-file-row", children: _jsx("button", { type: "button", onClick: () => {
|
|
13
|
+
onOpenFile(path);
|
|
14
|
+
onClose();
|
|
15
|
+
}, children: path.replace(/^\/+/, '') }) }, path))) })] }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=GitConflictsDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitConflictsDialog.js","sourceRoot":"","sources":["../../src/Git/GitConflictsDialog.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,UAAU,EACV,OAAO,GAKR;IACC,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAE5B,OAAO,CACL,MAAC,MAAM,IACL,KAAK,EAAC,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,MAAM,EACJ,8BACE,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,sBAAsB,EAAC,OAAO,EAAE,OAAO,sBAE9D,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,oBAAoB,EAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,mCAG3C,IACR,aAGL,YAAG,SAAS,EAAC,kBAAkB,iIAG3B,EACJ,aAAI,SAAS,EAAC,kBAAkB,YAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,aAAe,SAAS,EAAC,iBAAiB,YACxC,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE;4BACZ,UAAU,CAAC,IAAI,CAAC,CAAC;4BACjB,OAAO,EAAE,CAAC;wBACZ,CAAC,YAEA,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAClB,IATF,IAAI,CAUR,CACN,CAAC,GACC,IACE,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitContext — the seam between DocBlocksShell and every git UI surface.
|
|
3
|
+
*
|
|
4
|
+
* The shell calls useGit() once and provides the value here; the status
|
|
5
|
+
* bar, file-tree badges, toolbar control, and dialogs all consume it.
|
|
6
|
+
* Consumers must tolerate a null context (FileExplorer renders standalone
|
|
7
|
+
* in tests and on surfaces with no git).
|
|
8
|
+
*/
|
|
9
|
+
import type { DocBlocksHostGitAPI, GitCapabilities, GitRepoDetection, GitStatus } from '@bendyline/docblocks/host';
|
|
10
|
+
import type { FileSystemProvider } from '@bendyline/docblocks/filesystem';
|
|
11
|
+
import type { GitBadgeKind } from './git-status.js';
|
|
12
|
+
export type GitDialogState = {
|
|
13
|
+
kind: 'none';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'commit';
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'branches';
|
|
18
|
+
createFocus?: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'history';
|
|
21
|
+
path?: string;
|
|
22
|
+
}
|
|
23
|
+
/** `revision` absent → working tree vs HEAD; present → that commit vs its parent. */
|
|
24
|
+
| {
|
|
25
|
+
kind: 'diff';
|
|
26
|
+
path: string;
|
|
27
|
+
revision?: {
|
|
28
|
+
sha: string;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'clone';
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'auth-guidance';
|
|
34
|
+
operation: 'push' | 'pull' | 'fetch' | 'clone' | 'pr';
|
|
35
|
+
detail?: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'conflicts';
|
|
38
|
+
paths: string[];
|
|
39
|
+
};
|
|
40
|
+
export type GitBusyKind = 'push' | 'pull' | 'fetch' | 'commit' | 'branch' | 'pr' | null;
|
|
41
|
+
export interface GitInlineResult {
|
|
42
|
+
tone: 'info' | 'error';
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
export interface GitValue {
|
|
46
|
+
/** Tier 1 — Electron host with a working git. Gates the clone entry. */
|
|
47
|
+
available: boolean;
|
|
48
|
+
capabilities: GitCapabilities | null;
|
|
49
|
+
/** Tier 2 — the active workspace root is a repository. Gates everything else. */
|
|
50
|
+
repo: GitRepoDetection | null;
|
|
51
|
+
/** Main-owned repository capability; never a native path. */
|
|
52
|
+
repositoryId: string | null;
|
|
53
|
+
/** Parsed web location of the first remote, when one exists and parses. */
|
|
54
|
+
remoteWeb: {
|
|
55
|
+
host: string;
|
|
56
|
+
owner: string;
|
|
57
|
+
repo: string;
|
|
58
|
+
webUrl: string;
|
|
59
|
+
} | null;
|
|
60
|
+
/** Raw host API for read-heavy dialogs (log, branches, file-at-revision). */
|
|
61
|
+
gitApi: DocBlocksHostGitAPI | null;
|
|
62
|
+
provider: FileSystemProvider | null;
|
|
63
|
+
theme: 'light' | 'dark';
|
|
64
|
+
status: GitStatus | null;
|
|
65
|
+
badges: ReadonlyMap<string, GitBadgeKind>;
|
|
66
|
+
busy: GitBusyKind;
|
|
67
|
+
/** Latest operation outcome, surfaced in an aria-live region. */
|
|
68
|
+
lastResult: GitInlineResult | null;
|
|
69
|
+
refresh: () => void;
|
|
70
|
+
/** Debounced refresh — used after autosave writes. */
|
|
71
|
+
scheduleRefresh: () => void;
|
|
72
|
+
/** Actions route their typed errors to dialogs/lastResult internally. */
|
|
73
|
+
commit: (message: string, paths: string[]) => Promise<boolean>;
|
|
74
|
+
push: () => Promise<void>;
|
|
75
|
+
pull: () => Promise<void>;
|
|
76
|
+
fetchRemote: () => Promise<void>;
|
|
77
|
+
createBranch: (name: string) => Promise<boolean>;
|
|
78
|
+
switchBranch: (name: string) => Promise<boolean>;
|
|
79
|
+
/** Open the repo (or a file within it) on the remote's web host. */
|
|
80
|
+
openOnRemote: (filePath?: string) => void;
|
|
81
|
+
createPullRequest: () => Promise<void>;
|
|
82
|
+
dialog: GitDialogState;
|
|
83
|
+
openDialog: (dialog: GitDialogState) => void;
|
|
84
|
+
closeDialog: () => void;
|
|
85
|
+
}
|
|
86
|
+
export declare const GitContext: import("react").Context<GitValue | null>;
|
|
87
|
+
/** Null when no provider is mounted — callers must degrade gracefully. */
|
|
88
|
+
export declare function useGitContext(): GitValue | null;
|
|
89
|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AK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,oEAAoE;IACpE,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,UAAU,0CAAuC,CAAC;AAE/D,0EAA0E;AAC1E,wBAAgB,aAAa,IAAI,QAAQ,GAAG,IAAI,CAE/C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitContext — the seam between DocBlocksShell and every git UI surface.
|
|
3
|
+
*
|
|
4
|
+
* The shell calls useGit() once and provides the value here; the status
|
|
5
|
+
* bar, file-tree badges, toolbar control, and dialogs all consume it.
|
|
6
|
+
* Consumers must tolerate a null context (FileExplorer renders standalone
|
|
7
|
+
* in tests and on surfaces with no git).
|
|
8
|
+
*/
|
|
9
|
+
import { createContext, useContext } from 'react';
|
|
10
|
+
export const GitContext = createContext(null);
|
|
11
|
+
/** Null when no provider is mounted — callers must degrade gracefully. */
|
|
12
|
+
export function useGitContext() {
|
|
13
|
+
return useContext(GitContext);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=GitContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitContext.js","sourceRoot":"","sources":["../../src/Git/GitContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAyElD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAkB,IAAI,CAAC,CAAC;AAE/D,0EAA0E;AAC1E,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitDiffDialog — full-size modal showing a file diff.
|
|
3
|
+
*
|
|
4
|
+
* Without a revision: working tree vs HEAD (HEAD side via the git host API,
|
|
5
|
+
* working side via the workspace FileSystemProvider). With a revision: that
|
|
6
|
+
* commit vs its parent, both sides via readFileAtRevision. Absent sides
|
|
7
|
+
* render as empty text with an "(absent)" label; binary files short-circuit
|
|
8
|
+
* to a hint since there is no text diff to show.
|
|
9
|
+
*/
|
|
10
|
+
export interface GitDiffDialogProps {
|
|
11
|
+
/** Slash-prefixed workspace-relative path. */
|
|
12
|
+
path: string;
|
|
13
|
+
/** Absent → working tree vs HEAD; present → that commit vs its parent. */
|
|
14
|
+
revision?: {
|
|
15
|
+
sha: string;
|
|
16
|
+
};
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function GitDiffDialog({ path, revision, onClose }: GitDiffDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
+
//# sourceMappingURL=GitDiffDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitDiffDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitDiffDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,QAAQ,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAaD,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,kBAAkB,kDA+G5E"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GitDiffDialog — full-size modal showing a file diff.
|
|
4
|
+
*
|
|
5
|
+
* Without a revision: working tree vs HEAD (HEAD side via the git host API,
|
|
6
|
+
* working side via the workspace FileSystemProvider). With a revision: that
|
|
7
|
+
* commit vs its parent, both sides via readFileAtRevision. Absent sides
|
|
8
|
+
* render as empty text with an "(absent)" label; binary files short-circuit
|
|
9
|
+
* to a hint since there is no text diff to show.
|
|
10
|
+
*/
|
|
11
|
+
import { useEffect, useState } from 'react';
|
|
12
|
+
import { getFileSystemProviderV2, parseWorkspacePath } from '@bendyline/docblocks/filesystem';
|
|
13
|
+
import { Dialog } from '../components/Dialog.js';
|
|
14
|
+
import { useGitContext } from './GitContext.js';
|
|
15
|
+
import { GitDiffView } from './GitDiffView.js';
|
|
16
|
+
export function GitDiffDialog({ path, revision, onClose }) {
|
|
17
|
+
const git = useGitContext();
|
|
18
|
+
const gitApi = git?.gitApi ?? null;
|
|
19
|
+
const provider = git?.provider ?? null;
|
|
20
|
+
const repositoryId = git?.repositoryId ?? null;
|
|
21
|
+
const sha = revision?.sha ?? null;
|
|
22
|
+
const [state, setState] = useState({ phase: 'loading' });
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!gitApi || !repositoryId) {
|
|
25
|
+
setState({ phase: 'error', message: 'Git is not available for this workspace.' });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let cancelled = false;
|
|
29
|
+
setState({ phase: 'loading' });
|
|
30
|
+
const load = async () => {
|
|
31
|
+
if (sha) {
|
|
32
|
+
const short = sha.slice(0, 7);
|
|
33
|
+
const [parent, at] = await Promise.all([
|
|
34
|
+
gitApi.readFileAtRevision(repositoryId, path, { kind: 'parent-of', sha }),
|
|
35
|
+
gitApi.readFileAtRevision(repositoryId, path, { kind: 'commit', sha }),
|
|
36
|
+
]);
|
|
37
|
+
if (!parent.ok)
|
|
38
|
+
return { phase: 'error', message: parent.error.message };
|
|
39
|
+
if (!at.ok)
|
|
40
|
+
return { phase: 'error', message: at.error.message };
|
|
41
|
+
if ((parent.value.content === null && parent.value.binary) ||
|
|
42
|
+
(at.value.content === null && at.value.binary)) {
|
|
43
|
+
return { phase: 'binary' };
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
phase: 'ready',
|
|
47
|
+
original: parent.value.content ?? '',
|
|
48
|
+
modified: at.value.content ?? '',
|
|
49
|
+
labels: {
|
|
50
|
+
original: parent.value.content === null ? `${short}^ (absent)` : `${short}^`,
|
|
51
|
+
modified: at.value.content === null ? `${short} (absent)` : short,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!provider) {
|
|
56
|
+
return { phase: 'error', message: 'Workspace files are not available.' };
|
|
57
|
+
}
|
|
58
|
+
const providerV2 = getFileSystemProviderV2(provider);
|
|
59
|
+
const [head, working] = await Promise.all([
|
|
60
|
+
gitApi.readFileAtRevision(repositoryId, path, { kind: 'head' }),
|
|
61
|
+
providerV2
|
|
62
|
+
? providerV2
|
|
63
|
+
.readFile(parseWorkspacePath(path))
|
|
64
|
+
.then((file) => (file ? new TextDecoder().decode(file.data) : null))
|
|
65
|
+
: provider.readFile(path),
|
|
66
|
+
]);
|
|
67
|
+
if (!head.ok)
|
|
68
|
+
return { phase: 'error', message: head.error.message };
|
|
69
|
+
if (head.value.content === null && head.value.binary)
|
|
70
|
+
return { phase: 'binary' };
|
|
71
|
+
return {
|
|
72
|
+
phase: 'ready',
|
|
73
|
+
original: head.value.content ?? '',
|
|
74
|
+
modified: working ?? '',
|
|
75
|
+
labels: {
|
|
76
|
+
original: head.value.content === null ? 'HEAD (absent)' : 'HEAD',
|
|
77
|
+
modified: working === null ? 'Working tree (absent)' : 'Working tree',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
load()
|
|
82
|
+
.catch((err) => ({
|
|
83
|
+
phase: 'error',
|
|
84
|
+
message: err instanceof Error ? err.message : 'Failed to load the diff',
|
|
85
|
+
}))
|
|
86
|
+
.then((next) => {
|
|
87
|
+
if (!cancelled)
|
|
88
|
+
setState(next);
|
|
89
|
+
});
|
|
90
|
+
return () => {
|
|
91
|
+
cancelled = true;
|
|
92
|
+
};
|
|
93
|
+
}, [gitApi, provider, repositoryId, path, sha]);
|
|
94
|
+
if (!git)
|
|
95
|
+
return null;
|
|
96
|
+
const fullPath = path.replace(/^\/+/, '');
|
|
97
|
+
const baseName = fullPath.split('/').pop() || fullPath;
|
|
98
|
+
return (_jsxs(Dialog, { title: baseName, size: "full", onClose: onClose, children: [_jsx("p", { className: "db-settings-hint", children: fullPath }), state.phase === 'loading' && _jsx("p", { className: "db-git-hint", children: "Loading changes\u2026" }), state.phase === 'error' && (_jsx("p", { className: "db-git-form-error", role: "alert", children: state.message })), state.phase === 'binary' && (_jsx("p", { className: "db-git-hint", children: "Binary file \u2014 no text diff available." })), state.phase === 'ready' && (_jsx(GitDiffView, { original: state.original, modified: state.modified, fileName: baseName, theme: git.theme, labels: state.labels }))] }));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=GitDiffDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitDiffDialog.js","sourceRoot":"","sources":["../../src/Git/GitDiffDialog.tsx"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAqB/C,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAsB;IAC3E,MAA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CAAC,MAAM,GACpB,CACH,IACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitDiffView — read-only Monaco side-by-side diff.
|
|
3
|
+
*
|
|
4
|
+
* Monaco is never statically imported: squisq's useMonacoLoader() lazily
|
|
5
|
+
* imports the editor bundle once per page and hands back the namespace.
|
|
6
|
+
* The diff editor and both text models are created imperatively into a
|
|
7
|
+
* host div and disposed on unmount (the classic Monaco leak). Content and
|
|
8
|
+
* theme changes update the existing editor without recreating it.
|
|
9
|
+
*/
|
|
10
|
+
export interface GitDiffViewProps {
|
|
11
|
+
original: string;
|
|
12
|
+
modified: string;
|
|
13
|
+
/** Used for language detection (markdown for .md, plain text otherwise). */
|
|
14
|
+
fileName: string;
|
|
15
|
+
theme: 'light' | 'dark';
|
|
16
|
+
/** Optional column headers rendered above the two panes. */
|
|
17
|
+
labels?: {
|
|
18
|
+
original: string;
|
|
19
|
+
modified: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function GitDiffView({ original, modified, fileName, theme, labels }: GitDiffViewProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=GitDiffView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitDiffView.d.ts","sourceRoot":"","sources":["../../src/Git/GitDiffView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,4DAA4D;IAC5D,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAQD,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,gBAAgB,2CAmE5F"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GitDiffView — read-only Monaco side-by-side diff.
|
|
4
|
+
*
|
|
5
|
+
* Monaco is never statically imported: squisq's useMonacoLoader() lazily
|
|
6
|
+
* imports the editor bundle once per page and hands back the namespace.
|
|
7
|
+
* The diff editor and both text models are created imperatively into a
|
|
8
|
+
* host div and disposed on unmount (the classic Monaco leak). Content and
|
|
9
|
+
* theme changes update the existing editor without recreating it.
|
|
10
|
+
*/
|
|
11
|
+
import { useEffect, useRef } from 'react';
|
|
12
|
+
import { detectLanguageFromFileName, useMonacoLoader, } from '@bendyline/squisq-editor-react';
|
|
13
|
+
function languageFor(fileName) {
|
|
14
|
+
const detected = detectLanguageFromFileName(fileName);
|
|
15
|
+
if (detected)
|
|
16
|
+
return detected;
|
|
17
|
+
return fileName.toLowerCase().endsWith('.md') ? 'markdown' : 'plaintext';
|
|
18
|
+
}
|
|
19
|
+
export function GitDiffView({ original, modified, fileName, theme, labels }) {
|
|
20
|
+
const { monaco, ready } = useMonacoLoader();
|
|
21
|
+
const hostRef = useRef(null);
|
|
22
|
+
const editorRef = useRef(null);
|
|
23
|
+
const modelsRef = useRef(null);
|
|
24
|
+
const language = languageFor(fileName);
|
|
25
|
+
// Create the editor once monaco settles; dispose editor AND models on unmount.
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const host = hostRef.current;
|
|
28
|
+
if (!monaco || !host)
|
|
29
|
+
return;
|
|
30
|
+
const originalModel = monaco.editor.createModel('', 'plaintext');
|
|
31
|
+
const modifiedModel = monaco.editor.createModel('', 'plaintext');
|
|
32
|
+
const editor = monaco.editor.createDiffEditor(host, {
|
|
33
|
+
readOnly: true,
|
|
34
|
+
renderSideBySide: true,
|
|
35
|
+
automaticLayout: true,
|
|
36
|
+
minimap: { enabled: false },
|
|
37
|
+
wordWrap: 'on',
|
|
38
|
+
scrollBeyondLastLine: false,
|
|
39
|
+
renderOverviewRuler: false,
|
|
40
|
+
});
|
|
41
|
+
editor.setModel({ original: originalModel, modified: modifiedModel });
|
|
42
|
+
editorRef.current = editor;
|
|
43
|
+
modelsRef.current = { original: originalModel, modified: modifiedModel };
|
|
44
|
+
return () => {
|
|
45
|
+
editorRef.current = null;
|
|
46
|
+
modelsRef.current = null;
|
|
47
|
+
editor.dispose();
|
|
48
|
+
originalModel.dispose();
|
|
49
|
+
modifiedModel.dispose();
|
|
50
|
+
};
|
|
51
|
+
}, [monaco]);
|
|
52
|
+
// Sync content + language into the existing models — never recreate the editor.
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!monaco)
|
|
55
|
+
return;
|
|
56
|
+
const models = modelsRef.current;
|
|
57
|
+
if (!models)
|
|
58
|
+
return;
|
|
59
|
+
if (models.original.getValue() !== original)
|
|
60
|
+
models.original.setValue(original);
|
|
61
|
+
if (models.modified.getValue() !== modified)
|
|
62
|
+
models.modified.setValue(modified);
|
|
63
|
+
monaco.editor.setModelLanguage(models.original, language);
|
|
64
|
+
monaco.editor.setModelLanguage(models.modified, language);
|
|
65
|
+
}, [monaco, original, modified, language]);
|
|
66
|
+
// React to theme prop changes.
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!monaco)
|
|
69
|
+
return;
|
|
70
|
+
monaco.editor.setTheme(theme === 'dark' ? 'vs-dark' : 'vs');
|
|
71
|
+
}, [monaco, theme]);
|
|
72
|
+
if (!ready) {
|
|
73
|
+
return _jsx("div", { className: "db-git-diff-loading", children: "Loading diff\u2026" });
|
|
74
|
+
}
|
|
75
|
+
return (_jsxs(_Fragment, { children: [labels && (_jsxs("div", { className: "db-git-diff-labels", children: [_jsx("span", { children: labels.original }), _jsx("span", { children: labels.modified })] })), _jsx("div", { ref: hostRef, className: "db-git-diff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AQ,EAAE,KAAK,QAAQ;YAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChF,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE3C,+BAA+B;IAC/B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAEpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,cAAK,SAAS,EAAC,qBAAqB,mCAAoB,CAAC;IAClE,CAAC;IAED,OAAO,CACL,8BACG,MAAM,IAAI,CACT,eAAK,SAAS,EAAC,oBAAoB,aACjC,yBAAO,MAAM,CAAC,QAAQ,GAAQ,EAC9B,yBAAO,MAAM,CAAC,QAAQ,GAAQ,IAC1B,CACP,EACD,cAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,kBAAkB,GAAG,IACjD,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHistoryDialog — paged commit log for the repository or a single file.
|
|
3
|
+
*
|
|
4
|
+
* Pages `git log` 50 commits at a time; a row expands (one at a time) to
|
|
5
|
+
* show the full message body and the files changed in that commit — each
|
|
6
|
+
* file opens the commit-vs-parent diff dialog (which replaces this one;
|
|
7
|
+
* acceptable for v1).
|
|
8
|
+
*/
|
|
9
|
+
export interface GitHistoryDialogProps {
|
|
10
|
+
/** Slash-prefixed workspace-relative path; absent → whole-repo history. */
|
|
11
|
+
path?: string;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function GitHistoryDialog({ path, onClose }: GitHistoryDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
//# sourceMappingURL=GitHistoryDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHistoryDialog.d.ts","sourceRoot":"","sources":["../../src/Git/GitHistoryDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAsBD,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,qBAAqB,kDAyJxE"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GitHistoryDialog — paged commit log for the repository or a single file.
|
|
4
|
+
*
|
|
5
|
+
* Pages `git log` 50 commits at a time; a row expands (one at a time) to
|
|
6
|
+
* show the full message body and the files changed in that commit — each
|
|
7
|
+
* file opens the commit-vs-parent diff dialog (which replaces this one;
|
|
8
|
+
* acceptable for v1).
|
|
9
|
+
*/
|
|
10
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
11
|
+
import { Dialog } from '../components/Dialog.js';
|
|
12
|
+
import { useGitContext } from './GitContext.js';
|
|
13
|
+
import { BADGE_GLYPHS, BADGE_LABELS, badgeKindFor } from './git-status.js';
|
|
14
|
+
const PAGE_SIZE = 50;
|
|
15
|
+
/** Message body beyond the subject line, or '' when it adds nothing. */
|
|
16
|
+
function extraBody(body, subject) {
|
|
17
|
+
const trimmedBody = body.trim();
|
|
18
|
+
const trimmedSubject = subject.trim();
|
|
19
|
+
if (!trimmedBody || trimmedBody === trimmedSubject)
|
|
20
|
+
return '';
|
|
21
|
+
if (trimmedBody.startsWith(trimmedSubject)) {
|
|
22
|
+
return trimmedBody.slice(trimmedSubject.length).trim();
|
|
23
|
+
}
|
|
24
|
+
return trimmedBody;
|
|
25
|
+
}
|
|
26
|
+
function formatDate(iso) {
|
|
27
|
+
const date = new Date(iso);
|
|
28
|
+
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
29
|
+
}
|
|
30
|
+
export function GitHistoryDialog({ path, onClose }) {
|
|
31
|
+
const git = useGitContext();
|
|
32
|
+
const gitApi = git?.gitApi ?? null;
|
|
33
|
+
const repositoryId = git?.repositoryId ?? null;
|
|
34
|
+
const [entries, setEntries] = useState([]);
|
|
35
|
+
const [loading, setLoading] = useState(false);
|
|
36
|
+
const [error, setError] = useState(null);
|
|
37
|
+
const [hasMore, setHasMore] = useState(false);
|
|
38
|
+
const [expandedSha, setExpandedSha] = useState(null);
|
|
39
|
+
const [details, setDetails] = useState(new Map());
|
|
40
|
+
const loadPage = useCallback(async (skip) => {
|
|
41
|
+
if (!gitApi || !repositoryId)
|
|
42
|
+
return;
|
|
43
|
+
setLoading(true);
|
|
44
|
+
setError(null);
|
|
45
|
+
try {
|
|
46
|
+
const result = await gitApi.log(repositoryId, { path, maxCount: PAGE_SIZE, skip });
|
|
47
|
+
if (!result.ok) {
|
|
48
|
+
setError(result.error.message);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setEntries((prev) => (skip === 0 ? result.value : [...prev, ...result.value]));
|
|
52
|
+
setHasMore(result.value.length === PAGE_SIZE);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
setLoading(false);
|
|
56
|
+
}
|
|
57
|
+
}, [gitApi, repositoryId, path]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setEntries([]);
|
|
60
|
+
setExpandedSha(null);
|
|
61
|
+
setDetails(new Map());
|
|
62
|
+
setHasMore(false);
|
|
63
|
+
void loadPage(0);
|
|
64
|
+
}, [loadPage]);
|
|
65
|
+
const handleRowClick = (sha) => {
|
|
66
|
+
if (expandedSha === sha) {
|
|
67
|
+
setExpandedSha(null);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setExpandedSha(sha);
|
|
71
|
+
if (!gitApi || !repositoryId || details.has(sha))
|
|
72
|
+
return;
|
|
73
|
+
void gitApi.commitFiles(repositoryId, sha).then((result) => {
|
|
74
|
+
setDetails((prev) => {
|
|
75
|
+
const next = new Map(prev);
|
|
76
|
+
next.set(sha, result.ok ? result.value : { error: result.error.message });
|
|
77
|
+
return next;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
if (!git)
|
|
82
|
+
return null;
|
|
83
|
+
const baseName = path ? path.replace(/^\/+/, '').split('/').pop() : null;
|
|
84
|
+
const title = baseName ? `History — ${baseName}` : 'Commit history';
|
|
85
|
+
return (_jsxs(Dialog, { title: title, size: "wide", onClose: onClose, children: [error && (_jsx("p", { className: "db-git-form-error", role: "alert", children: error })), !error && entries.length === 0 && loading && _jsx("p", { className: "db-git-hint", children: "Loading history\u2026" }), !error && entries.length === 0 && !loading && _jsx("p", { className: "db-git-hint", children: "No commits yet." }), entries.length > 0 && (_jsx("ul", { className: "db-git-history-list", children: entries.map((entry) => {
|
|
86
|
+
const expanded = expandedSha === entry.sha;
|
|
87
|
+
const detail = details.get(entry.sha);
|
|
88
|
+
const meta = [
|
|
89
|
+
entry.authorName,
|
|
90
|
+
entry.sha.slice(0, 7),
|
|
91
|
+
formatDate(entry.authorDate),
|
|
92
|
+
entry.refs.join(', '),
|
|
93
|
+
]
|
|
94
|
+
.filter(Boolean)
|
|
95
|
+
.join(' · ');
|
|
96
|
+
const body = detail && !('error' in detail) ? extraBody(detail.body, entry.subject) : '';
|
|
97
|
+
return (_jsxs("li", { className: "db-git-history-item", children: [_jsxs("button", { type: "button", className: "db-git-history-toggle", "aria-expanded": expanded, onClick: () => handleRowClick(entry.sha), children: [_jsx("span", { className: "db-git-history-subject", children: entry.subject }), _jsx("span", { className: "db-git-history-meta", children: meta })] }), expanded && !detail && _jsx("p", { className: "db-git-hint", children: "Loading\u2026" }), expanded && detail && 'error' in detail && (_jsx("p", { className: "db-git-form-error", role: "alert", children: detail.error })), expanded && detail && !('error' in detail) && (_jsxs(_Fragment, { children: [body && _jsx("pre", { className: "db-git-history-body", children: body }), _jsx("ul", { className: "db-git-history-files", children: detail.files.map((file) => {
|
|
98
|
+
const kind = badgeKindFor(file);
|
|
99
|
+
return (_jsx("li", { children: _jsxs("button", { type: "button", className: "db-git-history-file", onClick: () => git.openDialog({
|
|
100
|
+
kind: 'diff',
|
|
101
|
+
path: file.path,
|
|
102
|
+
revision: { sha: entry.sha },
|
|
103
|
+
}), children: [_jsx("span", { className: "db-git-file-kind", "aria-label": BADGE_LABELS[kind], title: BADGE_LABELS[kind], children: BADGE_GLYPHS[kind] }), file.path.replace(/^\/+/, '')] }) }, file.path));
|
|
104
|
+
}) })] }))] }, entry.sha));
|
|
105
|
+
}) })), hasMore && (_jsx("button", { type: "button", className: "db-git-secondary-btn", disabled: loading, onClick: () => void loadPage(entries.length), children: "Show older commits" }))] }));
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=GitHistoryDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHistoryDialog.js","sourceRoot":"","sources":["../../src/Git/GitHistoryDialog.tsx"],"names":[],"mappings":";AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAA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qBb,CACN,CAAC;wCACJ,CAAC,CAAC,GACC,IACJ,CACJ,KAjDM,KAAK,CAAC,GAAG,CAkDb,CACN,CAAC;gBACJ,CAAC,CAAC,GACC,CACN,EACA,OAAO,IAAI,CACV,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,sBAAsB,EAChC,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,mCAGrC,CACV,IACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitStatusBar — slim sidebar row showing branch, ahead/behind, and dirty
|
|
3
|
+
* count, with the repo actions menu (commit, sync, branches, history,
|
|
4
|
+
* remote conveniences). Renders nothing unless the active workspace is a
|
|
5
|
+
* git repository.
|
|
6
|
+
*/
|
|
7
|
+
export declare function GitStatusBar(): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=GitStatusBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitStatusBar.d.ts","sourceRoot":"","sources":["../../src/Git/GitStatusBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,wBAAgB,YAAY,mDAiJ3B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GitStatusBar — slim sidebar row showing branch, ahead/behind, and dirty
|
|
4
|
+
* count, with the repo actions menu (commit, sync, branches, history,
|
|
5
|
+
* remote conveniences). Renders nothing unless the active workspace is a
|
|
6
|
+
* git repository.
|
|
7
|
+
*/
|
|
8
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { useGitContext } from './GitContext.js';
|
|
10
|
+
import { formatAheadBehind, summarizeDirty } from './git-status.js';
|
|
11
|
+
export function GitStatusBar() {
|
|
12
|
+
const git = useGitContext();
|
|
13
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
14
|
+
const rootRef = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!menuOpen)
|
|
17
|
+
return;
|
|
18
|
+
const onPointerDown = (e) => {
|
|
19
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) {
|
|
20
|
+
setMenuOpen(false);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
document.addEventListener('pointerdown', onPointerDown);
|
|
24
|
+
return () => document.removeEventListener('pointerdown', onPointerDown);
|
|
25
|
+
}, [menuOpen]);
|
|
26
|
+
const runItem = useCallback((action) => {
|
|
27
|
+
setMenuOpen(false);
|
|
28
|
+
action();
|
|
29
|
+
}, []);
|
|
30
|
+
if (!git || !git.repo || !git.status)
|
|
31
|
+
return null;
|
|
32
|
+
const { status } = git;
|
|
33
|
+
const branchLabel = status.detached ? 'detached HEAD' : (status.branch ?? 'no branch');
|
|
34
|
+
const aheadBehind = formatAheadBehind(status);
|
|
35
|
+
const dirty = summarizeDirty(status);
|
|
36
|
+
const merging = status.operation === 'merge';
|
|
37
|
+
const chipLabelParts = [`Git: branch ${branchLabel}`];
|
|
38
|
+
if (status.ahead > 0)
|
|
39
|
+
chipLabelParts.push(`${status.ahead} ahead`);
|
|
40
|
+
if (status.behind > 0)
|
|
41
|
+
chipLabelParts.push(`${status.behind} behind`);
|
|
42
|
+
if (dirty)
|
|
43
|
+
chipLabelParts.push(dirty);
|
|
44
|
+
if (merging)
|
|
45
|
+
chipLabelParts.push('merge in progress');
|
|
46
|
+
const canCreatePr = git.capabilities?.ghAvailable === true && git.remoteWeb?.host === 'github.com';
|
|
47
|
+
return (_jsxs("div", { ref: rootRef, className: "db-git-statusbar", children: [_jsxs("button", { type: "button", className: "db-git-statusbar-chip", onClick: () => setMenuOpen((open) => !open), "aria-haspopup": "menu", "aria-expanded": menuOpen, "aria-label": chipLabelParts.join(', '), title: chipLabelParts.join(', '), children: [_jsx("span", { className: "db-git-branch-glyph", "aria-hidden": "true", children: '⎇' }), _jsx("span", { className: "db-git-statusbar-branch", children: branchLabel }), aheadBehind && _jsx("span", { className: "db-git-statusbar-counts", children: aheadBehind }), dirty && _jsx("span", { className: "db-git-statusbar-dirty", children: dirty }), merging && _jsx("span", { className: "db-git-statusbar-merge", children: "merging" }), git.busy && (_jsx("span", { className: "db-git-statusbar-busy", "aria-hidden": "true", children: '…' }))] }), menuOpen && (_jsxs("div", { className: "db-git-menu", role: "menu", "aria-label": "Git actions", children: [_jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", disabled: status.changes.length === 0 && !merging, onClick: () => runItem(() => git.openDialog({ kind: 'commit' })), children: merging ? 'Commit merge…' : 'Commit…' }), _jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", disabled: git.busy !== null, onClick: () => runItem(() => void git.push()), children: status.upstream === null && !status.unborn ? 'Publish branch' : 'Push' }), _jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", disabled: git.busy !== null, onClick: () => runItem(() => void git.pull()), children: "Pull" }), _jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", disabled: git.busy !== null, onClick: () => runItem(() => void git.fetchRemote()), children: "Fetch" }), _jsx("div", { className: "db-git-menu-divider", role: "separator" }), _jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", onClick: () => runItem(() => git.openDialog({ kind: 'branches' })), children: "Branches\u2026" }), _jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", onClick: () => runItem(() => git.openDialog({ kind: 'history' })), children: "Commit history\u2026" }), (git.remoteWeb || canCreatePr) && (_jsx("div", { className: "db-git-menu-divider", role: "separator" })), git.remoteWeb && (_jsxs("button", { type: "button", role: "menuitem", className: "db-git-menu-item", onClick: () => runItem(() => git.openOnRemote()), children: ["Open on ", git.remoteWeb.host] })), canCreatePr && (_jsx("button", { type: "button", role: "menuitem", className: "db-git-menu-item", disabled: git.busy !== null, onClick: () => runItem(() => void git.createPullRequest()), children: "Create pull request" }))] }))] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=GitStatusBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitStatusBar.js","sourceRoot":"","sources":["../../src/Git/GitStatusBar.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,UAAU,YAAY;IAC1B,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,aAAa,GAAG,CAAC,CAAe,EAAE,EAAE;YACxC,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAc,CAAC,EAAE,CAAC;gBACnE,WAAW,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACxD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,MAAkB,EAAE,EAAE;QACjD,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,EAA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