dsh-vscode-workbench 0.1.4 → 0.1.5

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
@@ -4418,22 +4418,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
4418
4418
  }
4419
4419
  //#endregion
4420
4420
  //#region src/client/DshMark.tsx
4421
- /** Reuse the official DSH whale already rendered by the host brand plugin. */
4421
+ /** Bundled DSH fish logo — self-contained, no dependence on host DOM. */
4422
+ const WHALE_VIEWBOX = "0 0 23.16 17.04";
4423
+ const WHALE_PATH = "M22.9168 1.43018C22.6713 1.31018 22.5658 1.53918 22.4223 1.65519C22.3733 1.69269 22.3318 1.74169 22.2903 1.78669C21.9317 2.1697 21.5127 2.42121 20.9657 2.39121C20.1657 2.34621 19.4827 2.59771 18.8787 3.20973C18.7502 2.45521 18.3236 2.0047 17.6746 1.71569C17.3351 1.56568 16.9916 1.41518 16.7536 1.08867C16.5876 0.856163 16.5421 0.597155 16.4591 0.341647C16.4061 0.187643 16.3536 0.0301382 16.1761 0.00363739C15.9836 -0.0263635 15.9081 0.135141 15.8326 0.270145C15.5306 0.822162 15.4136 1.43018 15.4251 2.0462C15.4516 3.43174 16.0366 4.53527 17.1991 5.3203C17.3311 5.4103 17.3651 5.5003 17.3236 5.63181C17.2441 5.90231 17.1501 6.16482 17.0671 6.43533C17.0141 6.60784 16.9351 6.64584 16.7501 6.57033C16.1121 6.30383 15.5611 5.90931 15.074 5.4328C14.2475 4.63328 13.5 3.75075 12.568 3.05973C12.349 2.89822 12.13 2.74822 11.9034 2.60522C10.9524 1.68169 12.028 0.923165 12.277 0.833162C12.5375 0.739159 12.3675 0.41615 11.5259 0.42015C10.6844 0.42365 9.91439 0.705658 8.93286 1.08117C8.78935 1.13767 8.63835 1.17867 8.48384 1.21267C7.59332 1.04367 6.66829 1.00617 5.70226 1.11517C3.88321 1.31768 2.43016 2.1777 1.36213 3.64575C0.0790928 5.4103 -0.222916 7.41536 0.146595 9.50642C0.535106 11.7105 1.66014 13.535 3.38869 14.9616C5.18125 16.4406 7.24581 17.1657 9.60138 17.0266C11.0319 16.9441 12.6245 16.7526 14.421 15.2321C14.874 15.4576 15.3496 15.5476 16.1381 15.6151C16.7456 15.6716 17.3306 15.5851 17.7836 15.4911C18.4931 15.3411 18.4441 14.6841 18.1876 14.5636C16.1081 13.595 16.5646 13.9891 16.1496 13.67C17.2061 12.42 18.8202 10.1979 19.3182 7.17235C19.3672 6.83834 19.4297 6.36783 19.4222 6.09732C19.4182 5.93231 19.4562 5.86831 19.6447 5.84931C20.1657 5.78931 20.6712 5.64681 21.1357 5.3913C22.4833 4.65528 23.0268 3.44624 23.1548 1.9972C23.1738 1.77569 23.1508 1.54668 22.9168 1.43018ZM11.1749 14.4736C9.15936 12.889 8.18184 12.3675 7.77832 12.39C7.40081 12.4125 7.46881 12.8445 7.55182 13.126C7.63882 13.404 7.75182 13.5955 7.91033 13.8396C8.01983 14.0011 8.09533 14.2411 7.80083 14.4216C7.15181 14.8231 6.02327 14.2866 5.97027 14.2601C4.65673 13.4865 3.5587 12.4655 2.78467 11.069C2.03715 9.72493 1.60314 8.28289 1.53164 6.74384C1.51264 6.37233 1.62214 6.24082 1.99215 6.17332C2.47916 6.08332 2.98118 6.06432 3.46769 6.13582C5.52476 6.43633 7.27581 7.35586 8.74385 8.8129C9.58188 9.64243 10.2159 10.634 10.8689 11.6025C11.5634 12.631 12.3105 13.611 13.262 14.4146C13.598 14.6961 13.866 14.9101 14.1225 15.0681C13.349 15.1546 12.058 15.1731 11.1749 14.4746L11.1749 14.4736ZM12.141 8.25988C12.141 8.09488 12.273 7.96338 12.439 7.96338C12.4765 7.96338 12.5105 7.97088 12.541 7.98188C12.5825 7.99688 12.6205 8.01938 12.6505 8.05338C12.7035 8.10588 12.7335 8.18088 12.7335 8.25988C12.7335 8.42489 12.6015 8.55639 12.4355 8.55639C12.2695 8.55639 12.141 8.42489 12.141 8.25988ZM15.1415 9.79893C14.949 9.87793 14.7565 9.94544 14.5715 9.95294C14.2845 9.96794 13.9715 9.85143 13.8015 9.70893C13.5375 9.48742 13.3485 9.36342 13.2695 8.97691C13.2355 8.8119 13.2545 8.55639 13.2845 8.40989C13.3525 8.09438 13.277 7.89187 13.0545 7.70787C12.8735 7.55786 12.643 7.51636 12.39 7.51636C12.2955 7.51636 12.209 7.47486 12.1445 7.44136C12.039 7.38886 11.9519 7.25735 12.035 7.09585C12.0615 7.04335 12.19 6.91584 12.22 6.89334C12.5635 6.69784 12.9595 6.76184 13.326 6.90834C13.6655 7.04735 13.9225 7.30236 14.292 7.66287C14.6695 8.09838 14.7375 8.21838 14.9525 8.54539C15.1225 8.8009 15.277 9.06341 15.3831 9.36392C15.4471 9.55142 15.3641 9.70493 15.1415 9.79893Z";
4422
4424
  function DshMark({ size = 18 }) {
4423
- const mount = (0, react.useRef)(null);
4424
- (0, react.useLayoutEffect)(() => {
4425
- const source = [...document.querySelectorAll("svg")].find((svg) => svg.getAttribute("viewBox") === "0 0 23.16 17.04" && !mount.current?.contains(svg));
4426
- if (source === void 0 || mount.current === null) return;
4427
- const logo = source.cloneNode(true);
4428
- logo.setAttribute("width", String(size));
4429
- logo.setAttribute("height", String(size * 17.04 / 23.16));
4430
- mount.current.replaceChildren(logo);
4431
- }, [size]);
4432
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4425
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
4433
4426
  className: "dvw-dsh-mark",
4434
- ref: mount,
4427
+ width: size,
4428
+ height: size * 17.04 / 23.16,
4429
+ viewBox: WHALE_VIEWBOX,
4430
+ fill: "none",
4435
4431
  "aria-hidden": "true",
4436
- children: "DSH"
4432
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
4433
+ d: WHALE_PATH,
4434
+ fill: "currentColor"
4435
+ })
4437
4436
  });
4438
4437
  }
4439
4438
  //#endregion
@@ -4474,6 +4473,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
4474
4473
  const path = tab.title ?? tab.diffSourcePath ?? tab.path.replace(/^diff:/, "");
4475
4474
  return path.split(/[\\/]/).at(-1) ?? path;
4476
4475
  }
4476
+ /** Invoke `fn` at most once per `ms` after the latest call, always running the freshest callback. */
4477
+ function useDebouncedCallback(fn, ms) {
4478
+ const fnRef = (0, react.useRef)(fn);
4479
+ fnRef.current = fn;
4480
+ const timer = (0, react.useRef)();
4481
+ (0, react.useEffect)(() => () => clearTimeout(timer.current), []);
4482
+ return (0, react.useCallback)(() => {
4483
+ clearTimeout(timer.current);
4484
+ timer.current = setTimeout(() => fnRef.current(), ms);
4485
+ }, [ms]);
4486
+ }
4477
4487
  function useDshDarkTheme() {
4478
4488
  const read = () => document.body.hasAttribute("data-ds-dark-theme");
4479
4489
  const [dark, setDark] = (0, react.useState)(read);
@@ -4736,12 +4746,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
4736
4746
  const refreshStatus = (0, react.useCallback)(() => {
4737
4747
  api("git.status", { sessionId: props.sessionId }).then((status) => setStatuses(new Map(status.changes.map((change) => [change.path, gitStatusCode(change)])))).catch(() => setStatuses(/* @__PURE__ */ new Map()));
4738
4748
  }, [props.sessionId]);
4749
+ const refreshStatusDebounced = useDebouncedCallback(refreshStatus, 500);
4739
4750
  (0, react.useEffect)(() => {
4740
4751
  refreshStatus();
4741
- const handler = () => refreshStatus();
4752
+ const handler = () => refreshStatusDebounced();
4742
4753
  window.addEventListener("dvw-files-changed", handler);
4743
4754
  return () => window.removeEventListener("dvw-files-changed", handler);
4744
- }, [refreshStatus]);
4755
+ }, [refreshStatus, refreshStatusDebounced]);
4745
4756
  const create = async (kind) => {
4746
4757
  const path = prompt(kind === "file" ? "新文件路径" : "新目录路径");
4747
4758
  if (!path) return;
@@ -5320,12 +5331,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
5320
5331
  setError(void 0);
5321
5332
  }).catch((error) => setError(String(error)));
5322
5333
  }, [props.sessionId]);
5334
+ const refreshDebounced = useDebouncedCallback(refresh, 500);
5323
5335
  (0, react.useEffect)(refresh, [refresh]);
5324
5336
  (0, react.useEffect)(() => {
5325
- const fn = () => refresh();
5337
+ const fn = () => refreshDebounced();
5326
5338
  window.addEventListener("dvw-files-changed", fn);
5327
5339
  return () => window.removeEventListener("dvw-files-changed", fn);
5328
- }, [refresh]);
5340
+ }, [refreshDebounced]);
5329
5341
  const action = async (name, path, value) => {
5330
5342
  setBusy(true);
5331
5343
  try {
@@ -6319,7 +6331,7 @@ body[data-ds-dark-theme] .dvw-overlay,.dvw-overlay[data-dvw-theme=dark]{color-sc
6319
6331
  .dvw-chat{grid-column:4;grid-row:1/3;min-width:0;background:var(--dvw-base);border-left:1px solid var(--dvw-border);position:relative}
6320
6332
  .dvw-chat-head{height:36px;display:flex;align-items:center;justify-content:space-between;padding:0 6px 0 12px;border-bottom:1px solid var(--dvw-border);background:var(--dvw-base);font-weight:600}
6321
6333
  .dvw-chat-head>span{display:flex;align-items:center;gap:7px}.dvw-chat-body{height:calc(100% - 36px);background:var(--dvw-base)}
6322
- .dvw-dsh-mark{min-width:18px;height:18px;display:inline-grid;place-items:center;color:currentColor;font-size:0}.dvw-dsh-mark svg{display:block}
6334
+ .dvw-dsh-mark{display:block}
6323
6335
  .dvw-chat-resizer{position:fixed;top:0;right:calc(var(--dvw-chat-width) - 4px);bottom:0;width:8px;z-index:4;cursor:ew-resize;touch-action:none}
6324
6336
  .dvw-chat-resizer:hover,.dvw-chat-resizer:active{background:var(--dvw-accent)}
6325
6337
  .dvw-chat-toggle{position:absolute;z-index:5;top:6px;right:6px;border:1px solid var(--dvw-border);background:var(--dvw-base)}