dsh-plugin-core-demo 0.20.7 → 0.20.8

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.
Files changed (2) hide show
  1. package/dist/client.js +83 -30
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -2994,7 +2994,7 @@ var DICT = {
2994
2994
  explorerExpand: "Expand",
2995
2995
  explorerCollapse: "Collapse",
2996
2996
  explorerEnter: "Open",
2997
- explorerRootDir: "\u6839\u76EE\u5F55",
2997
+ explorerRootDir: "Root",
2998
2998
  explorerRootName: "(workspace root)",
2999
2999
  explorerCrumbsAria: "Breadcrumb",
3000
3000
  explorerPickFile: "Pick this file",
@@ -7354,7 +7354,7 @@ function NumberInput(props) {
7354
7354
  (0, import_react33.useEffect)(() => {
7355
7355
  setText(String(value));
7356
7356
  }, [value]);
7357
- const clamp2 = (n) => Math.min(max2, Math.max(min2, n));
7357
+ const clamp3 = (n) => Math.min(max2, Math.max(min2, n));
7358
7358
  const commit = (raw) => {
7359
7359
  if (raw.trim() === "") {
7360
7360
  setText(String(value));
@@ -7365,14 +7365,14 @@ function NumberInput(props) {
7365
7365
  setText(String(value));
7366
7366
  return;
7367
7367
  }
7368
- const next = clamp2(n);
7368
+ const next = clamp3(n);
7369
7369
  setText(String(next));
7370
7370
  if (next !== value)
7371
7371
  onChange(next);
7372
7372
  };
7373
7373
  const bump = (dir) => {
7374
7374
  const base3 = Number.isFinite(Number(text2)) ? Number(text2) : value;
7375
- const next = clamp2(base3 + dir * step);
7375
+ const next = clamp3(base3 + dir * step);
7376
7376
  setText(String(next));
7377
7377
  if (next !== value)
7378
7378
  onChange(next);
@@ -54833,6 +54833,64 @@ function getFsFace() {
54833
54833
  return current3;
54834
54834
  }
54835
54835
 
54836
+ // dist/explorer/picker-placement.js
54837
+ var PICKER_WIDTH = 480;
54838
+ var PICKER_MAX_H = 480;
54839
+ var PICKER_MIN_H = 240;
54840
+ var PICKER_MIN_FLOOR = 160;
54841
+ var PICKER_MIN_W = 240;
54842
+ var PICKER_GAP = 12;
54843
+ var VIEWPORT_EDGE = 12;
54844
+ function clamp2(value, low, high) {
54845
+ return Math.min(Math.max(value, low), Math.max(low, high));
54846
+ }
54847
+ function placePicker(anchor, viewport, placement = "auto") {
54848
+ const vw = viewport.width;
54849
+ const vh = viewport.height;
54850
+ const GAP2 = PICKER_GAP;
54851
+ const EDGE = VIEWPORT_EDGE;
54852
+ const fullWidth = Math.min(PICKER_WIDTH, Math.max(vw - 2 * EDGE, 0));
54853
+ if (placement === "auto") {
54854
+ const availBelow = vh - EDGE - (anchor.bottom + GAP2);
54855
+ const availAbove = anchor.top - GAP2 - EDGE;
54856
+ const below = availBelow >= PICKER_MIN_H || availBelow >= availAbove;
54857
+ const height2 = Math.max(Math.min(PICKER_MAX_H, below ? availBelow : availAbove), PICKER_MIN_FLOOR);
54858
+ const left2 = clamp2(anchor.left, EDGE, vw - EDGE - fullWidth);
54859
+ const top3 = below ? clamp2(Math.min(anchor.bottom + GAP2, vh - EDGE - height2), EDGE, vh - EDGE - height2) : clamp2(anchor.top - GAP2 - height2, EDGE, vh - EDGE - height2);
54860
+ return round2({ left: left2, top: top3, width: fullWidth, height: height2 });
54861
+ }
54862
+ const vertical = placement.startsWith("bottom") || placement.startsWith("top");
54863
+ if (vertical) {
54864
+ const below = placement.startsWith("bottom");
54865
+ const startAligned2 = placement.endsWith("start");
54866
+ const avail = below ? vh - EDGE - (anchor.bottom + GAP2) : anchor.top - GAP2 - EDGE;
54867
+ const height2 = Math.max(Math.min(PICKER_MAX_H, avail), PICKER_MIN_FLOOR);
54868
+ const rawLeft2 = startAligned2 ? anchor.left : anchor.right - fullWidth;
54869
+ const left2 = clamp2(rawLeft2, EDGE, vw - EDGE - fullWidth);
54870
+ const rawTop2 = below ? anchor.bottom + GAP2 : anchor.top - GAP2 - height2;
54871
+ const top3 = clamp2(rawTop2, EDGE, vh - EDGE - height2);
54872
+ return round2({ left: left2, top: top3, width: fullWidth, height: height2 });
54873
+ }
54874
+ const toRight = placement.startsWith("right");
54875
+ const startAligned = placement.endsWith("start");
54876
+ const availW = toRight ? vw - EDGE - (anchor.right + GAP2) : anchor.left - GAP2 - EDGE;
54877
+ const width = Math.max(Math.min(PICKER_WIDTH, availW), Math.min(PICKER_MIN_W, Math.max(vw - 2 * EDGE, 0)));
54878
+ const height = Math.min(PICKER_MAX_H, Math.max(vh - 2 * EDGE, 0));
54879
+ const rawLeft = toRight ? anchor.right + GAP2 : anchor.left - GAP2 - width;
54880
+ const left = clamp2(rawLeft, EDGE, vw - EDGE - width);
54881
+ const rawTop = startAligned ? anchor.top : anchor.bottom - height;
54882
+ const top2 = clamp2(rawTop, EDGE, vh - EDGE - height);
54883
+ return round2({ left, top: top2, width, height });
54884
+ }
54885
+ function round2(box) {
54886
+ return {
54887
+ left: Math.round(box.left),
54888
+ top: Math.round(box.top),
54889
+ width: Math.round(box.width),
54890
+ height: Math.round(box.height)
54891
+ };
54892
+ }
54893
+
54836
54894
  // dist/explorer/open.js
54837
54895
  function resolveStartPath(path, anchors, sessionId) {
54838
54896
  if (path === "")
@@ -54995,10 +55053,6 @@ function openFilePreview(options) {
54995
55053
  activePreview = { adopt, keepWidth, draw, close };
54996
55054
  return { close, path: opts.path ?? "" };
54997
55055
  }
54998
- var PICKER_WIDTH = 480;
54999
- var PICKER_MAX_H = 660;
55000
- var PICKER_MIN_H = 240;
55001
- var PICKER_MIN_FLOOR = 160;
55002
55056
  function pickWorkspaceFile(options) {
55003
55057
  return new Promise((resolve) => {
55004
55058
  if (typeof document === "undefined") {
@@ -55026,21 +55080,11 @@ function pickWorkspaceFile(options) {
55026
55080
  };
55027
55081
  const anchor = options.anchor ?? null;
55028
55082
  if (anchor !== null) {
55029
- const rect = anchor.getBoundingClientRect();
55030
- const GAP2 = 12;
55031
- const vw = window.innerWidth;
55032
- const vh = window.innerHeight;
55033
- const width = Math.min(PICKER_WIDTH, vw - 2 * GAP2);
55034
- const availBelow = vh - GAP2 - rect.bottom - GAP2;
55035
- const availAbove = rect.top - GAP2 - GAP2;
55036
- const below = availBelow >= PICKER_MIN_H || availBelow >= availAbove;
55037
- const height = Math.max(Math.min(PICKER_MAX_H, below ? availBelow : availAbove), PICKER_MIN_FLOOR);
55038
- const left = Math.max(GAP2, Math.min(rect.left, vw - GAP2 - width));
55039
- const top2 = below ? Math.min(rect.bottom + GAP2, Math.max(GAP2, vh - GAP2 - height)) : Math.max(GAP2, rect.top - GAP2 - height);
55040
- panelStyle.left = Math.round(left);
55041
- panelStyle.top = Math.round(top2);
55042
- panelStyle.width = Math.round(width);
55043
- panelStyle.height = Math.round(height);
55083
+ const box = placePicker(anchor.getBoundingClientRect(), { width: window.innerWidth, height: window.innerHeight }, options.placement ?? "auto");
55084
+ panelStyle.left = box.left;
55085
+ panelStyle.top = box.top;
55086
+ panelStyle.width = box.width;
55087
+ panelStyle.height = box.height;
55044
55088
  } else {
55045
55089
  panelStyle.width = `min(${PICKER_WIDTH}px,calc(100vw - 24px))`;
55046
55090
  panelStyle.height = PICKER_MAX_H;
@@ -58971,7 +59015,7 @@ var docData = {
58971
59015
  {
58972
59016
  "id": "explorer-usage-code",
58973
59017
  "lang": "tsx",
58974
- "src": "import { connectFs, openFilePreview, pickWorkspaceFile } from 'dsh-plugin-core/explorer'\nimport { serveFsRoute } from 'dsh-plugin-core/host'\nimport { FS_PATH } from './paths' // \u4F60\u81EA\u5DF1\u7684\u5E38\u91CF\uFF1A\u5BBF\u4E3B\u4E0E client \u5FC5\u987B\u7528\u540C\u4E00\u4E2A\n\n// \u2500\u2500 \u5BBF\u4E3B\u534A\u8FB9\uFF08apply\uFF09\uFF1A\u6302\u4E00\u6761\u53EA\u8BFB\u6587\u4EF6\u8DEF\u7531\uFF08\u4E0D\u9650\u5DE5\u4F5C\u533A\uFF1B\u8BFB\u6587\u4EF6/\u5217\u76EE\u5F55\u90FD\u5728\u5B83\u4E0A\u9762\uFF09 \u2500\u2500\nserveFsRoute(ctx, { path: FS_PATH })\n\n// \u2500\u2500 client \u534A\u8FB9\uFF08apply\uFF09\uFF1A\u63A5\u4E00\u6B21\uFF08connectHost \u7167\u65E7\u8D1F\u8D23\u5DE5\u4F5C\u533A\u5FEB\u7167\uFF09 \u2500\u2500\nconnectHost(ctx)\nconnectFs({ path: FS_PATH })\n\n// \u53F3\u4FA7\u5206\u680F\u9884\u89C8\uFF08\u5360\u5BBD\u5EA6\u3001\u6324\u7A84\u4E3B\u533A\uFF09\uFF1A\u4E00\u4E2A\u5BB9\u5668 + \u4E00\u4E2A\u8DEF\u5F84\u5C31\u591F\nopenFilePreview({ mount, path: '/abs/ledger' }) // \u6587\u4EF6\u5939 \u21D2 \u76EE\u5F55\u6811\uFF1B\u6587\u4EF6 \u21D2 \u76F4\u63A5\u9884\u89C8\nopenFilePreview({ mount, path: 'docs/README.md' }) // \u5DE5\u4F5C\u533A\u76F8\u5BF9\u8DEF\u5F84\u4E5F\u884C\uFF08\u76F8\u5BF9\u8C01\u89C1\u4E0B\uFF09\nopenFilePreview({ mount }) // \u4E0D\u7ED9\u8DEF\u5F84 \u21D2 \u6839\u8282\u70B9\uFF08\u5DE5\u4F5C\u533A\u6E05\u5355 + \u76D8\u7B26\uFF09\n\n// \u951A\u5B9A\u5F39\u7A97\u9009\u6587\u4EF6\uFF08Promise \u8FD4\u56DE**\u7EDD\u5BF9\u8DEF\u5F84**\uFF0C\u4E0D\u81EA\u5DF1\u6302 dock\uFF09\nconst r = await pickWorkspaceFile({ anchor, filter: { exts: ['md'] } })\nconst dir = await pickWorkspaceFile({ anchor, filter: { dirs: true } }) // \u53EA\u9009\u6587\u4EF6\u5939"
59018
+ "src": "import { connectFs, openFilePreview, pickWorkspaceFile } from 'dsh-plugin-core/explorer'\nimport { serveFsRoute } from 'dsh-plugin-core/host'\nimport { FS_PATH } from './paths' // \u4F60\u81EA\u5DF1\u7684\u5E38\u91CF\uFF1A\u5BBF\u4E3B\u4E0E client \u5FC5\u987B\u7528\u540C\u4E00\u4E2A\n\n// \u2500\u2500 \u5BBF\u4E3B\u534A\u8FB9\uFF08apply\uFF09\uFF1A\u6302\u4E00\u6761\u53EA\u8BFB\u6587\u4EF6\u8DEF\u7531\uFF08\u4E0D\u9650\u5DE5\u4F5C\u533A\uFF1B\u8BFB\u6587\u4EF6/\u5217\u76EE\u5F55\u90FD\u5728\u5B83\u4E0A\u9762\uFF09 \u2500\u2500\nserveFsRoute(ctx, { path: FS_PATH })\n\n// \u2500\u2500 client \u534A\u8FB9\uFF08apply\uFF09\uFF1A\u63A5\u4E00\u6B21\uFF08connectHost \u7167\u65E7\u8D1F\u8D23\u5DE5\u4F5C\u533A\u5FEB\u7167\uFF09 \u2500\u2500\nconnectHost(ctx)\nconnectFs({ path: FS_PATH })\n\n// \u53F3\u4FA7\u5206\u680F\u9884\u89C8\uFF08\u5360\u5BBD\u5EA6\u3001\u6324\u7A84\u4E3B\u533A\uFF09\uFF1A\u4E00\u4E2A\u5BB9\u5668 + \u4E00\u4E2A\u8DEF\u5F84\u5C31\u591F\nopenFilePreview({ mount, path: '/abs/ledger' }) // \u6587\u4EF6\u5939 \u21D2 \u76EE\u5F55\u6811\uFF1B\u6587\u4EF6 \u21D2 \u76F4\u63A5\u9884\u89C8\nopenFilePreview({ mount, path: 'docs/README.md' }) // \u5DE5\u4F5C\u533A\u76F8\u5BF9\u8DEF\u5F84\u4E5F\u884C\uFF08\u76F8\u5BF9\u8C01\u89C1\u4E0B\uFF09\nopenFilePreview({ mount }) // \u4E0D\u7ED9\u8DEF\u5F84 \u21D2 \u6839\u8282\u70B9\uFF08\u5DE5\u4F5C\u533A\u6E05\u5355 + \u76D8\u7B26\uFF09\n\n// \u951A\u5B9A\u5F39\u7A97\u9009\u6587\u4EF6\uFF08Promise \u8FD4\u56DE**\u7EDD\u5BF9\u8DEF\u5F84**\uFF0C\u4E0D\u81EA\u5DF1\u6302 dock\uFF09\nconst r = await pickWorkspaceFile({ anchor, filter: { exts: ['md'] } })\nconst dir = await pickWorkspaceFile({ anchor, filter: { dirs: true } }) // \u53EA\u9009\u6587\u4EF6\u5939\n\n// \u5C55\u5F00\u65B9\u4F4D\uFF1A\u9ED8\u8BA4 auto\uFF08\u4E0B\u65B9\u4F18\u5148\u3001\u4E0D\u591F\u7FFB\u4E0A\u65B9\uFF09\uFF1B\u6309\u94AE\u8D34\u7740\u5B9A\u5BBD\u533A\u53F3\u8FB9\u754C\u65F6\u6539\u5411\u5DE6\u5C55\u5F00\nawait pickWorkspaceFile({ anchor, placement: 'bottom-end' }) // \u4E0B\u65B9\u3001\u53F3\u7F18\u5BF9\u9F50\nawait pickWorkspaceFile({ anchor, placement: 'left-start' }) // \u5DE6\u4FA7\u3001\u9876\u8FB9\u9F50\u5E73"
58975
59019
  }
58976
59020
  ]
58977
59021
  },
@@ -59076,6 +59120,15 @@ var docData = {
59076
59120
  "zh": "`exts` \u53EA\u8981\u8FD9\u4E9B\u6269\u5C55\u540D\uFF08\u76EE\u5F55\u4ECD\u53EF\u5C55\u5F00\u5BFC\u822A\uFF09\uFF1B`dirs: true` \u53EA\u5141\u8BB8\u9009\u6587\u4EF6\u5939\uFF08\u6587\u4EF6\u4E0D\u6E32\u67D3\uFF09",
59077
59121
  "en": "`exts` limits files (folders still expand); `dirs: true` picks folders only (files hidden, plus a \u201CSelect this folder\u201D action in the crumb bar)"
59078
59122
  }
59123
+ },
59124
+ {
59125
+ "name": "opts.placement",
59126
+ "type": "PickPlacement",
59127
+ "def": "'auto'",
59128
+ "desc": {
59129
+ "zh": "\u5C55\u5F00\u65B9\u4F4D\u516B\u6863\uFF1A`bottom-start` / `bottom-end`\uFF08\u4E0B\u65B9\uFF0C\u5DE6\u7F18 / \u53F3\u7F18\u5BF9\u9F50\uFF09\u3001`top-start` / `top-end`\uFF08\u4E0A\u65B9\uFF09\u3001`right-start` / `right-end`\uFF08\u53F3\u4FA7\uFF0C\u9876\u8FB9 / \u5E95\u8FB9\u9F50\u5E73\uFF09\u3001`left-start` / `left-end`\uFF08\u5DE6\u4FA7\uFF09\uFF1B`auto` = \u65E7\u884C\u4E3A\uFF08\u4E0B\u65B9\u4F18\u5148\u3001\u4E0B\u65B9\u4E0D\u591F\u7FFB\u4E0A\u65B9\u3001\u6A2A\u5411\u5939\u7D27\uFF09\u3002**\u6307\u5B9A\u65B9\u4F4D\u540E\u4E0D\u518D\u81EA\u52A8\u7FFB\u8FB9**\uFF0C\u53EA\u5728\u8D85\u51FA\u89C6\u53E3\u65F6\u5939\u7D27\u2014\u2014\u6309\u94AE\u8D34\u7740\u5B9A\u5BBD\u533A\u53F3\u8FB9\u754C\u65F6\u7528 `bottom-end` / `left-start`",
59130
+ "en": "Expansion side, eight values: `bottom-start` / `bottom-end` (below, left / right edge aligned), `top-start` / `top-end` (above), `right-start` / `right-end` (right of the trigger, top / bottom edge aligned), `left-start` / `left-end` (left of the trigger); `auto` = old behaviour (below first, flip above when short, clamp horizontally). An explicit side **never auto-flips** \u2014 it is only clamped into the viewport, so use `bottom-end` / `left-start` when the trigger sits at the right edge of a fixed-width area"
59131
+ }
59079
59132
  }
59080
59133
  ]
59081
59134
  }
@@ -65906,9 +65959,9 @@ function ReferencePage() {
65906
65959
  "tbody",
65907
65960
  null,
65908
65961
  [
65909
- [t3("buildCore"), `v${"0.20.7"}`],
65910
- [t3("buildDemo"), `v${"0.20.7"}`],
65911
- [t3("buildStamp"), "261103-062511-864"]
65962
+ [t3("buildCore"), `v${"0.20.8"}`],
65963
+ [t3("buildDemo"), `v${"0.20.8"}`],
65964
+ [t3("buildStamp"), "261103-065849-385"]
65912
65965
  ].map(
65913
65966
  ([label, value]) => (0, import_react86.createElement)(
65914
65967
  "tr",
@@ -66230,9 +66283,9 @@ function DemoPage() {
66230
66283
  lineHeight: "14px"
66231
66284
  }
66232
66285
  },
66233
- (0, import_react88.createElement)("span", null, `core v${"0.20.7"}`),
66234
- (0, import_react88.createElement)("span", null, `demo v${"0.20.7"}`),
66235
- (0, import_react88.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261103-062511-864")
66286
+ (0, import_react88.createElement)("span", null, `core v${"0.20.8"}`),
66287
+ (0, import_react88.createElement)("span", null, `demo v${"0.20.8"}`),
66288
+ (0, import_react88.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261103-065849-385")
66236
66289
  )
66237
66290
  )
66238
66291
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-core-demo",
3
- "version": "0.20.7",
3
+ "version": "0.20.8",
4
4
  "description": "The shared UI foundation for DSH plugins, with a live component preview: design tokens, common controls, workspace browsing and notifications maintained in one place — install it to preview every component in a real host.",
5
5
  "icon": "./assets/icon-components.svg",
6
6
  "keywords": [