dsh-explorer 0.1.0 → 0.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/lib/client.js +817 -2772
- package/lib/index.js +124 -17
- package/package.json +1 -2
- package/src/client/ExplorerView.tsx +494 -652
- package/src/client/{ExplorerContextMenu.tsx → components/ExplorerContextMenu.tsx} +2 -4
- package/src/client/components/ExplorerDeleteModal.tsx +124 -0
- package/src/client/components/ExplorerEmptyContextMenu.tsx +125 -0
- package/src/client/{ExplorerHeader.tsx → components/ExplorerHeader.tsx} +18 -12
- package/src/client/{ExplorerOptionsModal.tsx → components/ExplorerOptionsModal.tsx} +2 -15
- package/src/client/{ExplorerRow.tsx → components/ExplorerRow.tsx} +45 -27
- package/src/client/{ExplorerSearch.tsx → components/ExplorerSearch.tsx} +18 -5
- package/src/client/components/TreeNode.tsx +384 -0
- package/src/client/explorer.module.css +215 -10
- package/src/client/hooks/useKeyboardNav.ts +89 -0
- package/src/client/hooks/useLiveSync.ts +81 -0
- package/src/client/index.tsx +82 -4
- package/src/client/{api.ts → utils/api.ts} +133 -3
- package/src/client/{conversation-draft.ts → utils/conversation-draft.ts} +38 -29
- package/src/client/utils/open-tab.ts +69 -0
- package/src/fs-search.ts +116 -0
- package/src/git-status.ts +19 -13
- package/src/index.ts +12 -0
- /package/src/client/{drag-drop.ts → utils/drag-drop.ts} +0 -0
- /package/src/client/{options.ts → utils/options.ts} +0 -0
- /package/src/client/{vscode-theme.tsx → utils/vscode-theme.tsx} +0 -0
package/lib/client.js
CHANGED
|
@@ -4,981 +4,844 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
|
|
7
|
-
"use strict";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
-
mod
|
|
33
|
-
));
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
|
|
36
|
-
// src/client/index.tsx
|
|
37
|
-
var index_exports = {};
|
|
38
|
-
__export(index_exports, {
|
|
39
|
-
apply: () => apply,
|
|
40
|
-
inject: () => inject
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(index_exports);
|
|
43
|
-
var import_react6 = require("react");
|
|
44
|
-
|
|
45
|
-
// src/client/ExplorerView.tsx
|
|
46
|
-
var import_react5 = __toESM(require("react"), 1);
|
|
47
|
-
|
|
48
|
-
// src/client/explorer.module.css
|
|
49
|
-
var cssText = ".dsh-exp-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background-color: var(--dsh-bg-base, #181818);\n color: var(--dsh-fg-base, #cccccc);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n font-size: var(--dsh-font-size, 13px);\n user-select: none;\n overflow: hidden;\n box-sizing: border-box;\n position: relative;\n}\n\n.dsh-exp-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n font-size: 11px;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--dsh-fg-muted, #858585);\n border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.08));\n flex-shrink: 0;\n}\n\n.dsh-exp-headerTitle {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.dsh-exp-headerActions {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.dsh-exp-iconBtn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n border-radius: 4px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n opacity: 0.75;\n transition: opacity 0.15s cubic-bezier(0.2, 0, 0, 1), background-color 0.15s cubic-bezier(0.2, 0, 0, 1), transform 0.12s ease;\n}\n\n.dsh-exp-iconBtn:hover {\n opacity: 1;\n background-color: var(--dsh-bg-hover, rgba(255, 255, 255, 0.1));\n}\n\n.dsh-exp-iconBtn:active {\n transform: scale(0.92);\n}\n\n.dsh-exp-iconBtnActive {\n background-color: var(--dsh-bg-active, rgba(255, 255, 255, 0.15));\n opacity: 1;\n}\n\n.dsh-exp-searchBar {\n padding: 6px 10px;\n border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.06));\n background-color: var(--dsh-bg-subtle, rgba(0, 0, 0, 0.15));\n display: flex;\n align-items: center;\n gap: 6px;\n flex-shrink: 0;\n animation: searchSlide 0.16s cubic-bezier(0, 0, 0.2, 1);\n}\n\n@keyframes searchSlide {\n from {\n opacity: 0;\n transform: translateY(-6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n.dsh-exp-searchInput {\n flex: 1;\n background: var(--dsh-input-bg, rgba(255, 255, 255, 0.06));\n border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.12));\n border-radius: 4px;\n color: inherit;\n padding: 4px 8px;\n font-size: 12px;\n outline: none;\n transition: border-color 0.15s ease;\n}\n\n.dsh-exp-searchInput:focus {\n border-color: #007fd4;\n}\n\n.dsh-exp-clearSearchBtn {\n background: transparent;\n border: none;\n color: inherit;\n cursor: pointer;\n opacity: 0.6;\n font-size: 11px;\n transition: opacity 0.12s ease;\n}\n\n.dsh-exp-clearSearchBtn:hover {\n opacity: 1;\n}\n\n.dsh-exp-treeBody {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n padding: 4px 0;\n outline: none;\n}\n\n.dsh-exp-row {\n display: flex;\n align-items: center;\n height: var(--dsh-row-height, 24px);\n line-height: var(--dsh-row-height, 24px);\n padding-right: 8px;\n cursor: pointer;\n position: relative;\n transition: background-color 0.12s cubic-bezier(0.2, 0, 0, 1);\n}\n\n.dsh-exp-row:hover {\n background-color: var(--dsh-row-hover, rgba(255, 255, 255, 0.05));\n}\n\n.dsh-exp-rowSelected {\n background-color: var(--dsh-row-selected, rgba(0, 122, 204, 0.25)) !important;\n}\n\n.dsh-exp-rowFocused {\n outline: 1px solid #007fd4;\n outline-offset: -1px;\n}\n\n.dsh-exp-indentGuide {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 1px;\n background-color: rgba(255, 255, 255, 0.06);\n}\n\n.dsh-exp-chevron {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--dsh-icon-size, 16px);\n height: var(--dsh-icon-size, 16px);\n margin-right: 2px;\n color: inherit;\n opacity: 0.6;\n transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1), opacity 0.15s ease;\n flex-shrink: 0;\n will-change: transform;\n}\n\n.dsh-exp-chevronExpanded {\n transform: rotate(90deg);\n}\n\n.dsh-exp-chevronHidden {\n visibility: hidden;\n}\n\n/* Motion Collapse: CSS Grid animation for silky smooth folder expanding & collapsing */\n.dsh-exp-folderGroup {\n display: flex;\n flex-direction: column;\n}\n\n.dsh-exp-folderChildren {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.22s cubic-bezier(0.2, 0, 0, 1), opacity 0.18s ease;\n opacity: 0;\n overflow: hidden;\n will-change: grid-template-rows, opacity;\n}\n\n.dsh-exp-folderChildrenOpen {\n grid-template-rows: 1fr;\n opacity: 1;\n}\n\n.dsh-exp-folderChildrenClosed {\n grid-template-rows: 0fr;\n opacity: 0;\n pointer-events: none;\n}\n\n.dsh-exp-folderChildrenInner {\n overflow: hidden;\n min-height: 0;\n}\n\n.dsh-exp-iconWrap {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--dsh-icon-size, 18px);\n height: var(--dsh-icon-size, 18px);\n margin-right: 6px;\n flex-shrink: 0;\n}\n\n.dsh-exp-label {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--dsh-font-size, 13px);\n}\n\n.dsh-exp-labelDimmed {\n opacity: 0.5;\n}\n\n.dsh-exp-gitBadge {\n font-size: 10px;\n font-weight: 700;\n margin-left: auto;\n margin-right: 4px;\n padding: 1px 5px;\n border-radius: 3px;\n line-height: 1;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n letter-spacing: 0.04em;\n}\n\n.dsh-exp-gitModified {\n color: #e2c08d !important;\n}\n\n.dsh-exp-gitUntracked {\n color: #73c991 !important;\n}\n\n.dsh-exp-gitDeleted {\n color: #e5534b !important;\n}\n\n.dsh-exp-gitBadge.dsh-exp-gitModified {\n background-color: rgba(226, 192, 141, 0.18);\n}\n\n.dsh-exp-gitBadge.dsh-exp-gitUntracked {\n background-color: rgba(115, 201, 145, 0.18);\n}\n\n.dsh-exp-gitBadge.dsh-exp-gitDeleted {\n background-color: rgba(229, 83, 75, 0.18);\n}\n\n.dsh-exp-hoverActions {\n display: none;\n align-items: center;\n gap: 2px;\n margin-left: 4px;\n flex-shrink: 0;\n animation: actionsFadeIn 0.12s ease;\n}\n\n@keyframes actionsFadeIn {\n from {\n opacity: 0;\n transform: translateX(4px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n.dsh-exp-row:hover .dsh-exp-hoverActions {\n display: flex;\n}\n\n.dsh-exp-actionBtn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border-radius: 3px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n opacity: 0.7;\n padding: 0;\n transition: opacity 0.12s ease, background-color 0.12s ease, transform 0.12s ease;\n}\n\n.dsh-exp-actionBtn:hover {\n opacity: 1;\n background-color: rgba(255, 255, 255, 0.15);\n transform: scale(1.08);\n}\n\n.dsh-exp-actionBtn:active {\n transform: scale(0.92);\n}\n\n.dsh-exp-inlineInput {\n flex: 1;\n background: var(--dsh-input-bg, #252526);\n border: 1px solid #007fd4;\n border-radius: 2px;\n color: inherit;\n padding: 1px 4px;\n font-size: 12px;\n outline: none;\n height: 20px;\n}\n\n.dsh-exp-contextMenu {\n position: fixed;\n background: var(--dsh-menu-bg, #252526);\n border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.1));\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);\n border-radius: 6px;\n padding: 4px 0;\n z-index: 10000;\n min-width: 180px;\n font-size: 12px;\n color: var(--dsh-fg-base, #cccccc);\n animation: contextMenuPop 0.12s cubic-bezier(0, 0, 0.2, 1);\n transform-origin: top left;\n}\n\n@keyframes contextMenuPop {\n from {\n opacity: 0;\n transform: scale(0.96) translateY(-4px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n.dsh-exp-menuItem {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 5px 12px;\n cursor: pointer;\n transition: background-color 0.1s ease;\n}\n\n.dsh-exp-menuItem:hover {\n background-color: var(--dsh-menu-hover, #094771);\n color: #ffffff;\n}\n\n.dsh-exp-menuDivider {\n height: 1px;\n background-color: var(--dsh-border, rgba(255, 255, 255, 0.08));\n margin: 4px 0;\n}\n\n.dsh-exp-menuShortcut {\n font-size: 10px;\n opacity: 0.6;\n margin-left: 16px;\n}\n\n.dsh-exp-emptyState {\n padding: 24px 16px;\n text-align: center;\n opacity: 0.6;\n font-size: 12px;\n}\n\n/* Motion disable override */\n.dsh-exp-noMotion,\n.dsh-exp-noMotion * {\n transition: none !important;\n animation: none !important;\n}\n\n.dsh-exp-noMotion .dsh-exp-chevron,\n.dsh-exp-noMotion .dsh-exp-folderChildren,\n.dsh-exp-noMotion .dsh-exp-actionBtn,\n.dsh-exp-noMotion .dsh-exp-hoverActions,\n.dsh-exp-noMotion .dsh-exp-optionsPopover,\n.dsh-exp-noMotion .dsh-exp-contextMenu {\n transition: none !important;\n animation: none !important;\n}\n\n/* Options Popover */\n.dsh-exp-optionsPopover {\n position: absolute;\n top: 36px;\n right: 8px;\n width: 280px;\n max-width: calc(100% - 16px);\n max-height: calc(100% - 48px);\n background-color: var(--dsh-bg-elevated, #202020);\n border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.14));\n border-radius: 6px;\n box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);\n display: flex;\n flex-direction: column;\n z-index: 1000;\n overflow: hidden;\n animation: popoverFadeIn 0.15s cubic-bezier(0, 0, 0.2, 1);\n}\n\n@keyframes popoverFadeIn {\n from {\n opacity: 0;\n transform: translateY(-6px) scale(0.97);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.dsh-exp-optionsHeader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background-color: rgba(0, 0, 0, 0.25);\n border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.08));\n}\n\n.dsh-exp-optionsHeaderTitle {\n display: flex;\n align-items: center;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.05em;\n color: var(--dsh-fg-muted, #999999);\n}\n\n.dsh-exp-optionsIconBtn {\n background: transparent;\n border: none;\n color: inherit;\n opacity: 0.7;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 3px;\n border-radius: 3px;\n transition: opacity 0.15s ease, background-color 0.15s ease;\n}\n\n.dsh-exp-optionsIconBtn:hover {\n opacity: 1;\n background-color: rgba(255, 255, 255, 0.1);\n}\n\n.dsh-exp-optionsBody {\n overflow-y: auto;\n padding: 10px 12px;\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n.dsh-exp-optionsSection {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.dsh-exp-optionsSectionTitle {\n font-size: 10.5px;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n color: var(--dsh-fg-muted, #858585);\n margin-bottom: 2px;\n}\n\n.dsh-exp-optionsRow {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n}\n\n.dsh-exp-optionsLabelWrap {\n display: flex;\n flex-direction: column;\n gap: 1px;\n}\n\n.dsh-exp-optionsLabel {\n font-size: 12px;\n font-weight: 500;\n color: var(--dsh-fg-base, #cccccc);\n}\n\n.dsh-exp-optionsSubLabel {\n font-size: 10.5px;\n color: var(--dsh-fg-muted, #808080);\n}\n\n.dsh-exp-optionsBadge {\n font-size: 11px;\n font-weight: 600;\n padding: 1px 6px;\n border-radius: 3px;\n background-color: rgba(255, 255, 255, 0.08);\n color: var(--dsh-fg-base, #cccccc);\n font-family: monospace;\n}\n\n.dsh-exp-optionsMiniBtn {\n background: rgba(255, 255, 255, 0.08);\n border: none;\n color: inherit;\n font-size: 10px;\n padding: 1px 5px;\n border-radius: 3px;\n cursor: pointer;\n opacity: 0.8;\n transition: opacity 0.12s ease;\n}\n\n.dsh-exp-optionsMiniBtn:hover {\n opacity: 1;\n background: rgba(255, 255, 255, 0.16);\n}\n\n.dsh-exp-optionsSlider {\n width: 100%;\n accent-color: #007fd4;\n cursor: pointer;\n margin-top: 4px;\n height: 4px;\n}\n\n.dsh-exp-segmentGroup {\n display: flex;\n background: rgba(0, 0, 0, 0.25);\n border-radius: 4px;\n padding: 2px;\n gap: 2px;\n border: 1px solid rgba(255, 255, 255, 0.06);\n}\n\n.dsh-exp-segmentBtn {\n flex: 1;\n border: none;\n background: transparent;\n color: inherit;\n padding: 4px 6px;\n font-size: 11px;\n border-radius: 3px;\n cursor: pointer;\n text-align: center;\n opacity: 0.75;\n transition: all 0.15s ease;\n}\n\n.dsh-exp-segmentBtn:hover {\n opacity: 1;\n background: rgba(255, 255, 255, 0.06);\n}\n\n.dsh-exp-segmentBtnActive {\n background: var(--dsh-bg-active, #007fd4) !important;\n color: #ffffff !important;\n opacity: 1;\n font-weight: 600;\n}\n\n.dsh-exp-switch {\n position: relative;\n width: 32px;\n height: 18px;\n border-radius: 9px;\n background: rgba(255, 255, 255, 0.16);\n cursor: pointer;\n transition: background 0.2s ease;\n flex-shrink: 0;\n}\n\n.dsh-exp-switchActive {\n background: #007fd4;\n}\n\n.dsh-exp-switchKnob {\n position: absolute;\n top: 2px;\n left: 2px;\n width: 14px;\n height: 14px;\n border-radius: 50%;\n background: #ffffff;\n transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);\n}\n\n.dsh-exp-switchKnobActive {\n transform: translateX(14px);\n}\n";
|
|
50
|
-
if (typeof document !== "undefined") {
|
|
51
|
-
let style = document.getElementById("dsh-explorer-styles");
|
|
52
|
-
if (!style) {
|
|
53
|
-
style = document.createElement("style");
|
|
54
|
-
style.id = "dsh-explorer-styles";
|
|
55
|
-
style.textContent = cssText;
|
|
56
|
-
document.head.appendChild(style);
|
|
57
|
-
}
|
|
7
|
+
"use strict";var wn=Object.create;var dt=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var Ln=(e,n)=>{for(var o in n)dt(e,o,{get:n[o],enumerable:!0})},jt=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of En(n))!kn.call(e,s)&&s!==o&&dt(e,s,{get:()=>n[s],enumerable:!(t=Cn(n,s))||t.enumerable});return e};var Nn=(e,n,o)=>(o=e!=null?wn(Sn(e)):{},jt(n||!e||!e.__esModule?dt(o,"default",{value:e,enumerable:!0}):o,e)),Dn=e=>jt(dt({},"__esModule",{value:!0}),e);var On={};Ln(On,{apply:()=>$n,inject:()=>In});module.exports=Dn(On);var ot=require("react");var y=require("react");var Rn=`.dsh-exp-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
height: 100%;
|
|
11
|
+
width: 100%;
|
|
12
|
+
background-color: var(--dsh-bg-base, #181818);
|
|
13
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
14
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
15
|
+
font-size: var(--dsh-font-size, 13px);
|
|
16
|
+
user-select: none;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
position: relative;
|
|
58
20
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!json.ok) throw new Error(json.message || "Failed to fetch directory");
|
|
73
|
-
return json.listing;
|
|
74
|
-
}
|
|
75
|
-
async function fetchBatchTree(paths) {
|
|
76
|
-
const res = await fetch("/dsh-explorer/api/batch-tree", {
|
|
77
|
-
method: "POST",
|
|
78
|
-
headers: { "Content-Type": "application/json" },
|
|
79
|
-
body: JSON.stringify({ paths })
|
|
80
|
-
});
|
|
81
|
-
const json = await res.json();
|
|
82
|
-
if (!json.ok) throw new Error(json.message || "Failed to fetch batch trees");
|
|
83
|
-
return json.results;
|
|
84
|
-
}
|
|
85
|
-
async function fetchGitStatus(sessionId, dir) {
|
|
86
|
-
const params = new URLSearchParams();
|
|
87
|
-
if (sessionId) params.set("sessionId", sessionId);
|
|
88
|
-
if (dir) params.set("dir", dir);
|
|
89
|
-
const res = await fetch(`/dsh-explorer/api/git-status?${params.toString()}`);
|
|
90
|
-
const json = await res.json();
|
|
91
|
-
if (!json.ok) return { isRepo: false, entries: [] };
|
|
92
|
-
return json.git;
|
|
93
|
-
}
|
|
94
|
-
async function fetchFileContent(path) {
|
|
95
|
-
const params = new URLSearchParams({ path });
|
|
96
|
-
const res = await fetch(`/dsh-explorer/api/read-file?${params.toString()}`);
|
|
97
|
-
const json = await res.json();
|
|
98
|
-
if (!json.ok) throw new Error(json.message || "Failed to read file");
|
|
99
|
-
return json.text;
|
|
100
|
-
}
|
|
101
|
-
async function apiCreateNewFile(dir, name) {
|
|
102
|
-
const res = await fetch("/dsh-explorer/api/new-file", {
|
|
103
|
-
method: "POST",
|
|
104
|
-
headers: { "Content-Type": "application/json" },
|
|
105
|
-
body: JSON.stringify({ dir, name })
|
|
106
|
-
});
|
|
107
|
-
const json = await res.json();
|
|
108
|
-
if (!json.ok) throw new Error(json.message || "Failed to create file");
|
|
109
|
-
return json;
|
|
110
|
-
}
|
|
111
|
-
async function apiCreateDirectory(dir, name) {
|
|
112
|
-
const res = await fetch("/dsh-explorer/api/mkdir", {
|
|
113
|
-
method: "POST",
|
|
114
|
-
headers: { "Content-Type": "application/json" },
|
|
115
|
-
body: JSON.stringify({ dir, name })
|
|
116
|
-
});
|
|
117
|
-
const json = await res.json();
|
|
118
|
-
if (!json.ok) throw new Error(json.message || "Failed to create folder");
|
|
119
|
-
return json;
|
|
120
|
-
}
|
|
121
|
-
async function apiRename(path, newName) {
|
|
122
|
-
const res = await fetch("/dsh-explorer/api/rename", {
|
|
123
|
-
method: "POST",
|
|
124
|
-
headers: { "Content-Type": "application/json" },
|
|
125
|
-
body: JSON.stringify({ path, newName })
|
|
126
|
-
});
|
|
127
|
-
const json = await res.json();
|
|
128
|
-
if (!json.ok) throw new Error(json.message || "Failed to rename");
|
|
129
|
-
return json;
|
|
130
|
-
}
|
|
131
|
-
async function apiDelete(path) {
|
|
132
|
-
const res = await fetch("/dsh-explorer/api/delete", {
|
|
133
|
-
method: "POST",
|
|
134
|
-
headers: { "Content-Type": "application/json" },
|
|
135
|
-
body: JSON.stringify({ path })
|
|
136
|
-
});
|
|
137
|
-
const json = await res.json();
|
|
138
|
-
if (!json.ok) throw new Error(json.message || "Failed to delete");
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/client/ExplorerHeader.tsx
|
|
142
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
143
|
-
var ExplorerHeader = ({
|
|
144
|
-
title,
|
|
145
|
-
searchOpen,
|
|
146
|
-
optionsOpen,
|
|
147
|
-
onToggleSearch,
|
|
148
|
-
onToggleOptions,
|
|
149
|
-
onNewFile,
|
|
150
|
-
onNewFolder,
|
|
151
|
-
onRefresh,
|
|
152
|
-
onCollapseAll
|
|
153
|
-
}) => {
|
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: explorer_default.header, children: [
|
|
155
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: explorer_default.headerTitle, title, children: title }),
|
|
156
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: explorer_default.headerActions, children: [
|
|
157
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
|
-
"button",
|
|
159
|
-
{
|
|
160
|
-
className: `${explorer_default.iconBtn} ${searchOpen ? explorer_default.iconBtnActive : ""}`,
|
|
161
|
-
title: "Filter files",
|
|
162
|
-
onClick: onToggleSearch,
|
|
163
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" }) })
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: explorer_default.iconBtn, title: "New File", onClick: onNewFile, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 1H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6L9 1zm0 1.5L12.5 6H9V2.5zM8 8.5V11h1V8.5h2.5v-1H9V5H8v2.5H5.5v1H8z" }) }) }),
|
|
167
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: explorer_default.iconBtn, title: "New Folder", onClick: onNewFolder, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M7 2l2 2h5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h5zm2.5 6.5H8V6H7v2.5H4.5v1H7V12h1V9.5h2.5v-1z" }) }) }),
|
|
168
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: explorer_default.iconBtn, title: "Refresh", onClick: onRefresh, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13.65 2.35A7.958 7.958 0 0 0 8 0a8 8 0 1 0 8 8h-2a6 6 0 1 1-1.76-4.24l-2.24 2.24H16V0l-2.35 2.35z" }) }) }),
|
|
169
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: explorer_default.iconBtn, title: "Collapse All Folders", onClick: onCollapseAll, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M1 3.5l1.5-1.5L8 7.5 13.5 2 15 3.5 8 10.5 1 3.5zM1 9.5l1.5-1.5L8 13.5 13.5 8 15 9.5 8 16.5 1 9.5z" }) }) }),
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
|
-
"button",
|
|
172
|
-
{
|
|
173
|
-
className: `${explorer_default.iconBtn} ${optionsOpen ? explorer_default.iconBtnActive : ""}`,
|
|
174
|
-
title: "Explorer Options",
|
|
175
|
-
onClick: onToggleOptions,
|
|
176
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z" }) })
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
] })
|
|
180
|
-
] });
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
// src/client/ExplorerSearch.tsx
|
|
184
|
-
var import_react = require("react");
|
|
185
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
186
|
-
var ExplorerSearch = ({ value, onChange, onClose }) => {
|
|
187
|
-
const inputRef = (0, import_react.useRef)(null);
|
|
188
|
-
(0, import_react.useEffect)(() => {
|
|
189
|
-
inputRef.current?.focus();
|
|
190
|
-
}, []);
|
|
191
|
-
const handleKeyDown = (e) => {
|
|
192
|
-
if (e.key === "Escape") {
|
|
193
|
-
onClose();
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: explorer_default.searchBar, children: [
|
|
197
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
198
|
-
"input",
|
|
199
|
-
{
|
|
200
|
-
ref: inputRef,
|
|
201
|
-
type: "text",
|
|
202
|
-
className: explorer_default.searchInput,
|
|
203
|
-
placeholder: "Filter by name (fuzzy)...",
|
|
204
|
-
value,
|
|
205
|
-
onChange: (e) => onChange(e.target.value),
|
|
206
|
-
onKeyDown: handleKeyDown
|
|
207
|
-
}
|
|
208
|
-
),
|
|
209
|
-
value && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: explorer_default.clearSearchBtn, title: "Clear filter", onClick: () => onChange(""), children: "\u2715" })
|
|
210
|
-
] });
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// src/client/ExplorerRow.tsx
|
|
214
|
-
var import_react2 = require("react");
|
|
215
|
-
|
|
216
|
-
// src/client/vscode-theme.tsx
|
|
217
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
218
|
-
function getFileExtension(filename) {
|
|
219
|
-
const at = filename.lastIndexOf(".");
|
|
220
|
-
return at <= 0 ? "" : filename.slice(at + 1).toLowerCase();
|
|
221
|
-
}
|
|
222
|
-
function getLanguageColor(filename, isDir) {
|
|
223
|
-
if (isDir) return "#dcb67a";
|
|
224
|
-
const ext = getFileExtension(filename);
|
|
225
|
-
const lowerName = filename.toLowerCase();
|
|
226
|
-
if (lowerName === "dockerfile" || lowerName.startsWith("dockerfile.")) return "#2496ed";
|
|
227
|
-
if (lowerName === ".gitignore" || lowerName === ".gitattributes") return "#f14e32";
|
|
228
|
-
if (lowerName === "package.json") return "#cb3837";
|
|
229
|
-
if (lowerName.startsWith(".env")) return "#ecd53f";
|
|
230
|
-
switch (ext) {
|
|
231
|
-
case "ts":
|
|
232
|
-
case "mts":
|
|
233
|
-
case "cts":
|
|
234
|
-
return "#3178c6";
|
|
235
|
-
case "tsx":
|
|
236
|
-
return "#3178c6";
|
|
237
|
-
case "js":
|
|
238
|
-
case "mjs":
|
|
239
|
-
case "cjs":
|
|
240
|
-
return "#f7df1e";
|
|
241
|
-
case "jsx":
|
|
242
|
-
return "#00d8ff";
|
|
243
|
-
case "py":
|
|
244
|
-
case "pyw":
|
|
245
|
-
return "#3572a5";
|
|
246
|
-
case "rs":
|
|
247
|
-
return "#dea584";
|
|
248
|
-
case "go":
|
|
249
|
-
return "#00add8";
|
|
250
|
-
case "c":
|
|
251
|
-
case "h":
|
|
252
|
-
return "#a8b9cc";
|
|
253
|
-
case "cpp":
|
|
254
|
-
case "cc":
|
|
255
|
-
case "cxx":
|
|
256
|
-
case "hpp":
|
|
257
|
-
return "#00599c";
|
|
258
|
-
case "cs":
|
|
259
|
-
return "#178600";
|
|
260
|
-
case "java":
|
|
261
|
-
case "jar":
|
|
262
|
-
return "#b07219";
|
|
263
|
-
case "kt":
|
|
264
|
-
case "kts":
|
|
265
|
-
return "#a97bff";
|
|
266
|
-
case "swift":
|
|
267
|
-
return "#f05138";
|
|
268
|
-
case "php":
|
|
269
|
-
return "#777bb4";
|
|
270
|
-
case "rb":
|
|
271
|
-
return "#cc342d";
|
|
272
|
-
case "html":
|
|
273
|
-
case "htm":
|
|
274
|
-
return "#e34c26";
|
|
275
|
-
case "css":
|
|
276
|
-
return "#42a5f5";
|
|
277
|
-
case "scss":
|
|
278
|
-
case "sass":
|
|
279
|
-
return "#cd6799";
|
|
280
|
-
case "less":
|
|
281
|
-
return "#1d365d";
|
|
282
|
-
case "json":
|
|
283
|
-
case "jsonc":
|
|
284
|
-
case "json5":
|
|
285
|
-
return "#cbcb41";
|
|
286
|
-
case "yaml":
|
|
287
|
-
case "yml":
|
|
288
|
-
return "#cb171e";
|
|
289
|
-
case "toml":
|
|
290
|
-
return "#9c4221";
|
|
291
|
-
case "md":
|
|
292
|
-
case "markdown":
|
|
293
|
-
case "mdx":
|
|
294
|
-
return "#519aba";
|
|
295
|
-
case "sql":
|
|
296
|
-
return "#e38c00";
|
|
297
|
-
case "sh":
|
|
298
|
-
case "bash":
|
|
299
|
-
case "zsh":
|
|
300
|
-
return "#89e051";
|
|
301
|
-
case "ps1":
|
|
302
|
-
case "psm1":
|
|
303
|
-
return "#012456";
|
|
304
|
-
case "svg":
|
|
305
|
-
return "#ff9800";
|
|
306
|
-
case "png":
|
|
307
|
-
case "jpg":
|
|
308
|
-
case "jpeg":
|
|
309
|
-
case "gif":
|
|
310
|
-
case "webp":
|
|
311
|
-
case "ico":
|
|
312
|
-
return "#ab47bc";
|
|
313
|
-
case "zip":
|
|
314
|
-
case "tar":
|
|
315
|
-
case "gz":
|
|
316
|
-
case "7z":
|
|
317
|
-
case "rar":
|
|
318
|
-
return "#ec407a";
|
|
319
|
-
default:
|
|
320
|
-
return "#90a4ae";
|
|
321
|
-
}
|
|
21
|
+
|
|
22
|
+
.dsh-exp-header {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
padding: 8px 10px;
|
|
27
|
+
min-height: 38px;
|
|
28
|
+
font-size: 11.5px;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
color: var(--dsh-fg-muted, #858585);
|
|
31
|
+
border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.08));
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
gap: 8px;
|
|
322
34
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", style: { flexShrink: 0 }, children: [
|
|
388
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M2.5 2C2.5 1.44772 2.94772 1 3.5 1H10L14 5V14C14 14.5523 13.5523 15 13 15H3.5C2.94772 15 2.5 14.5523 2.5 14V2Z", fill: "#2d3748" }),
|
|
389
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("text", { x: "4", y: "11", fill: "#cbcb41", fontSize: "9", fontWeight: "bold", fontFamily: "monospace", children: "{}" })
|
|
390
|
-
] });
|
|
35
|
+
|
|
36
|
+
.dsh-exp-headerTitle {
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
min-width: 0;
|
|
41
|
+
flex: 1;
|
|
42
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
43
|
+
font-size: 11px;
|
|
44
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
45
|
+
letter-spacing: normal;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.dsh-exp-headerActions {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: 3px;
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.dsh-exp-iconBtn {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
width: 26px;
|
|
60
|
+
height: 26px;
|
|
61
|
+
border-radius: 5px;
|
|
62
|
+
border: none;
|
|
63
|
+
background: transparent;
|
|
64
|
+
color: inherit;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
opacity: 0.8;
|
|
67
|
+
transition: opacity 0.15s cubic-bezier(0.2, 0, 0, 1), background-color 0.15s cubic-bezier(0.2, 0, 0, 1), transform 0.12s ease;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dsh-exp-iconBtn:hover {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
background-color: var(--dsh-bg-hover, rgba(255, 255, 255, 0.1));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.dsh-exp-iconBtn:active {
|
|
76
|
+
transform: scale(0.92);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.dsh-exp-iconBtnActive {
|
|
80
|
+
background-color: var(--dsh-bg-active, rgba(255, 255, 255, 0.15));
|
|
81
|
+
opacity: 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.dsh-exp-searchBar {
|
|
85
|
+
padding: 6px 10px;
|
|
86
|
+
border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.06));
|
|
87
|
+
background-color: var(--dsh-bg-subtle, rgba(0, 0, 0, 0.15));
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: 6px;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
animation: searchSlide 0.16s cubic-bezier(0, 0, 0.2, 1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@keyframes searchSlide {
|
|
96
|
+
from {
|
|
97
|
+
opacity: 0;
|
|
98
|
+
transform: translateY(-6px);
|
|
391
99
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3.5 10V6L5.5 8.5L7.5 6V10", stroke: "#519aba", strokeWidth: "1.1", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
396
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M11 6V10M9.5 8.5L11 10L12.5 8.5", stroke: "#519aba", strokeWidth: "1.1", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
397
|
-
] });
|
|
100
|
+
to {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
transform: translateY(0);
|
|
398
103
|
}
|
|
399
|
-
|
|
400
|
-
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.dsh-exp-searchInput {
|
|
107
|
+
flex: 1;
|
|
108
|
+
background: var(--dsh-input-bg, rgba(255, 255, 255, 0.06));
|
|
109
|
+
border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.12));
|
|
110
|
+
border-radius: 4px;
|
|
111
|
+
color: inherit;
|
|
112
|
+
padding: 4px 8px;
|
|
113
|
+
font-size: 12px;
|
|
114
|
+
outline: none;
|
|
115
|
+
transition: border-color 0.15s ease;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.dsh-exp-searchInput:focus {
|
|
119
|
+
border-color: #007fd4;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.dsh-exp-clearSearchBtn {
|
|
123
|
+
background: transparent;
|
|
124
|
+
border: none;
|
|
125
|
+
color: inherit;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
opacity: 0.6;
|
|
128
|
+
font-size: 11px;
|
|
129
|
+
transition: opacity 0.12s ease;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.dsh-exp-clearSearchBtn:hover {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.dsh-exp-searchSpinner {
|
|
137
|
+
width: 13px;
|
|
138
|
+
height: 13px;
|
|
139
|
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
|
140
|
+
border-top-color: #007fd4;
|
|
141
|
+
border-radius: 50%;
|
|
142
|
+
animation: searchSpin 0.6s linear infinite;
|
|
143
|
+
flex-shrink: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes searchSpin {
|
|
147
|
+
to {
|
|
148
|
+
transform: rotate(360deg);
|
|
401
149
|
}
|
|
402
|
-
|
|
403
|
-
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.dsh-exp-matchCountBadge {
|
|
153
|
+
font-size: 11px;
|
|
154
|
+
opacity: 0.7;
|
|
155
|
+
background: var(--dsh-badge-bg, rgba(255, 255, 255, 0.08));
|
|
156
|
+
border-radius: 3px;
|
|
157
|
+
padding: 1px 6px;
|
|
158
|
+
font-variant-numeric: tabular-nums;
|
|
159
|
+
white-space: nowrap;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.dsh-exp-treeBody {
|
|
163
|
+
flex: 1;
|
|
164
|
+
overflow-y: auto;
|
|
165
|
+
overflow-x: hidden;
|
|
166
|
+
padding: 4px 0;
|
|
167
|
+
outline: none;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.dsh-exp-row {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
height: var(--dsh-row-height, 24px);
|
|
174
|
+
line-height: var(--dsh-row-height, 24px);
|
|
175
|
+
padding-right: 8px;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
position: relative;
|
|
178
|
+
transition: background-color 0.12s cubic-bezier(0.2, 0, 0, 1);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.dsh-exp-row:hover {
|
|
182
|
+
background-color: var(--dsh-row-hover, rgba(255, 255, 255, 0.05));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.dsh-exp-rowSelected {
|
|
186
|
+
background-color: var(--dsh-row-selected, rgba(0, 122, 204, 0.25)) !important;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.dsh-exp-rowFocused {
|
|
190
|
+
outline: 1px solid #007fd4;
|
|
191
|
+
outline-offset: -1px;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.dsh-exp-indentGuide {
|
|
195
|
+
position: absolute;
|
|
196
|
+
top: 0;
|
|
197
|
+
bottom: 0;
|
|
198
|
+
width: 1px;
|
|
199
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.dsh-exp-chevron {
|
|
203
|
+
display: inline-flex;
|
|
204
|
+
align-items: center;
|
|
205
|
+
justify-content: center;
|
|
206
|
+
width: var(--dsh-icon-size, 16px);
|
|
207
|
+
height: var(--dsh-icon-size, 16px);
|
|
208
|
+
margin-right: 2px;
|
|
209
|
+
color: inherit;
|
|
210
|
+
opacity: 0.6;
|
|
211
|
+
transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1), opacity 0.15s ease;
|
|
212
|
+
flex-shrink: 0;
|
|
213
|
+
will-change: transform;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.dsh-exp-chevronExpanded {
|
|
217
|
+
transform: rotate(90deg);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.dsh-exp-chevronHidden {
|
|
221
|
+
visibility: hidden;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Motion Collapse: CSS Grid animation for silky smooth folder expanding & collapsing */
|
|
225
|
+
.dsh-exp-folderGroup {
|
|
226
|
+
display: flex;
|
|
227
|
+
flex-direction: column;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.dsh-exp-folderChildren {
|
|
231
|
+
display: grid;
|
|
232
|
+
grid-template-rows: 0fr;
|
|
233
|
+
transition: grid-template-rows 0.22s cubic-bezier(0.2, 0, 0, 1), opacity 0.18s ease;
|
|
234
|
+
opacity: 0;
|
|
235
|
+
overflow: hidden;
|
|
236
|
+
will-change: grid-template-rows, opacity;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.dsh-exp-folderChildrenOpen {
|
|
240
|
+
grid-template-rows: 1fr;
|
|
241
|
+
opacity: 1;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.dsh-exp-folderChildrenClosed {
|
|
245
|
+
grid-template-rows: 0fr;
|
|
246
|
+
opacity: 0;
|
|
247
|
+
pointer-events: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.dsh-exp-folderChildrenInner {
|
|
251
|
+
overflow: hidden;
|
|
252
|
+
min-height: 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.dsh-exp-iconWrap {
|
|
256
|
+
display: inline-flex;
|
|
257
|
+
align-items: center;
|
|
258
|
+
justify-content: center;
|
|
259
|
+
width: var(--dsh-icon-size, 18px);
|
|
260
|
+
height: var(--dsh-icon-size, 18px);
|
|
261
|
+
margin-right: 6px;
|
|
262
|
+
flex-shrink: 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.dsh-exp-label {
|
|
266
|
+
flex: 1;
|
|
267
|
+
overflow: hidden;
|
|
268
|
+
text-overflow: ellipsis;
|
|
269
|
+
white-space: nowrap;
|
|
270
|
+
font-size: var(--dsh-font-size, 13px);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.dsh-exp-labelDimmed {
|
|
274
|
+
opacity: 0.5;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.dsh-exp-gitBadge {
|
|
278
|
+
font-size: 10px;
|
|
279
|
+
font-weight: 700;
|
|
280
|
+
margin-left: auto;
|
|
281
|
+
margin-right: 4px;
|
|
282
|
+
padding: 1px 5px;
|
|
283
|
+
border-radius: 3px;
|
|
284
|
+
line-height: 1;
|
|
285
|
+
display: inline-flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
justify-content: center;
|
|
288
|
+
flex-shrink: 0;
|
|
289
|
+
letter-spacing: 0.04em;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.dsh-exp-gitModified {
|
|
293
|
+
color: #e2c08d !important;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.dsh-exp-gitUntracked {
|
|
297
|
+
color: #73c991 !important;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.dsh-exp-gitDeleted {
|
|
301
|
+
color: #e5534b !important;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.dsh-exp-gitBadge.dsh-exp-gitModified {
|
|
305
|
+
background-color: rgba(226, 192, 141, 0.18);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.dsh-exp-gitBadge.dsh-exp-gitUntracked {
|
|
309
|
+
background-color: rgba(115, 201, 145, 0.18);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.dsh-exp-gitBadge.dsh-exp-gitDeleted {
|
|
313
|
+
background-color: rgba(229, 83, 75, 0.18);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.dsh-exp-hoverActions {
|
|
317
|
+
display: none;
|
|
318
|
+
align-items: center;
|
|
319
|
+
gap: 2px;
|
|
320
|
+
margin-left: 4px;
|
|
321
|
+
flex-shrink: 0;
|
|
322
|
+
animation: actionsFadeIn 0.12s ease;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
@keyframes actionsFadeIn {
|
|
326
|
+
from {
|
|
327
|
+
opacity: 0;
|
|
328
|
+
transform: translateX(4px);
|
|
404
329
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M10 1V5H14", fill: "#3e4451", opacity: "0.6" }),
|
|
409
|
-
shortExt ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("text", { x: "4", y: "11", fill: color, fontSize: "6", fontWeight: "bold", fontFamily: "monospace", children: shortExt }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "8", cy: "9", r: "1.8", fill: color })
|
|
410
|
-
] });
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// src/client/conversation-draft.ts
|
|
414
|
-
var lastKnownSessionId = "";
|
|
415
|
-
var trackedCaret = null;
|
|
416
|
-
function setLastKnownSessionId(id) {
|
|
417
|
-
if (id) lastKnownSessionId = id;
|
|
418
|
-
}
|
|
419
|
-
function safeService(ctx, name) {
|
|
420
|
-
try {
|
|
421
|
-
return ctx?.get ? ctx.get(name) : ctx?.reflect?.get ? ctx.reflect.get(name, false) : ctx?.[name];
|
|
422
|
-
} catch {
|
|
423
|
-
try {
|
|
424
|
-
return ctx?.reflect?.get?.(name, false);
|
|
425
|
-
} catch {
|
|
426
|
-
return void 0;
|
|
427
|
-
}
|
|
330
|
+
to {
|
|
331
|
+
opacity: 1;
|
|
332
|
+
transform: translateX(0);
|
|
428
333
|
}
|
|
429
334
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
335
|
+
|
|
336
|
+
.dsh-exp-row:hover .dsh-exp-hoverActions {
|
|
337
|
+
display: flex;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.dsh-exp-actionBtn {
|
|
341
|
+
display: flex;
|
|
342
|
+
align-items: center;
|
|
343
|
+
justify-content: center;
|
|
344
|
+
width: 20px;
|
|
345
|
+
height: 20px;
|
|
346
|
+
border-radius: 3px;
|
|
347
|
+
border: none;
|
|
348
|
+
background: transparent;
|
|
349
|
+
color: inherit;
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
opacity: 0.7;
|
|
352
|
+
padding: 0;
|
|
353
|
+
transition: opacity 0.12s ease, background-color 0.12s ease, transform 0.12s ease;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.dsh-exp-actionBtn:hover {
|
|
357
|
+
opacity: 1;
|
|
358
|
+
background-color: rgba(255, 255, 255, 0.15);
|
|
359
|
+
transform: scale(1.08);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.dsh-exp-actionBtn:active {
|
|
363
|
+
transform: scale(0.92);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.dsh-exp-inlineInput {
|
|
367
|
+
flex: 1;
|
|
368
|
+
background: var(--dsh-input-bg, #252526);
|
|
369
|
+
border: 1px solid #007fd4;
|
|
370
|
+
border-radius: 2px;
|
|
371
|
+
color: inherit;
|
|
372
|
+
padding: 1px 4px;
|
|
373
|
+
font-size: 12px;
|
|
374
|
+
outline: none;
|
|
375
|
+
height: 20px;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.dsh-exp-contextMenu {
|
|
379
|
+
position: fixed;
|
|
380
|
+
background: var(--dsh-menu-bg, #252526);
|
|
381
|
+
border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.1));
|
|
382
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
|
|
383
|
+
border-radius: 6px;
|
|
384
|
+
padding: 4px 0;
|
|
385
|
+
z-index: 10000;
|
|
386
|
+
min-width: 180px;
|
|
387
|
+
font-size: 12px;
|
|
388
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
389
|
+
animation: contextMenuPop 0.12s cubic-bezier(0, 0, 0.2, 1);
|
|
390
|
+
transform-origin: top left;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
@keyframes contextMenuPop {
|
|
394
|
+
from {
|
|
395
|
+
opacity: 0;
|
|
396
|
+
transform: scale(0.96) translateY(-4px);
|
|
473
397
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if (typeof document === "undefined") return null;
|
|
478
|
-
const composerInput = document.querySelector('[data-composer-input="true"]') ?? document.querySelector("[data-composer-input]");
|
|
479
|
-
if (composerInput) return composerInput;
|
|
480
|
-
const slot = document.querySelector('[data-slot="conversation"]') ?? document.querySelector('[data-slot*="conversation"]') ?? document.body;
|
|
481
|
-
const ce = slot.querySelector('[contenteditable="true"][role="textbox"]') ?? slot.querySelector('[contenteditable="true"]');
|
|
482
|
-
if (ce) return ce;
|
|
483
|
-
return document.querySelector("textarea[data-phase]") ?? document.querySelector("textarea") ?? document.querySelector('[contenteditable="true"]') ?? null;
|
|
484
|
-
}
|
|
485
|
-
function recordLiveCaret() {
|
|
486
|
-
if (typeof document === "undefined") return;
|
|
487
|
-
const el = findComposerElement();
|
|
488
|
-
if (!el) return;
|
|
489
|
-
if (el.tagName === "TEXTAREA" || el.tagName === "INPUT") {
|
|
490
|
-
const ta = el;
|
|
491
|
-
const start = ta.selectionStart;
|
|
492
|
-
const end = ta.selectionEnd;
|
|
493
|
-
if (typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end)) {
|
|
494
|
-
trackedCaret = {
|
|
495
|
-
start: Math.max(0, Math.min(start, ta.value.length)),
|
|
496
|
-
end: Math.max(start, Math.min(end, ta.value.length)),
|
|
497
|
-
draft: ta.value,
|
|
498
|
-
timestamp: Date.now()
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
} else if (el.isContentEditable) {
|
|
502
|
-
const sel = window.getSelection();
|
|
503
|
-
if (sel && sel.rangeCount > 0 && el.contains(sel.anchorNode)) {
|
|
504
|
-
const range = sel.getRangeAt(0);
|
|
505
|
-
const preRange = range.cloneRange();
|
|
506
|
-
preRange.selectNodeContents(el);
|
|
507
|
-
preRange.setEnd(range.startContainer, range.startOffset);
|
|
508
|
-
const start = preRange.toString().length;
|
|
509
|
-
const length = range.toString().length;
|
|
510
|
-
trackedCaret = {
|
|
511
|
-
start,
|
|
512
|
-
end: start + length,
|
|
513
|
-
draft: el.innerText ?? el.textContent ?? "",
|
|
514
|
-
timestamp: Date.now()
|
|
515
|
-
};
|
|
516
|
-
}
|
|
398
|
+
to {
|
|
399
|
+
opacity: 1;
|
|
400
|
+
transform: scale(1) translateY(0);
|
|
517
401
|
}
|
|
518
402
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
403
|
+
|
|
404
|
+
.dsh-exp-menuItem {
|
|
405
|
+
display: flex;
|
|
406
|
+
align-items: center;
|
|
407
|
+
justify-content: space-between;
|
|
408
|
+
padding: 5px 12px;
|
|
409
|
+
cursor: pointer;
|
|
410
|
+
transition: background-color 0.1s ease;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.dsh-exp-menuItem:hover {
|
|
414
|
+
background-color: var(--dsh-menu-hover, #094771);
|
|
415
|
+
color: #ffffff;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.dsh-exp-menuDivider {
|
|
419
|
+
height: 1px;
|
|
420
|
+
background-color: var(--dsh-border, rgba(255, 255, 255, 0.08));
|
|
421
|
+
margin: 4px 0;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.dsh-exp-menuShortcut {
|
|
425
|
+
font-size: 10px;
|
|
426
|
+
opacity: 0.6;
|
|
427
|
+
margin-left: 16px;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.dsh-exp-emptyState {
|
|
431
|
+
padding: 24px 16px;
|
|
432
|
+
text-align: center;
|
|
433
|
+
opacity: 0.6;
|
|
434
|
+
font-size: 12px;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* Motion disable override */
|
|
438
|
+
.dsh-exp-noMotion,
|
|
439
|
+
.dsh-exp-noMotion * {
|
|
440
|
+
transition: none !important;
|
|
441
|
+
animation: none !important;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.dsh-exp-noMotion .dsh-exp-chevron,
|
|
445
|
+
.dsh-exp-noMotion .dsh-exp-folderChildren,
|
|
446
|
+
.dsh-exp-noMotion .dsh-exp-actionBtn,
|
|
447
|
+
.dsh-exp-noMotion .dsh-exp-hoverActions,
|
|
448
|
+
.dsh-exp-noMotion .dsh-exp-optionsPopover,
|
|
449
|
+
.dsh-exp-noMotion .dsh-exp-contextMenu {
|
|
450
|
+
transition: none !important;
|
|
451
|
+
animation: none !important;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/* Options Popover */
|
|
455
|
+
.dsh-exp-optionsPopover {
|
|
456
|
+
position: absolute;
|
|
457
|
+
top: 36px;
|
|
458
|
+
right: 8px;
|
|
459
|
+
width: 280px;
|
|
460
|
+
max-width: calc(100% - 16px);
|
|
461
|
+
max-height: calc(100% - 48px);
|
|
462
|
+
background-color: var(--dsh-bg-elevated, #202020);
|
|
463
|
+
border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.14));
|
|
464
|
+
border-radius: 6px;
|
|
465
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
|
|
466
|
+
display: flex;
|
|
467
|
+
flex-direction: column;
|
|
468
|
+
z-index: 1000;
|
|
469
|
+
overflow: hidden;
|
|
470
|
+
animation: popoverFadeIn 0.15s cubic-bezier(0, 0, 0.2, 1);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
@keyframes popoverFadeIn {
|
|
474
|
+
from {
|
|
475
|
+
opacity: 0;
|
|
476
|
+
transform: translateY(-6px) scale(0.97);
|
|
571
477
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return { start: clampedStart, end: clampedEnd };
|
|
478
|
+
to {
|
|
479
|
+
opacity: 1;
|
|
480
|
+
transform: translateY(0) scale(1);
|
|
576
481
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.dsh-exp-optionsHeader {
|
|
485
|
+
display: flex;
|
|
486
|
+
align-items: center;
|
|
487
|
+
justify-content: space-between;
|
|
488
|
+
padding: 8px 12px;
|
|
489
|
+
background-color: rgba(0, 0, 0, 0.25);
|
|
490
|
+
border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.08));
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.dsh-exp-optionsHeaderTitle {
|
|
494
|
+
display: flex;
|
|
495
|
+
align-items: center;
|
|
496
|
+
font-size: 11px;
|
|
497
|
+
font-weight: 700;
|
|
498
|
+
letter-spacing: 0.05em;
|
|
499
|
+
color: var(--dsh-fg-muted, #999999);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.dsh-exp-optionsIconBtn {
|
|
503
|
+
background: transparent;
|
|
504
|
+
border: none;
|
|
505
|
+
color: inherit;
|
|
506
|
+
opacity: 0.7;
|
|
507
|
+
cursor: pointer;
|
|
508
|
+
display: flex;
|
|
509
|
+
align-items: center;
|
|
510
|
+
justify-content: center;
|
|
511
|
+
padding: 3px;
|
|
512
|
+
border-radius: 3px;
|
|
513
|
+
transition: opacity 0.15s ease, background-color 0.15s ease;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.dsh-exp-optionsIconBtn:hover {
|
|
517
|
+
opacity: 1;
|
|
518
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.dsh-exp-optionsBody {
|
|
522
|
+
overflow-y: auto;
|
|
523
|
+
padding: 10px 12px;
|
|
524
|
+
display: flex;
|
|
525
|
+
flex-direction: column;
|
|
526
|
+
gap: 14px;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.dsh-exp-optionsSection {
|
|
530
|
+
display: flex;
|
|
531
|
+
flex-direction: column;
|
|
532
|
+
gap: 6px;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.dsh-exp-optionsSectionTitle {
|
|
536
|
+
font-size: 10.5px;
|
|
537
|
+
font-weight: 700;
|
|
538
|
+
text-transform: uppercase;
|
|
539
|
+
letter-spacing: 0.04em;
|
|
540
|
+
color: var(--dsh-fg-muted, #858585);
|
|
541
|
+
margin-bottom: 2px;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.dsh-exp-optionsRow {
|
|
545
|
+
display: flex;
|
|
546
|
+
align-items: center;
|
|
547
|
+
justify-content: space-between;
|
|
548
|
+
gap: 8px;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.dsh-exp-optionsLabelWrap {
|
|
552
|
+
display: flex;
|
|
553
|
+
flex-direction: column;
|
|
554
|
+
gap: 1px;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.dsh-exp-optionsLabel {
|
|
558
|
+
font-size: 12px;
|
|
559
|
+
font-weight: 500;
|
|
560
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.dsh-exp-optionsSubLabel {
|
|
564
|
+
font-size: 10.5px;
|
|
565
|
+
color: var(--dsh-fg-muted, #808080);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.dsh-exp-optionsBadge {
|
|
569
|
+
font-size: 11px;
|
|
570
|
+
font-weight: 600;
|
|
571
|
+
padding: 1px 6px;
|
|
572
|
+
border-radius: 3px;
|
|
573
|
+
background-color: rgba(255, 255, 255, 0.08);
|
|
574
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
575
|
+
font-family: monospace;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.dsh-exp-optionsMiniBtn {
|
|
579
|
+
background: rgba(255, 255, 255, 0.08);
|
|
580
|
+
border: none;
|
|
581
|
+
color: inherit;
|
|
582
|
+
font-size: 10px;
|
|
583
|
+
padding: 1px 5px;
|
|
584
|
+
border-radius: 3px;
|
|
585
|
+
cursor: pointer;
|
|
586
|
+
opacity: 0.8;
|
|
587
|
+
transition: opacity 0.12s ease;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.dsh-exp-optionsMiniBtn:hover {
|
|
591
|
+
opacity: 1;
|
|
592
|
+
background: rgba(255, 255, 255, 0.16);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.dsh-exp-optionsSlider {
|
|
596
|
+
width: 100%;
|
|
597
|
+
accent-color: #007fd4;
|
|
598
|
+
cursor: pointer;
|
|
599
|
+
margin-top: 4px;
|
|
600
|
+
height: 4px;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.dsh-exp-segmentGroup {
|
|
604
|
+
display: flex;
|
|
605
|
+
background: rgba(0, 0, 0, 0.25);
|
|
606
|
+
border-radius: 4px;
|
|
607
|
+
padding: 2px;
|
|
608
|
+
gap: 2px;
|
|
609
|
+
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.dsh-exp-segmentBtn {
|
|
613
|
+
flex: 1;
|
|
614
|
+
border: none;
|
|
615
|
+
background: transparent;
|
|
616
|
+
color: inherit;
|
|
617
|
+
padding: 4px 6px;
|
|
618
|
+
font-size: 11px;
|
|
619
|
+
border-radius: 3px;
|
|
620
|
+
cursor: pointer;
|
|
621
|
+
text-align: center;
|
|
622
|
+
opacity: 0.75;
|
|
623
|
+
transition: all 0.15s ease;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.dsh-exp-segmentBtn:hover {
|
|
627
|
+
opacity: 1;
|
|
628
|
+
background: rgba(255, 255, 255, 0.06);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.dsh-exp-segmentBtnActive {
|
|
632
|
+
background: var(--dsh-bg-active, #007fd4) !important;
|
|
633
|
+
color: #ffffff !important;
|
|
634
|
+
opacity: 1;
|
|
635
|
+
font-weight: 600;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.dsh-exp-switch {
|
|
639
|
+
position: relative;
|
|
640
|
+
width: 32px;
|
|
641
|
+
height: 18px;
|
|
642
|
+
border-radius: 9px;
|
|
643
|
+
background: rgba(255, 255, 255, 0.16);
|
|
644
|
+
cursor: pointer;
|
|
645
|
+
transition: background 0.2s ease;
|
|
646
|
+
flex-shrink: 0;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.dsh-exp-switchActive {
|
|
650
|
+
background: #007fd4;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.dsh-exp-switchKnob {
|
|
654
|
+
position: absolute;
|
|
655
|
+
top: 2px;
|
|
656
|
+
left: 2px;
|
|
657
|
+
width: 14px;
|
|
658
|
+
height: 14px;
|
|
659
|
+
border-radius: 50%;
|
|
660
|
+
background: #ffffff;
|
|
661
|
+
transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
|
|
662
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
.dsh-exp-switchKnobActive {
|
|
666
|
+
transform: translateX(14px);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.dsh-exp-modalOverlay {
|
|
670
|
+
position: absolute;
|
|
671
|
+
inset: 0;
|
|
672
|
+
background-color: rgba(0, 0, 0, 0.65);
|
|
673
|
+
backdrop-filter: blur(2px);
|
|
674
|
+
display: flex;
|
|
675
|
+
align-items: center;
|
|
676
|
+
justify-content: center;
|
|
677
|
+
z-index: 1200;
|
|
678
|
+
padding: 16px;
|
|
679
|
+
animation: modalFadeIn 0.15s cubic-bezier(0, 0, 0.2, 1);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
@keyframes modalFadeIn {
|
|
683
|
+
from {
|
|
684
|
+
opacity: 0;
|
|
611
685
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const left = prefix === "" || /\s$/.test(prefix) ? "" : " ";
|
|
615
|
-
const right = suffix === "" || /^\s/.test(suffix) || /\s$/.test(text) ? "" : " ";
|
|
616
|
-
const next = `${prefix}${left}${text}${right}${suffix}`;
|
|
617
|
-
const caretAfter = prefix.length + left.length + text.length;
|
|
618
|
-
return {
|
|
619
|
-
draft: next,
|
|
620
|
-
caretAfter
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
function mentionForPath(relativePath, isDir) {
|
|
624
|
-
const norm = relativePath.replace(/[\\/]+$/, "").replace(/\\/g, "/");
|
|
625
|
-
const target = isDir ? `${norm}/` : norm;
|
|
626
|
-
return /\s/.test(target) ? `@"${target}"` : `@${target}`;
|
|
627
|
-
}
|
|
628
|
-
function baseName(path) {
|
|
629
|
-
const at = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
630
|
-
return at === -1 ? path : path.slice(at + 1);
|
|
631
|
-
}
|
|
632
|
-
function insertMentionToComposer(ctx, sessionId, relativePath, isDir, targetPoint) {
|
|
633
|
-
try {
|
|
634
|
-
const mention = mentionForPath(relativePath, isDir);
|
|
635
|
-
const name = baseName(relativePath);
|
|
636
|
-
const label = isDir ? `${name}/` : name;
|
|
637
|
-
const appearance = isDir ? "folder" : "file";
|
|
638
|
-
if (targetPoint && typeof document !== "undefined") {
|
|
639
|
-
const el2 = findComposerElement();
|
|
640
|
-
if (el2) {
|
|
641
|
-
let range = null;
|
|
642
|
-
if (typeof document.caretRangeFromPoint === "function") {
|
|
643
|
-
range = document.caretRangeFromPoint(targetPoint.x, targetPoint.y);
|
|
644
|
-
} else if (typeof document.caretPositionFromPoint === "function") {
|
|
645
|
-
const pos = document.caretPositionFromPoint(targetPoint.x, targetPoint.y);
|
|
646
|
-
if (pos && pos.offsetNode) {
|
|
647
|
-
range = document.createRange();
|
|
648
|
-
range.setStart(pos.offsetNode, pos.offset);
|
|
649
|
-
range.collapse(true);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
if (range && el2.contains(range.startContainer)) {
|
|
653
|
-
const sel = window.getSelection();
|
|
654
|
-
sel?.removeAllRanges();
|
|
655
|
-
sel?.addRange(range);
|
|
656
|
-
el2.focus({ preventScroll: true });
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
const sessions = safeService(ctx, "sessions");
|
|
661
|
-
const targetSessionId = resolveActiveSessionId(ctx, sessionId);
|
|
662
|
-
const actx = targetSessionId && sessions?.scope ? sessions.scope(targetSessionId) : void 0;
|
|
663
|
-
const conversation = safeService(ctx, "conversation");
|
|
664
|
-
if (conversation && actx) {
|
|
665
|
-
const shell = conversation.input?.for(actx);
|
|
666
|
-
if (shell) {
|
|
667
|
-
if (shell.draftEditor && typeof shell.draftEditor.insertFileReferences === "function") {
|
|
668
|
-
try {
|
|
669
|
-
const revBefore = shell.rev ?? shell.state?.getSnapshot?.()?.draftRev ?? 0;
|
|
670
|
-
const applied = shell.draftEditor.insertFileReferences([
|
|
671
|
-
{
|
|
672
|
-
source: "reference",
|
|
673
|
-
ref: mention,
|
|
674
|
-
label,
|
|
675
|
-
appearance,
|
|
676
|
-
clipboardText: mention
|
|
677
|
-
}
|
|
678
|
-
]);
|
|
679
|
-
const revAfter = shell.rev ?? shell.state?.getSnapshot?.()?.draftRev ?? 0;
|
|
680
|
-
if (applied || revAfter !== revBefore) {
|
|
681
|
-
shell.focus?.();
|
|
682
|
-
return true;
|
|
683
|
-
}
|
|
684
|
-
} catch (err) {
|
|
685
|
-
console.warn("[dsh-explorer] draftEditor.insertFileReferences failed, trying actx.bail:", err);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
let span = shell.actions?.captureInsertion?.() ?? shell.captureInsertion?.();
|
|
689
|
-
if (span && span.draftRev !== void 0) {
|
|
690
|
-
const detectText = shell.projection?.detectText ?? "";
|
|
691
|
-
let charBefore = span.start > 0 ? detectText[span.start - 1] ?? "" : "";
|
|
692
|
-
if (!charBefore) {
|
|
693
|
-
try {
|
|
694
|
-
const sel = window.getSelection();
|
|
695
|
-
if (sel && sel.anchorNode) {
|
|
696
|
-
const text = sel.anchorNode.textContent ?? "";
|
|
697
|
-
const offset = sel.anchorOffset;
|
|
698
|
-
if (offset > 0) charBefore = text[offset - 1] ?? "";
|
|
699
|
-
}
|
|
700
|
-
} catch {
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
if (!charBefore) {
|
|
704
|
-
const draftText = shell.state?.getSnapshot?.()?.draft ?? "";
|
|
705
|
-
if (span.start > 0 && span.start <= draftText.length) {
|
|
706
|
-
charBefore = draftText[span.start - 1] ?? "";
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
if (charBefore && !/\s/.test(charBefore)) {
|
|
710
|
-
if (typeof shell.actions?.insertText === "function") {
|
|
711
|
-
try {
|
|
712
|
-
shell.actions.insertText(" ", span);
|
|
713
|
-
} catch {
|
|
714
|
-
}
|
|
715
|
-
} else if (typeof shell.insertText === "function") {
|
|
716
|
-
try {
|
|
717
|
-
shell.insertText(" ", span);
|
|
718
|
-
} catch {
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
const updated = shell.actions?.captureInsertion?.() ?? shell.captureInsertion?.();
|
|
722
|
-
if (updated && updated.draftRev !== void 0) {
|
|
723
|
-
span = updated;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
const revBefore = shell.rev ?? shell.state?.getSnapshot?.()?.draftRev ?? 0;
|
|
727
|
-
let applied = false;
|
|
728
|
-
try {
|
|
729
|
-
if (typeof actx.bail === "function") {
|
|
730
|
-
applied = Boolean(
|
|
731
|
-
actx.bail(actx, "slash/input-insert-reference", {
|
|
732
|
-
reference: {
|
|
733
|
-
source: "reference",
|
|
734
|
-
ref: mention,
|
|
735
|
-
label,
|
|
736
|
-
appearance,
|
|
737
|
-
clipboardText: mention
|
|
738
|
-
},
|
|
739
|
-
span
|
|
740
|
-
})
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
} catch {
|
|
744
|
-
}
|
|
745
|
-
if (!applied) {
|
|
746
|
-
try {
|
|
747
|
-
actx.emit?.("slash/input-insert-reference", {
|
|
748
|
-
reference: {
|
|
749
|
-
source: "reference",
|
|
750
|
-
ref: mention,
|
|
751
|
-
label,
|
|
752
|
-
appearance,
|
|
753
|
-
clipboardText: mention
|
|
754
|
-
},
|
|
755
|
-
span
|
|
756
|
-
});
|
|
757
|
-
} catch {
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
const revAfter = shell.rev ?? shell.state?.getSnapshot?.()?.draftRev ?? 0;
|
|
761
|
-
if (applied || revAfter !== revBefore) {
|
|
762
|
-
shell.focus?.();
|
|
763
|
-
return true;
|
|
764
|
-
}
|
|
765
|
-
let leadSpace = "";
|
|
766
|
-
if (charBefore && !/\s/.test(charBefore)) leadSpace = " ";
|
|
767
|
-
const textToInsert = `${leadSpace}${mention} `;
|
|
768
|
-
if (typeof shell.actions?.insertText === "function") {
|
|
769
|
-
try {
|
|
770
|
-
if (shell.actions.insertText(textToInsert, span)) {
|
|
771
|
-
shell.focus?.();
|
|
772
|
-
return true;
|
|
773
|
-
}
|
|
774
|
-
} catch {
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
if (typeof shell.insertText === "function") {
|
|
778
|
-
try {
|
|
779
|
-
if (shell.insertText(textToInsert, span)) {
|
|
780
|
-
shell.focus?.();
|
|
781
|
-
return true;
|
|
782
|
-
}
|
|
783
|
-
} catch {
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
const el = findComposerElement();
|
|
790
|
-
if (el) {
|
|
791
|
-
if (el.isContentEditable) {
|
|
792
|
-
el.focus();
|
|
793
|
-
let needLeadingSpace = false;
|
|
794
|
-
try {
|
|
795
|
-
const sel = window.getSelection();
|
|
796
|
-
if (sel && sel.rangeCount > 0) {
|
|
797
|
-
const r = sel.getRangeAt(0);
|
|
798
|
-
if (r.startContainer.nodeType === Node.TEXT_NODE) {
|
|
799
|
-
const text = r.startContainer.textContent ?? "";
|
|
800
|
-
if (r.startOffset > 0 && !/\s/.test(text[r.startOffset - 1])) {
|
|
801
|
-
needLeadingSpace = true;
|
|
802
|
-
}
|
|
803
|
-
} else if (r.startContainer.previousSibling) {
|
|
804
|
-
const text = r.startContainer.previousSibling.textContent ?? "";
|
|
805
|
-
if (text && !/\s/.test(text.slice(-1))) {
|
|
806
|
-
needLeadingSpace = true;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
} catch {
|
|
811
|
-
}
|
|
812
|
-
const textToInsert = `${needLeadingSpace ? " " : ""}${mention} `;
|
|
813
|
-
try {
|
|
814
|
-
if (document.execCommand("insertText", false, textToInsert)) {
|
|
815
|
-
recordLiveCaret();
|
|
816
|
-
return true;
|
|
817
|
-
}
|
|
818
|
-
} catch {
|
|
819
|
-
}
|
|
820
|
-
try {
|
|
821
|
-
const sel = window.getSelection();
|
|
822
|
-
if (sel && sel.rangeCount > 0) {
|
|
823
|
-
const range = sel.getRangeAt(0);
|
|
824
|
-
range.deleteContents();
|
|
825
|
-
const textNode = document.createTextNode(textToInsert);
|
|
826
|
-
range.insertNode(textNode);
|
|
827
|
-
range.collapse(false);
|
|
828
|
-
sel.removeAllRanges();
|
|
829
|
-
sel.addRange(range);
|
|
830
|
-
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
831
|
-
recordLiveCaret();
|
|
832
|
-
return true;
|
|
833
|
-
}
|
|
834
|
-
} catch {
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
if (el.tagName === "TEXTAREA" || el.tagName === "INPUT") {
|
|
838
|
-
const textarea = el;
|
|
839
|
-
const current = textarea.value;
|
|
840
|
-
const rawCaret = probeComposerCaret(current, targetPoint) ?? {
|
|
841
|
-
start: textarea.selectionStart ?? current.length,
|
|
842
|
-
end: textarea.selectionEnd ?? current.length
|
|
843
|
-
};
|
|
844
|
-
const { draft: next, caretAfter } = spliceInsert(current, `${mention} `, rawCaret);
|
|
845
|
-
textarea.value = next;
|
|
846
|
-
textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
847
|
-
placeComposerCaret(next, caretAfter);
|
|
848
|
-
return true;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
if (conversation && actx) {
|
|
852
|
-
const shell = conversation.input?.for(actx);
|
|
853
|
-
if (shell?.setDraft) {
|
|
854
|
-
const currentDraft = shell.state?.getSnapshot?.()?.draft ?? "";
|
|
855
|
-
const rawCaret = probeComposerCaret(currentDraft, targetPoint);
|
|
856
|
-
const { draft: next, caretAfter } = spliceInsert(currentDraft, `${mention} `, rawCaret);
|
|
857
|
-
shell.setDraft(next);
|
|
858
|
-
placeComposerCaret(next, caretAfter);
|
|
859
|
-
return true;
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
return false;
|
|
863
|
-
} catch (err) {
|
|
864
|
-
console.warn("[dsh-explorer] insertMentionToComposer failed:", err);
|
|
865
|
-
return false;
|
|
686
|
+
to {
|
|
687
|
+
opacity: 1;
|
|
866
688
|
}
|
|
867
689
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
if (conversation && actx) {
|
|
881
|
-
const shell = conversation.input?.for(actx);
|
|
882
|
-
if (shell) {
|
|
883
|
-
const span = shell.actions?.captureInsertion?.() ?? shell.captureInsertion?.();
|
|
884
|
-
if (span && span.draftRev !== void 0) {
|
|
885
|
-
if (typeof shell.actions?.insertText === "function") {
|
|
886
|
-
try {
|
|
887
|
-
if (shell.actions.insertText(block, span)) {
|
|
888
|
-
shell.focus?.();
|
|
889
|
-
return true;
|
|
890
|
-
}
|
|
891
|
-
} catch {
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
if (typeof shell.insertText === "function") {
|
|
895
|
-
try {
|
|
896
|
-
if (shell.insertText(block, span)) {
|
|
897
|
-
shell.focus?.();
|
|
898
|
-
return true;
|
|
899
|
-
}
|
|
900
|
-
} catch {
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
const el = findComposerElement();
|
|
907
|
-
if (el) {
|
|
908
|
-
if (el.isContentEditable) {
|
|
909
|
-
el.focus();
|
|
910
|
-
try {
|
|
911
|
-
if (document.execCommand("insertText", false, block)) {
|
|
912
|
-
recordLiveCaret();
|
|
913
|
-
return true;
|
|
914
|
-
}
|
|
915
|
-
} catch {
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
if (el.tagName === "TEXTAREA" || el.tagName === "INPUT") {
|
|
919
|
-
const textarea = el;
|
|
920
|
-
const current = textarea.value;
|
|
921
|
-
const rawCaret = probeComposerCaret(current, targetPoint) ?? {
|
|
922
|
-
start: textarea.selectionStart ?? current.length,
|
|
923
|
-
end: textarea.selectionEnd ?? current.length
|
|
924
|
-
};
|
|
925
|
-
const { draft: next, caretAfter } = spliceInsert(current, block, rawCaret);
|
|
926
|
-
textarea.value = next;
|
|
927
|
-
textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
928
|
-
placeComposerCaret(next, caretAfter);
|
|
929
|
-
return true;
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
return false;
|
|
933
|
-
} catch (err) {
|
|
934
|
-
console.warn("[dsh-explorer] insertSnippetToComposer failed:", err);
|
|
935
|
-
return false;
|
|
936
|
-
}
|
|
690
|
+
|
|
691
|
+
.dsh-exp-modalCard {
|
|
692
|
+
background-color: var(--dsh-bg-elevated, #202020);
|
|
693
|
+
border: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.14));
|
|
694
|
+
border-radius: 8px;
|
|
695
|
+
width: 100%;
|
|
696
|
+
max-width: 320px;
|
|
697
|
+
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.45);
|
|
698
|
+
overflow: hidden;
|
|
699
|
+
display: flex;
|
|
700
|
+
flex-direction: column;
|
|
701
|
+
animation: modalCardScale 0.16s cubic-bezier(0.16, 1, 0.3, 1);
|
|
937
702
|
}
|
|
938
703
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
currentDragItems = items;
|
|
944
|
-
const payload = JSON.stringify(items);
|
|
945
|
-
try {
|
|
946
|
-
e.dataTransfer.setData(DSH_EXPLORER_MIME, payload);
|
|
947
|
-
} catch {
|
|
704
|
+
@keyframes modalCardScale {
|
|
705
|
+
from {
|
|
706
|
+
opacity: 0;
|
|
707
|
+
transform: scale(0.95) translateY(-4px);
|
|
948
708
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
} catch {
|
|
709
|
+
to {
|
|
710
|
+
opacity: 1;
|
|
711
|
+
transform: scale(1) translateY(0);
|
|
953
712
|
}
|
|
954
|
-
e.dataTransfer.effectAllowed = "copy";
|
|
955
713
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
714
|
+
|
|
715
|
+
.dsh-exp-modalHeader {
|
|
716
|
+
display: flex;
|
|
717
|
+
align-items: center;
|
|
718
|
+
justify-content: space-between;
|
|
719
|
+
padding: 10px 14px;
|
|
720
|
+
background-color: rgba(0, 0, 0, 0.25);
|
|
721
|
+
border-bottom: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.08));
|
|
960
722
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
723
|
+
|
|
724
|
+
.dsh-exp-modalTitleWrap {
|
|
725
|
+
display: flex;
|
|
726
|
+
align-items: center;
|
|
727
|
+
gap: 7px;
|
|
728
|
+
font-size: 12px;
|
|
729
|
+
font-weight: 600;
|
|
730
|
+
color: #ff5252;
|
|
731
|
+
letter-spacing: 0.02em;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.dsh-exp-modalBody {
|
|
735
|
+
padding: 14px;
|
|
736
|
+
display: flex;
|
|
737
|
+
flex-direction: column;
|
|
738
|
+
gap: 10px;
|
|
739
|
+
font-size: 12px;
|
|
740
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
741
|
+
line-height: 1.45;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.dsh-exp-modalItemPreview {
|
|
745
|
+
display: flex;
|
|
746
|
+
align-items: center;
|
|
747
|
+
gap: 8px;
|
|
748
|
+
padding: 8px 10px;
|
|
749
|
+
background-color: rgba(0, 0, 0, 0.25);
|
|
750
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
751
|
+
border-radius: 6px;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
.dsh-exp-modalItemInfo {
|
|
755
|
+
display: flex;
|
|
756
|
+
flex-direction: column;
|
|
757
|
+
gap: 2px;
|
|
758
|
+
min-width: 0;
|
|
759
|
+
flex: 1;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.dsh-exp-modalItemName {
|
|
763
|
+
font-weight: 600;
|
|
764
|
+
color: #ffffff;
|
|
765
|
+
overflow: hidden;
|
|
766
|
+
text-overflow: ellipsis;
|
|
767
|
+
white-space: nowrap;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.dsh-exp-modalItemPath {
|
|
771
|
+
font-size: 10.5px;
|
|
772
|
+
color: var(--dsh-fg-muted, #858585);
|
|
773
|
+
overflow: hidden;
|
|
774
|
+
text-overflow: ellipsis;
|
|
775
|
+
white-space: nowrap;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
.dsh-exp-modalWarning {
|
|
779
|
+
font-size: 11px;
|
|
780
|
+
color: #e0a443;
|
|
781
|
+
line-height: 1.35;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
.dsh-exp-modalErrorBanner {
|
|
785
|
+
padding: 6px 10px;
|
|
786
|
+
border-radius: 4px;
|
|
787
|
+
background-color: rgba(244, 67, 54, 0.15);
|
|
788
|
+
border: 1px solid rgba(244, 67, 54, 0.3);
|
|
789
|
+
color: #ff8a80;
|
|
790
|
+
font-size: 11.5px;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
.dsh-exp-modalFooter {
|
|
794
|
+
display: flex;
|
|
795
|
+
align-items: center;
|
|
796
|
+
justify-content: flex-end;
|
|
797
|
+
gap: 8px;
|
|
798
|
+
padding: 10px 14px;
|
|
799
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
800
|
+
border-top: 1px solid var(--dsh-border, rgba(255, 255, 255, 0.06));
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
.dsh-exp-modalBtnCancel {
|
|
804
|
+
padding: 5px 12px;
|
|
805
|
+
font-size: 12px;
|
|
806
|
+
font-weight: 500;
|
|
807
|
+
border-radius: 4px;
|
|
808
|
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
809
|
+
background: transparent;
|
|
810
|
+
color: var(--dsh-fg-base, #cccccc);
|
|
811
|
+
cursor: pointer;
|
|
812
|
+
transition: all 0.15s ease;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
.dsh-exp-modalBtnCancel:hover {
|
|
816
|
+
background-color: rgba(255, 255, 255, 0.08);
|
|
817
|
+
color: #ffffff;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
.dsh-exp-modalBtnDanger {
|
|
821
|
+
padding: 5px 14px;
|
|
822
|
+
font-size: 12px;
|
|
823
|
+
font-weight: 600;
|
|
824
|
+
border-radius: 4px;
|
|
825
|
+
border: none;
|
|
826
|
+
background-color: #d32f2f;
|
|
827
|
+
color: #ffffff;
|
|
828
|
+
cursor: pointer;
|
|
829
|
+
transition: background-color 0.15s ease, opacity 0.15s ease;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
.dsh-exp-modalBtnDanger:hover {
|
|
833
|
+
background-color: #e53935;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
.dsh-exp-modalBtnDanger:disabled {
|
|
837
|
+
opacity: 0.6;
|
|
838
|
+
cursor: not-allowed;
|
|
839
|
+
}
|
|
840
|
+
`;if(typeof document<"u"){let e=document.getElementById("dsh-explorer-styles");e||(e=document.createElement("style"),e.id="dsh-explorer-styles",e.textContent=Rn,document.head.appendChild(e))}var r={folderChildrenClosed:"dsh-exp-folderChildrenClosed",folderChildrenInner:"dsh-exp-folderChildrenInner",optionsSectionTitle:"dsh-exp-optionsSectionTitle",folderChildrenOpen:"dsh-exp-folderChildrenOpen",optionsHeaderTitle:"dsh-exp-optionsHeaderTitle",optionsLabelWrap:"dsh-exp-optionsLabelWrap",segmentBtnActive:"dsh-exp-segmentBtnActive",switchKnobActive:"dsh-exp-switchKnobActive",modalItemPreview:"dsh-exp-modalItemPreview",modalErrorBanner:"dsh-exp-modalErrorBanner",matchCountBadge:"dsh-exp-matchCountBadge",chevronExpanded:"dsh-exp-chevronExpanded",optionsSubLabel:"dsh-exp-optionsSubLabel",clearSearchBtn:"dsh-exp-clearSearchBtn",folderChildren:"dsh-exp-folderChildren",optionsPopover:"dsh-exp-optionsPopover",optionsIconBtn:"dsh-exp-optionsIconBtn",optionsSection:"dsh-exp-optionsSection",optionsMiniBtn:"dsh-exp-optionsMiniBtn",modalTitleWrap:"dsh-exp-modalTitleWrap",modalBtnCancel:"dsh-exp-modalBtnCancel",modalBtnDanger:"dsh-exp-modalBtnDanger",headerActions:"dsh-exp-headerActions",iconBtnActive:"dsh-exp-iconBtnActive",searchSpinner:"dsh-exp-searchSpinner",chevronHidden:"dsh-exp-chevronHidden",optionsHeader:"dsh-exp-optionsHeader",optionsSlider:"dsh-exp-optionsSlider",modalItemInfo:"dsh-exp-modalItemInfo",modalItemName:"dsh-exp-modalItemName",modalItemPath:"dsh-exp-modalItemPath",gitUntracked:"dsh-exp-gitUntracked",hoverActions:"dsh-exp-hoverActions",menuShortcut:"dsh-exp-menuShortcut",optionsLabel:"dsh-exp-optionsLabel",optionsBadge:"dsh-exp-optionsBadge",segmentGroup:"dsh-exp-segmentGroup",switchActive:"dsh-exp-switchActive",modalOverlay:"dsh-exp-modalOverlay",modalWarning:"dsh-exp-modalWarning",headerTitle:"dsh-exp-headerTitle",searchInput:"dsh-exp-searchInput",rowSelected:"dsh-exp-rowSelected",indentGuide:"dsh-exp-indentGuide",folderGroup:"dsh-exp-folderGroup",labelDimmed:"dsh-exp-labelDimmed",gitModified:"dsh-exp-gitModified",inlineInput:"dsh-exp-inlineInput",contextMenu:"dsh-exp-contextMenu",menuDivider:"dsh-exp-menuDivider",optionsBody:"dsh-exp-optionsBody",modalHeader:"dsh-exp-modalHeader",modalFooter:"dsh-exp-modalFooter",rowFocused:"dsh-exp-rowFocused",gitDeleted:"dsh-exp-gitDeleted",emptyState:"dsh-exp-emptyState",optionsRow:"dsh-exp-optionsRow",segmentBtn:"dsh-exp-segmentBtn",switchKnob:"dsh-exp-switchKnob",container:"dsh-exp-container",searchBar:"dsh-exp-searchBar",actionBtn:"dsh-exp-actionBtn",modalCard:"dsh-exp-modalCard",modalBody:"dsh-exp-modalBody",treeBody:"dsh-exp-treeBody",iconWrap:"dsh-exp-iconWrap",gitBadge:"dsh-exp-gitBadge",menuItem:"dsh-exp-menuItem",noMotion:"dsh-exp-noMotion",iconBtn:"dsh-exp-iconBtn",chevron:"dsh-exp-chevron",header:"dsh-exp-header",switch:"dsh-exp-switch",label:"dsh-exp-label",row:"dsh-exp-row"};async function et(e,n){let o=new URLSearchParams;e&&o.set("sessionId",e),n&&o.set("dir",n);let t=await fetch(`/dsh-explorer/api/tree?${o.toString()}`);if(!t.ok){let a=await t.text().catch(()=>"");throw new Error(`HTTP ${t.status}: ${a||t.statusText}`)}let s=await t.json();if(!s.ok)throw new Error(s.message||"Failed to fetch directory");return s.listing}async function ht(e){let o=await(await fetch("/dsh-explorer/api/batch-tree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})})).json();if(!o.ok)throw new Error(o.message||"Failed to fetch batch trees");return o.results}async function Vt(e,n){let o=new URLSearchParams;typeof e=="object"&&e!==null?(e.dir&&o.set("dir",e.dir),e.sessionId&&o.set("sessionId",e.sessionId)):(e&&o.set("dir",e),n&&o.set("sessionId",n));let t=await fetch(`/dsh-explorer/api/git-status?${o.toString()}`);if(!t.ok)return{isRepo:!1,entries:[]};let s=await t.json();return s.ok?s.git:{isRepo:!1,entries:[]}}async function pt(e,n,o,t,s=250){let a=n.trim().toLowerCase();if(!a)return{query:n,matches:[],totalMatches:0,truncated:!1};let l=[],x=[e],h=new Set,c=new Set(["node_modules",".agent",".git","dist","target","build",".system_generated",".cache",".dsh",".gemini",".vscode",".idea"]),m=0,f=1500;for(;x.length>0&&l.length<s&&m<f&&!t?.aborted;){let v=x.shift();if(!h.has(v)){h.add(v);try{let C=await et(o,v);if(!C?.entries)continue;for(let d of C.entries){if(!d||d.name.startsWith("."))continue;m++;let u=e.replace(/\\/g,"/").replace(/\/+$/,""),E=d.path.replace(/\\/g,"/"),k=E.toLowerCase().startsWith(`${u.toLowerCase()}/`)?E.slice(u.length+1):d.path,F=d.name.toLowerCase(),X=k.toLowerCase();if((F.includes(a)||X.includes(a))&&(l.push({name:d.name,path:d.path,relativePath:k,isDir:d.isDir}),l.length>=s))break;d.isDir&&!c.has(d.name)&&x.push(d.path)}}catch{continue}}}return{query:n,matches:l,totalMatches:l.length,truncated:m>=f}}async function Wt(e,n,o,t){let s=new URLSearchParams({dir:e,q:n});o&&s.set("sessionId",o);try{let a=await fetch(`/dsh-explorer/api/search?${s.toString()}`,{signal:t});if(a.status===404||!a.ok)return pt(e,n,o,t);let l=await a.json();return!l.ok||!l.result?pt(e,n,o,t):l.result}catch(a){if(a?.name==="AbortError")throw a;return pt(e,n,o,t)}}async function ft(e){let n=new URLSearchParams({path:e}),t=await(await fetch(`/dsh-explorer/api/read-file?${n.toString()}`)).json();if(!t.ok)throw new Error(t.message||"Failed to read file");return t.text}async function Kt(e,n){let t=await(await fetch("/dsh-explorer/api/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:e,name:n})})).json();if(!t.ok)throw new Error(t.message||"Failed to create file");return t}async function Gt(e,n){let t=await(await fetch("/dsh-explorer/api/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:e,name:n})})).json();if(!t.ok)throw new Error(t.message||"Failed to create folder");return t}async function Ut(e,n){let t=await(await fetch("/dsh-explorer/api/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,newName:n})})).json();if(!t.ok)throw new Error(t.message||"Failed to rename");return t}async function qt(e){let o=await(await fetch("/dsh-explorer/api/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})).json();if(!o.ok)throw new Error(o.message||"Failed to delete")}var $=require("react/jsx-runtime"),Zt=({title:e,searchOpen:n,optionsOpen:o,onToggleSearch:t,onToggleOptions:s,onNewFile:a,onNewFolder:l,onRefresh:x,onExpandAll:h,onCollapseAll:c})=>(0,$.jsxs)("div",{className:r.header,children:[(0,$.jsx)("span",{className:r.headerTitle,title:e,children:e}),(0,$.jsxs)("div",{className:r.headerActions,children:[(0,$.jsx)("button",{className:`${r.iconBtn} ${n?r.iconBtnActive:""}`,title:"Search files and folders",onClick:t,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"})})}),(0,$.jsx)("button",{className:r.iconBtn,title:"New File",onClick:a,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M9 1H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6L9 1zm0 1.5L12.5 6H9V2.5zM8 8.5V11h1V8.5h2.5v-1H9V5H8v2.5H5.5v1H8z"})})}),(0,$.jsx)("button",{className:r.iconBtn,title:"New Folder",onClick:l,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M7 2l2 2h5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h5zm2.5 6.5H8V6H7v2.5H4.5v1H7V12h1V9.5h2.5v-1z"})})}),(0,$.jsx)("button",{className:r.iconBtn,title:"Refresh",onClick:x,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M13.65 2.35A7.958 7.958 0 0 0 8 0a8 8 0 1 0 8 8h-2a6 6 0 1 1-1.76-4.24l-2.24 2.24H16V0l-2.35 2.35z"})})}),(0,$.jsx)("button",{className:r.iconBtn,title:"Expand All",onClick:h,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M4.646 5.854a.5.5 0 0 1 0-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8 3.207 5.354 5.854a.5.5 0 0 1-.708 0zm0 4.292a.5.5 0 0 0 0 .708l3 3a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8 12.793l-2.646-2.647a.5.5 0 0 0-.708 0z"})})}),(0,$.jsx)("button",{className:r.iconBtn,title:"Collapse All",onClick:c,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M4.646 2.854a.5.5 0 0 0 0 .708l3 3a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8 5.293 5.354 2.854a.5.5 0 0 0-.708 0zm0 10.292a.5.5 0 0 1 0-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8 10.707l-2.646 2.647a.5.5 0 0 1-.708 0z"})})}),(0,$.jsx)("button",{className:`${r.iconBtn} ${o?r.iconBtnActive:""}`,title:"Explorer display preferences",onClick:s,children:(0,$.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,$.jsx)("path",{d:"M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"})})})]})]});var ut=require("react");var $e=require("react/jsx-runtime"),Xt=({value:e,loading:n=!1,matchCount:o=null,onChange:t,onClose:s})=>{let a=(0,ut.useRef)(null);(0,ut.useEffect)(()=>{a.current?.focus()},[]);let l=x=>{x.key==="Escape"&&s()};return(0,$e.jsxs)("div",{className:r.searchBar,children:[(0,$e.jsx)("input",{ref:a,type:"text",className:r.searchInput,placeholder:"Search files and folders by name...",value:e,onChange:x=>t(x.target.value),onKeyDown:l}),n&&(0,$e.jsx)("div",{className:r.searchSpinner,title:"Searching workspace..."}),!n&&o!==null&&e.trim()!==""&&(0,$e.jsx)("span",{className:r.matchCountBadge,title:`${o} matches found`,children:o}),e&&(0,$e.jsx)("button",{className:r.clearSearchBtn,title:"Clear search (Esc)",onClick:()=>t(""),children:"\u2715"})]})};var mt=require("react");var R=require("react/jsx-runtime"),_t=({x:e,y:n,entry:o,relativePath:t,onClose:s,onOpenFile:a,onInsertReference:l,onInsertSnippet:x,onCopyPath:h,onCopyRelativePath:c,onNewFile:m,onNewFolder:f,onRename:v,onDelete:C})=>{let d=(0,mt.useRef)(null);(0,mt.useEffect)(()=>{let k=F=>{d.current&&!d.current.contains(F.target)&&s()};return window.addEventListener("mousedown",k),()=>window.removeEventListener("mousedown",k)},[s]);let u=Math.min(n,window.innerHeight-260),E=Math.min(e,window.innerWidth-200);return(0,R.jsxs)("div",{ref:d,className:r.contextMenu,style:{top:u,left:E},children:[!o.isDir&&a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)("div",{className:r.menuItem,onClick:()=>{a(),s()},children:[(0,R.jsx)("span",{children:"Open in New Tab"}),(0,R.jsx)("span",{className:r.menuShortcut,children:"Double-Click"})]}),(0,R.jsx)("div",{className:r.menuDivider})]}),(0,R.jsxs)("div",{className:r.menuItem,onClick:()=>{l(),s()},children:[(0,R.jsx)("span",{children:"Insert Mention to Chat"}),(0,R.jsx)("span",{className:r.menuShortcut,children:"@"})]}),!o.isDir&&(0,R.jsxs)("div",{className:r.menuItem,onClick:()=>{x(),s()},children:[(0,R.jsx)("span",{children:"Insert Code to Chat"}),(0,R.jsx)("span",{className:r.menuShortcut,children:"Alt+Drop"})]}),(0,R.jsx)("div",{className:r.menuDivider}),o.isDir&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)("div",{className:r.menuItem,onClick:()=>{m(),s()},children:(0,R.jsx)("span",{children:"New File..."})}),(0,R.jsx)("div",{className:r.menuItem,onClick:()=>{f(),s()},children:(0,R.jsx)("span",{children:"New Folder..."})}),(0,R.jsx)("div",{className:r.menuDivider})]}),(0,R.jsx)("div",{className:r.menuItem,onClick:()=>{c(),s()},children:(0,R.jsx)("span",{children:"Copy Relative Path"})}),(0,R.jsx)("div",{className:r.menuItem,onClick:()=>{h(),s()},children:(0,R.jsx)("span",{children:"Copy Path"})}),(0,R.jsx)("div",{className:r.menuDivider}),(0,R.jsxs)("div",{className:r.menuItem,onClick:()=>{v(),s()},children:[(0,R.jsx)("span",{children:"Rename..."}),(0,R.jsx)("span",{className:r.menuShortcut,children:"F2"})]}),(0,R.jsxs)("div",{className:r.menuItem,onClick:()=>{C(),s()},children:[(0,R.jsx)("span",{style:{color:"#f44336"},children:"Delete"}),(0,R.jsx)("span",{className:r.menuShortcut,children:"Del"})]})]})};var gt=require("react");var G=require("react/jsx-runtime"),Yt=({x:e,y:n,onClose:o,onNewFile:t,onNewFolder:s,onToggleSearch:a,onExpandAll:l,onCollapseAll:x,onRefresh:h,onOpenOptions:c})=>{let m=(0,gt.useRef)(null);(0,gt.useEffect)(()=>{let C=u=>{m.current&&!m.current.contains(u.target)&&o()},d=u=>{u.key==="Escape"&&o()};return window.addEventListener("mousedown",C),window.addEventListener("keydown",d),()=>{window.removeEventListener("mousedown",C),window.removeEventListener("keydown",d)}},[o]);let f=Math.min(n,window.innerHeight-250),v=Math.min(e,window.innerWidth-200);return(0,G.jsxs)("div",{ref:m,className:r.contextMenu,style:{top:f,left:v},children:[(0,G.jsx)("div",{className:r.menuItem,onClick:()=>{t(),o()},children:(0,G.jsx)("span",{children:"New File..."})}),(0,G.jsx)("div",{className:r.menuItem,onClick:()=>{s(),o()},children:(0,G.jsx)("span",{children:"New Folder..."})}),(0,G.jsx)("div",{className:r.menuDivider}),(0,G.jsxs)("div",{className:r.menuItem,onClick:()=>{a(),o()},children:[(0,G.jsx)("span",{children:"Search Files..."}),(0,G.jsx)("span",{className:r.menuShortcut,children:"Ctrl+F"})]}),(0,G.jsx)("div",{className:r.menuDivider}),(0,G.jsx)("div",{className:r.menuItem,onClick:()=>{l(),o()},children:(0,G.jsx)("span",{children:"Expand All"})}),(0,G.jsx)("div",{className:r.menuItem,onClick:()=>{x(),o()},children:(0,G.jsx)("span",{children:"Collapse All"})}),(0,G.jsx)("div",{className:r.menuDivider}),(0,G.jsx)("div",{className:r.menuItem,onClick:()=>{h(),o()},children:(0,G.jsx)("span",{children:"Refresh"})}),(0,G.jsx)("div",{className:r.menuDivider}),(0,G.jsx)("div",{className:r.menuItem,onClick:()=>{c(),o()},children:(0,G.jsx)("span",{children:"Display Preferences..."})})]})};var xt=require("react");var g=require("react/jsx-runtime"),Jt=({options:e,onChange:n,onReset:o,onClose:t})=>{let s=(0,xt.useRef)(null);(0,xt.useEffect)(()=>{let h=m=>{s.current&&!s.current.contains(m.target)&&t()},c=m=>{m.key==="Escape"&&t()};return document.addEventListener("mousedown",h,!0),document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("mousedown",h,!0),document.removeEventListener("keydown",c,!0)}},[t]);let a=h=>{n({density:h})},l=h=>{let c=parseFloat(h.target.value);Number.isNaN(c)||n({scale:Math.round(c*100)/100})},x=h=>{n({singleClickAction:h})};return(0,g.jsxs)("div",{ref:s,className:r.optionsPopover,children:[(0,g.jsxs)("div",{className:r.optionsHeader,children:[(0,g.jsxs)("div",{className:r.optionsHeaderTitle,children:[(0,g.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",style:{marginRight:"6px"},children:(0,g.jsx)("path",{d:"M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"})}),"EXPLORER OPTIONS"]}),(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,g.jsx)("button",{className:r.optionsIconBtn,title:"Reset to defaults",onClick:o,children:(0,g.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:(0,g.jsx)("path",{d:"M13.65 2.35A7.958 7.958 0 0 0 8 0a8 8 0 1 0 8 8h-2a6 6 0 1 1-1.76-4.24l-2.24 2.24H16V0l-2.35 2.35z"})})}),(0,g.jsx)("button",{className:r.optionsIconBtn,title:"Close",onClick:t,children:(0,g.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:(0,g.jsx)("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"})})})]})]}),(0,g.jsxs)("div",{className:r.optionsBody,children:[(0,g.jsxs)("div",{className:r.optionsSection,children:[(0,g.jsx)("div",{className:r.optionsSectionTitle,children:"Scale & Density"}),(0,g.jsxs)("div",{className:r.segmentGroup,children:[(0,g.jsx)("button",{type:"button",className:`${r.segmentBtn} ${e.density==="compact"?r.segmentBtnActive:""}`,onClick:()=>a("compact"),children:"Compact"}),(0,g.jsx)("button",{type:"button",className:`${r.segmentBtn} ${e.density==="normal"?r.segmentBtnActive:""}`,onClick:()=>a("normal"),children:"Normal"}),(0,g.jsx)("button",{type:"button",className:`${r.segmentBtn} ${e.density==="relaxed"?r.segmentBtnActive:""}`,onClick:()=>a("relaxed"),children:"Relaxed"})]}),(0,g.jsxs)("div",{className:r.optionsRow,style:{marginTop:"6px"},children:[(0,g.jsxs)("div",{className:r.optionsLabelWrap,children:[(0,g.jsx)("span",{className:r.optionsLabel,children:"Zoom Scale"}),(0,g.jsx)("span",{className:r.optionsSubLabel,children:"Resize tree text and icons"})]}),(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,g.jsxs)("span",{className:r.optionsBadge,children:[Math.round(e.scale*100),"%"]}),e.scale!==1&&(0,g.jsx)("button",{type:"button",className:r.optionsMiniBtn,title:"Reset scale to 100%",onClick:()=>n({scale:1}),children:"1x"})]})]}),(0,g.jsx)("input",{type:"range",min:"0.75",max:"1.35",step:"0.05",value:e.scale,onChange:l,className:r.optionsSlider})]}),(0,g.jsxs)("div",{className:r.optionsSection,children:[(0,g.jsx)("div",{className:r.optionsSectionTitle,children:"Motion & Transitions"}),(0,g.jsxs)("div",{className:r.optionsRow,children:[(0,g.jsxs)("div",{className:r.optionsLabelWrap,children:[(0,g.jsx)("span",{className:r.optionsLabel,children:"Smooth Animations"}),(0,g.jsx)("span",{className:r.optionsSubLabel,children:"Fluid folder collapse & icon turns"})]}),(0,g.jsx)("div",{className:`${r.switch} ${e.enableMotion?r.switchActive:""}`,onClick:()=>n({enableMotion:!e.enableMotion}),role:"switch","aria-checked":e.enableMotion,children:(0,g.jsx)("div",{className:`${r.switchKnob} ${e.enableMotion?r.switchKnobActive:""}`})})]})]}),(0,g.jsxs)("div",{className:r.optionsSection,children:[(0,g.jsx)("div",{className:r.optionsSectionTitle,children:"Workspace View"}),(0,g.jsxs)("div",{className:r.optionsRow,children:[(0,g.jsxs)("div",{className:r.optionsLabelWrap,children:[(0,g.jsx)("span",{className:r.optionsLabel,children:"Show Hidden Files"}),(0,g.jsx)("span",{className:r.optionsSubLabel,children:"Include dotfiles and config directories"})]}),(0,g.jsx)("div",{className:`${r.switch} ${e.showHiddenFiles?r.switchActive:""}`,onClick:()=>n({showHiddenFiles:!e.showHiddenFiles}),role:"switch","aria-checked":e.showHiddenFiles,children:(0,g.jsx)("div",{className:`${r.switchKnob} ${e.showHiddenFiles?r.switchKnobActive:""}`})})]}),(0,g.jsxs)("div",{className:r.optionsRow,children:[(0,g.jsxs)("div",{className:r.optionsLabelWrap,children:[(0,g.jsx)("span",{className:r.optionsLabel,children:"Git Status Indicators"}),(0,g.jsx)("span",{className:r.optionsSubLabel,children:"Highlight modified & untracked files"})]}),(0,g.jsx)("div",{className:`${r.switch} ${e.showGitBadges?r.switchActive:""}`,onClick:()=>n({showGitBadges:!e.showGitBadges}),role:"switch","aria-checked":e.showGitBadges,children:(0,g.jsx)("div",{className:`${r.switchKnob} ${e.showGitBadges?r.switchKnobActive:""}`})})]}),(0,g.jsxs)("div",{className:r.optionsRow,children:[(0,g.jsxs)("div",{className:r.optionsLabelWrap,children:[(0,g.jsx)("span",{className:r.optionsLabel,children:"Compact Folders"}),(0,g.jsx)("span",{className:r.optionsSubLabel,children:"Chain single-child directory paths"})]}),(0,g.jsx)("div",{className:`${r.switch} ${e.compactFolders?r.switchActive:""}`,onClick:()=>n({compactFolders:!e.compactFolders}),role:"switch","aria-checked":e.compactFolders,children:(0,g.jsx)("div",{className:`${r.switchKnob} ${e.compactFolders?r.switchKnobActive:""}`})})]})]}),(0,g.jsxs)("div",{className:r.optionsSection,children:[(0,g.jsx)("div",{className:r.optionsSectionTitle,children:"Interaction"}),(0,g.jsx)("div",{className:r.optionsRow,children:(0,g.jsxs)("div",{className:r.optionsLabelWrap,children:[(0,g.jsx)("span",{className:r.optionsLabel,children:"File Click Behavior"}),(0,g.jsx)("span",{className:r.optionsSubLabel,children:"Direct action when clicking a file"})]})}),(0,g.jsxs)("div",{className:r.segmentGroup,style:{marginTop:"4px"},children:[(0,g.jsx)("button",{type:"button",className:`${r.segmentBtn} ${e.singleClickAction==="select"?r.segmentBtnActive:""}`,onClick:()=>x("select"),children:"Select / Focus"}),(0,g.jsx)("button",{type:"button",className:`${r.segmentBtn} ${e.singleClickAction==="mention"?r.segmentBtnActive:""}`,onClick:()=>x("mention"),children:"Insert @Mention"})]})]})]})]})};var Te=require("react");var w=require("react/jsx-runtime");function Qt(e){let n=e.lastIndexOf(".");return n<=0?"":e.slice(n+1).toLowerCase()}function Mn(e,n){if(n)return"#dcb67a";let o=Qt(e),t=e.toLowerCase();if(t==="dockerfile"||t.startsWith("dockerfile."))return"#2496ed";if(t===".gitignore"||t===".gitattributes")return"#f14e32";if(t==="package.json")return"#cb3837";if(t.startsWith(".env"))return"#ecd53f";switch(o){case"ts":case"mts":case"cts":return"#3178c6";case"tsx":return"#3178c6";case"js":case"mjs":case"cjs":return"#f7df1e";case"jsx":return"#00d8ff";case"py":case"pyw":return"#3572a5";case"rs":return"#dea584";case"go":return"#00add8";case"c":case"h":return"#a8b9cc";case"cpp":case"cc":case"cxx":case"hpp":return"#00599c";case"cs":return"#178600";case"java":case"jar":return"#b07219";case"kt":case"kts":return"#a97bff";case"swift":return"#f05138";case"php":return"#777bb4";case"rb":return"#cc342d";case"html":case"htm":return"#e34c26";case"css":return"#42a5f5";case"scss":case"sass":return"#cd6799";case"less":return"#1d365d";case"json":case"jsonc":case"json5":return"#cbcb41";case"yaml":case"yml":return"#cb171e";case"toml":return"#9c4221";case"md":case"markdown":case"mdx":return"#519aba";case"sql":return"#e38c00";case"sh":case"bash":case"zsh":return"#89e051";case"ps1":case"psm1":return"#012456";case"svg":return"#ff9800";case"png":case"jpg":case"jpeg":case"gif":case"webp":case"ico":return"#ab47bc";case"zip":case"tar":case"gz":case"7z":case"rar":return"#ec407a";default:return"#90a4ae"}}function vt(e,n,o=!1,t=16){if(n){let h=o?"#e5c07b":"#dcb67a";return o?(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("path",{d:"M1.5 2.5C1.5 1.94772 1.94772 1.5 2.5 1.5H6.29289C6.5581 1.5 6.81249 1.60536 7 1.79289L8.20711 3H13.5C14.0523 3 14.5 3.44772 14.5 4V5H2.5L1.5 2.5Z",fill:h,opacity:"0.8"}),(0,w.jsx)("path",{d:"M1.5 5.5H14.5L13.5 13.5C13.5 14.0523 13.0523 14.5 12.5 14.5H3.5C2.94772 14.5 2.5 14.0523 2.5 13.5L1.5 5.5Z",fill:h}),(0,w.jsx)("path",{d:"M1.5 5.5L2.8 14H13.2L14.5 5.5H1.5Z",fill:"#ffe082",fillOpacity:"0.25"})]}):(0,w.jsx)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:(0,w.jsx)("path",{d:"M1.5 2.5C1.5 1.94772 1.94772 1.5 2.5 1.5H6.29289C6.5581 1.5 6.81249 1.60536 7 1.79289L8.20711 3H13.5C14.0523 3 14.5 3.44772 14.5 4V13.5C14.5 14.0523 14.0523 14.5 13.5 14.5H2.5C1.94772 14.5 1.5 14.0523 1.5 13.5V2.5Z",fill:h})})}let s=Qt(e),a=e.toLowerCase(),l=Mn(e,!1);if(s==="ts")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("rect",{width:"16",height:"16",rx:"2.5",fill:"#3178c6"}),(0,w.jsx)("text",{x:"3",y:"12",fill:"#ffffff",fontSize:"9.5",fontWeight:"bold",fontFamily:"monospace",children:"TS"})]});if(s==="tsx")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("rect",{width:"16",height:"16",rx:"2.5",fill:"#3178c6"}),(0,w.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"#00d8ff"}),(0,w.jsx)("ellipse",{cx:"8",cy:"8",rx:"5",ry:"2.2",stroke:"#00d8ff",strokeWidth:"0.9",fill:"none"}),(0,w.jsx)("ellipse",{cx:"8",cy:"8",rx:"5",ry:"2.2",stroke:"#00d8ff",strokeWidth:"0.9",fill:"none",transform:"rotate(60 8 8)"}),(0,w.jsx)("ellipse",{cx:"8",cy:"8",rx:"5",ry:"2.2",stroke:"#00d8ff",strokeWidth:"0.9",fill:"none",transform:"rotate(120 8 8)"})]});if(s==="js"||s==="mjs"||s==="cjs")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("rect",{width:"16",height:"16",rx:"2.5",fill:"#f7df1e"}),(0,w.jsx)("text",{x:"3.5",y:"12",fill:"#000000",fontSize:"9.5",fontWeight:"bold",fontFamily:"monospace",children:"JS"})]});if(s==="jsx")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("rect",{width:"16",height:"16",rx:"2.5",fill:"#20232a"}),(0,w.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"#00d8ff"}),(0,w.jsx)("ellipse",{cx:"8",cy:"8",rx:"5",ry:"2.2",stroke:"#00d8ff",strokeWidth:"0.9",fill:"none"}),(0,w.jsx)("ellipse",{cx:"8",cy:"8",rx:"5",ry:"2.2",stroke:"#00d8ff",strokeWidth:"0.9",fill:"none",transform:"rotate(60 8 8)"}),(0,w.jsx)("ellipse",{cx:"8",cy:"8",rx:"5",ry:"2.2",stroke:"#00d8ff",strokeWidth:"0.9",fill:"none",transform:"rotate(120 8 8)"})]});if(s==="py")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("path",{d:"M7.9 1.5C5.2 1.5 5.3 2.7 5.3 2.7V4H8V4.4H3.8C2.5 4.4 1.5 5.5 1.5 7.2C1.5 8.9 2.3 9.4 3.3 9.4H4.3V8.1C4.3 6.6 5.5 5.5 7 5.5H9.6C10.5 5.5 11.2 4.8 11.2 3.9V2.7C11.2 1.8 10.3 1.5 7.9 1.5ZM6.5 2.6C6.9 2.6 7.2 2.9 7.2 3.3C7.2 3.7 6.9 4 6.5 4C6.1 4 5.8 3.7 5.8 3.3C5.8 2.9 6.1 2.6 6.5 2.6Z",fill:"#3572a5"}),(0,w.jsx)("path",{d:"M8.1 14.5C10.8 14.5 10.7 13.3 10.7 13.3V12H8V11.6H12.2C13.5 11.6 14.5 10.5 14.5 8.8C14.5 7.1 13.7 6.6 12.7 6.6H11.7V7.9C11.7 9.4 10.5 10.5 9 10.5H6.4C5.5 10.5 4.8 11.2 4.8 12.1V13.3C4.8 14.2 5.7 14.5 8.1 14.5ZM9.5 13.4C9.1 13.4 8.8 13.1 8.8 12.7C8.8 12.3 9.1 12 9.5 12C9.9 12 10.2 12.3 10.2 12.7C10.2 13.1 9.9 13.4 9.5 13.4Z",fill:"#ffd43b"})]});if(s==="rs")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("circle",{cx:"8",cy:"8",r:"6.5",stroke:"#dea584",strokeWidth:"1.2",fill:"#1e1e1e"}),(0,w.jsx)("path",{d:"M5.5 5H9C9.8 5 10.5 5.5 10.5 6.3C10.5 7 10 7.6 9.3 7.8L10.8 11H9.3L8 8.2H7V11H5.5V5ZM7 7.1H8.8C9.2 7.1 9.5 6.8 9.5 6.4C9.5 6 9.2 5.8 8.8 5.8H7V7.1Z",fill:"#dea584"})]});if(s==="go")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("rect",{width:"16",height:"16",rx:"2.5",fill:"#00add8"}),(0,w.jsx)("text",{x:"2",y:"11.5",fill:"#ffffff",fontSize:"8",fontWeight:"bold",fontFamily:"sans-serif",children:"GO"})]});if(s==="json")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("path",{d:"M2.5 2C2.5 1.44772 2.94772 1 3.5 1H10L14 5V14C14 14.5523 13.5523 15 13 15H3.5C2.94772 15 2.5 14.5523 2.5 14V2Z",fill:"#2d3748"}),(0,w.jsx)("text",{x:"4",y:"11",fill:"#cbcb41",fontSize:"9",fontWeight:"bold",fontFamily:"monospace",children:"{}"})]});if(s==="md"||s==="markdown")return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("rect",{x:"1",y:"3",width:"14",height:"10",rx:"1.5",stroke:"#519aba",strokeWidth:"1.2",fill:"#1e1e1e"}),(0,w.jsx)("path",{d:"M3.5 10V6L5.5 8.5L7.5 6V10",stroke:"#519aba",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,w.jsx)("path",{d:"M11 6V10M9.5 8.5L11 10L12.5 8.5",stroke:"#519aba",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round"})]});if(a===".gitignore"||a===".gitattributes")return(0,w.jsx)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:(0,w.jsx)("path",{d:"M14.6 7.4L8.6 1.4C8.2 1 7.6 1 7.2 1.4L1.4 7.2C1 7.6 1 8.2 1.4 8.6L7.4 14.6C7.8 15 8.4 15 8.8 14.6L14.6 8.8C15 8.4 15 7.8 14.6 7.4ZM8.5 10.8V8.3C7.4 8.4 6.8 9 6.8 9.5C6.8 9.7 6.6 9.8 6.4 9.8C6.2 9.8 6 9.6 6 9.4C6 8.3 7 7.3 8.5 7.1V5.5C8.1 5.4 7.8 5 7.8 4.5C7.8 3.9 8.2 3.5 8.8 3.5C9.4 3.5 9.8 3.9 9.8 4.5C9.8 5 9.4 5.4 9.1 5.5V10.8C9.4 10.9 9.8 11.3 9.8 11.8C9.8 12.4 9.4 12.8 8.8 12.8C8.2 12.8 7.8 12.4 7.8 11.8C7.8 11.3 8.1 10.9 8.5 10.8Z",fill:"#f14e32"})});if(a==="dockerfile"||a.startsWith("dockerfile."))return(0,w.jsx)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:(0,w.jsx)("path",{d:"M14.5 7.5C14 7.5 13.5 7.8 13.2 8.2C12.4 7.7 11.2 7.7 10.5 8.2V5H8.5V7H9.5V8.5H5.5V6H3.5V8.5H2V7H1V8.5C0.4 8.8 0 9.4 0 10C0 12.2 2.5 14 6.5 14C11.5 14 14.8 11.2 15 8.5C15 8 14.8 7.5 14.5 7.5Z",fill:"#2496ed"})});let x=s.slice(0,3).toUpperCase();return(0,w.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[(0,w.jsx)("path",{d:"M3 2C3 1.44772 3.44772 1 4 1H10L14 5V14C14 14.5523 13.5523 15 13 15H4C3.44772 15 3 14.5523 3 14V2Z",fill:"#2b313c",stroke:"#3e4451",strokeWidth:"0.8"}),(0,w.jsx)("path",{d:"M10 1V5H14",fill:"#3e4451",opacity:"0.6"}),x?(0,w.jsx)("text",{x:"4",y:"11",fill:l,fontSize:"6",fontWeight:"bold",fontFamily:"monospace",children:x}):(0,w.jsx)("circle",{cx:"8",cy:"9",r:"1.8",fill:l})]})}var V=require("react/jsx-runtime"),en=({entry:e,relativePath:n,onConfirm:o,onClose:t})=>{let[s,a]=(0,Te.useState)(!1),[l,x]=(0,Te.useState)(null),h=(0,Te.useRef)(null),c=(0,Te.useRef)(null);(0,Te.useEffect)(()=>{h.current?.focus();let f=C=>{C.key==="Escape"&&(C.preventDefault(),t())},v=C=>{c.current&&!c.current.contains(C.target)&&t()};return document.addEventListener("keydown",f),document.addEventListener("mousedown",v),()=>{document.removeEventListener("keydown",f),document.removeEventListener("mousedown",v)}},[t]);let m=async()=>{if(!s){a(!0),x(null);try{await o(),t()}catch(f){x(f?.message||"Failed to delete"),a(!1)}}};return(0,V.jsx)("div",{className:r.modalOverlay,children:(0,V.jsxs)("div",{ref:c,className:r.modalCard,role:"dialog","aria-modal":"true",children:[(0,V.jsxs)("div",{className:r.modalHeader,children:[(0,V.jsxs)("div",{className:r.modalTitleWrap,children:[(0,V.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"currentColor",children:(0,V.jsx)("path",{d:"M6.5 1h3a.5.5 0 0 1 .5.5v1H14a.5.5 0 0 1 0 1h-.6l-.8 11.2A2 2 0 0 1 10.6 16H5.4a2 2 0 0 1-2-1.8L2.6 3.5H2a.5.5 0 0 1 0-1h4v-1a.5.5 0 0 1 .5-.5zM7 2v.5h2V2H7zm-2.4 12.4a1 1 0 0 0 1 .6h5.2a1 1 0 0 0 1-.9L12.4 3.5H3.6l.8 10.9h.2zm2.9-9.9a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zm3 0a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5z"})}),(0,V.jsx)("span",{children:e.isDir?"Delete Folder":"Delete File"})]}),(0,V.jsx)("button",{className:r.optionsIconBtn,title:"Close",onClick:t,children:(0,V.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:(0,V.jsx)("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"})})})]}),(0,V.jsxs)("div",{className:r.modalBody,children:[(0,V.jsxs)("div",{children:["Are you sure you want to permanently delete this ",e.isDir?"directory":"file","?"]}),(0,V.jsxs)("div",{className:r.modalItemPreview,children:[(0,V.jsx)("span",{className:r.iconWrap,children:vt(e.name,e.isDir,!1,16)}),(0,V.jsxs)("div",{className:r.modalItemInfo,children:[(0,V.jsx)("div",{className:r.modalItemName,children:e.name}),(0,V.jsx)("div",{className:r.modalItemPath,children:n})]})]}),e.isDir&&(0,V.jsx)("div",{className:r.modalWarning,children:"Warning: All nested files and subdirectories inside this folder will be permanently removed."}),l&&(0,V.jsx)("div",{className:r.modalErrorBanner,children:l})]}),(0,V.jsxs)("div",{className:r.modalFooter,children:[(0,V.jsx)("button",{ref:h,type:"button",className:r.modalBtnCancel,onClick:t,disabled:s,children:"Cancel"}),(0,V.jsx)("button",{type:"button",className:r.modalBtnDanger,onClick:m,disabled:s,children:s?"Deleting...":"Delete"})]})]})})};var Be=Nn(require("react"),1);var Xe=require("react");var ye="",Fe=null;function tn(e){e&&(ye=e)}function tt(e,n){try{return e?.get?e.get(n):e?.reflect?.get?e.reflect.get(n,!1):e?.[n]}catch{try{return e?.reflect?.get?.(n,!1)}catch{return}}}function yt(e,n){if(n)return ye=n,n;if(ye)return ye;try{let o=tt(e,"sessions");if(o){let t=o.list?.getSnapshot?.();if(t?.byId){for(let[a,l]of Object.entries(t.byId))if((l?.retainedBy?.mainView??0)>0)return ye=a,a;if(t.activeId)return ye=t.activeId,t.activeId;if(Array.isArray(t.ids)&&t.ids.length>0){let a=t.ids[t.ids.length-1];return ye=a,a}let s=Object.keys(t.byId);if(s.length>0){let a=s[s.length-1];return ye=a,a}}if(o.active?.id)return ye=o.active.id,o.active.id;if(o.current?.id)return ye=o.current.id,o.current.id}}catch{}return""}function Ze(){if(typeof document>"u")return null;let e=document.querySelector('[data-composer-input="true"]')??document.querySelector("[data-composer-input]");if(e)return e;let n=document.querySelector('[data-slot="conversation"]')??document.querySelector('[data-slot*="conversation"]')??document.body,o=n.querySelector('[contenteditable="true"][role="textbox"]')??n.querySelector('[contenteditable="true"]');return o||(document.querySelector("textarea[data-phase]")??document.querySelector("textarea")??document.querySelector('[contenteditable="true"]')??null)}function bt(){try{if(typeof document>"u")return;let e=Ze();if(!e)return;if(e.tagName==="TEXTAREA"||e.tagName==="INPUT"){let n=e,o=n.selectionStart,t=n.selectionEnd;typeof o=="number"&&typeof t=="number"&&Number.isFinite(o)&&Number.isFinite(t)&&(Fe={start:Math.max(0,Math.min(o,n.value.length)),end:Math.max(o,Math.min(t,n.value.length)),draft:n.value,timestamp:Date.now()})}else if(e.isContentEditable){let n=window.getSelection();if(n&&n.rangeCount>0&&n.anchorNode&&e.contains(n.anchorNode)){let o=n.getRangeAt(0);if(o&&o.startContainer&&e.contains(o.startContainer)){let t=o.startContainer.nodeType===Node.TEXT_NODE?o.startContainer.nodeValue?.length??0:o.startContainer.childNodes.length,s=Math.max(0,Math.min(o.startOffset,t)),a=o.cloneRange();a.selectNodeContents(e),a.setEnd(o.startContainer,s);let l=a.toString().length,x=o.toString().length;Fe={start:l,end:l+x,draft:e.innerText??e.textContent??"",timestamp:Date.now()}}}}}catch{}}var St=!1;function nn(){if(St||typeof document>"u")return()=>{};St=!0;let e=()=>bt();return document.addEventListener("selectionchange",e,{passive:!0}),document.addEventListener("keyup",e,{passive:!0}),document.addEventListener("mouseup",e,{passive:!0}),document.addEventListener("input",e,{passive:!0}),document.addEventListener("focusin",e,{passive:!0}),()=>{document.removeEventListener("selectionchange",e),document.removeEventListener("keyup",e),document.removeEventListener("mouseup",e),document.removeEventListener("input",e),document.removeEventListener("focusin",e),St=!1}}function Tn(e,n){if(!n||e.length===0)return n;let{start:o,end:t}=n,s=a=>!!(a&&!/[\s\r\n\t]/.test(a));if(o===t&&o>0&&o<e.length){let a=e[o-1],l=e[o];if(s(a)&&s(l)){for(;o<e.length&&s(e[o]);)o++;t=o}}return{start:o,end:t}}function kt(e,n){let o=Ze();if(o&&(o.tagName==="TEXTAREA"||o.tagName==="INPUT")){let t=o;if(!t.disabled&&!t.readOnly){let s=t.selectionStart,a=t.selectionEnd;if(typeof s=="number"&&typeof a=="number"&&Number.isFinite(s)&&Number.isFinite(a)&&(document.activeElement===t||t.value===e)){let l=Math.max(0,Math.min(s,e.length)),x=Math.max(l,Math.min(a,e.length));return Fe={start:l,end:x,draft:e,timestamp:Date.now()},{start:l,end:x}}}}if(Fe){let t=Math.max(0,Math.min(Fe.start,e.length)),s=Math.max(t,Math.min(Fe.end,e.length));return{start:t,end:s}}return null}function Lt(e,n){let o=3,t=()=>{o-=1;let s=Ze();if(s){if(s.tagName==="TEXTAREA"||s.tagName==="INPUT"){let a=s;if(a.disabled||a.readOnly)return;let l=Math.max(0,Math.min(n,a.value.length));a.focus(),a.setSelectionRange(l,l),Fe={start:l,end:l,draft:a.value,timestamp:Date.now()};return}else if(s.isContentEditable){s.focus(),Fe={start:n,end:n,draft:e,timestamp:Date.now()};return}o>0&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(t):setTimeout(t,16))}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):setTimeout(t,16)}function Nt(e,n,o){let t=Tn(e,o);if(!t||e===""){let m=e.trim()===""?n:`${e}${/\s$/.test(e)?"":" "}${n}`;return{draft:m,caretAfter:m.length}}let s=e.slice(0,t.start),a=e.slice(t.end),l=s===""||/\s$/.test(s)?"":" ",x=a===""||/^\s/.test(a)||/\s$/.test(n)?"":" ",h=`${s}${l}${n}${x}${a}`,c=s.length+l.length+n.length;return{draft:h,caretAfter:c}}function Fn(e,n){let o=e.replace(/[\\/]+$/,"").replace(/\\/g,"/"),t=n?`${o}/`:o;return/\s/.test(t)?`@"${t}"`:`@${t}`}function Dt(e){let n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return n===-1?e:e.slice(n+1)}function Oe(e,n,o,t,s){try{let a=Fn(o,t),l=Dt(o),x=t?`${l}/`:l,h=t?"folder":"file";if(s&&typeof document<"u"){let d=Ze();if(d){let u=null;if(typeof document.caretRangeFromPoint=="function")u=document.caretRangeFromPoint(s.x,s.y);else if(typeof document.caretPositionFromPoint=="function"){let E=document.caretPositionFromPoint(s.x,s.y);E&&E.offsetNode&&(u=document.createRange(),u.setStart(E.offsetNode,E.offset),u.collapse(!0))}if(u&&d.contains(u.startContainer)){let E=window.getSelection();E?.removeAllRanges(),E?.addRange(u),d.focus({preventScroll:!0})}}}let c=tt(e,"sessions"),m=yt(e,n),f=m&&c?.scope?c.scope(m):void 0,v=tt(e,"conversation");if(v&&f){let d=v.input?.for(f);if(d){if(d.draftEditor&&typeof d.draftEditor.insertFileReferences=="function")try{let E=d.rev??d.state?.getSnapshot?.()?.draftRev??0,k=d.draftEditor.insertFileReferences([{source:"reference",ref:a,label:x,appearance:h,clipboardText:a}]),F=d.rev??d.state?.getSnapshot?.()?.draftRev??0;if(k||F!==E)return d.focus?.(),!0}catch(E){console.warn("[dsh-explorer] draftEditor.insertFileReferences failed, trying actx.bail:",E)}let u=d.actions?.captureInsertion?.()??d.captureInsertion?.();if(u&&u.draftRev!==void 0){let E=d.projection?.detectText??"",k=u.start>0?E[u.start-1]??"":"";if(!k)try{let P=window.getSelection();if(P&&P.anchorNode){let we=P.anchorNode.textContent??"",J=P.anchorOffset;J>0&&(k=we[J-1]??"")}}catch{}if(!k){let P=d.state?.getSnapshot?.()?.draft??"";u.start>0&&u.start<=P.length&&(k=P[u.start-1]??"")}if(k&&!/\s/.test(k)){if(typeof d.actions?.insertText=="function")try{d.actions.insertText(" ",u)}catch{}else if(typeof d.insertText=="function")try{d.insertText(" ",u)}catch{}let P=d.actions?.captureInsertion?.()??d.captureInsertion?.();P&&P.draftRev!==void 0&&(u=P)}let F=d.rev??d.state?.getSnapshot?.()?.draftRev??0,X=!1;try{typeof f.bail=="function"&&(X=!!f.bail(f,"slash/input-insert-reference",{reference:{source:"reference",ref:a,label:x,appearance:h,clipboardText:a},span:u}))}catch{}if(!X)try{f.emit?.("slash/input-insert-reference",{reference:{source:"reference",ref:a,label:x,appearance:h,clipboardText:a},span:u})}catch{}let ve=d.rev??d.state?.getSnapshot?.()?.draftRev??0;if(X||ve!==F)return d.focus?.(),!0;let Y="";k&&!/\s/.test(k)&&(Y=" ");let le=`${Y}${a} `;if(typeof d.actions?.insertText=="function")try{if(d.actions.insertText(le,u))return d.focus?.(),!0}catch{}if(typeof d.insertText=="function")try{if(d.insertText(le,u))return d.focus?.(),!0}catch{}}}}let C=Ze();if(C){if(C.isContentEditable){C.focus();let d=!1;try{let E=window.getSelection();if(E&&E.rangeCount>0){let k=E.getRangeAt(0);if(k.startContainer.nodeType===Node.TEXT_NODE){let F=k.startContainer.textContent??"";k.startOffset>0&&!/\s/.test(F[k.startOffset-1])&&(d=!0)}else if(k.startContainer.previousSibling){let F=k.startContainer.previousSibling.textContent??"";F&&!/\s/.test(F.slice(-1))&&(d=!0)}}}catch{}let u=`${d?" ":""}${a} `;try{if(document.execCommand("insertText",!1,u))return bt(),!0}catch{}try{let E=window.getSelection();if(E&&E.rangeCount>0){let k=E.getRangeAt(0);k.deleteContents();let F=document.createTextNode(u);return k.insertNode(F),k.collapse(!1),E.removeAllRanges(),E.addRange(k),C.dispatchEvent(new Event("input",{bubbles:!0})),bt(),!0}}catch{}}if(C.tagName==="TEXTAREA"||C.tagName==="INPUT"){let d=C,u=d.value,E=kt(u,s)??{start:d.selectionStart??u.length,end:d.selectionEnd??u.length},{draft:k,caretAfter:F}=Nt(u,`${a} `,E);return d.value=k,d.dispatchEvent(new Event("input",{bubbles:!0})),Lt(k,F),!0}}if(v&&f){let d=v.input?.for(f);if(d?.setDraft){let u=d.state?.getSnapshot?.()?.draft??"",E=kt(u,s),{draft:k,caretAfter:F}=Nt(u,`${a} `,E);return d.setDraft(k),Lt(k,F),!0}}return!1}catch(a){return console.warn("[dsh-explorer] insertMentionToComposer failed:",a),!1}}function wt(e,n,o,t,s){try{let l=`
|
|
841
|
+
\`\`\`${o.slice(o.lastIndexOf(".")+1)||"text"} title="${o}"
|
|
842
|
+
${t}
|
|
843
|
+
\`\`\`
|
|
844
|
+
`,x=yt(e,n),h=tt(e,"sessions"),c=x&&h?.scope?h.scope(x):void 0,m=tt(e,"conversation");if(m&&c){let v=m.input?.for(c);if(v){let C=v.actions?.captureInsertion?.()??v.captureInsertion?.();if(C&&C.draftRev!==void 0){if(typeof v.actions?.insertText=="function")try{if(v.actions.insertText(l,C))return v.focus?.(),!0}catch{}if(typeof v.insertText=="function")try{if(v.insertText(l,C))return v.focus?.(),!0}catch{}}}}let f=Ze();if(f){if(f.isContentEditable){f.focus();try{if(document.execCommand("insertText",!1,l))return bt(),!0}catch{}}if(f.tagName==="TEXTAREA"||f.tagName==="INPUT"){let v=f,C=v.value,d=kt(C,s)??{start:v.selectionStart??C.length,end:v.selectionEnd??C.length},{draft:u,caretAfter:E}=Nt(C,l,d);return v.value=u,v.dispatchEvent(new Event("input",{bubbles:!0})),Lt(u,E),!0}}return!1}catch(a){return console.warn("[dsh-explorer] insertSnippetToComposer failed:",a),!1}}var Rt="application/vnd.dsh.explorer-items",nt=null;function on(e,n){nt=n;let o=JSON.stringify(n);try{e.dataTransfer.setData(Rt,o)}catch{}let t=n.map(s=>s.isDir?`@${s.relativePath}/`:`@${s.relativePath}`).join(" ");try{e.dataTransfer.setData("text/plain",t)}catch{}e.dataTransfer.effectAllowed="copy"}function rn(){setTimeout(()=>{nt=null},200)}var ze=null;function Bn(e){if(ze&&document.body.contains(ze))return ze;let n=document.createElement("div");return n.style.position="absolute",n.style.inset="0",n.style.backgroundColor="rgba(33, 150, 243, 0.08)",n.style.border="2px dashed #007fd4",n.style.borderRadius="8px",n.style.zIndex="9999",n.style.pointerEvents="none",n.style.display="flex",n.style.flexDirection="column",n.style.alignItems="center",n.style.justifyContent="center",n.style.gap="8px",n.style.backdropFilter="blur(2px)",n.style.transition="opacity 0.15s cubic-bezier(0.2, 0, 0, 1)",n.innerHTML=`
|
|
982
845
|
<div style="font-weight: 600; font-size: 13px; color: #58a6ff; background: rgba(22, 27, 34, 0.85); border: 1px solid rgba(88, 166, 255, 0.3); padding: 8px 16px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); display: flex; align-items: center; gap: 8px;">
|
|
983
846
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
984
847
|
<path d="M8 2a.75.75 0 0 1 .75.75v8.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V2.75A.75.75 0 0 1 8 2z"/>
|
|
@@ -988,1825 +851,7 @@ function getOrCreateOverlay(targetEl) {
|
|
|
988
851
|
<div style="font-size: 11px; opacity: 0.9; color: #8b949e; background: rgba(22, 27, 34, 0.7); padding: 3px 8px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.06);">
|
|
989
852
|
Hold <b>Alt</b> or <b>Shift</b> to embed code snippet
|
|
990
853
|
</div>
|
|
991
|
-
`;
|
|
992
|
-
activeOverlay = div;
|
|
993
|
-
return div;
|
|
994
|
-
}
|
|
995
|
-
function attachGlobalConversationDropListener(ctx) {
|
|
996
|
-
let dragDepth = 0;
|
|
997
|
-
const hasExplorerData = (e) => {
|
|
998
|
-
if (currentDragItems && currentDragItems.length > 0) return true;
|
|
999
|
-
try {
|
|
1000
|
-
const types = Array.from(e.dataTransfer?.types ?? []);
|
|
1001
|
-
return types.includes(DSH_EXPLORER_MIME) || types.includes("text/plain");
|
|
1002
|
-
} catch {
|
|
1003
|
-
return false;
|
|
1004
|
-
}
|
|
1005
|
-
};
|
|
1006
|
-
const getConversationContainer = () => {
|
|
1007
|
-
return document.querySelector('[data-slot="conversation.session"]') ?? document.querySelector('[data-slot="conversation.shell"]') ?? document.querySelector('[data-slot*="conversation"]') ?? document.querySelector(".an3WzG_root") ?? document.querySelector(".conversation-main") ?? document.querySelector("main") ?? document.querySelector("#root > div") ?? null;
|
|
1008
|
-
};
|
|
1009
|
-
const handleDragEnter = (e) => {
|
|
1010
|
-
if (!hasExplorerData(e)) return;
|
|
1011
|
-
const container = getConversationContainer();
|
|
1012
|
-
if (!container) return;
|
|
1013
|
-
dragDepth += 1;
|
|
1014
|
-
const overlay = getOrCreateOverlay(container);
|
|
1015
|
-
if (!container.contains(overlay)) {
|
|
1016
|
-
if (getComputedStyle(container).position === "static") {
|
|
1017
|
-
container.style.position = "relative";
|
|
1018
|
-
}
|
|
1019
|
-
container.appendChild(overlay);
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
const handleDragOver = (e) => {
|
|
1023
|
-
if (!hasExplorerData(e)) return;
|
|
1024
|
-
e.preventDefault();
|
|
1025
|
-
if (e.dataTransfer) {
|
|
1026
|
-
e.dataTransfer.dropEffect = "copy";
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
const handleDragLeave = (e) => {
|
|
1030
|
-
if (!hasExplorerData(e)) return;
|
|
1031
|
-
dragDepth -= 1;
|
|
1032
|
-
if (dragDepth <= 0) {
|
|
1033
|
-
dragDepth = 0;
|
|
1034
|
-
activeOverlay?.remove();
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
const handleDrop = async (e) => {
|
|
1038
|
-
if (!hasExplorerData(e)) return;
|
|
1039
|
-
e.preventDefault();
|
|
1040
|
-
e.stopPropagation();
|
|
1041
|
-
dragDepth = 0;
|
|
1042
|
-
activeOverlay?.remove();
|
|
1043
|
-
let items = currentDragItems;
|
|
1044
|
-
if (!items || items.length === 0) {
|
|
1045
|
-
try {
|
|
1046
|
-
const raw = e.dataTransfer?.getData(DSH_EXPLORER_MIME);
|
|
1047
|
-
if (raw) items = JSON.parse(raw);
|
|
1048
|
-
} catch {
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
if (!items || items.length === 0) {
|
|
1052
|
-
const plain = e.dataTransfer?.getData("text/plain");
|
|
1053
|
-
if (plain && plain.startsWith("@")) {
|
|
1054
|
-
const relativePath = plain.replace(/^@"?/, "").replace(/"?$/, "");
|
|
1055
|
-
items = [{
|
|
1056
|
-
path: relativePath,
|
|
1057
|
-
relativePath,
|
|
1058
|
-
isDir: relativePath.endsWith("/"),
|
|
1059
|
-
name: relativePath
|
|
1060
|
-
}];
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
if (!items || items.length === 0) return;
|
|
1064
|
-
try {
|
|
1065
|
-
const activeSessionId = resolveActiveSessionId(ctx);
|
|
1066
|
-
const isAlt = e.altKey || e.shiftKey;
|
|
1067
|
-
let currentPoint = { x: e.clientX, y: e.clientY };
|
|
1068
|
-
for (const item of items) {
|
|
1069
|
-
if (isAlt && !item.isDir) {
|
|
1070
|
-
try {
|
|
1071
|
-
const content = await fetchFileContent(item.path);
|
|
1072
|
-
insertSnippetToComposer(ctx, activeSessionId, item.relativePath, content, currentPoint);
|
|
1073
|
-
} catch {
|
|
1074
|
-
insertMentionToComposer(ctx, activeSessionId, item.relativePath, item.isDir, currentPoint);
|
|
1075
|
-
}
|
|
1076
|
-
} else {
|
|
1077
|
-
insertMentionToComposer(ctx, activeSessionId, item.relativePath, item.isDir, currentPoint);
|
|
1078
|
-
}
|
|
1079
|
-
currentPoint = void 0;
|
|
1080
|
-
if (items.length > 1) {
|
|
1081
|
-
await new Promise((resolve) => setTimeout(resolve, 40));
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
} catch (err) {
|
|
1085
|
-
console.warn("[dsh-explorer] drop failed:", err);
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
document.addEventListener("dragenter", handleDragEnter, true);
|
|
1089
|
-
document.addEventListener("dragover", handleDragOver, true);
|
|
1090
|
-
document.addEventListener("dragleave", handleDragLeave, true);
|
|
1091
|
-
document.addEventListener("drop", handleDrop, true);
|
|
1092
|
-
return () => {
|
|
1093
|
-
document.removeEventListener("dragenter", handleDragEnter, true);
|
|
1094
|
-
document.removeEventListener("dragover", handleDragOver, true);
|
|
1095
|
-
document.removeEventListener("dragleave", handleDragLeave, true);
|
|
1096
|
-
document.removeEventListener("drop", handleDrop, true);
|
|
1097
|
-
activeOverlay?.remove();
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// src/client/ExplorerRow.tsx
|
|
1102
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1103
|
-
var ExplorerRow = ({
|
|
1104
|
-
entry,
|
|
1105
|
-
depth,
|
|
1106
|
-
isExpanded,
|
|
1107
|
-
isSelected,
|
|
1108
|
-
isFocused,
|
|
1109
|
-
gitStatus,
|
|
1110
|
-
relativePath,
|
|
1111
|
-
compactChain,
|
|
1112
|
-
indentStep = 16,
|
|
1113
|
-
iconSize = 16,
|
|
1114
|
-
enableMotion = true,
|
|
1115
|
-
showGitBadges = true,
|
|
1116
|
-
compactFolders = true,
|
|
1117
|
-
singleClickAction = "select",
|
|
1118
|
-
onToggle,
|
|
1119
|
-
onSelect,
|
|
1120
|
-
onDoubleClick,
|
|
1121
|
-
onContextMenu,
|
|
1122
|
-
onInsertReference,
|
|
1123
|
-
onCopyRelativePath,
|
|
1124
|
-
onRenameSubmit,
|
|
1125
|
-
onDelete
|
|
1126
|
-
}) => {
|
|
1127
|
-
const [isRenaming, setIsRenaming] = (0, import_react2.useState)(false);
|
|
1128
|
-
const [renameVal, setRenameVal] = (0, import_react2.useState)(entry.name);
|
|
1129
|
-
const inputRef = (0, import_react2.useRef)(null);
|
|
1130
|
-
(0, import_react2.useEffect)(() => {
|
|
1131
|
-
if (isRenaming) {
|
|
1132
|
-
inputRef.current?.focus();
|
|
1133
|
-
inputRef.current?.select();
|
|
1134
|
-
}
|
|
1135
|
-
}, [isRenaming]);
|
|
1136
|
-
const handleDragStart = (e) => {
|
|
1137
|
-
const item = {
|
|
1138
|
-
path: entry.path,
|
|
1139
|
-
relativePath,
|
|
1140
|
-
isDir: entry.isDir,
|
|
1141
|
-
name: entry.name
|
|
1142
|
-
};
|
|
1143
|
-
setupDragStart(e, [item]);
|
|
1144
|
-
};
|
|
1145
|
-
const handleRenameKeyDown = (e) => {
|
|
1146
|
-
if (e.key === "Enter") {
|
|
1147
|
-
const trimmed = renameVal.trim();
|
|
1148
|
-
if (trimmed && trimmed !== entry.name) {
|
|
1149
|
-
onRenameSubmit(trimmed);
|
|
1150
|
-
}
|
|
1151
|
-
setIsRenaming(false);
|
|
1152
|
-
} else if (e.key === "Escape") {
|
|
1153
|
-
setRenameVal(entry.name);
|
|
1154
|
-
setIsRenaming(false);
|
|
1155
|
-
}
|
|
1156
|
-
};
|
|
1157
|
-
const displayName = compactFolders && compactChain && compactChain.length > 1 ? compactChain.map((c) => c.name).join("/") : compactFolders && entry.compactName ? entry.compactName : entry.name;
|
|
1158
|
-
let gitClass = "";
|
|
1159
|
-
let gitLetter = "";
|
|
1160
|
-
if (gitStatus) {
|
|
1161
|
-
if (gitStatus.includes("M")) {
|
|
1162
|
-
gitClass = explorer_default.gitModified;
|
|
1163
|
-
gitLetter = "M";
|
|
1164
|
-
} else if (gitStatus.includes("?") || gitStatus.includes("A")) {
|
|
1165
|
-
gitClass = explorer_default.gitUntracked;
|
|
1166
|
-
gitLetter = "U";
|
|
1167
|
-
} else if (gitStatus.includes("D")) {
|
|
1168
|
-
gitClass = explorer_default.gitDeleted;
|
|
1169
|
-
gitLetter = "D";
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
const isIgnored = gitStatus?.includes("!");
|
|
1173
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1174
|
-
"div",
|
|
1175
|
-
{
|
|
1176
|
-
className: `${explorer_default.row} ${isSelected ? explorer_default.rowSelected : ""} ${isFocused ? explorer_default.rowFocused : ""}`,
|
|
1177
|
-
style: { paddingLeft: `${depth * indentStep + 8}px` },
|
|
1178
|
-
onClick: (e) => {
|
|
1179
|
-
onSelect(e);
|
|
1180
|
-
if (entry.isDir) {
|
|
1181
|
-
onToggle();
|
|
1182
|
-
} else if (singleClickAction === "mention") {
|
|
1183
|
-
onInsertReference();
|
|
1184
|
-
}
|
|
1185
|
-
},
|
|
1186
|
-
onDoubleClick: (e) => {
|
|
1187
|
-
if (!entry.isDir) {
|
|
1188
|
-
e.stopPropagation();
|
|
1189
|
-
onDoubleClick?.();
|
|
1190
|
-
}
|
|
1191
|
-
},
|
|
1192
|
-
onContextMenu,
|
|
1193
|
-
draggable: !isRenaming,
|
|
1194
|
-
onDragStart: handleDragStart,
|
|
1195
|
-
onDragEnd: setupDragEnd,
|
|
1196
|
-
children: [
|
|
1197
|
-
Array.from({ length: depth }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1198
|
-
"span",
|
|
1199
|
-
{
|
|
1200
|
-
className: explorer_default.indentGuide,
|
|
1201
|
-
style: { left: `${i * indentStep + 15}px` }
|
|
1202
|
-
},
|
|
1203
|
-
i
|
|
1204
|
-
)),
|
|
1205
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1206
|
-
"span",
|
|
1207
|
-
{
|
|
1208
|
-
className: `${explorer_default.chevron} ${isExpanded ? explorer_default.chevronExpanded : ""} ${!entry.isDir ? explorer_default.chevronHidden : ""}`,
|
|
1209
|
-
style: !enableMotion ? { transition: "none" } : void 0,
|
|
1210
|
-
onClick: (e) => {
|
|
1211
|
-
e.stopPropagation();
|
|
1212
|
-
onToggle();
|
|
1213
|
-
},
|
|
1214
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M6 3.5L10.5 8 6 12.5V3.5Z" }) })
|
|
1215
|
-
}
|
|
1216
|
-
),
|
|
1217
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: explorer_default.iconWrap, children: renderFileIcon(entry.name, entry.isDir, isExpanded, iconSize) }),
|
|
1218
|
-
isRenaming ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1219
|
-
"input",
|
|
1220
|
-
{
|
|
1221
|
-
ref: inputRef,
|
|
1222
|
-
type: "text",
|
|
1223
|
-
className: explorer_default.inlineInput,
|
|
1224
|
-
value: renameVal,
|
|
1225
|
-
onChange: (e) => setRenameVal(e.target.value),
|
|
1226
|
-
onKeyDown: handleRenameKeyDown,
|
|
1227
|
-
onBlur: () => {
|
|
1228
|
-
const trimmed = renameVal.trim();
|
|
1229
|
-
if (trimmed && trimmed !== entry.name) {
|
|
1230
|
-
onRenameSubmit(trimmed);
|
|
1231
|
-
}
|
|
1232
|
-
setIsRenaming(false);
|
|
1233
|
-
},
|
|
1234
|
-
onClick: (e) => e.stopPropagation()
|
|
1235
|
-
}
|
|
1236
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1237
|
-
"span",
|
|
1238
|
-
{
|
|
1239
|
-
className: `${explorer_default.label} ${isIgnored ? explorer_default.labelDimmed : ""} ${showGitBadges ? gitClass : ""}`,
|
|
1240
|
-
title: relativePath,
|
|
1241
|
-
children: displayName
|
|
1242
|
-
}
|
|
1243
|
-
),
|
|
1244
|
-
showGitBadges && gitLetter && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `${explorer_default.gitBadge} ${gitClass}`, children: gitLetter }),
|
|
1245
|
-
!isRenaming && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: explorer_default.hoverActions, onClick: (e) => e.stopPropagation(), children: [
|
|
1246
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1247
|
-
"button",
|
|
1248
|
-
{
|
|
1249
|
-
className: explorer_default.actionBtn,
|
|
1250
|
-
title: "Mention in Chat (@)",
|
|
1251
|
-
onClick: (e) => {
|
|
1252
|
-
e.stopPropagation();
|
|
1253
|
-
onInsertReference();
|
|
1254
|
-
},
|
|
1255
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2zM7 5h2v2h2v2H9v2H7V9H5V7h2V5z" }) })
|
|
1256
|
-
}
|
|
1257
|
-
),
|
|
1258
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1259
|
-
"button",
|
|
1260
|
-
{
|
|
1261
|
-
className: explorer_default.actionBtn,
|
|
1262
|
-
title: "Copy Relative Path",
|
|
1263
|
-
onClick: (e) => {
|
|
1264
|
-
e.stopPropagation();
|
|
1265
|
-
onCopyRelativePath();
|
|
1266
|
-
},
|
|
1267
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4 4h6v1H4v9h7v-4h1v5H3V4h1zm3-2h7v7h-1V3.7L7.7 9 7 8.3 12.3 3H7V2z" }) })
|
|
1268
|
-
}
|
|
1269
|
-
),
|
|
1270
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1271
|
-
"button",
|
|
1272
|
-
{
|
|
1273
|
-
className: explorer_default.actionBtn,
|
|
1274
|
-
title: "Rename (F2)",
|
|
1275
|
-
onClick: (e) => {
|
|
1276
|
-
e.stopPropagation();
|
|
1277
|
-
setIsRenaming(true);
|
|
1278
|
-
},
|
|
1279
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "11", height: "11", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z" }) })
|
|
1280
|
-
}
|
|
1281
|
-
)
|
|
1282
|
-
] })
|
|
1283
|
-
]
|
|
1284
|
-
}
|
|
1285
|
-
);
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
// src/client/ExplorerContextMenu.tsx
|
|
1289
|
-
var import_react3 = require("react");
|
|
1290
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1291
|
-
var ExplorerContextMenu = ({
|
|
1292
|
-
x,
|
|
1293
|
-
y,
|
|
1294
|
-
entry,
|
|
1295
|
-
relativePath,
|
|
1296
|
-
onClose,
|
|
1297
|
-
onOpenFile,
|
|
1298
|
-
onInsertReference,
|
|
1299
|
-
onInsertSnippet,
|
|
1300
|
-
onCopyPath,
|
|
1301
|
-
onCopyRelativePath,
|
|
1302
|
-
onNewFile,
|
|
1303
|
-
onNewFolder,
|
|
1304
|
-
onRename,
|
|
1305
|
-
onDelete
|
|
1306
|
-
}) => {
|
|
1307
|
-
const menuRef = (0, import_react3.useRef)(null);
|
|
1308
|
-
(0, import_react3.useEffect)(() => {
|
|
1309
|
-
const handleOutsideClick = (e) => {
|
|
1310
|
-
if (menuRef.current && !menuRef.current.contains(e.target)) {
|
|
1311
|
-
onClose();
|
|
1312
|
-
}
|
|
1313
|
-
};
|
|
1314
|
-
window.addEventListener("mousedown", handleOutsideClick);
|
|
1315
|
-
return () => window.removeEventListener("mousedown", handleOutsideClick);
|
|
1316
|
-
}, [onClose]);
|
|
1317
|
-
const top = Math.min(y, window.innerHeight - 260);
|
|
1318
|
-
const left = Math.min(x, window.innerWidth - 200);
|
|
1319
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref: menuRef, className: explorer_default.contextMenu, style: { top, left }, children: [
|
|
1320
|
-
!entry.isDir && onOpenFile && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1321
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1322
|
-
"div",
|
|
1323
|
-
{
|
|
1324
|
-
className: explorer_default.menuItem,
|
|
1325
|
-
onClick: () => {
|
|
1326
|
-
onOpenFile();
|
|
1327
|
-
onClose();
|
|
1328
|
-
},
|
|
1329
|
-
children: [
|
|
1330
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Open in New Tab" }),
|
|
1331
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: explorer_default.menuShortcut, children: "Double-Click" })
|
|
1332
|
-
]
|
|
1333
|
-
}
|
|
1334
|
-
),
|
|
1335
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: explorer_default.menuDivider })
|
|
1336
|
-
] }),
|
|
1337
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1338
|
-
"div",
|
|
1339
|
-
{
|
|
1340
|
-
className: explorer_default.menuItem,
|
|
1341
|
-
onClick: () => {
|
|
1342
|
-
onInsertReference();
|
|
1343
|
-
onClose();
|
|
1344
|
-
},
|
|
1345
|
-
children: [
|
|
1346
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Insert Mention to Chat" }),
|
|
1347
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: explorer_default.menuShortcut, children: "@" })
|
|
1348
|
-
]
|
|
1349
|
-
}
|
|
1350
|
-
),
|
|
1351
|
-
!entry.isDir && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1352
|
-
"div",
|
|
1353
|
-
{
|
|
1354
|
-
className: explorer_default.menuItem,
|
|
1355
|
-
onClick: () => {
|
|
1356
|
-
onInsertSnippet();
|
|
1357
|
-
onClose();
|
|
1358
|
-
},
|
|
1359
|
-
children: [
|
|
1360
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Insert Code to Chat" }),
|
|
1361
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: explorer_default.menuShortcut, children: "Alt+Drop" })
|
|
1362
|
-
]
|
|
1363
|
-
}
|
|
1364
|
-
),
|
|
1365
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: explorer_default.menuDivider }),
|
|
1366
|
-
entry.isDir && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1367
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1368
|
-
"div",
|
|
1369
|
-
{
|
|
1370
|
-
className: explorer_default.menuItem,
|
|
1371
|
-
onClick: () => {
|
|
1372
|
-
onNewFile();
|
|
1373
|
-
onClose();
|
|
1374
|
-
},
|
|
1375
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "New File..." })
|
|
1376
|
-
}
|
|
1377
|
-
),
|
|
1378
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1379
|
-
"div",
|
|
1380
|
-
{
|
|
1381
|
-
className: explorer_default.menuItem,
|
|
1382
|
-
onClick: () => {
|
|
1383
|
-
onNewFolder();
|
|
1384
|
-
onClose();
|
|
1385
|
-
},
|
|
1386
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "New Folder..." })
|
|
1387
|
-
}
|
|
1388
|
-
),
|
|
1389
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: explorer_default.menuDivider })
|
|
1390
|
-
] }),
|
|
1391
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1392
|
-
"div",
|
|
1393
|
-
{
|
|
1394
|
-
className: explorer_default.menuItem,
|
|
1395
|
-
onClick: () => {
|
|
1396
|
-
onCopyRelativePath();
|
|
1397
|
-
onClose();
|
|
1398
|
-
},
|
|
1399
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Copy Relative Path" })
|
|
1400
|
-
}
|
|
1401
|
-
),
|
|
1402
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1403
|
-
"div",
|
|
1404
|
-
{
|
|
1405
|
-
className: explorer_default.menuItem,
|
|
1406
|
-
onClick: () => {
|
|
1407
|
-
onCopyPath();
|
|
1408
|
-
onClose();
|
|
1409
|
-
},
|
|
1410
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Copy Path" })
|
|
1411
|
-
}
|
|
1412
|
-
),
|
|
1413
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: explorer_default.menuDivider }),
|
|
1414
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1415
|
-
"div",
|
|
1416
|
-
{
|
|
1417
|
-
className: explorer_default.menuItem,
|
|
1418
|
-
onClick: () => {
|
|
1419
|
-
onRename();
|
|
1420
|
-
onClose();
|
|
1421
|
-
},
|
|
1422
|
-
children: [
|
|
1423
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Rename..." }),
|
|
1424
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: explorer_default.menuShortcut, children: "F2" })
|
|
1425
|
-
]
|
|
1426
|
-
}
|
|
1427
|
-
),
|
|
1428
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1429
|
-
"div",
|
|
1430
|
-
{
|
|
1431
|
-
className: explorer_default.menuItem,
|
|
1432
|
-
onClick: () => {
|
|
1433
|
-
onDelete();
|
|
1434
|
-
onClose();
|
|
1435
|
-
},
|
|
1436
|
-
children: [
|
|
1437
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { color: "#f44336" }, children: "Delete" }),
|
|
1438
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: explorer_default.menuShortcut, children: "Del" })
|
|
1439
|
-
]
|
|
1440
|
-
}
|
|
1441
|
-
)
|
|
1442
|
-
] });
|
|
1443
|
-
};
|
|
1444
|
-
|
|
1445
|
-
// src/client/ExplorerOptionsModal.tsx
|
|
1446
|
-
var import_react4 = require("react");
|
|
1447
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1448
|
-
var ExplorerOptionsModal = ({
|
|
1449
|
-
options,
|
|
1450
|
-
onChange,
|
|
1451
|
-
onReset,
|
|
1452
|
-
onClose
|
|
1453
|
-
}) => {
|
|
1454
|
-
const popoverRef = (0, import_react4.useRef)(null);
|
|
1455
|
-
(0, import_react4.useEffect)(() => {
|
|
1456
|
-
const handleMouseDown = (e) => {
|
|
1457
|
-
if (popoverRef.current && !popoverRef.current.contains(e.target)) {
|
|
1458
|
-
onClose();
|
|
1459
|
-
}
|
|
1460
|
-
};
|
|
1461
|
-
const handleKeyDown = (e) => {
|
|
1462
|
-
if (e.key === "Escape") {
|
|
1463
|
-
onClose();
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
document.addEventListener("mousedown", handleMouseDown, true);
|
|
1467
|
-
document.addEventListener("keydown", handleKeyDown, true);
|
|
1468
|
-
return () => {
|
|
1469
|
-
document.removeEventListener("mousedown", handleMouseDown, true);
|
|
1470
|
-
document.removeEventListener("keydown", handleKeyDown, true);
|
|
1471
|
-
};
|
|
1472
|
-
}, [onClose]);
|
|
1473
|
-
const handleDensityChange = (density) => {
|
|
1474
|
-
onChange({ density });
|
|
1475
|
-
};
|
|
1476
|
-
const handleScaleChange = (e) => {
|
|
1477
|
-
const scale = parseFloat(e.target.value);
|
|
1478
|
-
if (!Number.isNaN(scale)) {
|
|
1479
|
-
onChange({ scale: Math.round(scale * 100) / 100 });
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
const handleActionChange = (action) => {
|
|
1483
|
-
onChange({ singleClickAction: action });
|
|
1484
|
-
};
|
|
1485
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: popoverRef, className: explorer_default.optionsPopover, children: [
|
|
1486
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsHeader, children: [
|
|
1487
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsHeaderTitle, children: [
|
|
1488
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "13", height: "13", viewBox: "0 0 16 16", fill: "currentColor", style: { marginRight: "6px" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z" }) }),
|
|
1489
|
-
"EXPLORER OPTIONS"
|
|
1490
|
-
] }),
|
|
1491
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
1492
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: explorer_default.optionsIconBtn, title: "Reset to defaults", onClick: onReset, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M13.65 2.35A7.958 7.958 0 0 0 8 0a8 8 0 1 0 8 8h-2a6 6 0 1 1-1.76-4.24l-2.24 2.24H16V0l-2.35 2.35z" }) }) }),
|
|
1493
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: explorer_default.optionsIconBtn, title: "Close", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" }) }) })
|
|
1494
|
-
] })
|
|
1495
|
-
] }),
|
|
1496
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsBody, children: [
|
|
1497
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsSection, children: [
|
|
1498
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: explorer_default.optionsSectionTitle, children: "Scale & Density" }),
|
|
1499
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.segmentGroup, children: [
|
|
1500
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1501
|
-
"button",
|
|
1502
|
-
{
|
|
1503
|
-
type: "button",
|
|
1504
|
-
className: `${explorer_default.segmentBtn} ${options.density === "compact" ? explorer_default.segmentBtnActive : ""}`,
|
|
1505
|
-
onClick: () => handleDensityChange("compact"),
|
|
1506
|
-
children: "Compact"
|
|
1507
|
-
}
|
|
1508
|
-
),
|
|
1509
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1510
|
-
"button",
|
|
1511
|
-
{
|
|
1512
|
-
type: "button",
|
|
1513
|
-
className: `${explorer_default.segmentBtn} ${options.density === "normal" ? explorer_default.segmentBtnActive : ""}`,
|
|
1514
|
-
onClick: () => handleDensityChange("normal"),
|
|
1515
|
-
children: "Normal"
|
|
1516
|
-
}
|
|
1517
|
-
),
|
|
1518
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1519
|
-
"button",
|
|
1520
|
-
{
|
|
1521
|
-
type: "button",
|
|
1522
|
-
className: `${explorer_default.segmentBtn} ${options.density === "relaxed" ? explorer_default.segmentBtnActive : ""}`,
|
|
1523
|
-
onClick: () => handleDensityChange("relaxed"),
|
|
1524
|
-
children: "Relaxed"
|
|
1525
|
-
}
|
|
1526
|
-
)
|
|
1527
|
-
] }),
|
|
1528
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsRow, style: { marginTop: "6px" }, children: [
|
|
1529
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsLabelWrap, children: [
|
|
1530
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsLabel, children: "Zoom Scale" }),
|
|
1531
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsSubLabel, children: "Resize tree text and icons" })
|
|
1532
|
-
] }),
|
|
1533
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "6px" }, children: [
|
|
1534
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: explorer_default.optionsBadge, children: [
|
|
1535
|
-
Math.round(options.scale * 100),
|
|
1536
|
-
"%"
|
|
1537
|
-
] }),
|
|
1538
|
-
options.scale !== 1 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1539
|
-
"button",
|
|
1540
|
-
{
|
|
1541
|
-
type: "button",
|
|
1542
|
-
className: explorer_default.optionsMiniBtn,
|
|
1543
|
-
title: "Reset scale to 100%",
|
|
1544
|
-
onClick: () => onChange({ scale: 1 }),
|
|
1545
|
-
children: "1x"
|
|
1546
|
-
}
|
|
1547
|
-
)
|
|
1548
|
-
] })
|
|
1549
|
-
] }),
|
|
1550
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1551
|
-
"input",
|
|
1552
|
-
{
|
|
1553
|
-
type: "range",
|
|
1554
|
-
min: "0.75",
|
|
1555
|
-
max: "1.35",
|
|
1556
|
-
step: "0.05",
|
|
1557
|
-
value: options.scale,
|
|
1558
|
-
onChange: handleScaleChange,
|
|
1559
|
-
className: explorer_default.optionsSlider
|
|
1560
|
-
}
|
|
1561
|
-
)
|
|
1562
|
-
] }),
|
|
1563
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsSection, children: [
|
|
1564
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: explorer_default.optionsSectionTitle, children: "Motion & Transitions" }),
|
|
1565
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsRow, children: [
|
|
1566
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsLabelWrap, children: [
|
|
1567
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsLabel, children: "Smooth Animations" }),
|
|
1568
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsSubLabel, children: "Fluid folder collapse & icon turns" })
|
|
1569
|
-
] }),
|
|
1570
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1571
|
-
"div",
|
|
1572
|
-
{
|
|
1573
|
-
className: `${explorer_default.switch} ${options.enableMotion ? explorer_default.switchActive : ""}`,
|
|
1574
|
-
onClick: () => onChange({ enableMotion: !options.enableMotion }),
|
|
1575
|
-
role: "switch",
|
|
1576
|
-
"aria-checked": options.enableMotion,
|
|
1577
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `${explorer_default.switchKnob} ${options.enableMotion ? explorer_default.switchKnobActive : ""}` })
|
|
1578
|
-
}
|
|
1579
|
-
)
|
|
1580
|
-
] })
|
|
1581
|
-
] }),
|
|
1582
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsSection, children: [
|
|
1583
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: explorer_default.optionsSectionTitle, children: "Workspace View" }),
|
|
1584
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsRow, children: [
|
|
1585
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsLabelWrap, children: [
|
|
1586
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsLabel, children: "Show Hidden Files" }),
|
|
1587
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsSubLabel, children: "Include dotfiles and config directories" })
|
|
1588
|
-
] }),
|
|
1589
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1590
|
-
"div",
|
|
1591
|
-
{
|
|
1592
|
-
className: `${explorer_default.switch} ${options.showHiddenFiles ? explorer_default.switchActive : ""}`,
|
|
1593
|
-
onClick: () => onChange({ showHiddenFiles: !options.showHiddenFiles }),
|
|
1594
|
-
role: "switch",
|
|
1595
|
-
"aria-checked": options.showHiddenFiles,
|
|
1596
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `${explorer_default.switchKnob} ${options.showHiddenFiles ? explorer_default.switchKnobActive : ""}` })
|
|
1597
|
-
}
|
|
1598
|
-
)
|
|
1599
|
-
] }),
|
|
1600
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsRow, children: [
|
|
1601
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsLabelWrap, children: [
|
|
1602
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsLabel, children: "Git Status Indicators" }),
|
|
1603
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsSubLabel, children: "Highlight modified & untracked files" })
|
|
1604
|
-
] }),
|
|
1605
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1606
|
-
"div",
|
|
1607
|
-
{
|
|
1608
|
-
className: `${explorer_default.switch} ${options.showGitBadges ? explorer_default.switchActive : ""}`,
|
|
1609
|
-
onClick: () => onChange({ showGitBadges: !options.showGitBadges }),
|
|
1610
|
-
role: "switch",
|
|
1611
|
-
"aria-checked": options.showGitBadges,
|
|
1612
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `${explorer_default.switchKnob} ${options.showGitBadges ? explorer_default.switchKnobActive : ""}` })
|
|
1613
|
-
}
|
|
1614
|
-
)
|
|
1615
|
-
] }),
|
|
1616
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsRow, children: [
|
|
1617
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsLabelWrap, children: [
|
|
1618
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsLabel, children: "Compact Folders" }),
|
|
1619
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsSubLabel, children: "Chain single-child directory paths" })
|
|
1620
|
-
] }),
|
|
1621
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1622
|
-
"div",
|
|
1623
|
-
{
|
|
1624
|
-
className: `${explorer_default.switch} ${options.compactFolders ? explorer_default.switchActive : ""}`,
|
|
1625
|
-
onClick: () => onChange({ compactFolders: !options.compactFolders }),
|
|
1626
|
-
role: "switch",
|
|
1627
|
-
"aria-checked": options.compactFolders,
|
|
1628
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `${explorer_default.switchKnob} ${options.compactFolders ? explorer_default.switchKnobActive : ""}` })
|
|
1629
|
-
}
|
|
1630
|
-
)
|
|
1631
|
-
] })
|
|
1632
|
-
] }),
|
|
1633
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsSection, children: [
|
|
1634
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: explorer_default.optionsSectionTitle, children: "Interaction" }),
|
|
1635
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: explorer_default.optionsRow, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.optionsLabelWrap, children: [
|
|
1636
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsLabel, children: "File Click Behavior" }),
|
|
1637
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: explorer_default.optionsSubLabel, children: "Direct action when clicking a file" })
|
|
1638
|
-
] }) }),
|
|
1639
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: explorer_default.segmentGroup, style: { marginTop: "4px" }, children: [
|
|
1640
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1641
|
-
"button",
|
|
1642
|
-
{
|
|
1643
|
-
type: "button",
|
|
1644
|
-
className: `${explorer_default.segmentBtn} ${options.singleClickAction === "select" ? explorer_default.segmentBtnActive : ""}`,
|
|
1645
|
-
onClick: () => handleActionChange("select"),
|
|
1646
|
-
children: "Select / Focus"
|
|
1647
|
-
}
|
|
1648
|
-
),
|
|
1649
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1650
|
-
"button",
|
|
1651
|
-
{
|
|
1652
|
-
type: "button",
|
|
1653
|
-
className: `${explorer_default.segmentBtn} ${options.singleClickAction === "mention" ? explorer_default.segmentBtnActive : ""}`,
|
|
1654
|
-
onClick: () => handleActionChange("mention"),
|
|
1655
|
-
children: "Insert @Mention"
|
|
1656
|
-
}
|
|
1657
|
-
)
|
|
1658
|
-
] })
|
|
1659
|
-
] })
|
|
1660
|
-
] })
|
|
1661
|
-
] });
|
|
1662
|
-
};
|
|
1663
|
-
|
|
1664
|
-
// src/client/options.ts
|
|
1665
|
-
var DEFAULT_OPTIONS = {
|
|
1666
|
-
scale: 1,
|
|
1667
|
-
density: "normal",
|
|
1668
|
-
enableMotion: true,
|
|
1669
|
-
showHiddenFiles: true,
|
|
1670
|
-
showGitBadges: true,
|
|
1671
|
-
compactFolders: false,
|
|
1672
|
-
singleClickAction: "select"
|
|
1673
|
-
};
|
|
1674
|
-
var STORAGE_KEY = "dsh_explorer_options_v1";
|
|
1675
|
-
function loadExplorerOptions() {
|
|
1676
|
-
if (typeof window === "undefined" || !window.localStorage) {
|
|
1677
|
-
return { ...DEFAULT_OPTIONS };
|
|
1678
|
-
}
|
|
1679
|
-
try {
|
|
1680
|
-
const raw = window.localStorage.getItem(STORAGE_KEY);
|
|
1681
|
-
if (!raw) return { ...DEFAULT_OPTIONS };
|
|
1682
|
-
const parsed = JSON.parse(raw);
|
|
1683
|
-
return {
|
|
1684
|
-
scale: typeof parsed.scale === "number" && Number.isFinite(parsed.scale) ? Math.max(0.75, Math.min(1.35, Math.round(parsed.scale * 100) / 100)) : DEFAULT_OPTIONS.scale,
|
|
1685
|
-
density: parsed.density === "compact" || parsed.density === "relaxed" ? parsed.density : "normal",
|
|
1686
|
-
enableMotion: typeof parsed.enableMotion === "boolean" ? parsed.enableMotion : DEFAULT_OPTIONS.enableMotion,
|
|
1687
|
-
showHiddenFiles: typeof parsed.showHiddenFiles === "boolean" ? parsed.showHiddenFiles : DEFAULT_OPTIONS.showHiddenFiles,
|
|
1688
|
-
showGitBadges: typeof parsed.showGitBadges === "boolean" ? parsed.showGitBadges : DEFAULT_OPTIONS.showGitBadges,
|
|
1689
|
-
compactFolders: typeof parsed.compactFolders === "boolean" ? parsed.compactFolders : DEFAULT_OPTIONS.compactFolders,
|
|
1690
|
-
singleClickAction: parsed.singleClickAction === "mention" ? "mention" : "select"
|
|
1691
|
-
};
|
|
1692
|
-
} catch {
|
|
1693
|
-
return { ...DEFAULT_OPTIONS };
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
function saveExplorerOptions(options) {
|
|
1697
|
-
if (typeof window === "undefined" || !window.localStorage) return;
|
|
1698
|
-
try {
|
|
1699
|
-
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(options));
|
|
1700
|
-
} catch {
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// src/client/ExplorerView.tsx
|
|
1705
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1706
|
-
function safeService2(ctx, name) {
|
|
1707
|
-
if (!ctx) return void 0;
|
|
1708
|
-
try {
|
|
1709
|
-
if (typeof ctx.get === "function") {
|
|
1710
|
-
const val = ctx.get(name);
|
|
1711
|
-
if (val !== void 0) return val;
|
|
1712
|
-
}
|
|
1713
|
-
return ctx[name];
|
|
1714
|
-
} catch {
|
|
1715
|
-
return void 0;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
function openFileInTab(ctx, sessionId, filePath, relPath) {
|
|
1719
|
-
const normPath = filePath.replace(/\\/g, "/");
|
|
1720
|
-
const fileName = baseName(filePath);
|
|
1721
|
-
try {
|
|
1722
|
-
const betterSidebar = safeService2(ctx, "betterSidebar");
|
|
1723
|
-
if (betterSidebar && typeof betterSidebar.openTab === "function") {
|
|
1724
|
-
betterSidebar.openTab({
|
|
1725
|
-
type: "editor",
|
|
1726
|
-
title: fileName,
|
|
1727
|
-
path: filePath,
|
|
1728
|
-
id: `editor:${filePath}`
|
|
1729
|
-
});
|
|
1730
|
-
return;
|
|
1731
|
-
}
|
|
1732
|
-
} catch {
|
|
1733
|
-
}
|
|
1734
|
-
try {
|
|
1735
|
-
const sidebarRight = safeService2(ctx, "sidebarRight");
|
|
1736
|
-
if (sidebarRight && typeof sidebarRight.openResource === "function") {
|
|
1737
|
-
const normRel = relPath.replace(/\\/g, "/");
|
|
1738
|
-
const encodePath = (p) => p.split("/").map((seg) => encodeURIComponent(seg).replace(/%3A/gi, ":")).join("/");
|
|
1739
|
-
const address = sessionId ? `dsh-resource://file/session/${encodeURIComponent(sessionId)}/${encodePath(normRel)}` : `dsh-resource://file/absolute/${encodePath(normPath.replace(/^\/+/, ""))}`;
|
|
1740
|
-
sidebarRight.openResource(address);
|
|
1741
|
-
return;
|
|
1742
|
-
}
|
|
1743
|
-
} catch {
|
|
1744
|
-
}
|
|
1745
|
-
try {
|
|
1746
|
-
const tabs = safeService2(ctx, "tabs");
|
|
1747
|
-
if (tabs && typeof tabs.open === "function") {
|
|
1748
|
-
tabs.open({ path: filePath, title: fileName });
|
|
1749
|
-
return;
|
|
1750
|
-
}
|
|
1751
|
-
} catch {
|
|
1752
|
-
}
|
|
1753
|
-
try {
|
|
1754
|
-
const remote = ctx?.remote?.session;
|
|
1755
|
-
if (remote && typeof remote.openWorkspacePath === "function") {
|
|
1756
|
-
remote.openWorkspacePath({ path: filePath });
|
|
1757
|
-
return;
|
|
1758
|
-
}
|
|
1759
|
-
} catch {
|
|
1760
|
-
}
|
|
1761
|
-
try {
|
|
1762
|
-
window.open(`/dsh-explorer/api/read-file?path=${encodeURIComponent(filePath)}`, "_blank");
|
|
1763
|
-
} catch {
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
var TreeNode = import_react5.default.memo(({
|
|
1767
|
-
entry,
|
|
1768
|
-
depth,
|
|
1769
|
-
rootPath,
|
|
1770
|
-
levels,
|
|
1771
|
-
expanded,
|
|
1772
|
-
selected,
|
|
1773
|
-
focusedPath,
|
|
1774
|
-
gitStatusMap,
|
|
1775
|
-
filterText,
|
|
1776
|
-
creating,
|
|
1777
|
-
creatingName,
|
|
1778
|
-
createInputRef,
|
|
1779
|
-
options,
|
|
1780
|
-
indentStep,
|
|
1781
|
-
iconSize,
|
|
1782
|
-
reloadDirectory,
|
|
1783
|
-
onToggle,
|
|
1784
|
-
onSelect,
|
|
1785
|
-
onOpenFile,
|
|
1786
|
-
onContextMenu,
|
|
1787
|
-
onInsertReference,
|
|
1788
|
-
onCopyRelativePath,
|
|
1789
|
-
onRenameSubmit,
|
|
1790
|
-
onDelete,
|
|
1791
|
-
onCreatingNameChange,
|
|
1792
|
-
onCreatingKeyDown,
|
|
1793
|
-
onCreatingBlur,
|
|
1794
|
-
getRelativePath
|
|
1795
|
-
}) => {
|
|
1796
|
-
const relPath = getRelativePath(entry.path);
|
|
1797
|
-
const normPath = entry.path.replace(/\\/g, "/");
|
|
1798
|
-
const listing = levels[entry.path] ?? levels[normPath];
|
|
1799
|
-
const hasLoaded = listing !== void 0;
|
|
1800
|
-
if (!options.showHiddenFiles && (entry.hidden || entry.name.startsWith("."))) {
|
|
1801
|
-
return null;
|
|
1802
|
-
}
|
|
1803
|
-
if (filterText) {
|
|
1804
|
-
const selfMatches = entry.name.toLowerCase().includes(filterText.toLowerCase()) || relPath.toLowerCase().includes(filterText.toLowerCase());
|
|
1805
|
-
if (!selfMatches && !entry.isDir) {
|
|
1806
|
-
return null;
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
const compactChain = (0, import_react5.useMemo)(() => {
|
|
1810
|
-
if (!options.compactFolders || !entry.isDir) return void 0;
|
|
1811
|
-
const chain = [entry];
|
|
1812
|
-
let curr = entry;
|
|
1813
|
-
let currListing = levels[curr.path] ?? levels[curr.path.replace(/\\/g, "/")];
|
|
1814
|
-
while (currListing && currListing.entries) {
|
|
1815
|
-
const valid = options.showHiddenFiles ? currListing.entries : currListing.entries.filter((c) => !c.hidden && !c.name.startsWith("."));
|
|
1816
|
-
if (valid.length === 1 && valid[0].isDir) {
|
|
1817
|
-
const next = valid[0];
|
|
1818
|
-
chain.push(next);
|
|
1819
|
-
curr = next;
|
|
1820
|
-
currListing = levels[curr.path] ?? levels[curr.path.replace(/\\/g, "/")];
|
|
1821
|
-
} else {
|
|
1822
|
-
break;
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
return chain.length > 1 ? chain : void 0;
|
|
1826
|
-
}, [options.compactFolders, options.showHiddenFiles, entry, levels]);
|
|
1827
|
-
const isCompacted = compactChain !== void 0 && compactChain.length > 1;
|
|
1828
|
-
const effectiveEntry = isCompacted ? compactChain[compactChain.length - 1] : entry;
|
|
1829
|
-
const targetPath = effectiveEntry.path;
|
|
1830
|
-
const targetRelPath = getRelativePath(targetPath);
|
|
1831
|
-
const isExpanded = entry.isDir && (expanded.has(entry.path) || expanded.has(targetPath) || Boolean(filterText));
|
|
1832
|
-
const isSel = selected.has(entry.path) || selected.has(targetPath);
|
|
1833
|
-
const isFoc = focusedPath === entry.path || focusedPath === targetPath;
|
|
1834
|
-
const normRel = targetRelPath.replace(/\\/g, "/").toLowerCase();
|
|
1835
|
-
const status = gitStatusMap.get(normRel) ?? gitStatusMap.get(targetPath.replace(/\\/g, "/").toLowerCase()) ?? gitStatusMap.get(relPath.replace(/\\/g, "/").toLowerCase());
|
|
1836
|
-
const targetListing = levels[targetPath] ?? levels[targetPath.replace(/\\/g, "/")];
|
|
1837
|
-
const hasTargetLoaded = targetListing !== void 0;
|
|
1838
|
-
(0, import_react5.useEffect)(() => {
|
|
1839
|
-
if (isExpanded && targetPath !== entry.path && !hasTargetLoaded) {
|
|
1840
|
-
reloadDirectory(targetPath);
|
|
1841
|
-
}
|
|
1842
|
-
}, [isExpanded, targetPath, entry.path, hasTargetLoaded, reloadDirectory]);
|
|
1843
|
-
(0, import_react5.useEffect)(() => {
|
|
1844
|
-
if (options.compactFolders && entry.isDir && entry.compact && !hasLoaded) {
|
|
1845
|
-
reloadDirectory(entry.path);
|
|
1846
|
-
}
|
|
1847
|
-
}, [options.compactFolders, entry.isDir, entry.compact, hasLoaded, entry.path, reloadDirectory]);
|
|
1848
|
-
const handleToggle = () => {
|
|
1849
|
-
if (isCompacted && targetPath !== entry.path) {
|
|
1850
|
-
const isCurrentlyExpanded = expanded.has(entry.path) || expanded.has(targetPath);
|
|
1851
|
-
if (isCurrentlyExpanded) {
|
|
1852
|
-
if (expanded.has(entry.path)) onToggle(entry.path);
|
|
1853
|
-
if (expanded.has(targetPath)) onToggle(targetPath);
|
|
1854
|
-
} else {
|
|
1855
|
-
onToggle(entry.path);
|
|
1856
|
-
onToggle(targetPath);
|
|
1857
|
-
}
|
|
1858
|
-
} else {
|
|
1859
|
-
onToggle(entry.path);
|
|
1860
|
-
}
|
|
1861
|
-
};
|
|
1862
|
-
if (!entry.isDir) {
|
|
1863
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1864
|
-
ExplorerRow,
|
|
1865
|
-
{
|
|
1866
|
-
entry,
|
|
1867
|
-
depth,
|
|
1868
|
-
isExpanded: false,
|
|
1869
|
-
isSelected: isSel,
|
|
1870
|
-
isFocused: isFoc,
|
|
1871
|
-
gitStatus: status,
|
|
1872
|
-
relativePath: relPath,
|
|
1873
|
-
indentStep,
|
|
1874
|
-
iconSize,
|
|
1875
|
-
enableMotion: options.enableMotion,
|
|
1876
|
-
showGitBadges: options.showGitBadges,
|
|
1877
|
-
compactFolders: options.compactFolders,
|
|
1878
|
-
singleClickAction: options.singleClickAction,
|
|
1879
|
-
onToggle: () => {
|
|
1880
|
-
},
|
|
1881
|
-
onSelect: (e) => onSelect(entry.path, e),
|
|
1882
|
-
onDoubleClick: () => onOpenFile(entry.path, relPath),
|
|
1883
|
-
onContextMenu: (e) => onContextMenu(entry, relPath, e),
|
|
1884
|
-
onInsertReference: () => onInsertReference(relPath, false),
|
|
1885
|
-
onCopyRelativePath: () => onCopyRelativePath(relPath),
|
|
1886
|
-
onRenameSubmit: (newName) => onRenameSubmit(entry.path, newName),
|
|
1887
|
-
onDelete: () => onDelete(entry)
|
|
1888
|
-
}
|
|
1889
|
-
);
|
|
1890
|
-
}
|
|
1891
|
-
const visibleChildren = hasTargetLoaded && targetListing.entries ? options.showHiddenFiles ? targetListing.entries : targetListing.entries.filter((c) => !c.hidden && !c.name.startsWith(".")) : [];
|
|
1892
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: explorer_default.folderGroup, children: [
|
|
1893
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1894
|
-
ExplorerRow,
|
|
1895
|
-
{
|
|
1896
|
-
entry,
|
|
1897
|
-
depth,
|
|
1898
|
-
isExpanded,
|
|
1899
|
-
isSelected: isSel,
|
|
1900
|
-
isFocused: isFoc,
|
|
1901
|
-
gitStatus: status,
|
|
1902
|
-
relativePath: targetRelPath,
|
|
1903
|
-
compactChain,
|
|
1904
|
-
indentStep,
|
|
1905
|
-
iconSize,
|
|
1906
|
-
enableMotion: options.enableMotion,
|
|
1907
|
-
showGitBadges: options.showGitBadges,
|
|
1908
|
-
compactFolders: options.compactFolders,
|
|
1909
|
-
singleClickAction: options.singleClickAction,
|
|
1910
|
-
onToggle: handleToggle,
|
|
1911
|
-
onSelect: (e) => onSelect(targetPath, e),
|
|
1912
|
-
onContextMenu: (e) => onContextMenu(entry, targetRelPath, e),
|
|
1913
|
-
onInsertReference: () => onInsertReference(targetRelPath, true),
|
|
1914
|
-
onCopyRelativePath: () => onCopyRelativePath(targetRelPath),
|
|
1915
|
-
onRenameSubmit: (newName) => onRenameSubmit(entry.path, newName),
|
|
1916
|
-
onDelete: () => onDelete(entry)
|
|
1917
|
-
}
|
|
1918
|
-
),
|
|
1919
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1920
|
-
"div",
|
|
1921
|
-
{
|
|
1922
|
-
className: `${explorer_default.folderChildren} ${isExpanded ? explorer_default.folderChildrenOpen : explorer_default.folderChildrenClosed}`,
|
|
1923
|
-
style: !options.enableMotion ? { transition: "none" } : void 0,
|
|
1924
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: explorer_default.folderChildrenInner, children: [
|
|
1925
|
-
creating && (creating.parentDir === entry.path || creating.parentDir === targetPath) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: explorer_default.row, style: { paddingLeft: `${(depth + 1) * indentStep + 8}px` }, children: [
|
|
1926
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: explorer_default.iconWrap, children: creating.isDir ? "\u{1F4C1}" : "\u{1F4C4}" }),
|
|
1927
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1928
|
-
"input",
|
|
1929
|
-
{
|
|
1930
|
-
ref: createInputRef,
|
|
1931
|
-
autoFocus: true,
|
|
1932
|
-
type: "text",
|
|
1933
|
-
className: explorer_default.inlineInput,
|
|
1934
|
-
placeholder: creating.isDir ? "Folder name..." : "File name...",
|
|
1935
|
-
value: creatingName,
|
|
1936
|
-
onChange: (e) => onCreatingNameChange(e.target.value),
|
|
1937
|
-
onKeyDown: onCreatingKeyDown,
|
|
1938
|
-
onBlur: onCreatingBlur
|
|
1939
|
-
}
|
|
1940
|
-
)
|
|
1941
|
-
] }),
|
|
1942
|
-
visibleChildren.length > 0 ? visibleChildren.map((child) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1943
|
-
TreeNode,
|
|
1944
|
-
{
|
|
1945
|
-
entry: child,
|
|
1946
|
-
depth: depth + 1,
|
|
1947
|
-
parentDir: targetPath,
|
|
1948
|
-
rootPath,
|
|
1949
|
-
levels,
|
|
1950
|
-
expanded,
|
|
1951
|
-
selected,
|
|
1952
|
-
focusedPath,
|
|
1953
|
-
gitStatusMap,
|
|
1954
|
-
filterText,
|
|
1955
|
-
creating,
|
|
1956
|
-
creatingName,
|
|
1957
|
-
createInputRef,
|
|
1958
|
-
options,
|
|
1959
|
-
indentStep,
|
|
1960
|
-
iconSize,
|
|
1961
|
-
reloadDirectory,
|
|
1962
|
-
onToggle,
|
|
1963
|
-
onSelect,
|
|
1964
|
-
onOpenFile,
|
|
1965
|
-
onContextMenu,
|
|
1966
|
-
onInsertReference,
|
|
1967
|
-
onCopyRelativePath,
|
|
1968
|
-
onRenameSubmit,
|
|
1969
|
-
onDelete,
|
|
1970
|
-
onCreatingNameChange,
|
|
1971
|
-
onCreatingKeyDown,
|
|
1972
|
-
onCreatingBlur,
|
|
1973
|
-
getRelativePath
|
|
1974
|
-
},
|
|
1975
|
-
child.path
|
|
1976
|
-
)) : hasTargetLoaded && targetListing.entries && targetListing.entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1977
|
-
"div",
|
|
1978
|
-
{
|
|
1979
|
-
className: explorer_default.row,
|
|
1980
|
-
style: {
|
|
1981
|
-
paddingLeft: `${(depth + 1) * indentStep + 8}px`,
|
|
1982
|
-
opacity: 0.45,
|
|
1983
|
-
fontStyle: "italic",
|
|
1984
|
-
fontSize: "12px"
|
|
1985
|
-
},
|
|
1986
|
-
children: "Empty folder"
|
|
1987
|
-
}
|
|
1988
|
-
) : null
|
|
1989
|
-
] })
|
|
1990
|
-
}
|
|
1991
|
-
)
|
|
1992
|
-
] });
|
|
1993
|
-
});
|
|
1994
|
-
var ExplorerView = ({ ctx, sessionId, initialCwd }) => {
|
|
1995
|
-
const [rootPath, setRootPath] = (0, import_react5.useState)(initialCwd ?? "");
|
|
1996
|
-
const [levels, setLevels] = (0, import_react5.useState)({});
|
|
1997
|
-
const [expanded, setExpanded] = (0, import_react5.useState)(() => /* @__PURE__ */ new Set());
|
|
1998
|
-
const [selected, setSelected] = (0, import_react5.useState)(() => /* @__PURE__ */ new Set());
|
|
1999
|
-
const [focusedPath, setFocusedPath] = (0, import_react5.useState)(null);
|
|
2000
|
-
const [filterText, setFilterText] = (0, import_react5.useState)("");
|
|
2001
|
-
const [searchOpen, setSearchOpen] = (0, import_react5.useState)(false);
|
|
2002
|
-
const [optionsOpen, setOptionsOpen] = (0, import_react5.useState)(false);
|
|
2003
|
-
const [options, setOptions] = (0, import_react5.useState)(() => loadExplorerOptions());
|
|
2004
|
-
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
2005
|
-
const [errorMessage, setErrorMessage] = (0, import_react5.useState)(null);
|
|
2006
|
-
const [gitData, setGitData] = (0, import_react5.useState)({ isRepo: false, entries: [] });
|
|
2007
|
-
const [creating, setCreating] = (0, import_react5.useState)(null);
|
|
2008
|
-
const [creatingName, setCreatingName] = (0, import_react5.useState)("");
|
|
2009
|
-
const [contextMenu, setContextMenu] = (0, import_react5.useState)(null);
|
|
2010
|
-
const treeBodyRef = (0, import_react5.useRef)(null);
|
|
2011
|
-
const createInputRef = (0, import_react5.useRef)(null);
|
|
2012
|
-
const handleUpdateOptions = (0, import_react5.useCallback)((patch) => {
|
|
2013
|
-
setOptions((prev) => {
|
|
2014
|
-
const next = { ...prev, ...patch };
|
|
2015
|
-
saveExplorerOptions(next);
|
|
2016
|
-
return next;
|
|
2017
|
-
});
|
|
2018
|
-
}, []);
|
|
2019
|
-
const handleResetOptions = (0, import_react5.useCallback)(() => {
|
|
2020
|
-
setOptions({ ...DEFAULT_OPTIONS });
|
|
2021
|
-
saveExplorerOptions({ ...DEFAULT_OPTIONS });
|
|
2022
|
-
}, []);
|
|
2023
|
-
const baseRowHeight = options.density === "compact" ? 20 : options.density === "relaxed" ? 28 : 24;
|
|
2024
|
-
const baseFontSize = options.density === "compact" ? 11.5 : options.density === "relaxed" ? 14 : 13;
|
|
2025
|
-
const baseIconSize = options.density === "compact" ? 14 : options.density === "relaxed" ? 18 : 16;
|
|
2026
|
-
const baseIndent = options.density === "compact" ? 12 : options.density === "relaxed" ? 20 : 16;
|
|
2027
|
-
const rowHeight = Math.round(baseRowHeight * options.scale);
|
|
2028
|
-
const fontSize = Math.round(baseFontSize * options.scale);
|
|
2029
|
-
const iconSize = Math.round(baseIconSize * options.scale);
|
|
2030
|
-
const indentStep = Math.round(baseIndent * options.scale);
|
|
2031
|
-
const containerStyles = (0, import_react5.useMemo)(
|
|
2032
|
-
() => ({
|
|
2033
|
-
"--dsh-row-height": `${rowHeight}px`,
|
|
2034
|
-
"--dsh-font-size": `${fontSize}px`,
|
|
2035
|
-
"--dsh-icon-size": `${iconSize}px`,
|
|
2036
|
-
"--dsh-scale": `${options.scale}`
|
|
2037
|
-
}),
|
|
2038
|
-
[rowHeight, fontSize, iconSize, options.scale]
|
|
2039
|
-
);
|
|
2040
|
-
(0, import_react5.useEffect)(() => {
|
|
2041
|
-
if (sessionId) {
|
|
2042
|
-
setLastKnownSessionId(sessionId);
|
|
2043
|
-
}
|
|
2044
|
-
}, [sessionId]);
|
|
2045
|
-
(0, import_react5.useEffect)(() => {
|
|
2046
|
-
if (rootPath) return;
|
|
2047
|
-
const sessions = safeService2(ctx, "sessions");
|
|
2048
|
-
const snapshot = sessions?.list?.getSnapshot?.();
|
|
2049
|
-
const activeId = sessionId ?? sessions?.active?.id ?? sessions?.current?.id ?? snapshot?.ids?.[0];
|
|
2050
|
-
if (activeId && snapshot?.byId?.[activeId]?.cwd) {
|
|
2051
|
-
setRootPath(snapshot.byId[activeId].cwd);
|
|
2052
|
-
return;
|
|
2053
|
-
}
|
|
2054
|
-
if (snapshot?.byId) {
|
|
2055
|
-
const first = Object.values(snapshot.byId).find((s) => s?.cwd);
|
|
2056
|
-
if (first?.cwd) {
|
|
2057
|
-
setRootPath(first.cwd);
|
|
2058
|
-
return;
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
const workspaces = safeService2(ctx, "workspaces");
|
|
2062
|
-
const ws = workspaces?.list?.getSnapshot?.();
|
|
2063
|
-
const item = ws?.items?.find((w) => w.sessionIds?.includes(activeId)) ?? ws?.items?.[0];
|
|
2064
|
-
if (item?.path) {
|
|
2065
|
-
setRootPath(item.path);
|
|
2066
|
-
return;
|
|
2067
|
-
}
|
|
2068
|
-
setLoading(true);
|
|
2069
|
-
fetchTree(activeId).then((listing) => {
|
|
2070
|
-
const normPath = listing.path.replace(/\\/g, "/");
|
|
2071
|
-
setRootPath(listing.path);
|
|
2072
|
-
setLevels((prev) => ({
|
|
2073
|
-
...prev,
|
|
2074
|
-
[listing.path]: listing,
|
|
2075
|
-
[normPath]: listing
|
|
2076
|
-
}));
|
|
2077
|
-
setExpanded((prev) => new Set(prev).add(listing.path));
|
|
2078
|
-
}).catch((err) => {
|
|
2079
|
-
console.warn("[dsh-explorer] root fetchTree error:", err);
|
|
2080
|
-
setErrorMessage(err?.message || "Failed to connect to file service");
|
|
2081
|
-
}).finally(() => {
|
|
2082
|
-
setLoading(false);
|
|
2083
|
-
});
|
|
2084
|
-
}, [rootPath, sessionId, ctx]);
|
|
2085
|
-
const reloadDirectory = (0, import_react5.useCallback)(
|
|
2086
|
-
async (dir) => {
|
|
2087
|
-
setLoading(true);
|
|
2088
|
-
setErrorMessage(null);
|
|
2089
|
-
const normDir = dir.replace(/\\/g, "/");
|
|
2090
|
-
try {
|
|
2091
|
-
const sessions = safeService2(ctx, "sessions");
|
|
2092
|
-
const snapshot = sessions?.list?.getSnapshot?.();
|
|
2093
|
-
const activeId = sessionId ?? sessions?.active?.id ?? snapshot?.ids?.[0];
|
|
2094
|
-
const listing = await fetchTree(activeId, dir);
|
|
2095
|
-
if (listing) {
|
|
2096
|
-
const normListingPath = listing.path.replace(/\\/g, "/");
|
|
2097
|
-
setLevels((prev) => ({
|
|
2098
|
-
...prev,
|
|
2099
|
-
[dir]: listing,
|
|
2100
|
-
[normDir]: listing,
|
|
2101
|
-
[listing.path]: listing,
|
|
2102
|
-
[normListingPath]: listing
|
|
2103
|
-
}));
|
|
2104
|
-
}
|
|
2105
|
-
} catch (err) {
|
|
2106
|
-
console.warn("[dsh-explorer] failed to load dir:", dir, err);
|
|
2107
|
-
setErrorMessage(err?.message || "Failed to load directory");
|
|
2108
|
-
} finally {
|
|
2109
|
-
setLoading(false);
|
|
2110
|
-
}
|
|
2111
|
-
},
|
|
2112
|
-
[sessionId, ctx]
|
|
2113
|
-
);
|
|
2114
|
-
const reloadGit = (0, import_react5.useCallback)(
|
|
2115
|
-
async (dir) => {
|
|
2116
|
-
try {
|
|
2117
|
-
const sessions = safeService2(ctx, "sessions");
|
|
2118
|
-
const activeId = sessionId ?? sessions?.active?.id;
|
|
2119
|
-
const git = await fetchGitStatus(activeId, dir);
|
|
2120
|
-
setGitData(git);
|
|
2121
|
-
} catch {
|
|
2122
|
-
}
|
|
2123
|
-
},
|
|
2124
|
-
[sessionId, ctx]
|
|
2125
|
-
);
|
|
2126
|
-
const expandedRef = (0, import_react5.useRef)(expanded);
|
|
2127
|
-
(0, import_react5.useEffect)(() => {
|
|
2128
|
-
expandedRef.current = expanded;
|
|
2129
|
-
}, [expanded]);
|
|
2130
|
-
const refreshAll = (0, import_react5.useCallback)(async () => {
|
|
2131
|
-
if (!rootPath) return;
|
|
2132
|
-
const currentExpanded = Array.from(expandedRef.current);
|
|
2133
|
-
const dirsToRefresh = Array.from(/* @__PURE__ */ new Set([rootPath, ...currentExpanded]));
|
|
2134
|
-
try {
|
|
2135
|
-
const [batch, rootListing2] = await Promise.all([
|
|
2136
|
-
fetchBatchTree(dirsToRefresh).catch(() => ({})),
|
|
2137
|
-
fetchTree(sessionId, rootPath).catch(() => null)
|
|
2138
|
-
]);
|
|
2139
|
-
const mergedBatch = { ...batch };
|
|
2140
|
-
if (rootListing2) {
|
|
2141
|
-
mergedBatch[rootPath] = rootListing2;
|
|
2142
|
-
if (rootListing2.path) mergedBatch[rootListing2.path] = rootListing2;
|
|
2143
|
-
}
|
|
2144
|
-
setLevels((prev) => {
|
|
2145
|
-
const next = { ...prev };
|
|
2146
|
-
for (const [dirKey, listing] of Object.entries(mergedBatch)) {
|
|
2147
|
-
if (!listing) continue;
|
|
2148
|
-
const norm = dirKey.replace(/\\/g, "/");
|
|
2149
|
-
next[dirKey] = listing;
|
|
2150
|
-
next[norm] = listing;
|
|
2151
|
-
if (listing.path) {
|
|
2152
|
-
next[listing.path] = listing;
|
|
2153
|
-
next[listing.path.replace(/\\/g, "/")] = listing;
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
for (const path of dirsToRefresh) {
|
|
2157
|
-
const norm = path.replace(/\\/g, "/");
|
|
2158
|
-
if (!mergedBatch[path] && !mergedBatch[norm] && path !== rootPath) {
|
|
2159
|
-
delete next[path];
|
|
2160
|
-
delete next[norm];
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
return next;
|
|
2164
|
-
});
|
|
2165
|
-
setExpanded((prev) => {
|
|
2166
|
-
let changed = false;
|
|
2167
|
-
const next = new Set(prev);
|
|
2168
|
-
for (const expPath of prev) {
|
|
2169
|
-
if (expPath === rootPath) continue;
|
|
2170
|
-
const normExp = expPath.replace(/\\/g, "/");
|
|
2171
|
-
if (!mergedBatch[expPath] && !mergedBatch[normExp]) {
|
|
2172
|
-
next.delete(expPath);
|
|
2173
|
-
changed = true;
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
return changed ? next : prev;
|
|
2177
|
-
});
|
|
2178
|
-
reloadGit(rootPath);
|
|
2179
|
-
} catch (err) {
|
|
2180
|
-
console.warn("[dsh-explorer] refreshAll failed:", err);
|
|
2181
|
-
}
|
|
2182
|
-
}, [rootPath, sessionId, reloadGit]);
|
|
2183
|
-
(0, import_react5.useEffect)(() => {
|
|
2184
|
-
if (!rootPath) return;
|
|
2185
|
-
refreshAll();
|
|
2186
|
-
setExpanded((prev) => new Set(prev).add(rootPath));
|
|
2187
|
-
}, [rootPath, refreshAll]);
|
|
2188
|
-
(0, import_react5.useEffect)(() => {
|
|
2189
|
-
if (!rootPath) return;
|
|
2190
|
-
let debounceTimer = null;
|
|
2191
|
-
const scheduleRefresh = () => {
|
|
2192
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
2193
|
-
debounceTimer = setTimeout(() => {
|
|
2194
|
-
refreshAll();
|
|
2195
|
-
}, 100);
|
|
2196
|
-
};
|
|
2197
|
-
let es = null;
|
|
2198
|
-
try {
|
|
2199
|
-
const sseUrl = `/dsh-explorer/api/events?dir=${encodeURIComponent(rootPath)}`;
|
|
2200
|
-
es = new EventSource(sseUrl);
|
|
2201
|
-
es.onmessage = (e) => {
|
|
2202
|
-
try {
|
|
2203
|
-
const data = JSON.parse(e.data);
|
|
2204
|
-
if (data.type === "connected") return;
|
|
2205
|
-
} catch {
|
|
2206
|
-
}
|
|
2207
|
-
scheduleRefresh();
|
|
2208
|
-
};
|
|
2209
|
-
} catch (err) {
|
|
2210
|
-
console.warn("[dsh-explorer] SSE init error:", err);
|
|
2211
|
-
}
|
|
2212
|
-
let ws = null;
|
|
2213
|
-
try {
|
|
2214
|
-
const loc = window.location;
|
|
2215
|
-
const host = loc.host || (loc.port ? `127.0.0.1:${loc.port}` : "127.0.0.1");
|
|
2216
|
-
const wsProtocol = loc.protocol === "https:" ? "wss:" : "ws:";
|
|
2217
|
-
const wsUrl = `${wsProtocol}//${host}/dsh-explorer/api/watch?dir=${encodeURIComponent(rootPath)}`;
|
|
2218
|
-
ws = new WebSocket(wsUrl);
|
|
2219
|
-
ws.onmessage = () => {
|
|
2220
|
-
scheduleRefresh();
|
|
2221
|
-
};
|
|
2222
|
-
} catch {
|
|
2223
|
-
}
|
|
2224
|
-
const onFocus = () => {
|
|
2225
|
-
scheduleRefresh();
|
|
2226
|
-
};
|
|
2227
|
-
const onVisibilityChange = () => {
|
|
2228
|
-
if (document.visibilityState === "visible") {
|
|
2229
|
-
scheduleRefresh();
|
|
2230
|
-
}
|
|
2231
|
-
};
|
|
2232
|
-
window.addEventListener("focus", onFocus);
|
|
2233
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
2234
|
-
const interval = setInterval(() => {
|
|
2235
|
-
if (document.visibilityState === "visible") {
|
|
2236
|
-
scheduleRefresh();
|
|
2237
|
-
}
|
|
2238
|
-
}, 3e3);
|
|
2239
|
-
return () => {
|
|
2240
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
2241
|
-
clearInterval(interval);
|
|
2242
|
-
window.removeEventListener("focus", onFocus);
|
|
2243
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2244
|
-
if (es) {
|
|
2245
|
-
try {
|
|
2246
|
-
es.close();
|
|
2247
|
-
} catch {
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
if (ws) {
|
|
2251
|
-
try {
|
|
2252
|
-
ws.close();
|
|
2253
|
-
} catch {
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
};
|
|
2257
|
-
}, [rootPath, refreshAll]);
|
|
2258
|
-
const toggleExpand = (0, import_react5.useCallback)(
|
|
2259
|
-
async (path) => {
|
|
2260
|
-
setExpanded((prev) => {
|
|
2261
|
-
const next = new Set(prev);
|
|
2262
|
-
if (next.has(path)) {
|
|
2263
|
-
next.delete(path);
|
|
2264
|
-
} else {
|
|
2265
|
-
next.add(path);
|
|
2266
|
-
const norm = path.replace(/\\/g, "/");
|
|
2267
|
-
if (!levels[path] && !levels[norm]) {
|
|
2268
|
-
reloadDirectory(path);
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
return next;
|
|
2272
|
-
});
|
|
2273
|
-
},
|
|
2274
|
-
[levels, reloadDirectory]
|
|
2275
|
-
);
|
|
2276
|
-
const getRelativePath = (0, import_react5.useCallback)(
|
|
2277
|
-
(fullPath) => {
|
|
2278
|
-
if (!rootPath) return fullPath;
|
|
2279
|
-
const normRoot = rootPath.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
2280
|
-
const normTarget = fullPath.replace(/\\/g, "/");
|
|
2281
|
-
if (normTarget.toLowerCase().startsWith(`${normRoot.toLowerCase()}/`)) {
|
|
2282
|
-
return normTarget.slice(normRoot.length + 1);
|
|
2283
|
-
}
|
|
2284
|
-
return fullPath;
|
|
2285
|
-
},
|
|
2286
|
-
[rootPath]
|
|
2287
|
-
);
|
|
2288
|
-
const gitStatusMap = (0, import_react5.useMemo)(() => {
|
|
2289
|
-
const map = /* @__PURE__ */ new Map();
|
|
2290
|
-
for (const entry of gitData.entries) {
|
|
2291
|
-
const p = entry.path.replace(/\\/g, "/").toLowerCase();
|
|
2292
|
-
map.set(p, entry.xy);
|
|
2293
|
-
let parent = p;
|
|
2294
|
-
while (true) {
|
|
2295
|
-
const lastSlash = parent.lastIndexOf("/");
|
|
2296
|
-
if (lastSlash === -1) break;
|
|
2297
|
-
parent = parent.slice(0, lastSlash);
|
|
2298
|
-
if (!parent) break;
|
|
2299
|
-
const existing = map.get(parent);
|
|
2300
|
-
if (!existing) {
|
|
2301
|
-
map.set(parent, entry.xy);
|
|
2302
|
-
} else if (entry.xy.includes("M") && !existing.includes("M")) {
|
|
2303
|
-
map.set(parent, " M");
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
return map;
|
|
2308
|
-
}, [gitData]);
|
|
2309
|
-
const visibleFlatRows = (0, import_react5.useMemo)(() => {
|
|
2310
|
-
const normRoot = rootPath.replace(/\\/g, "/");
|
|
2311
|
-
const rootListing2 = levels[rootPath] ?? levels[normRoot];
|
|
2312
|
-
if (!rootPath || !rootListing2) return [];
|
|
2313
|
-
const rows = [];
|
|
2314
|
-
const walk = (dir) => {
|
|
2315
|
-
const normD = dir.replace(/\\/g, "/");
|
|
2316
|
-
const listing = levels[dir] ?? levels[normD];
|
|
2317
|
-
if (!listing) return;
|
|
2318
|
-
for (const entry of listing.entries) {
|
|
2319
|
-
if (!options.showHiddenFiles && (entry.hidden || entry.name.startsWith("."))) {
|
|
2320
|
-
continue;
|
|
2321
|
-
}
|
|
2322
|
-
const rel = getRelativePath(entry.path);
|
|
2323
|
-
if (filterText) {
|
|
2324
|
-
const match = entry.name.toLowerCase().includes(filterText.toLowerCase()) || rel.toLowerCase().includes(filterText.toLowerCase());
|
|
2325
|
-
if (!match && !entry.isDir) continue;
|
|
2326
|
-
}
|
|
2327
|
-
if (options.compactFolders && entry.isDir) {
|
|
2328
|
-
const chain = [entry];
|
|
2329
|
-
let curr = entry;
|
|
2330
|
-
let currL = levels[curr.path] ?? levels[curr.path.replace(/\\/g, "/")];
|
|
2331
|
-
while (currL && currL.entries) {
|
|
2332
|
-
const valid = options.showHiddenFiles ? currL.entries : currL.entries.filter((c) => !c.hidden && !c.name.startsWith("."));
|
|
2333
|
-
if (valid.length === 1 && valid[0].isDir) {
|
|
2334
|
-
const next = valid[0];
|
|
2335
|
-
chain.push(next);
|
|
2336
|
-
curr = next;
|
|
2337
|
-
currL = levels[curr.path] ?? levels[curr.path.replace(/\\/g, "/")];
|
|
2338
|
-
} else {
|
|
2339
|
-
break;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
if (chain.length > 1) {
|
|
2343
|
-
const compactRel = getRelativePath(curr.path);
|
|
2344
|
-
rows.push({ entry: curr, relativePath: compactRel });
|
|
2345
|
-
if (expanded.has(entry.path) || expanded.has(curr.path) || Boolean(filterText)) {
|
|
2346
|
-
walk(curr.path);
|
|
2347
|
-
}
|
|
2348
|
-
continue;
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
rows.push({ entry, relativePath: rel });
|
|
2352
|
-
if (entry.isDir && (expanded.has(entry.path) || Boolean(filterText))) {
|
|
2353
|
-
walk(entry.path);
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
};
|
|
2357
|
-
walk(rootPath);
|
|
2358
|
-
return rows;
|
|
2359
|
-
}, [rootPath, levels, expanded, filterText, getRelativePath, options.showHiddenFiles, options.compactFolders]);
|
|
2360
|
-
const handleKeyDown = (e) => {
|
|
2361
|
-
if (visibleFlatRows.length === 0) return;
|
|
2362
|
-
const currentIndex = visibleFlatRows.findIndex((r) => r.entry.path === focusedPath);
|
|
2363
|
-
if (e.key === "ArrowDown") {
|
|
2364
|
-
e.preventDefault();
|
|
2365
|
-
const nextIndex = currentIndex < visibleFlatRows.length - 1 ? currentIndex + 1 : 0;
|
|
2366
|
-
const nextRow = visibleFlatRows[nextIndex];
|
|
2367
|
-
if (nextRow) {
|
|
2368
|
-
setFocusedPath(nextRow.entry.path);
|
|
2369
|
-
setSelected(/* @__PURE__ */ new Set([nextRow.entry.path]));
|
|
2370
|
-
}
|
|
2371
|
-
} else if (e.key === "ArrowUp") {
|
|
2372
|
-
e.preventDefault();
|
|
2373
|
-
const prevIndex = currentIndex > 0 ? currentIndex - 1 : visibleFlatRows.length - 1;
|
|
2374
|
-
const prevRow = visibleFlatRows[prevIndex];
|
|
2375
|
-
if (prevRow) {
|
|
2376
|
-
setFocusedPath(prevRow.entry.path);
|
|
2377
|
-
setSelected(/* @__PURE__ */ new Set([prevRow.entry.path]));
|
|
2378
|
-
}
|
|
2379
|
-
} else if (e.key === "ArrowRight") {
|
|
2380
|
-
const currentRow = visibleFlatRows[currentIndex];
|
|
2381
|
-
if (currentRow?.entry.isDir && !expanded.has(currentRow.entry.path)) {
|
|
2382
|
-
e.preventDefault();
|
|
2383
|
-
toggleExpand(currentRow.entry.path);
|
|
2384
|
-
}
|
|
2385
|
-
} else if (e.key === "ArrowLeft") {
|
|
2386
|
-
const currentRow = visibleFlatRows[currentIndex];
|
|
2387
|
-
if (currentRow?.entry.isDir && expanded.has(currentRow.entry.path)) {
|
|
2388
|
-
e.preventDefault();
|
|
2389
|
-
toggleExpand(currentRow.entry.path);
|
|
2390
|
-
}
|
|
2391
|
-
} else if (e.key === "Enter") {
|
|
2392
|
-
const currentRow = visibleFlatRows[currentIndex];
|
|
2393
|
-
if (currentRow) {
|
|
2394
|
-
e.preventDefault();
|
|
2395
|
-
if (currentRow.entry.isDir) {
|
|
2396
|
-
toggleExpand(currentRow.entry.path);
|
|
2397
|
-
} else {
|
|
2398
|
-
const activeId = sessionId ?? safeService2(ctx, "sessions")?.active?.id ?? "";
|
|
2399
|
-
insertMentionToComposer(ctx, activeId, currentRow.relativePath, false);
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
};
|
|
2404
|
-
const handleRowSelect = (entryPath, e) => {
|
|
2405
|
-
setFocusedPath(entryPath);
|
|
2406
|
-
if (e.ctrlKey || e.metaKey) {
|
|
2407
|
-
setSelected((prev) => {
|
|
2408
|
-
const next = new Set(prev);
|
|
2409
|
-
if (next.has(entryPath)) next.delete(entryPath);
|
|
2410
|
-
else next.add(entryPath);
|
|
2411
|
-
return next;
|
|
2412
|
-
});
|
|
2413
|
-
} else {
|
|
2414
|
-
setSelected(/* @__PURE__ */ new Set([entryPath]));
|
|
2415
|
-
}
|
|
2416
|
-
};
|
|
2417
|
-
const handleCreateSubmit = async () => {
|
|
2418
|
-
if (!creating || !creatingName.trim()) {
|
|
2419
|
-
setCreating(null);
|
|
2420
|
-
return;
|
|
2421
|
-
}
|
|
2422
|
-
const name = creatingName.trim();
|
|
2423
|
-
const parent = creating.parentDir;
|
|
2424
|
-
try {
|
|
2425
|
-
if (creating.isDir) {
|
|
2426
|
-
await apiCreateDirectory(parent, name);
|
|
2427
|
-
} else {
|
|
2428
|
-
await apiCreateNewFile(parent, name);
|
|
2429
|
-
}
|
|
2430
|
-
refreshAll();
|
|
2431
|
-
setExpanded((prev) => new Set(prev).add(parent));
|
|
2432
|
-
} catch (err) {
|
|
2433
|
-
alert(err.message || "Operation failed");
|
|
2434
|
-
} finally {
|
|
2435
|
-
setCreating(null);
|
|
2436
|
-
setCreatingName("");
|
|
2437
|
-
}
|
|
2438
|
-
};
|
|
2439
|
-
const handleRename = async (entryPath, newName) => {
|
|
2440
|
-
try {
|
|
2441
|
-
await apiRename(entryPath, newName);
|
|
2442
|
-
refreshAll();
|
|
2443
|
-
} catch (err) {
|
|
2444
|
-
alert(err.message || "Rename failed");
|
|
2445
|
-
}
|
|
2446
|
-
};
|
|
2447
|
-
const handleDelete = async (entry) => {
|
|
2448
|
-
if (!confirm(`Are you sure you want to delete "${entry.name}"?`)) return;
|
|
2449
|
-
try {
|
|
2450
|
-
await apiDelete(entry.path);
|
|
2451
|
-
refreshAll();
|
|
2452
|
-
} catch (err) {
|
|
2453
|
-
alert(err.message || "Delete failed");
|
|
2454
|
-
}
|
|
2455
|
-
};
|
|
2456
|
-
const handleExplorerDrop = async (e) => {
|
|
2457
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
2458
|
-
e.preventDefault();
|
|
2459
|
-
e.stopPropagation();
|
|
2460
|
-
const targetDir = rootPath;
|
|
2461
|
-
for (let i = 0; i < e.dataTransfer.files.length; i++) {
|
|
2462
|
-
const file = e.dataTransfer.files[i];
|
|
2463
|
-
const uploadUrl = `/dsh-explorer/api/upload?dir=${encodeURIComponent(targetDir)}&relativePath=${encodeURIComponent(file.name)}`;
|
|
2464
|
-
await fetch(uploadUrl, { method: "POST", body: file });
|
|
2465
|
-
}
|
|
2466
|
-
refreshAll();
|
|
2467
|
-
}
|
|
2468
|
-
};
|
|
2469
|
-
const handleOpenFile = (0, import_react5.useCallback)(
|
|
2470
|
-
(filePath, relPath) => {
|
|
2471
|
-
openFileInTab(ctx, sessionId ?? "", filePath, relPath);
|
|
2472
|
-
},
|
|
2473
|
-
[ctx, sessionId]
|
|
2474
|
-
);
|
|
2475
|
-
const title = rootPath ? baseName(rootPath) : "EXPLORER";
|
|
2476
|
-
const rootListing = levels[rootPath] ?? levels[rootPath.replace(/\\/g, "/")];
|
|
2477
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2478
|
-
"div",
|
|
2479
|
-
{
|
|
2480
|
-
className: `${explorer_default.container} ${!options.enableMotion ? explorer_default.noMotion : ""}`,
|
|
2481
|
-
style: containerStyles,
|
|
2482
|
-
children: [
|
|
2483
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2484
|
-
ExplorerHeader,
|
|
2485
|
-
{
|
|
2486
|
-
title: `EXPLORER: ${title}`,
|
|
2487
|
-
searchOpen,
|
|
2488
|
-
optionsOpen,
|
|
2489
|
-
onToggleSearch: () => setSearchOpen(!searchOpen),
|
|
2490
|
-
onToggleOptions: () => setOptionsOpen(!optionsOpen),
|
|
2491
|
-
onNewFile: () => {
|
|
2492
|
-
setCreating({ parentDir: rootPath, isDir: false });
|
|
2493
|
-
setCreatingName("");
|
|
2494
|
-
},
|
|
2495
|
-
onNewFolder: () => {
|
|
2496
|
-
setCreating({ parentDir: rootPath, isDir: true });
|
|
2497
|
-
setCreatingName("");
|
|
2498
|
-
},
|
|
2499
|
-
onRefresh: () => {
|
|
2500
|
-
refreshAll();
|
|
2501
|
-
},
|
|
2502
|
-
onCollapseAll: () => {
|
|
2503
|
-
setExpanded(/* @__PURE__ */ new Set());
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
),
|
|
2507
|
-
optionsOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2508
|
-
ExplorerOptionsModal,
|
|
2509
|
-
{
|
|
2510
|
-
options,
|
|
2511
|
-
onChange: handleUpdateOptions,
|
|
2512
|
-
onReset: handleResetOptions,
|
|
2513
|
-
onClose: () => setOptionsOpen(false)
|
|
2514
|
-
}
|
|
2515
|
-
),
|
|
2516
|
-
searchOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2517
|
-
ExplorerSearch,
|
|
2518
|
-
{
|
|
2519
|
-
value: filterText,
|
|
2520
|
-
onChange: setFilterText,
|
|
2521
|
-
onClose: () => {
|
|
2522
|
-
setFilterText("");
|
|
2523
|
-
setSearchOpen(false);
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
),
|
|
2527
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2528
|
-
"div",
|
|
2529
|
-
{
|
|
2530
|
-
ref: treeBodyRef,
|
|
2531
|
-
className: explorer_default.treeBody,
|
|
2532
|
-
tabIndex: 0,
|
|
2533
|
-
onKeyDown: handleKeyDown,
|
|
2534
|
-
onDragOver: (e) => {
|
|
2535
|
-
e.preventDefault();
|
|
2536
|
-
e.dataTransfer.dropEffect = "copy";
|
|
2537
|
-
},
|
|
2538
|
-
onDrop: handleExplorerDrop,
|
|
2539
|
-
children: [
|
|
2540
|
-
creating && creating.parentDir === rootPath && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: explorer_default.row, style: { paddingLeft: `${indentStep + 8}px` }, children: [
|
|
2541
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: explorer_default.iconWrap, children: creating.isDir ? "\u{1F4C1}" : "\u{1F4C4}" }),
|
|
2542
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2543
|
-
"input",
|
|
2544
|
-
{
|
|
2545
|
-
ref: createInputRef,
|
|
2546
|
-
autoFocus: true,
|
|
2547
|
-
type: "text",
|
|
2548
|
-
className: explorer_default.inlineInput,
|
|
2549
|
-
placeholder: creating.isDir ? "Folder name..." : "File name...",
|
|
2550
|
-
value: creatingName,
|
|
2551
|
-
onChange: (e) => setCreatingName(e.target.value),
|
|
2552
|
-
onKeyDown: (e) => {
|
|
2553
|
-
if (e.key === "Enter") handleCreateSubmit();
|
|
2554
|
-
else if (e.key === "Escape") setCreating(null);
|
|
2555
|
-
},
|
|
2556
|
-
onBlur: handleCreateSubmit
|
|
2557
|
-
}
|
|
2558
|
-
)
|
|
2559
|
-
] }),
|
|
2560
|
-
rootListing?.entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2561
|
-
TreeNode,
|
|
2562
|
-
{
|
|
2563
|
-
entry,
|
|
2564
|
-
depth: 0,
|
|
2565
|
-
parentDir: rootPath,
|
|
2566
|
-
rootPath,
|
|
2567
|
-
levels,
|
|
2568
|
-
expanded,
|
|
2569
|
-
selected,
|
|
2570
|
-
focusedPath,
|
|
2571
|
-
gitStatusMap,
|
|
2572
|
-
filterText,
|
|
2573
|
-
creating,
|
|
2574
|
-
creatingName,
|
|
2575
|
-
createInputRef,
|
|
2576
|
-
options,
|
|
2577
|
-
indentStep,
|
|
2578
|
-
iconSize,
|
|
2579
|
-
reloadDirectory,
|
|
2580
|
-
onToggle: toggleExpand,
|
|
2581
|
-
onSelect: handleRowSelect,
|
|
2582
|
-
onOpenFile: handleOpenFile,
|
|
2583
|
-
onContextMenu: (ent, rel, e) => {
|
|
2584
|
-
e.preventDefault();
|
|
2585
|
-
setContextMenu({
|
|
2586
|
-
x: e.clientX,
|
|
2587
|
-
y: e.clientY,
|
|
2588
|
-
entry: ent,
|
|
2589
|
-
relativePath: rel
|
|
2590
|
-
});
|
|
2591
|
-
},
|
|
2592
|
-
onInsertReference: (rel, isDir) => {
|
|
2593
|
-
const activeId = sessionId ?? safeService2(ctx, "sessions")?.active?.id ?? "";
|
|
2594
|
-
insertMentionToComposer(ctx, activeId, rel, isDir);
|
|
2595
|
-
},
|
|
2596
|
-
onCopyRelativePath: (rel) => {
|
|
2597
|
-
navigator.clipboard.writeText(rel);
|
|
2598
|
-
},
|
|
2599
|
-
onRenameSubmit: (path, newName) => handleRename(path, newName),
|
|
2600
|
-
onDelete: handleDelete,
|
|
2601
|
-
onCreatingNameChange: setCreatingName,
|
|
2602
|
-
onCreatingKeyDown: (e) => {
|
|
2603
|
-
if (e.key === "Enter") handleCreateSubmit();
|
|
2604
|
-
else if (e.key === "Escape") setCreating(null);
|
|
2605
|
-
},
|
|
2606
|
-
onCreatingBlur: handleCreateSubmit,
|
|
2607
|
-
getRelativePath
|
|
2608
|
-
},
|
|
2609
|
-
entry.path
|
|
2610
|
-
)),
|
|
2611
|
-
visibleFlatRows.length === 0 && !creating && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: explorer_default.emptyState, children: loading ? "Loading workspace files..." : errorMessage ? `Error: ${errorMessage}` : filterText ? "No matching files found" : !options.showHiddenFiles ? "Only hidden files present (enable in options)" : "Empty directory" })
|
|
2612
|
-
]
|
|
2613
|
-
}
|
|
2614
|
-
),
|
|
2615
|
-
contextMenu && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2616
|
-
ExplorerContextMenu,
|
|
2617
|
-
{
|
|
2618
|
-
x: contextMenu.x,
|
|
2619
|
-
y: contextMenu.y,
|
|
2620
|
-
entry: contextMenu.entry,
|
|
2621
|
-
relativePath: contextMenu.relativePath,
|
|
2622
|
-
onClose: () => setContextMenu(null),
|
|
2623
|
-
onOpenFile: () => handleOpenFile(contextMenu.entry.path, contextMenu.relativePath),
|
|
2624
|
-
onInsertReference: () => {
|
|
2625
|
-
const activeId = sessionId ?? safeService2(ctx, "sessions")?.active?.id ?? "";
|
|
2626
|
-
insertMentionToComposer(ctx, activeId, contextMenu.relativePath, contextMenu.entry.isDir);
|
|
2627
|
-
},
|
|
2628
|
-
onInsertSnippet: async () => {
|
|
2629
|
-
const activeId = sessionId ?? safeService2(ctx, "sessions")?.active?.id ?? "";
|
|
2630
|
-
try {
|
|
2631
|
-
const content = await fetchFileContent(contextMenu.entry.path);
|
|
2632
|
-
insertSnippetToComposer(ctx, activeId, contextMenu.relativePath, content);
|
|
2633
|
-
} catch (err) {
|
|
2634
|
-
alert(err.message || "Failed to read file");
|
|
2635
|
-
}
|
|
2636
|
-
},
|
|
2637
|
-
onCopyPath: () => {
|
|
2638
|
-
navigator.clipboard.writeText(contextMenu.entry.path);
|
|
2639
|
-
},
|
|
2640
|
-
onCopyRelativePath: () => {
|
|
2641
|
-
navigator.clipboard.writeText(contextMenu.relativePath);
|
|
2642
|
-
},
|
|
2643
|
-
onNewFile: () => {
|
|
2644
|
-
setCreating({ parentDir: contextMenu.entry.path, isDir: false });
|
|
2645
|
-
setCreatingName("");
|
|
2646
|
-
},
|
|
2647
|
-
onNewFolder: () => {
|
|
2648
|
-
setCreating({ parentDir: contextMenu.entry.path, isDir: true });
|
|
2649
|
-
setCreatingName("");
|
|
2650
|
-
},
|
|
2651
|
-
onRename: () => {
|
|
2652
|
-
setFocusedPath(contextMenu.entry.path);
|
|
2653
|
-
},
|
|
2654
|
-
onDelete: () => handleDelete(contextMenu.entry)
|
|
2655
|
-
}
|
|
2656
|
-
)
|
|
2657
|
-
]
|
|
2658
|
-
}
|
|
2659
|
-
);
|
|
2660
|
-
};
|
|
2661
|
-
|
|
2662
|
-
// src/client/index.tsx
|
|
2663
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2664
|
-
var inject = [
|
|
2665
|
-
"slots",
|
|
2666
|
-
"sessions",
|
|
2667
|
-
"locale"
|
|
2668
|
-
];
|
|
2669
|
-
var ExplorerTabIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M14 4.5V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h6.5L14 4.5zm-1 0H9.5a.5.5 0 0 1-.5-.5V2H3v12h10V4.5z" }) });
|
|
2670
|
-
var ExplorerTabTitle = (0, import_react6.memo)(function ExplorerTabTitle2() {
|
|
2671
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "12px" }, children: [
|
|
2672
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExplorerTabIcon, {}),
|
|
2673
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Explorer" })
|
|
2674
|
-
] });
|
|
2675
|
-
});
|
|
2676
|
-
var ExplorerPaneBody = (0, import_react6.memo)(function ExplorerPaneBody2(props) {
|
|
2677
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExplorerView, { ctx: props.ctx, sessionId: props.sessionId });
|
|
2678
|
-
});
|
|
2679
|
-
var ExplorerHeaderButton = ({ ctx, sessionId }) => {
|
|
2680
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2681
|
-
"button",
|
|
2682
|
-
{
|
|
2683
|
-
type: "button",
|
|
2684
|
-
title: "Explorer (File Tree)",
|
|
2685
|
-
"aria-label": "Explorer",
|
|
2686
|
-
onClick: () => {
|
|
2687
|
-
try {
|
|
2688
|
-
const sr = ctx.get ? ctx.get("sidebarRight") : ctx.sidebarRight;
|
|
2689
|
-
if (sessionId && sr?.openTabIn) {
|
|
2690
|
-
sr.openTabIn(sessionId, "explorer");
|
|
2691
|
-
} else if (sr?.openTab) {
|
|
2692
|
-
sr.openTab("explorer");
|
|
2693
|
-
}
|
|
2694
|
-
} catch (err) {
|
|
2695
|
-
console.warn("[dsh-explorer] failed to open sidebar tab:", err);
|
|
2696
|
-
}
|
|
2697
|
-
},
|
|
2698
|
-
style: {
|
|
2699
|
-
display: "inline-flex",
|
|
2700
|
-
alignItems: "center",
|
|
2701
|
-
justifyContent: "center",
|
|
2702
|
-
background: "transparent",
|
|
2703
|
-
border: "none",
|
|
2704
|
-
cursor: "pointer",
|
|
2705
|
-
padding: "3px 6px",
|
|
2706
|
-
borderRadius: "6px",
|
|
2707
|
-
color: "var(--dsw-alias-label-secondary, #8b949e)",
|
|
2708
|
-
transition: "color 0.15s, background-color 0.15s"
|
|
2709
|
-
},
|
|
2710
|
-
onMouseEnter: (e) => {
|
|
2711
|
-
e.currentTarget.style.color = "var(--dsw-alias-label-primary, #ffffff)";
|
|
2712
|
-
e.currentTarget.style.backgroundColor = "var(--dsw-alias-bg-hover, rgba(255, 255, 255, 0.08))";
|
|
2713
|
-
},
|
|
2714
|
-
onMouseLeave: (e) => {
|
|
2715
|
-
e.currentTarget.style.color = "var(--dsw-alias-label-secondary, #8b949e)";
|
|
2716
|
-
e.currentTarget.style.backgroundColor = "transparent";
|
|
2717
|
-
},
|
|
2718
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExplorerTabIcon, {})
|
|
2719
|
-
}
|
|
2720
|
-
);
|
|
2721
|
-
};
|
|
2722
|
-
function apply(ctx) {
|
|
2723
|
-
ctx.effect(() => {
|
|
2724
|
-
try {
|
|
2725
|
-
return setupCaretTracker();
|
|
2726
|
-
} catch (err) {
|
|
2727
|
-
console.warn("[dsh-explorer] failed to setup caret tracker:", err);
|
|
2728
|
-
return () => {
|
|
2729
|
-
};
|
|
2730
|
-
}
|
|
2731
|
-
}, "dsh-explorer: caret tracker");
|
|
2732
|
-
ctx.effect(() => {
|
|
2733
|
-
try {
|
|
2734
|
-
return attachGlobalConversationDropListener(ctx);
|
|
2735
|
-
} catch (err) {
|
|
2736
|
-
console.warn("[dsh-explorer] failed to attach conversation drop listener:", err);
|
|
2737
|
-
return () => {
|
|
2738
|
-
};
|
|
2739
|
-
}
|
|
2740
|
-
}, "dsh-explorer: conversation drop listener");
|
|
2741
|
-
ctx.slots.inject(
|
|
2742
|
-
"conversation.session.header.utilities",
|
|
2743
|
-
() => ctx.slots.register(
|
|
2744
|
-
{
|
|
2745
|
-
name: "conversation.session.header.utilities",
|
|
2746
|
-
id: "dsh-explorer:header-button",
|
|
2747
|
-
order: 15,
|
|
2748
|
-
inject: (sessionId) => ({ sessionId })
|
|
2749
|
-
},
|
|
2750
|
-
(props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExplorerHeaderButton, { ctx, sessionId: props.sessionId })
|
|
2751
|
-
)
|
|
2752
|
-
);
|
|
2753
|
-
ctx.inject(["sidebarRightTabs"], (injected) => {
|
|
2754
|
-
const tabs = injected.get ? injected.get("sidebarRightTabs") : injected.sidebarRightTabs;
|
|
2755
|
-
if (!tabs?.register) return;
|
|
2756
|
-
const unregisterExplorer = tabs.register({
|
|
2757
|
-
id: "dsh-explorer",
|
|
2758
|
-
kind: "explorer",
|
|
2759
|
-
keepMounted: true,
|
|
2760
|
-
priority: "extension",
|
|
2761
|
-
title: () => "Explorer",
|
|
2762
|
-
guide: [
|
|
2763
|
-
{
|
|
2764
|
-
id: "dsh-explorer",
|
|
2765
|
-
order: 5,
|
|
2766
|
-
title: () => "Explorer",
|
|
2767
|
-
description: () => "VS Code style file explorer with drag & drop to chat",
|
|
2768
|
-
icon: ExplorerTabIcon
|
|
2769
|
-
}
|
|
2770
|
-
]
|
|
2771
|
-
});
|
|
2772
|
-
const offBody = ctx.slots.inject(
|
|
2773
|
-
"sidebar.right.pane.tab",
|
|
2774
|
-
() => ctx.slots.register(
|
|
2775
|
-
{
|
|
2776
|
-
name: "sidebar.right.pane.tab",
|
|
2777
|
-
key: "dsh-explorer",
|
|
2778
|
-
inject: (sessionId) => ({ ctx, sessionId })
|
|
2779
|
-
},
|
|
2780
|
-
ExplorerPaneBody
|
|
2781
|
-
)
|
|
2782
|
-
);
|
|
2783
|
-
const offTitle = ctx.slots.inject(
|
|
2784
|
-
"sidebar.right.pane.tab.title",
|
|
2785
|
-
() => ctx.slots.register(
|
|
2786
|
-
{
|
|
2787
|
-
name: "sidebar.right.pane.tab.title",
|
|
2788
|
-
key: "dsh-explorer",
|
|
2789
|
-
inject: (sessionId) => ({ sessionId })
|
|
2790
|
-
},
|
|
2791
|
-
ExplorerTabTitle
|
|
2792
|
-
)
|
|
2793
|
-
);
|
|
2794
|
-
return () => {
|
|
2795
|
-
try {
|
|
2796
|
-
offTitle?.();
|
|
2797
|
-
} catch {
|
|
2798
|
-
}
|
|
2799
|
-
try {
|
|
2800
|
-
offBody?.();
|
|
2801
|
-
} catch {
|
|
2802
|
-
}
|
|
2803
|
-
try {
|
|
2804
|
-
unregisterExplorer?.();
|
|
2805
|
-
} catch {
|
|
2806
|
-
}
|
|
2807
|
-
};
|
|
2808
|
-
});
|
|
2809
|
-
}
|
|
854
|
+
`,ze=n,n}function an(e){let n=0,o=h=>{if(nt&&nt.length>0)return!0;try{let c=Array.from(h.dataTransfer?.types??[]);return c.includes(Rt)||c.includes("text/plain")}catch{return!1}},t=()=>document.querySelector('[data-slot="conversation.session"]')??document.querySelector('[data-slot="conversation.shell"]')??document.querySelector('[data-slot*="conversation"]')??document.querySelector(".an3WzG_root")??document.querySelector(".conversation-main")??document.querySelector("main")??document.querySelector("#root > div")??null,s=h=>{if(!o(h))return;let c=t();if(!c)return;n+=1;let m=Bn(c);c.contains(m)||(getComputedStyle(c).position==="static"&&(c.style.position="relative"),c.appendChild(m))},a=h=>{o(h)&&(h.preventDefault(),h.dataTransfer&&(h.dataTransfer.dropEffect="copy"))},l=h=>{o(h)&&(n-=1,n<=0&&(n=0,ze?.remove()))},x=async h=>{if(!o(h))return;h.preventDefault(),h.stopPropagation(),n=0,ze?.remove();let c=nt;if(!c||c.length===0)try{let m=h.dataTransfer?.getData(Rt);m&&(c=JSON.parse(m))}catch{}if(!c||c.length===0){let m=h.dataTransfer?.getData("text/plain");if(m&&m.startsWith("@")){let f=m.replace(/^@"?/,"").replace(/"?$/,"");c=[{path:f,relativePath:f,isDir:f.endsWith("/"),name:f}]}}if(!(!c||c.length===0))try{let m=yt(e),f=h.altKey||h.shiftKey,v={x:h.clientX,y:h.clientY};for(let C of c){if(f&&!C.isDir)try{let d=await ft(C.path);wt(e,m,C.relativePath,d,v)}catch{Oe(e,m,C.relativePath,C.isDir,v)}else Oe(e,m,C.relativePath,C.isDir,v);v=void 0,c.length>1&&await new Promise(d=>setTimeout(d,40))}}catch(m){console.warn("[dsh-explorer] drop failed:",m)}};return document.addEventListener("dragenter",s,!0),document.addEventListener("dragover",a,!0),document.addEventListener("dragleave",l,!0),document.addEventListener("drop",x,!0),()=>{document.removeEventListener("dragenter",s,!0),document.removeEventListener("dragover",a,!0),document.removeEventListener("dragleave",l,!0),document.removeEventListener("drop",x,!0),ze?.remove()}}var U=require("react/jsx-runtime"),Mt=({entry:e,depth:n,isExpanded:o,isSelected:t,isFocused:s,isRenaming:a=!1,gitStatus:l,relativePath:x,compactChain:h,indentStep:c=16,iconSize:m=16,enableMotion:f=!0,showGitBadges:v=!0,compactFolders:C=!0,singleClickAction:d="select",onToggle:u,onSelect:E,onDoubleClick:k,onContextMenu:F,onInsertReference:X,onCopyRelativePath:ve,onStartRename:Y,onCancelRename:le,onRenameSubmit:P,onDelete:we})=>{let[J,fe]=(0,Xe.useState)(e.name),ae=(0,Xe.useRef)(null);(0,Xe.useEffect)(()=>{a&&(fe(e.name),requestAnimationFrame(()=>{if(ae.current){ae.current.focus();let N=e.isDir?-1:e.name.lastIndexOf(".");N>0?ae.current.setSelectionRange(0,N):ae.current.select()}}))},[a,e.name,e.isDir]);let Ce=N=>{let se={path:e.path,relativePath:x,isDir:e.isDir,name:e.name};on(N,[se])},Le=N=>{if(N.key==="Enter"){N.stopPropagation();let se=J.trim();se&&se!==e.name?P(se):le?.()}else N.key==="Escape"&&(N.stopPropagation(),fe(e.name),le?.())},H=()=>{let N=J.trim();N&&N!==e.name?P(N):le?.()},Ae=C&&h&&h.length>1?h.map(N=>N.name).join("/"):C&&e.compactName?e.compactName:e.name,de="",Q="";l&&(l.includes("M")?(de=r.gitModified,Q="M"):l.includes("?")||l.includes("A")?(de=r.gitUntracked,Q="U"):l.includes("D")?(de=r.gitDeleted,Q="D"):l.includes("R")&&(de=r.gitModified,Q="R"));let Pe=l?.includes("!");return(0,U.jsxs)("div",{className:`${r.row} ${t?r.rowSelected:""} ${s?r.rowFocused:""}`,style:{paddingLeft:`${n*c+8}px`},onClick:N=>{a||(E(N),e.isDir?u():d==="mention"&&X())},onDoubleClick:N=>{a||e.isDir||(N.stopPropagation(),k?.())},onContextMenu:F,draggable:!a,onDragStart:Ce,onDragEnd:rn,children:[Array.from({length:n}).map((N,se)=>(0,U.jsx)("span",{className:r.indentGuide,style:{left:`${se*c+15}px`}},se)),(0,U.jsx)("span",{className:`${r.chevron} ${o?r.chevronExpanded:""} ${e.isDir?"":r.chevronHidden}`,style:f?void 0:{transition:"none"},onClick:N=>{N.stopPropagation(),u()},children:(0,U.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:(0,U.jsx)("path",{d:"M6 3.5L10.5 8 6 12.5V3.5Z"})})}),(0,U.jsx)("span",{className:r.iconWrap,children:vt(e.name,e.isDir,o,m)}),a?(0,U.jsx)("input",{ref:ae,type:"text",className:r.inlineInput,value:J,onChange:N=>fe(N.target.value),onKeyDown:Le,onBlur:H,onClick:N=>N.stopPropagation()}):(0,U.jsx)("span",{className:`${r.label} ${Pe?r.labelDimmed:""} ${v?de:""}`,title:x,children:Ae}),v&&Q&&(0,U.jsx)("span",{className:`${r.gitBadge} ${de}`,children:Q}),!a&&(0,U.jsxs)("div",{className:r.hoverActions,onClick:N=>N.stopPropagation(),children:[(0,U.jsx)("button",{className:r.actionBtn,title:"Mention in Chat (@)",onClick:N=>{N.stopPropagation(),X()},children:(0,U.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:(0,U.jsx)("path",{d:"M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2zM7 5h2v2h2v2H9v2H7V9H5V7h2V5z"})})}),(0,U.jsx)("button",{className:r.actionBtn,title:"Copy Relative Path",onClick:N=>{N.stopPropagation(),ve()},children:(0,U.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:(0,U.jsx)("path",{d:"M4 4h6v1H4v9h7v-4h1v5H3V4h1zm3-2h7v7h-1V3.7L7.7 9 7 8.3 12.3 3H7V2z"})})}),(0,U.jsx)("button",{className:r.actionBtn,title:"Rename (F2)",onClick:N=>{N.stopPropagation(),Y?.()},children:(0,U.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:(0,U.jsx)("path",{d:"M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"})})})]})]})};var he=require("react/jsx-runtime"),Tt=Be.default.memo(({entry:e,depth:n,rootPath:o,levels:t,expanded:s,selected:a,focusedPath:l,renamingPath:x,gitStatusMap:h,filterText:c,matchingPaths:m,ancestorPaths:f,creating:v,creatingName:C,createInputRef:d,options:u,indentStep:E,iconSize:k,reloadDirectory:F,onToggle:X,onSelect:ve,onOpenFile:Y,onContextMenu:le,onInsertReference:P,onCopyRelativePath:we,onStartRename:J,onCancelRename:fe,onRenameSubmit:ae,onDelete:Ce,onCreatingNameChange:Le,onCreatingKeyDown:H,onCreatingBlur:Ae,getRelativePath:de})=>{let Q=de(e?.path??""),Pe=(e?.path??"").replace(/\\/g,"/").toLowerCase(),se=(t[e?.path??""]??t[(e?.path??"").replace(/\\/g,"/")]??t[(e?.path??"").replace(/\//g,"\\")]??(Pe?Object.entries(t).find(([D])=>D.replace(/\\/g,"/").toLowerCase()===Pe)?.[1]:void 0))!==void 0,Ne=(0,Be.useMemo)(()=>{if(!u.compactFolders||!e?.isDir)return;let D=[e],Se=e,ke=t[Se.path]??t[Se.path.replace(/\\/g,"/")]??t[Se.path.replace(/\//g,"\\")];for(;ke&&Array.isArray(ke.entries);){let Ue=u.showHiddenFiles?ke.entries:ke.entries.filter(te=>te&&!te.hidden&&!te.name.startsWith("."));if(Ue.length===1&&Ue[0].isDir){let te=Ue[0];D.push(te),Se=te,ke=t[Se.path]??t[Se.path.replace(/\\/g,"/")]??t[Se.path.replace(/\//g,"\\")]}else break}return D.length>1?D:void 0},[u.compactFolders,u.showHiddenFiles,e,t]),oe=Ne!==void 0&&Ne.length>1,L=(oe?Ne[Ne.length-1]:e)?.path??"",ee=de(L)||"",_e=ee.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase(),Ee=(Q||"").replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase(),pe=(L||"").replace(/\\/g,"/").toLowerCase(),De=(e?.path||"").replace(/\\/g,"/").toLowerCase(),z=!!(c&&m),je=!!(z&&m&&(m.has(_e)||m.has(Ee)||m.has(pe)||m.has(De)||e?.path&&m.has(e.path)||e?.path&&m.has(e.path.toLowerCase())||L&&m.has(L)||L&&m.has(L.toLowerCase()))),Ve=!!(z&&f&&(f.has(_e)||f.has(Ee)||f.has(pe)||f.has(De)||e?.path&&f.has(e.path)||e?.path&&f.has(e.path.toLowerCase())||L&&f.has(L)||L&&f.has(L.toLowerCase()))),We=(L||"").replace(/\\/g,"/").toLowerCase(),Re=t[L]??t[L.replace(/\\/g,"/")]??t[L.replace(/\//g,"\\")]??(We?Object.entries(t).find(([D])=>D.replace(/\\/g,"/").toLowerCase()===We)?.[1]:void 0),He=Re!==void 0,Ke=!!(e?.isDir&&(Ve||s.has(e.path)||s.has(L)||De&&s.has(De)||pe&&s.has(pe)||e?.path&&s.has(e.path.toLowerCase())||L&&s.has(L.toLowerCase()))),me=!0;!e||!u.showHiddenFiles&&(e.hidden||e.name.startsWith("."))?me=!1:z?e.isDir?!je&&!Ve&&(me=!1):je||(me=!1):c&&!(e.name.toLowerCase().includes(c.toLowerCase())||Q.toLowerCase().includes(c.toLowerCase()))&&!e.isDir&&(me=!1);let Ge=Be.default.useRef(null);if((0,Be.useEffect)(()=>{!me||!e||!e.isDir||Ke&&!He&&Ge.current!==L&&(Ge.current=L,F(L).finally(()=>{Ge.current===L&&(Ge.current=null)}))},[me,Ke,L,e,He,F]),(0,Be.useEffect)(()=>{!me||!e||u.compactFolders&&e.isDir&&e.compact&&!se&&F(e.path)},[me,u.compactFolders,e,se,F]),!e||!me)return null;let rt=a.has(e.path)||a.has(L),at=l===e.path||l===L,st=h?.get(_e)??h?.get(Ee)??h?.get(pe)??h?.get(De),it=()=>{oe&&L!==e.path?s.has(e.path)||s.has(L)?(s.has(e.path)&&X(e.path),s.has(L)&&X(L)):(X(e.path),X(L)):X(e.path)};if(!e.isDir)return(0,he.jsx)(Mt,{entry:e,depth:n,isExpanded:!1,isSelected:rt,isFocused:at,isRenaming:x===e.path,gitStatus:st,relativePath:Q,indentStep:E,iconSize:k,enableMotion:u.enableMotion,showGitBadges:u.showGitBadges,compactFolders:u.compactFolders,singleClickAction:u.singleClickAction,onToggle:()=>{},onSelect:D=>ve(e.path,D),onDoubleClick:()=>Y(e.path,Q),onContextMenu:D=>le(e,Q,D),onInsertReference:()=>P(Q,!1),onCopyRelativePath:()=>we(Q),onStartRename:()=>J(e.path),onCancelRename:fe,onRenameSubmit:D=>ae(e.path,D),onDelete:()=>Ce(e,Q)});let Ye=He&&Array.isArray(Re?.entries)?u.showHiddenFiles?Re.entries:Re.entries.filter(D=>D&&!D.hidden&&!D.name.startsWith(".")):[],Je=x===e.path||oe&&x===L;return(0,he.jsxs)("div",{className:r.folderGroup,children:[(0,he.jsx)(Mt,{entry:e,depth:n,isExpanded:Ke,isSelected:rt,isFocused:at,isRenaming:Je,gitStatus:st,relativePath:ee,compactChain:Ne,indentStep:E,iconSize:k,enableMotion:u.enableMotion,showGitBadges:u.showGitBadges,compactFolders:u.compactFolders,singleClickAction:u.singleClickAction,onToggle:it,onSelect:D=>ve(L,D),onContextMenu:D=>le(e,ee,D),onInsertReference:()=>P(ee,!0),onCopyRelativePath:()=>we(ee),onStartRename:()=>J(oe?L:e.path),onCancelRename:fe,onRenameSubmit:D=>ae(oe?L:e.path,D),onDelete:()=>Ce(e,ee)}),(0,he.jsx)("div",{className:`${r.folderChildren} ${Ke?r.folderChildrenOpen:r.folderChildrenClosed}`,style:u.enableMotion?void 0:{transition:"none"},children:(0,he.jsxs)("div",{className:r.folderChildrenInner,children:[v&&(v.parentDir===e.path||v.parentDir===L)&&(0,he.jsxs)("div",{className:r.row,style:{paddingLeft:`${(n+1)*E+8}px`},children:[(0,he.jsx)("span",{className:r.iconWrap,children:v.isDir?"\u{1F4C1}":"\u{1F4C4}"}),(0,he.jsx)("input",{ref:d,autoFocus:!0,type:"text",className:r.inlineInput,placeholder:v.isDir?"Folder name...":"File name...",value:C,onChange:D=>Le(D.target.value),onKeyDown:H,onBlur:Ae})]}),Ye.length>0?Ye.map(D=>(0,he.jsx)(Tt,{entry:D,depth:n+1,parentDir:L,rootPath:o,levels:t,expanded:s,selected:a,focusedPath:l,renamingPath:x,gitStatusMap:h,filterText:c,matchingPaths:m,ancestorPaths:f,creating:v,creatingName:C,createInputRef:d,options:u,indentStep:E,iconSize:k,reloadDirectory:F,onToggle:X,onSelect:ve,onOpenFile:Y,onContextMenu:le,onInsertReference:P,onCopyRelativePath:we,onStartRename:J,onCancelRename:fe,onRenameSubmit:ae,onDelete:Ce,onCreatingNameChange:Le,onCreatingKeyDown:H,onCreatingBlur:Ae,getRelativePath:de},D.path)):!z&&He&&Re.entries&&Re.entries.length===0?(0,he.jsx)("div",{className:r.row,style:{paddingLeft:`${(n+1)*E+8}px`,opacity:.45,fontStyle:"italic",fontSize:"12px"},children:"Empty folder"}):null]})})]})});var sn=require("react");function ln({rootPath:e,onRefresh:n}){(0,sn.useEffect)(()=>{if(!e)return;let o=null,t=()=>{o&&clearTimeout(o),o=setTimeout(()=>{n()},100)},s=null;try{let c=`/dsh-explorer/api/events?dir=${encodeURIComponent(e)}`;s=new EventSource(c),s.onmessage=m=>{try{if(JSON.parse(m.data).type==="connected")return}catch{}t()}}catch(c){console.warn("[dsh-explorer] SSE init error:",c)}let a=null;try{let c=window.location,m=c.host||(c.port?`127.0.0.1:${c.port}`:"127.0.0.1"),v=`${c.protocol==="https:"?"wss:":"ws:"}//${m}/dsh-explorer/api/watch?dir=${encodeURIComponent(e)}`;a=new WebSocket(v),a.onmessage=()=>{t()}}catch{}let l=()=>{t()},x=()=>{document.visibilityState==="visible"&&t()};window.addEventListener("focus",l),document.addEventListener("visibilitychange",x);let h=setInterval(()=>{document.visibilityState==="visible"&&t()},3e3);return()=>{if(o&&clearTimeout(o),clearInterval(h),window.removeEventListener("focus",l),document.removeEventListener("visibilitychange",x),s)try{s.close()}catch{}if(a)try{a.close()}catch{}}},[e,n])}function cn({visibleFlatRows:e,focusedPath:n,expanded:o,setFocusedPath:t,setSelected:s,toggleExpand:a,onMention:l,onStartRename:x,onDelete:h}){return c=>{if(e.length===0)return;let m=e.findIndex(f=>f.entry.path===n);if(c.key==="ArrowDown"){c.preventDefault();let f=m<e.length-1?m+1:0,v=e[f];v&&(t(v.entry.path),s(new Set([v.entry.path])))}else if(c.key==="ArrowUp"){c.preventDefault();let f=m>0?m-1:e.length-1,v=e[f];v&&(t(v.entry.path),s(new Set([v.entry.path])))}else if(c.key==="ArrowRight"){let f=e[m];f?.entry.isDir&&!o.has(f.entry.path)&&(c.preventDefault(),a(f.entry.path))}else if(c.key==="ArrowLeft"){let f=e[m];f?.entry.isDir&&o.has(f.entry.path)&&(c.preventDefault(),a(f.entry.path))}else if(c.key==="Enter"){let f=e[m];f&&(c.preventDefault(),f.entry.isDir?a(f.entry.path):l(f.relativePath))}else if(c.key==="F2")n&&(c.preventDefault(),x(n));else if(c.key==="Delete"&&n){c.preventDefault();let f=e.find(v=>v.entry.path===n);f&&h(f.entry,f.relativePath)}}}var xe={scale:1,density:"normal",enableMotion:!0,showHiddenFiles:!0,showGitBadges:!0,compactFolders:!1,singleClickAction:"select"},dn="dsh_explorer_options_v1";function pn(){if(typeof window>"u"||!window.localStorage)return{...xe};try{let e=window.localStorage.getItem(dn);if(!e)return{...xe};let n=JSON.parse(e);return{scale:typeof n.scale=="number"&&Number.isFinite(n.scale)?Math.max(.75,Math.min(1.35,Math.round(n.scale*100)/100)):xe.scale,density:n.density==="compact"||n.density==="relaxed"?n.density:"normal",enableMotion:typeof n.enableMotion=="boolean"?n.enableMotion:xe.enableMotion,showHiddenFiles:typeof n.showHiddenFiles=="boolean"?n.showHiddenFiles:xe.showHiddenFiles,showGitBadges:typeof n.showGitBadges=="boolean"?n.showGitBadges:xe.showGitBadges,compactFolders:typeof n.compactFolders=="boolean"?n.compactFolders:xe.compactFolders,singleClickAction:n.singleClickAction==="mention"?"mention":"select"}}catch{return{...xe}}}function Ft(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(dn,JSON.stringify(e))}catch{}}function Ie(e,n){if(e)try{if(typeof e.get=="function"){let o=e.get(n);if(o!==void 0)return o}return e[n]}catch{return}}function hn(e,n,o,t){let s=o.replace(/\\/g,"/"),a=Dt(o);try{let l=Ie(e,"betterSidebar");if(l&&typeof l.openTab=="function"){l.openTab({type:"editor",title:a,path:o,id:`editor:${o}`});return}}catch{}try{let l=Ie(e,"sidebarRight");if(l&&typeof l.openResource=="function"){let x=t.replace(/\\/g,"/"),h=m=>m.split("/").map(f=>encodeURIComponent(f).replace(/%3A/gi,":")).join("/"),c=n?`dsh-resource://file/session/${encodeURIComponent(n)}/${h(x)}`:`dsh-resource://file/absolute/${h(s.replace(/^\/+/,""))}`;l.openResource(c);return}}catch{}try{let l=Ie(e,"tabs");if(l&&typeof l.open=="function"){l.open({path:o,title:a});return}}catch{}try{let l=e?.remote?.session;if(l&&typeof l.openWorkspacePath=="function"){l.openWorkspacePath({path:o});return}}catch{}try{window.open(`/dsh-explorer/api/read-file?path=${encodeURIComponent(o)}`,"_blank")}catch{}}var re=require("react/jsx-runtime");var fn=({ctx:e,sessionId:n,initialCwd:o})=>{let[t,s]=(0,y.useState)(o??""),[a,l]=(0,y.useState)({}),[x,h]=(0,y.useState)(()=>new Set),[c,m]=(0,y.useState)(()=>new Set),[f,v]=(0,y.useState)(null),[C,d]=(0,y.useState)(""),[u,E]=(0,y.useState)(""),[k,F]=(0,y.useState)(!1),[X,ve]=(0,y.useState)(null),[Y,le]=(0,y.useState)(null),[P,we]=(0,y.useState)(null),J=(0,y.useRef)(null),[fe,ae]=(0,y.useState)(!1),[Ce,Le]=(0,y.useState)(!1),[H,Ae]=(0,y.useState)(()=>pn()),[de,Q]=(0,y.useState)(!1),[Pe,N]=(0,y.useState)(null),[se,Ne]=(0,y.useState)({isRepo:!1,entries:[]}),[oe,ue]=(0,y.useState)(null),[L,ee]=(0,y.useState)(""),[_e,Ee]=(0,y.useState)(null),[pe,De]=(0,y.useState)(null),[z,je]=(0,y.useState)(null),[Ve,We]=(0,y.useState)(null),Re=(0,y.useRef)(null),He=(0,y.useRef)(null),Ke=(0,y.useCallback)(i=>{Ae(p=>{let b={...p,...i};return Ft(b),b})},[]),me=(0,y.useCallback)(()=>{Ae({...xe}),Ft({...xe})},[]),Ge=H.density==="compact"?20:H.density==="relaxed"?28:24,rt=H.density==="compact"?11.5:H.density==="relaxed"?14:13,at=H.density==="compact"?14:H.density==="relaxed"?18:16,st=H.density==="compact"?12:H.density==="relaxed"?20:16,it=Math.round(Ge*H.scale),Ye=Math.round(rt*H.scale),Je=Math.round(at*H.scale),D=Math.round(st*H.scale),Se=(0,y.useMemo)(()=>({"--dsh-row-height":`${it}px`,"--dsh-font-size":`${Ye}px`,"--dsh-icon-size":`${Je}px`,"--dsh-indent-step":`${D}px`}),[it,Ye,Je,D]);(0,y.useEffect)(()=>{n&&tn(n)},[n]),(0,y.useEffect)(()=>{if(o&&!t){s(o);return}if(!t){let i=!0;return et(n).then(p=>{i&&p&&p.path&&(s(p.path),l({[p.path]:p}))}).catch(p=>{i&&N(p?.message||"Failed to connect to file service")}),()=>{i=!1}}},[n,o,t]);let ke=(0,y.useCallback)(async i=>{try{N(null);let p=await et(n,i);l(b=>{let S=i.replace(/\\/g,"/"),A=i.replace(/\//g,"\\");return{...b,[i]:p,[S]:p,[A]:p}})}catch(p){N(p?.message||"Failed to load directory")}},[n]),Ue=(0,y.useCallback)(async i=>{let p=i||t;if(!(!p&&!n))try{let b=await Vt(p,n);Ne(b)}catch{Ne({isRepo:!1,entries:[]})}},[t,n]),te=(0,y.useCallback)(async()=>{if(t){Ue(t);try{let i=Array.from(x),p=Array.from(new Set([t,...i])),b=await ht(p),S={};for(let[I,B]of Object.entries(b))S[I]=B,S[I.replace(/\\/g,"/")]=B;let A=t.replace(/\\/g,"/").toLowerCase();l(I=>{let B={...I,...S};for(let O of Object.keys(I))O.replace(/\\/g,"/").toLowerCase()!==A&&!S[O]&&!S[O.replace(/\\/g,"/")]&&!S[O.replace(/\//g,"\\")]&&delete B[O];return B}),h(I=>{let B=!1,O=new Set(I);for(let M of I)M.replace(/\\/g,"/").toLowerCase()!==A&&!S[M]&&!S[M.replace(/\\/g,"/")]&&!S[M.replace(/\//g,"\\")]&&(O.delete(M),B=!0);return B?O:I})}catch(i){console.warn("[dsh-explorer] refreshAll failed:",i)}}},[t,x,Ue]);(0,y.useEffect)(()=>{t&&(te(),h(i=>new Set(i).add(t)))},[t]),ln({rootPath:t,onRefresh:te});let At=(0,y.useCallback)(async i=>{h(p=>{let b=new Set(p);if(b.has(i))b.delete(i);else{b.add(i);let S=i.replace(/\\/g,"/");!a[i]&&!a[S]&&ke(i)}return b})},[a,ke]),Me=(0,y.useCallback)(i=>{if(!t)return i;let p=t.replace(/\\/g,"/").replace(/\/+$/,""),b=i.replace(/\\/g,"/");return b.toLowerCase().startsWith(`${p.toLowerCase()}/`)?b.slice(p.length+1):i},[t]),Pt=(0,y.useRef)(a);(0,y.useEffect)(()=>{Pt.current=a},[a]),(0,y.useEffect)(()=>{let i=setTimeout(()=>{E(C)},200);return()=>clearTimeout(i)},[C]),(0,y.useEffect)(()=>{let i=u.trim();if(!i||!t){le(null),we(null),ve(null),F(!1),J.current&&(h(J.current),J.current=null);return}J.current||(J.current=new Set(x));let p=!1,b=new AbortController;return F(!0),(async()=>{try{let A=await Wt(t,i,n,b.signal);if(p)return;let I=Pt.current,B=new Set,O=new Set,M=new Set,qe=t.replace(/\\/g,"/").replace(/\/+$/,""),Qe=t.replace(/\//g,"\\").replace(/\\+$/,"");for(let W of A.matches){let K=W.path.replace(/\\/g,"/").toLowerCase(),_=W.path.replace(/\//g,"\\").toLowerCase(),T=W.relativePath.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase(),j=W.relativePath.replace(/\//g,"\\").toLowerCase();if(B.add(K),B.add(_),B.add(T),B.add(j),B.add(W.path),B.add(W.path.toLowerCase()),B.add(W.relativePath),B.add(W.relativePath.toLowerCase()),W.isDir){let ge=W.path.replace(/\\/g,"/"),ie=W.path.replace(/\//g,"\\");!I[W.path]&&!I[ge]&&!I[ie]&&M.add(ie)}let q=T.split("/"),Z=q.length-1,ce="";for(let ge=0;ge<Z;ge++){ce=ce?`${ce}/${q[ge]}`:q[ge],O.add(ce.toLowerCase());let ie=`${qe}/${ce}`,be=`${Qe}\\${ce.replace(/\//g,"\\")}`;O.add(ie.toLowerCase()),O.add(be.toLowerCase()),O.add(ie),O.add(be),!I[ie]&&!I[be]&&!I[ie.toLowerCase()]&&!I[be.toLowerCase()]&&M.add(be)}}for(let[,W]of Object.entries(I))if(W?.entries)for(let K of W.entries){let _=Me(K.path),T=K.path.replace(/\\/g,"/").toLowerCase(),j=K.path.replace(/\//g,"\\").toLowerCase(),q=_.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase(),Z=_.replace(/\//g,"\\").toLowerCase();if(K.name.toLowerCase().includes(i.toLowerCase())||q.includes(i.toLowerCase())){B.add(T),B.add(j),B.add(q),B.add(Z),B.add(K.path),B.add(K.path.toLowerCase()),B.add(_),B.add(_.toLowerCase());let ce=q.split("/"),ge=ce.length-1,ie="";for(let be=0;be<ge;be++){ie=ie?`${ie}/${ce[be]}`:ce[be],O.add(ie.toLowerCase());let Et=`${qe}/${ie}`,ct=`${Qe}\\${ie.replace(/\//g,"\\")}`;O.add(Et.toLowerCase()),O.add(ct.toLowerCase()),O.add(Et),O.add(ct),!I[Et]&&!I[ct]&&M.add(ct)}}}if(M.size>0&&!p){let W=Array.from(new Set(Array.from(M).map(T=>T.replace(/\//g,"\\")))),K={};try{let T=await ht(W.slice(0,100));T&&typeof T=="object"&&(K=T)}catch{K={}}let _=W.filter(T=>!K[T]&&!K[T.replace(/\\/g,"/")]&&!K[T.replace(/\//g,"\\")]);if(_.length>0&&!p){let T=await Promise.all(_.slice(0,60).map(async j=>{try{let q=await et(n,j);return{dir:j,listing:q}}catch{return null}}));for(let j of T)j&&j.listing&&(K[j.dir]=j.listing)}!p&&Object.keys(K).length>0&&l(T=>{let j={...T};for(let[q,Z]of Object.entries(K)){if(!Z)continue;let ce=q.replace(/\\/g,"/"),ge=q.replace(/\//g,"\\");j[q]=Z,j[ce]=Z,j[ge]=Z,j[ce.toLowerCase()]=Z,j[ge.toLowerCase()]=Z}return j})}p||(le(B),we(O),ve(A.matches.length),F(!1),h(W=>{let K=new Set(W);for(let _ of O)K.add(_);return K}))}catch(A){!p&&A?.name!=="AbortError"&&F(!1)}})(),()=>{p=!0,b.abort()}},[u,t,n,Me]);let un=(0,y.useMemo)(()=>{let i=new Map,p=t?t.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase():"";for(let b of se?.entries??[]){if(!b||!b.path)continue;let S=b.path.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase();i.set(S,b.xy),p&&i.set(`${p}/${S}`,b.xy);let A=S;for(;;){let I=A.lastIndexOf("/");if(I===-1||(A=A.slice(0,I),!A))break;let B=i.get(A);B?b.xy.includes("M")&&!B.includes("M")&&(i.set(A," M"),p&&i.set(`${p}/${A}`," M")):(i.set(A,b.xy),p&&i.set(`${p}/${A}`,b.xy))}}return i},[se,t]),Ht=(0,y.useMemo)(()=>{if(!t)return[];let i=t.replace(/\\/g,"/").toLowerCase(),p=a[t]??a[t.replace(/\\/g,"/")]??a[t.replace(/\//g,"\\")]??Object.entries(a).find(([I])=>I.replace(/\\/g,"/").toLowerCase()===i)?.[1];if(!p||!Array.isArray(p.entries))return[];let b=[],S=!!(u&&Y),A=I=>{let B=I.replace(/\\/g,"/").toLowerCase(),O=a[I]??a[I.replace(/\\/g,"/")]??a[I.replace(/\//g,"\\")]??Object.entries(a).find(([M])=>M.replace(/\\/g,"/").toLowerCase()===B)?.[1];if(!(!O||!Array.isArray(O.entries)))for(let M of O.entries){if(!M||!H.showHiddenFiles&&(M.hidden||M.name.startsWith(".")))continue;let qe=Me(M.path),Qe=qe.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").toLowerCase(),W=M.path.replace(/\\/g,"/").toLowerCase();if(S&&Y&&P){let _=Y.has(Qe)||Y.has(W)||Y.has(M.path)||Y.has(M.path.toLowerCase());if(M.isDir){let T=P.has(Qe)||P.has(W)||P.has(M.path)||P.has(M.path.toLowerCase());if(!_&&!T)continue}else if(!_)continue}if(H.compactFolders&&M.isDir){let _=[M],T=M,j=a[T.path]??a[T.path.replace(/\\/g,"/")]??a[T.path.replace(/\//g,"\\")];for(;j&&Array.isArray(j.entries);){let q=H.showHiddenFiles?j.entries:j.entries.filter(Z=>Z&&!Z.hidden&&!Z.name.startsWith("."));if(q.length===1&&q[0].isDir){let Z=q[0];_.push(Z),T=Z,j=a[T.path]??a[T.path.replace(/\\/g,"/")]??a[T.path.replace(/\//g,"\\")]}else break}if(_.length>1){let q=Me(T.path);b.push({entry:T,relativePath:q}),(S||x.has(M.path)||x.has(T.path))&&A(T.path);continue}}b.push({entry:M,relativePath:qe});let K=S||x.has(M.path);M.isDir&&K&&A(M.path)}};return A(t),b},[t,a,x,u,Y,P,Me,H.showHiddenFiles,H.compactFolders]),$t=(0,y.useCallback)(async()=>{let i=new Set;t&&i.add(t);for(let[b,S]of Object.entries(a))if(i.add(b),S?.entries)for(let A of S.entries)A.isDir&&i.add(A.path);h(i);let p=Array.from(i).filter(b=>{let S=b.replace(/\\/g,"/");return!a[b]&&!a[S]});if(p.length>0)try{let b=await ht(p);l(S=>({...S,...b}))}catch{}},[t,a]),Ct=(0,y.useCallback)((i,p)=>{let b=p??Me(i.path);De({entry:i,relativePath:b})},[Me]),mn=(0,y.useCallback)(async()=>{pe&&(await qt(pe.entry.path),te())},[pe,te]),gn=cn({visibleFlatRows:Ht,focusedPath:f,expanded:x,setFocusedPath:v,setSelected:m,toggleExpand:At,onMention:i=>{let p=n??Ie(e,"sessions")?.active?.id??"";Oe(e,p,i,!1)},onStartRename:i=>Ee(i),onDelete:(i,p)=>Ct(i,p)}),xn=(i,p)=>{v(i),p.ctrlKey||p.metaKey?m(b=>{let S=new Set(b);return S.has(i)?S.delete(i):S.add(i),S}):m(new Set([i]))},lt=async()=>{if(!oe||!L.trim()){ue(null);return}let i=L.trim(),p=oe.parentDir;try{oe.isDir?await Gt(p,i):await Kt(p,i),te(),h(b=>new Set(b).add(p))}catch(b){console.error("[dsh-explorer] Operation failed:",b)}finally{ue(null),ee("")}},vn=async(i,p)=>{Ee(null);try{await Ut(i,p),te()}catch(b){console.error("[dsh-explorer] Rename failed:",b)}},bn=async i=>{if(i.dataTransfer.files&&i.dataTransfer.files.length>0){i.preventDefault(),i.stopPropagation();let p=t;for(let b=0;b<i.dataTransfer.files.length;b++){let S=i.dataTransfer.files[b],A=`/dsh-explorer/api/upload?dir=${encodeURIComponent(p)}&relativePath=${encodeURIComponent(S.name)}`;await fetch(A,{method:"POST",body:S})}te()}},Ot=(0,y.useCallback)((i,p)=>{hn(e,n??"",i,p)},[e,n]),zt=t?t.replace(/\\/g,"/").toLowerCase():"",yn=a[t]??a[t.replace(/\\/g,"/")]??a[t.replace(/\//g,"\\")]??(zt?Object.entries(a).find(([i])=>i.replace(/\\/g,"/").toLowerCase()===zt)?.[1]:void 0);return(0,re.jsxs)("div",{className:`${r.container} ${H.enableMotion?"":r.noMotion}`,style:Se,children:[(0,re.jsx)(Zt,{title:t||"EXPLORER",searchOpen:fe,optionsOpen:Ce,onToggleSearch:()=>{fe?(d(""),E(""),ae(!1)):ae(!0)},onToggleOptions:()=>Le(!Ce),onNewFile:()=>{ue({parentDir:t,isDir:!1}),ee("")},onNewFolder:()=>{ue({parentDir:t,isDir:!0}),ee("")},onRefresh:()=>{te()},onExpandAll:$t,onCollapseAll:()=>{h(new Set)}}),Ce&&(0,re.jsx)(Jt,{options:H,onChange:Ke,onReset:me,onClose:()=>Le(!1)}),fe&&(0,re.jsx)(Xt,{value:C,loading:k,matchCount:X,onChange:d,onClose:()=>{d(""),E(""),ae(!1)}}),(0,re.jsxs)("div",{ref:Re,className:r.treeBody,tabIndex:0,onKeyDown:gn,onContextMenu:i=>{i.preventDefault(),je(null),We({x:i.clientX,y:i.clientY})},onDragOver:i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},onDrop:bn,children:[oe&&oe.parentDir===t&&(0,re.jsxs)("div",{className:r.row,style:{paddingLeft:`${D+8}px`},children:[(0,re.jsx)("span",{className:r.iconWrap,children:oe.isDir?"\u{1F4C1}":"\u{1F4C4}"}),(0,re.jsx)("input",{ref:He,autoFocus:!0,type:"text",className:r.inlineInput,placeholder:oe.isDir?"Folder name...":"File name...",value:L,onChange:i=>ee(i.target.value),onKeyDown:i=>{i.key==="Enter"?lt():i.key==="Escape"&&ue(null)},onBlur:lt})]}),(yn?.entries??[]).map(i=>(0,re.jsx)(Tt,{entry:i,depth:0,parentDir:t,rootPath:t,levels:a,expanded:x,selected:c,focusedPath:f,renamingPath:_e,gitStatusMap:un,filterText:u,matchingPaths:Y,ancestorPaths:P,creating:oe,creatingName:L,createInputRef:He,options:H,indentStep:D,iconSize:Je,reloadDirectory:ke,onToggle:At,onSelect:xn,onOpenFile:Ot,onContextMenu:(p,b,S)=>{S.preventDefault(),S.stopPropagation(),We(null),je({x:S.clientX,y:S.clientY,entry:p,relativePath:b})},onInsertReference:(p,b)=>{let S=n??Ie(e,"sessions")?.active?.id??"";Oe(e,S,p,b)},onCopyRelativePath:p=>{navigator.clipboard.writeText(p)},onStartRename:p=>Ee(p),onCancelRename:()=>Ee(null),onRenameSubmit:(p,b)=>vn(p,b),onDelete:Ct,onCreatingNameChange:ee,onCreatingKeyDown:p=>{p.key==="Enter"?lt():p.key==="Escape"&&ue(null)},onCreatingBlur:lt,getRelativePath:Me},i.path)),Ht.length===0&&!oe&&(0,re.jsx)("div",{className:r.emptyState,children:de||k?"Searching workspace files...":Pe?`Error: ${Pe}`:u?`No files matching "${u}"`:H.showHiddenFiles?"Empty directory":"Only hidden files present (enable in options)"})]}),z&&(0,re.jsx)(_t,{x:z.x,y:z.y,entry:z.entry,relativePath:z.relativePath,onClose:()=>je(null),onOpenFile:()=>Ot(z.entry.path,z.relativePath),onInsertReference:()=>{let i=n??Ie(e,"sessions")?.active?.id??"";Oe(e,i,z.relativePath,z.entry.isDir)},onInsertSnippet:async()=>{let i=n??Ie(e,"sessions")?.active?.id??"";try{let p=await ft(z.entry.path);wt(e,i,z.relativePath,p)}catch(p){console.error("[dsh-explorer] Failed to read file:",p)}},onCopyPath:()=>{navigator.clipboard.writeText(z.entry.path)},onCopyRelativePath:()=>{navigator.clipboard.writeText(z.relativePath)},onNewFile:()=>{ue({parentDir:z.entry.path,isDir:!1}),ee("")},onNewFolder:()=>{ue({parentDir:z.entry.path,isDir:!0}),ee("")},onRename:()=>{v(z.entry.path),Ee(z.entry.path)},onDelete:()=>Ct(z.entry,z.relativePath)}),Ve&&(0,re.jsx)(Yt,{x:Ve.x,y:Ve.y,onClose:()=>We(null),onNewFile:()=>{ue({parentDir:t,isDir:!1}),ee("")},onNewFolder:()=>{ue({parentDir:t,isDir:!0}),ee("")},onToggleSearch:()=>{ae(i=>!i)},onExpandAll:$t,onCollapseAll:()=>{h(new Set)},onRefresh:te,onOpenOptions:()=>{Le(!0)}}),pe&&(0,re.jsx)(en,{entry:pe.entry,relativePath:pe.relativePath,onConfirm:mn,onClose:()=>De(null)})]})};var ne=require("react/jsx-runtime"),In=["slots","sessions","locale"],Bt=class extends ot.Component{state={hasError:!1,error:null};static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,o){console.error("[dsh-explorer] Render error:",n,o)}render(){return this.state.hasError?(0,ne.jsxs)("div",{style:{padding:"16px",color:"var(--dsw-alias-label-primary, #ffffff)",fontSize:"12px",fontFamily:"var(--dsw-font-code, monospace)",display:"flex",flexDirection:"column",gap:"12px",height:"100%",boxSizing:"border-box"},children:[(0,ne.jsx)("div",{style:{fontWeight:600,color:"var(--dsw-alias-danger, #f85149)"},children:"Explorer encountered an error"}),(0,ne.jsx)("div",{style:{fontSize:"11px",opacity:.85,wordBreak:"break-word",background:"var(--dsw-alias-bg-hover, rgba(255, 255, 255, 0.05))",padding:"8px",borderRadius:"4px"},children:this.state.error?.message||"Unknown render exception"}),(0,ne.jsx)("button",{type:"button",onClick:()=>this.setState({hasError:!1,error:null}),style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid var(--dsw-alias-hairline, rgba(255, 255, 255, 0.15))",background:"var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.08))",color:"var(--dsw-alias-label-primary, #ffffff)",cursor:"pointer",alignSelf:"flex-start",fontSize:"12px"},children:"Reload Explorer"})]}):this.props.children}},It=()=>(0,ne.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:(0,ne.jsx)("path",{d:"M14 4.5V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h6.5L14 4.5zm-1 0H9.5a.5.5 0 0 1-.5-.5V2H3v12h10V4.5z"})}),An=(0,ot.memo)(function(){return(0,ne.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",fontSize:"12px"},children:[(0,ne.jsx)(It,{}),(0,ne.jsx)("span",{children:"Explorer"})]})}),Pn=(0,ot.memo)(function(n){return(0,ne.jsx)(Bt,{children:(0,ne.jsx)(fn,{ctx:n.ctx,sessionId:n.sessionId})})}),Hn=({ctx:e,sessionId:n})=>(0,ne.jsx)("button",{type:"button",title:"Explorer (File Tree)","aria-label":"Explorer",onClick:()=>{try{let o=e.get?e.get("sidebarRight"):e.sidebarRight;n&&o?.openTabIn?o.openTabIn(n,"explorer"):o?.openTab&&o.openTab("explorer")}catch(o){console.warn("[dsh-explorer] failed to open sidebar tab:",o)}},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",cursor:"pointer",padding:"3px 6px",borderRadius:"6px",color:"var(--dsw-alias-label-secondary, #8b949e)",transition:"color 0.15s, background-color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.color="var(--dsw-alias-label-primary, #ffffff)",o.currentTarget.style.backgroundColor="var(--dsw-alias-bg-hover, rgba(255, 255, 255, 0.08))"},onMouseLeave:o=>{o.currentTarget.style.color="var(--dsw-alias-label-secondary, #8b949e)",o.currentTarget.style.backgroundColor="transparent"},children:(0,ne.jsx)(It,{})});function $n(e){e.effect(()=>{try{return nn()}catch(n){return console.warn("[dsh-explorer] failed to setup caret tracker:",n),()=>{}}},"dsh-explorer: caret tracker"),e.effect(()=>{try{return an(e)}catch(n){return console.warn("[dsh-explorer] failed to attach conversation drop listener:",n),()=>{}}},"dsh-explorer: conversation drop listener"),e.slots.inject("conversation.session.header.utilities",()=>e.slots.register({name:"conversation.session.header.utilities",id:"dsh-explorer:header-button",order:15,inject:n=>({sessionId:n})},n=>(0,ne.jsx)(Hn,{ctx:e,sessionId:n.sessionId}))),e.inject(["sidebarRightTabs"],n=>{let o=n.get?n.get("sidebarRightTabs"):n.sidebarRightTabs;if(!o?.register)return;let t=o.register({id:"dsh-explorer",kind:"explorer",keepMounted:!0,priority:"extension",title:()=>"Explorer",guide:[{id:"dsh-explorer",order:5,title:()=>"Explorer",description:()=>"VS Code style file explorer with drag & drop to chat",icon:It}]}),s=e.slots.inject("sidebar.right.pane.tab",()=>e.slots.register({name:"sidebar.right.pane.tab",key:"dsh-explorer",inject:l=>({ctx:e,sessionId:l})},Pn)),a=e.slots.inject("sidebar.right.pane.tab.title",()=>e.slots.register({name:"sidebar.right.pane.tab.title",key:"dsh-explorer",inject:l=>({sessionId:l})},An));return()=>{try{a?.()}catch{}try{s?.()}catch{}try{t?.()}catch{}}})}
|
|
2810
855
|
|
|
2811
856
|
|
|
2812
857
|
return module.exports;
|