@dong-victor/dsh-better-sidebar-starter 0.1.8 → 0.1.9

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 CHANGED
@@ -1089,29 +1089,28 @@ window.__ModuleLoader__.load({
1089
1089
  //#endregion
1090
1090
  //#region src/client/DirChooser.tsx
1091
1091
  /**
1092
- * Shared directory chooser: a filesystem folder tree (backed by the sidebar
1093
- * fs.tree API, which can list any absolute path) plus a browse button that
1094
- * opens a modal popup. Browsing starts at the user's home directory and can
1095
- * navigate up to any drive/root, so runtime tool paths (JDK/Maven/...) that
1096
- * live outside the workspace can be selected.
1092
+ * Shared directory chooser: a filesystem folder tree (backed by the starter
1093
+ * plugin's own fs-dirs host route) plus a browse button that opens a modal
1094
+ * popup. Browsing starts at the user's home directory and can navigate up to
1095
+ * any drive/root, so runtime tool paths (JDK/Maven/...) that live outside the
1096
+ * workspace can be selected. The sidebar fs.tree API cannot be used here — it
1097
+ * is workspace-confined since dsh-better-sidebar 0.16 (403 outside the
1098
+ * session workspace).
1097
1099
  * @module dsh-better-sidebar-starter/client/DirChooser
1098
1100
  */
1099
- /** Call the sidebar fs.tree API directly via fetch. Returns directories only. */
1100
- async function fsTree$1(scope, path) {
1101
- const payload = {
1102
- sessionId: scope.sessionId,
1103
- path
1104
- };
1105
- if (scope.cwd !== void 0 && scope.cwd !== "") payload.cwd = scope.cwd;
1106
- const resp = await fetch("/sidebar/api/fs.tree", {
1101
+ /** Call the starter fs-dirs host route via fetch. Returns directories only. */
1102
+ async function fsTree(scope, path) {
1103
+ const resp = await fetch("/api/dsh-better-sidebar-starter/fs-dirs", {
1107
1104
  method: "POST",
1108
1105
  headers: { "content-type": "application/json" },
1109
- body: JSON.stringify(payload)
1106
+ body: JSON.stringify({
1107
+ sessionId: scope.sessionId,
1108
+ path
1109
+ })
1110
1110
  });
1111
- if (!resp.ok) throw new Error(`fs.tree ${path}: ${resp.status}`);
1112
- const parsed = await resp.json();
1113
- if (!parsed.ok || parsed.value === void 0) throw new Error(`fs.tree ${path}: ${parsed.error?.message ?? "unknown error"}`);
1114
- return parsed.value.entries.filter((e) => e.isDir && !e.hidden);
1111
+ const parsed = await resp.json().catch(() => void 0);
1112
+ if (!resp.ok) throw new Error(`fs-dirs ${path}: ${parsed?.error ?? resp.status}`);
1113
+ return (parsed?.entries ?? []).filter((e) => e.isDir && !e.hidden);
1115
1114
  }
1116
1115
  /** Fetch the user's home directory from the host. Falls back to cwd. */
1117
1116
  async function fetchHomeDefault(scope) {
@@ -1163,7 +1162,7 @@ window.__ModuleLoader__.load({
1163
1162
  const loadDir = (s, path) => {
1164
1163
  setLoading(true);
1165
1164
  setError(null);
1166
- fsTree$1(s, path).then((dirs) => {
1165
+ fsTree(s, path).then((dirs) => {
1167
1166
  setEntries(dirs);
1168
1167
  setLoading(false);
1169
1168
  }).catch((err) => {
@@ -1244,7 +1243,7 @@ window.__ModuleLoader__.load({
1244
1243
  onToggleExpand(entry.path);
1245
1244
  if (children === null) {
1246
1245
  setLoading(true);
1247
- fsTree$1(scope, entry.path).then((dirs) => {
1246
+ fsTree(scope, entry.path).then((dirs) => {
1248
1247
  setChildren(dirs);
1249
1248
  setLoading(false);
1250
1249
  }).catch(() => {
@@ -1356,23 +1355,6 @@ window.__ModuleLoader__.load({
1356
1355
  * and environment variables.
1357
1356
  * @module dsh-better-sidebar-starter/client/ConfigEditorModal
1358
1357
  */
1359
- /** Call the sidebar fs.tree API directly via fetch. Returns directories only.
1360
- * If path is omitted, the server uses the session cwd (root listing).
1361
- * The sidebar API wraps responses in { ok: true, value: ... } envelope. */
1362
- async function fsTree(scope, path) {
1363
- const payload = { sessionId: scope.sessionId };
1364
- if (scope.cwd !== void 0 && scope.cwd !== "") payload.cwd = scope.cwd;
1365
- if (path !== void 0) payload.path = path;
1366
- const resp = await fetch("/sidebar/api/fs.tree", {
1367
- method: "POST",
1368
- headers: { "content-type": "application/json" },
1369
- body: JSON.stringify(payload)
1370
- });
1371
- if (!resp.ok) throw new Error(`fs.tree ${path ?? "(root)"}: ${resp.status}`);
1372
- const parsed = await resp.json();
1373
- if (!parsed.ok || parsed.value === void 0) throw new Error(`fs.tree ${path ?? "(root)"}: ${parsed.error?.message ?? "unknown error"}`);
1374
- return parsed.value.entries.filter((e) => e.isDir && !e.hidden);
1375
- }
1376
1358
  /** Recursive tree node: loads its own children on expand. */
1377
1359
  function TreeNode(props) {
1378
1360
  const { scope, entry, depth, selectedPath, onSelect } = props;
@@ -1426,7 +1408,8 @@ window.__ModuleLoader__.load({
1426
1408
  if (!expanded && children === null) {
1427
1409
  setLoading(true);
1428
1410
  setError(null);
1429
- fsTree(scope).then((dirs) => {
1411
+ const root = scope.cwd ?? "";
1412
+ (root === "" ? Promise.reject(/* @__PURE__ */ new Error("fs-dirs: 会话工作目录不可用")) : fsTree(scope, root)).then((dirs) => {
1430
1413
  setChildren(dirs);
1431
1414
  setLoading(false);
1432
1415
  }).catch((err) => {
@@ -3104,39 +3087,7 @@ window.__ModuleLoader__.load({
3104
3087
  icon: (size) => (0, react.createElement)(RocketIcon, { size }),
3105
3088
  order: 50,
3106
3089
  single: true,
3107
- settings: {
3108
- pluginToggles: [
3109
- {
3110
- key: "autoSelectOnStart",
3111
- type: "switch",
3112
- title: "启动后自动选中日志"
3113
- },
3114
- {
3115
- key: "autoScroll",
3116
- type: "switch",
3117
- title: "自动滚动到最新日志"
3118
- },
3119
- {
3120
- key: "javaHome",
3121
- type: "text",
3122
- title: "Java 主目录 (JAVA_HOME)",
3123
- desc: "Spring Boot 用的 JDK 路径,留空则自动查找"
3124
- },
3125
- {
3126
- key: "nodePath",
3127
- type: "text",
3128
- title: "Node.js 路径",
3129
- desc: "npm 命令用的 Node 路径,留空则用系统默认"
3130
- },
3131
- {
3132
- key: "pythonPath",
3133
- type: "text",
3134
- title: "Python 路径",
3135
- desc: "Python 命令用的解释器路径,留空则用系统默认"
3136
- }
3137
- ],
3138
- render: (props) => (0, react.createElement)(SettingsPanel, props)
3139
- },
3090
+ settings: { render: (props) => (0, react.createElement)(SettingsPanel, props) },
3140
3091
  component: (props) => (0, react.createElement)(ServicesTab, props)
3141
3092
  }), "dsh-better-sidebar-starter: services tab");
3142
3093
  }