dsh-plugin-core-demo 0.20.7 → 0.20.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.
Files changed (2) hide show
  1. package/dist/client.js +94 -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,75 @@ 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 flipSide(preferred, own, other, min2) {
54848
+ if (own >= min2)
54849
+ return preferred;
54850
+ return other > own ? !preferred : preferred;
54851
+ }
54852
+ function placePicker(anchor, viewport, placement = "auto") {
54853
+ const vw = viewport.width;
54854
+ const vh = viewport.height;
54855
+ const GAP2 = PICKER_GAP;
54856
+ const EDGE = VIEWPORT_EDGE;
54857
+ const fullWidth = Math.min(PICKER_WIDTH, Math.max(vw - 2 * EDGE, 0));
54858
+ if (placement === "auto") {
54859
+ const availBelow = vh - EDGE - (anchor.bottom + GAP2);
54860
+ const availAbove = anchor.top - GAP2 - EDGE;
54861
+ const below = flipSide(true, availBelow, availAbove, PICKER_MIN_H);
54862
+ const height2 = Math.max(Math.min(PICKER_MAX_H, below ? availBelow : availAbove), PICKER_MIN_FLOOR);
54863
+ const left2 = clamp2(anchor.left, EDGE, vw - EDGE - fullWidth);
54864
+ 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);
54865
+ return round2({ left: left2, top: top3, width: fullWidth, height: height2 });
54866
+ }
54867
+ const vertical = placement.startsWith("bottom") || placement.startsWith("top");
54868
+ if (vertical) {
54869
+ const belowAvail = vh - EDGE - (anchor.bottom + GAP2);
54870
+ const aboveAvail = anchor.top - GAP2 - EDGE;
54871
+ const startAligned2 = placement.endsWith("start");
54872
+ const prefersBelow = placement.startsWith("bottom");
54873
+ const below = flipSide(prefersBelow, prefersBelow ? belowAvail : aboveAvail, prefersBelow ? aboveAvail : belowAvail, PICKER_MIN_H);
54874
+ const avail = below ? belowAvail : aboveAvail;
54875
+ const height2 = Math.max(Math.min(PICKER_MAX_H, avail), PICKER_MIN_FLOOR);
54876
+ const rawLeft2 = startAligned2 ? anchor.left : anchor.right - fullWidth;
54877
+ const left2 = clamp2(rawLeft2, EDGE, vw - EDGE - fullWidth);
54878
+ const rawTop2 = below ? anchor.bottom + GAP2 : anchor.top - GAP2 - height2;
54879
+ const top3 = clamp2(rawTop2, EDGE, vh - EDGE - height2);
54880
+ return round2({ left: left2, top: top3, width: fullWidth, height: height2 });
54881
+ }
54882
+ const startAligned = placement.endsWith("start");
54883
+ const rightAvail = vw - EDGE - (anchor.right + GAP2);
54884
+ const leftAvail = anchor.left - GAP2 - EDGE;
54885
+ const prefersRight = placement.startsWith("right");
54886
+ const toRight = flipSide(prefersRight, prefersRight ? rightAvail : leftAvail, prefersRight ? leftAvail : rightAvail, PICKER_MIN_W);
54887
+ const availW = toRight ? rightAvail : leftAvail;
54888
+ const width = Math.max(Math.min(PICKER_WIDTH, availW), Math.min(PICKER_MIN_W, Math.max(vw - 2 * EDGE, 0)));
54889
+ const height = Math.min(PICKER_MAX_H, Math.max(vh - 2 * EDGE, 0));
54890
+ const rawLeft = toRight ? anchor.right + GAP2 : anchor.left - GAP2 - width;
54891
+ const left = clamp2(rawLeft, EDGE, vw - EDGE - width);
54892
+ const rawTop = startAligned ? anchor.top : anchor.bottom - height;
54893
+ const top2 = clamp2(rawTop, EDGE, vh - EDGE - height);
54894
+ return round2({ left, top: top2, width, height });
54895
+ }
54896
+ function round2(box) {
54897
+ return {
54898
+ left: Math.round(box.left),
54899
+ top: Math.round(box.top),
54900
+ width: Math.round(box.width),
54901
+ height: Math.round(box.height)
54902
+ };
54903
+ }
54904
+
54836
54905
  // dist/explorer/open.js
54837
54906
  function resolveStartPath(path, anchors, sessionId) {
54838
54907
  if (path === "")
@@ -54995,10 +55064,6 @@ function openFilePreview(options) {
54995
55064
  activePreview = { adopt, keepWidth, draw, close };
54996
55065
  return { close, path: opts.path ?? "" };
54997
55066
  }
54998
- var PICKER_WIDTH = 480;
54999
- var PICKER_MAX_H = 660;
55000
- var PICKER_MIN_H = 240;
55001
- var PICKER_MIN_FLOOR = 160;
55002
55067
  function pickWorkspaceFile(options) {
55003
55068
  return new Promise((resolve) => {
55004
55069
  if (typeof document === "undefined") {
@@ -55026,21 +55091,11 @@ function pickWorkspaceFile(options) {
55026
55091
  };
55027
55092
  const anchor = options.anchor ?? null;
55028
55093
  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);
55094
+ const box = placePicker(anchor.getBoundingClientRect(), { width: window.innerWidth, height: window.innerHeight }, options.placement ?? "auto");
55095
+ panelStyle.left = box.left;
55096
+ panelStyle.top = box.top;
55097
+ panelStyle.width = box.width;
55098
+ panelStyle.height = box.height;
55044
55099
  } else {
55045
55100
  panelStyle.width = `min(${PICKER_WIDTH}px,calc(100vw - 24px))`;
55046
55101
  panelStyle.height = PICKER_MAX_H;
@@ -58971,7 +59026,7 @@ var docData = {
58971
59026
  {
58972
59027
  "id": "explorer-usage-code",
58973
59028
  "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"
59029
+ "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
59030
  }
58976
59031
  ]
58977
59032
  },
@@ -59076,6 +59131,15 @@ var docData = {
59076
59131
  "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
59132
  "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
59133
  }
59134
+ },
59135
+ {
59136
+ "name": "opts.placement",
59137
+ "type": "PickPlacement",
59138
+ "def": "'auto'",
59139
+ "desc": {
59140
+ "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\u65B9\u4F4D\u662F**\u4F18\u5148**\uFF1A\u8BE5\u4FA7\u653E\u5F97\u4E0B\u5C31\u7167\u5B83\uFF1B\u653E\u4E0D\u4E0B\u800C\u5BF9\u4FA7\u591F \u21D2 **\u81EA\u52A8\u7FFB\u8FB9**\uFF08bottom\u2194top\u3001left\u2194right\uFF0C\u5BF9\u9F50\u8F74\u4E0D\u53D8\uFF09\uFF1B\u4E24\u4FA7\u90FD\u4E0D\u591F\u624D\u5939\u7D27\u8FDB\u89C6\u53E3\u2014\u2014\u6309\u94AE\u8D34\u7740\u5B9A\u5BBD\u533A\u53F3\u8FB9\u754C\u65F6\u7528 `bottom-end` / `left-start`",
59141
+ "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). The side is a **preference**: used when it fits; if it does not fit but the opposite side does, the panel **flips** (bottom\u2194top, left\u2194right, same start/end alignment); only when neither fits is it clamped into the viewport \u2014 use `bottom-end` / `left-start` when the trigger sits at the right edge of a fixed-width area"
59142
+ }
59079
59143
  }
59080
59144
  ]
59081
59145
  }
@@ -65906,9 +65970,9 @@ function ReferencePage() {
65906
65970
  "tbody",
65907
65971
  null,
65908
65972
  [
65909
- [t3("buildCore"), `v${"0.20.7"}`],
65910
- [t3("buildDemo"), `v${"0.20.7"}`],
65911
- [t3("buildStamp"), "261103-062511-864"]
65973
+ [t3("buildCore"), `v${"0.20.9"}`],
65974
+ [t3("buildDemo"), `v${"0.20.9"}`],
65975
+ [t3("buildStamp"), "261103-071505-720"]
65912
65976
  ].map(
65913
65977
  ([label, value]) => (0, import_react86.createElement)(
65914
65978
  "tr",
@@ -66230,9 +66294,9 @@ function DemoPage() {
66230
66294
  lineHeight: "14px"
66231
66295
  }
66232
66296
  },
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")
66297
+ (0, import_react88.createElement)("span", null, `core v${"0.20.9"}`),
66298
+ (0, import_react88.createElement)("span", null, `demo v${"0.20.9"}`),
66299
+ (0, import_react88.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261103-071505-720")
66236
66300
  )
66237
66301
  )
66238
66302
  ),
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.9",
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": [