dsh-plugin-core-demo 0.14.0 → 0.14.2

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 +175 -67
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -62090,6 +62090,29 @@ function sortEntries(entries2) {
62090
62090
  function listPathOf(dir) {
62091
62091
  return dir === "" ? "." : dir;
62092
62092
  }
62093
+ function createRequestGate() {
62094
+ let active = null;
62095
+ return {
62096
+ begin() {
62097
+ active?.abort();
62098
+ const next = new AbortController();
62099
+ active = next;
62100
+ return {
62101
+ signal: next.signal,
62102
+ current: () => active === next && !next.signal.aborted
62103
+ };
62104
+ },
62105
+ abort() {
62106
+ active?.abort();
62107
+ active = null;
62108
+ }
62109
+ };
62110
+ }
62111
+ function isAborted(signal, error) {
62112
+ if (signal?.aborted === true)
62113
+ return true;
62114
+ return typeof error === "object" && error !== null && error.name === "AbortError";
62115
+ }
62093
62116
  function createRootCache() {
62094
62117
  const map = /* @__PURE__ */ new Map();
62095
62118
  return {
@@ -62126,17 +62149,21 @@ function relativizeToRoot(cache5, sessionId, dir) {
62126
62149
  return dir.slice(norm.length + 1);
62127
62150
  return dir;
62128
62151
  }
62129
- async function findAnyFileAbs(workspaceFiles2, sessionId, startDir) {
62152
+ async function findAnyFileAbs(workspaceFiles2, sessionId, startDir, signal) {
62130
62153
  const stat = workspaceFiles2.stat;
62131
62154
  if (stat === void 0)
62132
62155
  return null;
62133
62156
  let frontier = [startDir];
62134
62157
  for (let depth = 0; depth < 3 && frontier.length > 0; depth++) {
62158
+ if (signal?.aborted)
62159
+ return null;
62135
62160
  const nextDirs = [];
62136
62161
  for (const dir of frontier.slice(0, 5)) {
62162
+ if (signal?.aborted)
62163
+ return null;
62137
62164
  let entries2;
62138
62165
  try {
62139
- const parsed = listingOf(await workspaceFiles2.list(sessionId, listPathOf(dir)));
62166
+ const parsed = listingOf(await workspaceFiles2.list(sessionId, listPathOf(dir), signal));
62140
62167
  if (parsed === null || isFailed(parsed))
62141
62168
  continue;
62142
62169
  entries2 = parsed.entries;
@@ -62147,7 +62174,7 @@ async function findAnyFileAbs(workspaceFiles2, sessionId, startDir) {
62147
62174
  if (file !== void 0) {
62148
62175
  const rel = relJoin(dir, file.name);
62149
62176
  try {
62150
- const abs = absolutePathOf(await stat(sessionId, rel));
62177
+ const abs = absolutePathOf(await stat(sessionId, rel, signal));
62151
62178
  if (abs !== null)
62152
62179
  return { absolutePath: abs, relativePath: rel };
62153
62180
  } catch {
@@ -62162,7 +62189,7 @@ async function findAnyFileAbs(workspaceFiles2, sessionId, startDir) {
62162
62189
  }
62163
62190
  return null;
62164
62191
  }
62165
- async function absolutizeDir(cache5, workspaceFiles2, sessionId, dir, canonical, entries2) {
62192
+ async function absolutizeDir(cache5, workspaceFiles2, sessionId, dir, canonical, entries2, signal) {
62166
62193
  if (isAbsoluteish(dir))
62167
62194
  return dir;
62168
62195
  const rel = canonical !== "" ? canonical : dir;
@@ -62176,14 +62203,14 @@ async function absolutizeDir(cache5, workspaceFiles2, sessionId, dir, canonical,
62176
62203
  if (file !== void 0) {
62177
62204
  try {
62178
62205
  const sub = relJoin(rel, file.name);
62179
- const abs = absolutePathOf(await stat(sessionId, sub));
62206
+ const abs = absolutePathOf(await stat(sessionId, sub, signal));
62180
62207
  if (abs?.endsWith(`/${file.name}`) === true && learnRoot(cache5, sessionId, sub, abs) !== null) {
62181
62208
  return abs.slice(0, abs.length - file.name.length - 1);
62182
62209
  }
62183
62210
  } catch {
62184
62211
  }
62185
62212
  }
62186
- const found = await findAnyFileAbs(workspaceFiles2, sessionId, rel);
62213
+ const found = await findAnyFileAbs(workspaceFiles2, sessionId, rel, signal);
62187
62214
  if (found === null)
62188
62215
  return dir;
62189
62216
  const root = learnRoot(cache5, sessionId, found.relativePath, found.absolutePath);
@@ -62279,14 +62306,14 @@ function BytesPreview(props) {
62279
62306
  const [url, setUrl] = (0, import_react65.useState)(null);
62280
62307
  const [failed, setFailed] = (0, import_react65.useState)(null);
62281
62308
  (0, import_react65.useEffect)(() => {
62282
- let alive = true;
62309
+ const controller = new AbortController();
62283
62310
  let objectUrl = null;
62284
62311
  setUrl(null);
62285
62312
  setFailed(null);
62286
- props.workspaceFiles.readBytes(props.sessionId, props.path, {}).then((res) => {
62287
- const data2 = bytesOf(res);
62288
- if (!alive)
62313
+ props.workspaceFiles.readBytes(props.sessionId, props.path, {}, controller.signal).then((res) => {
62314
+ if (controller.signal.aborted)
62289
62315
  return;
62316
+ const data2 = bytesOf(res);
62290
62317
  if (data2 === null) {
62291
62318
  console.warn("[dsh-plugin-core:explorer] readBytes \u8FD4\u56DE\u4F53\u65E0\u6CD5\u89E3\u6790\u4E3A\u5B57\u8282", props.path, res);
62292
62319
  setFailed({ key: "previewBadPayload" });
@@ -62300,11 +62327,12 @@ function BytesPreview(props) {
62300
62327
  objectUrl = URL.createObjectURL(blob);
62301
62328
  setUrl(objectUrl);
62302
62329
  }).catch((error) => {
62303
- if (alive)
62304
- setFailed(errView(error));
62330
+ if (isAborted(controller.signal, error))
62331
+ return;
62332
+ setFailed(errView(error));
62305
62333
  });
62306
62334
  return () => {
62307
- alive = false;
62335
+ controller.abort();
62308
62336
  if (objectUrl !== null)
62309
62337
  URL.revokeObjectURL(objectUrl);
62310
62338
  };
@@ -62333,10 +62361,16 @@ function TextPreview(props) {
62333
62361
  const [loading, setLoading] = (0, import_react66.useState)(false);
62334
62362
  const [failed, setFailed] = (0, import_react66.useState)(null);
62335
62363
  const accRef = (0, import_react66.useRef)("");
62364
+ const abortRef = (0, import_react66.useRef)(null);
62336
62365
  const load = (0, import_react66.useCallback)(async (offset4, append2) => {
62366
+ abortRef.current?.abort();
62367
+ const controller = new AbortController();
62368
+ abortRef.current = controller;
62337
62369
  setLoading(true);
62338
62370
  try {
62339
- const parsed = textPageOf(await props.workspaceFiles.read(props.sessionId, props.path, offset4 > 0 ? { offset: offset4 } : {}));
62371
+ const parsed = textPageOf(await props.workspaceFiles.read(props.sessionId, props.path, offset4 > 0 ? { offset: offset4 } : {}, controller.signal));
62372
+ if (controller.signal.aborted)
62373
+ return;
62340
62374
  if (parsed === null) {
62341
62375
  console.warn("[dsh-plugin-core:explorer] read \u8FD4\u56DE\u4F53\u65E0\u6CD5\u89E3\u6790\u4E3A\u6587\u672C\u9875", props.path);
62342
62376
  setFailed({ key: "previewBadPayload" });
@@ -62363,9 +62397,12 @@ function TextPreview(props) {
62363
62397
  }
62364
62398
  setNextOffset(parsed.eof ? null : parsed.offset + parsed.lines);
62365
62399
  } catch (error) {
62400
+ if (isAborted(controller.signal, error))
62401
+ return;
62366
62402
  setFailed(errView(error));
62367
62403
  } finally {
62368
- setLoading(false);
62404
+ if (!controller.signal.aborted)
62405
+ setLoading(false);
62369
62406
  }
62370
62407
  }, [props.workspaceFiles, props.sessionId, props.path, props.maxBytes]);
62371
62408
  (0, import_react66.useEffect)(() => {
@@ -62375,6 +62412,9 @@ function TextPreview(props) {
62375
62412
  setNextOffset(null);
62376
62413
  setFailed(null);
62377
62414
  void load(0, false);
62415
+ return () => {
62416
+ abortRef.current?.abort();
62417
+ };
62378
62418
  }, [load]);
62379
62419
  if (failed !== null)
62380
62420
  return (0, import_react66.createElement)("div", { className: "dshpc-fb__note" }, tt(failed.key, failed.params));
@@ -62427,13 +62467,13 @@ function HtmlPreview(props) {
62427
62467
  (0, import_react67.useEffect)(() => {
62428
62468
  if (props.sourceView)
62429
62469
  return;
62430
- let alive = true;
62470
+ const controller = new AbortController();
62431
62471
  setDoc(null);
62432
62472
  setFailed(null);
62433
- props.workspaceFiles.readBytes(props.sessionId, props.path, {}).then((res) => {
62434
- const data2 = bytesOf(res);
62435
- if (!alive)
62473
+ props.workspaceFiles.readBytes(props.sessionId, props.path, {}, controller.signal).then((res) => {
62474
+ if (controller.signal.aborted)
62436
62475
  return;
62476
+ const data2 = bytesOf(res);
62437
62477
  if (data2 === null) {
62438
62478
  console.warn("[dsh-plugin-core:explorer] readBytes \u8FD4\u56DE\u4F53\u65E0\u6CD5\u89E3\u6790\u4E3A\u5B57\u8282", props.path, res);
62439
62479
  setFailed({ key: "previewBadPayload" });
@@ -62450,11 +62490,12 @@ function HtmlPreview(props) {
62450
62490
  }
62451
62491
  setDoc(html2);
62452
62492
  }).catch((error) => {
62453
- if (alive)
62454
- setFailed(errView(error));
62493
+ if (isAborted(controller.signal, error))
62494
+ return;
62495
+ setFailed(errView(error));
62455
62496
  });
62456
62497
  return () => {
62457
- alive = false;
62498
+ controller.abort();
62458
62499
  };
62459
62500
  }, [props.workspaceFiles, props.sessionId, props.path, props.sourceView]);
62460
62501
  if (props.sourceView) {
@@ -62483,17 +62524,17 @@ function OfficePreview(props) {
62483
62524
  const [url, setUrl] = (0, import_react68.useState)(null);
62484
62525
  const [failed, setFailed] = (0, import_react68.useState)(null);
62485
62526
  (0, import_react68.useEffect)(() => {
62486
- let alive = true;
62527
+ const controller = new AbortController();
62487
62528
  let objectUrl = null;
62488
62529
  setUrl(null);
62489
62530
  setFailed(null);
62490
62531
  const face = props.officeToPdf;
62491
62532
  if (face === null)
62492
62533
  return;
62493
- face.render(props.sessionId, props.path, "foreground").then((res) => {
62494
- const data2 = bytesOf(res);
62495
- if (!alive)
62534
+ face.render(props.sessionId, props.path, "foreground", controller.signal).then((res) => {
62535
+ if (controller.signal.aborted)
62496
62536
  return;
62537
+ const data2 = bytesOf(res);
62497
62538
  if (data2 === null || "failed" in data2) {
62498
62539
  setFailed(errView(data2 === null ? void 0 : data2.failed));
62499
62540
  return;
@@ -62502,11 +62543,12 @@ function OfficePreview(props) {
62502
62543
  objectUrl = URL.createObjectURL(blob);
62503
62544
  setUrl(objectUrl);
62504
62545
  }).catch((error) => {
62505
- if (alive)
62506
- setFailed(errView(error));
62546
+ if (isAborted(controller.signal, error))
62547
+ return;
62548
+ setFailed(errView(error));
62507
62549
  });
62508
62550
  return () => {
62509
- alive = false;
62551
+ controller.abort();
62510
62552
  if (objectUrl !== null)
62511
62553
  URL.revokeObjectURL(objectUrl);
62512
62554
  };
@@ -62647,11 +62689,32 @@ function FileBrowser(props) {
62647
62689
  const [childCache, setChildCache] = (0, import_react70.useState)({});
62648
62690
  const [rootNonce, setRootNonce] = (0, import_react70.useState)(0);
62649
62691
  const [outside, setOutside] = (0, import_react70.useState)(false);
62692
+ const revision = props.revision ?? 0;
62693
+ const listGateRef = (0, import_react70.useRef)(null);
62694
+ if (listGateRef.current === null)
62695
+ listGateRef.current = createRequestGate();
62696
+ const listGate = listGateRef.current;
62697
+ const rootGateRef = (0, import_react70.useRef)(null);
62698
+ if (rootGateRef.current === null)
62699
+ rootGateRef.current = createRequestGate();
62700
+ const rootGate = rootGateRef.current;
62701
+ const childAbortsRef = (0, import_react70.useRef)(/* @__PURE__ */ new Map());
62702
+ const abortChildren = (0, import_react70.useCallback)(() => {
62703
+ for (const controller of childAbortsRef.current.values())
62704
+ controller.abort();
62705
+ childAbortsRef.current.clear();
62706
+ }, []);
62707
+ const dirRef = (0, import_react70.useRef)("");
62708
+ const listingRef = (0, import_react70.useRef)(null);
62709
+ (0, import_react70.useLayoutEffect)(() => {
62710
+ dirRef.current = dir;
62711
+ listingRef.current = listing;
62712
+ }, [dir, listing]);
62650
62713
  const hostWorkspaces = (0, import_react70.useSyncExternalStore)(workspaceList.subscribe, workspaceList.getSnapshot);
62651
62714
  const anchors = props.workspaceAnchors ?? hostWorkspaces;
62652
62715
  const anchorMatch = (0, import_react70.useMemo)(() => workspaceAnchorForPath(props.path, anchors), [props.path, anchors]);
62653
62716
  const listSessionId = anchorMatch?.sessionId ?? props.sessionId;
62654
- const noteOutside = (parsed) => {
62717
+ const noteOutside = (0, import_react70.useCallback)((parsed) => {
62655
62718
  if (parsed === null || parsed === void 0)
62656
62719
  return;
62657
62720
  if (!isFailed(parsed)) {
@@ -62661,8 +62724,10 @@ function FileBrowser(props) {
62661
62724
  const code3 = bareCode(parsed.failed);
62662
62725
  if (code3 === "outside-workspace" || code3 === "not-found")
62663
62726
  setOutside(true);
62664
- };
62727
+ }, []);
62665
62728
  const fetchDir = (0, import_react70.useCallback)((targetDir) => {
62729
+ const token = listGate.begin();
62730
+ abortChildren();
62666
62731
  setDir(targetDir);
62667
62732
  setViewing(null);
62668
62733
  setListErr(null);
@@ -62670,7 +62735,9 @@ function FileBrowser(props) {
62670
62735
  setMode("loading");
62671
62736
  setOpenDirs(/* @__PURE__ */ new Set());
62672
62737
  setChildCache({});
62673
- props.workspaceFiles.list(listSessionId, listPathOf(targetDir)).then((result) => {
62738
+ props.workspaceFiles.list(listSessionId, listPathOf(targetDir), token.signal).then((result) => {
62739
+ if (!token.current())
62740
+ return;
62674
62741
  const parsed = listingOf(result);
62675
62742
  noteOutside(parsed);
62676
62743
  if (isFailed(parsed)) {
@@ -62687,10 +62754,12 @@ function FileBrowser(props) {
62687
62754
  setTruncated(parsed.truncated);
62688
62755
  setMode("dir");
62689
62756
  }).catch((error) => {
62757
+ if (isAborted(token.signal, error))
62758
+ return;
62690
62759
  setListErr(errView(error));
62691
62760
  setMode("error");
62692
62761
  });
62693
- }, [listSessionId, props.workspaceFiles]);
62762
+ }, [abortChildren, listGate, listSessionId, noteOutside, props.workspaceFiles]);
62694
62763
  const loadDir = (0, import_react70.useCallback)((targetDir) => {
62695
62764
  if (targetDir === dir) {
62696
62765
  fetchDir(targetDir);
@@ -62699,7 +62768,21 @@ function FileBrowser(props) {
62699
62768
  fetchDir(targetDir);
62700
62769
  }, [dir, fetchDir]);
62701
62770
  (0, import_react70.useEffect)(() => {
62702
- let alive = true;
62771
+ const parent = dirnameOf(props.path);
62772
+ const name2 = baseNameOfPath(props.path);
62773
+ const knownFile = listingRef.current?.some((entry) => entry.name === name2 && entry.type === "file") === true;
62774
+ if (props.path !== "" && dirRef.current !== "" && parent === dirRef.current && knownFile) {
62775
+ setViewing(props.path);
62776
+ setMode("file");
62777
+ setSourceView(false);
62778
+ setReloadNonce((n) => n + 1);
62779
+ setListErr(null);
62780
+ setMenuOpen(false);
62781
+ return;
62782
+ }
62783
+ const token = listGate.begin();
62784
+ const rootToken = rootGate.begin();
62785
+ abortChildren();
62703
62786
  setMode("loading");
62704
62787
  setListErr(null);
62705
62788
  setViewing(null);
@@ -62713,8 +62796,8 @@ function FileBrowser(props) {
62713
62796
  return;
62714
62797
  void (async () => {
62715
62798
  try {
62716
- const parsed = listingOf(await props.workspaceFiles.list(listSessionId, listPathOf(currentDir)));
62717
- if (!alive || parsed === null || isFailed(parsed))
62799
+ const parsed = listingOf(await props.workspaceFiles.list(listSessionId, listPathOf(currentDir), rootToken.signal));
62800
+ if (!rootToken.current() || parsed === null || isFailed(parsed))
62718
62801
  return;
62719
62802
  const stat = props.workspaceFiles.stat;
62720
62803
  if (stat === void 0)
@@ -62723,14 +62806,18 @@ function FileBrowser(props) {
62723
62806
  const file = parsed.entries.find((entry) => entry.type === "file");
62724
62807
  if (file !== void 0) {
62725
62808
  const sub = rel === "" ? file.name : `${rel}/${file.name}`;
62726
- const abs = await stat(listSessionId, sub).catch(() => null);
62809
+ const abs = await stat(listSessionId, sub, rootToken.signal).catch(() => null);
62810
+ if (!rootToken.current())
62811
+ return;
62727
62812
  const absPath = typeof abs?.absolutePath === "string" ? abs.absolutePath : null;
62728
62813
  if (absPath !== null && learnRoot(rootCache, listSessionId, sub, absPath) !== null) {
62729
62814
  setRootNonce((n) => n + 1);
62730
62815
  return;
62731
62816
  }
62732
62817
  }
62733
- const found = await findAnyFileAbs(props.workspaceFiles, listSessionId, rel);
62818
+ const found = await findAnyFileAbs(props.workspaceFiles, listSessionId, rel, rootToken.signal);
62819
+ if (!rootToken.current())
62820
+ return;
62734
62821
  if (found !== null && learnRoot(rootCache, listSessionId, found.relativePath, found.absolutePath) !== null) {
62735
62822
  setRootNonce((n) => n + 1);
62736
62823
  }
@@ -62738,14 +62825,14 @@ function FileBrowser(props) {
62738
62825
  }
62739
62826
  })();
62740
62827
  };
62741
- props.workspaceFiles.list(listSessionId, listPathOf(props.path)).then(async (result) => {
62742
- if (!alive)
62828
+ props.workspaceFiles.list(listSessionId, listPathOf(props.path), token.signal).then(async (result) => {
62829
+ if (!token.current())
62743
62830
  return;
62744
62831
  const parsed = listingOf(result);
62745
62832
  if (!isFailed(parsed) && parsed !== null) {
62746
62833
  setOutside(false);
62747
- const absDir = await absolutizeDir(rootCache, props.workspaceFiles, listSessionId, props.path, parsed.path, parsed.entries);
62748
- if (!alive)
62834
+ const absDir = await absolutizeDir(rootCache, props.workspaceFiles, listSessionId, props.path, parsed.path, parsed.entries, token.signal);
62835
+ if (!token.current())
62749
62836
  return;
62750
62837
  setDir(absDir);
62751
62838
  setListing(parsed.entries);
@@ -62754,29 +62841,31 @@ function FileBrowser(props) {
62754
62841
  ensureRootLearned(absDir);
62755
62842
  return;
62756
62843
  }
62757
- let parent = dirnameOf(props.path);
62844
+ let parentDir = dirnameOf(props.path);
62758
62845
  if (!isAbsoluteish(props.path)) {
62759
62846
  const stat = props.workspaceFiles.stat;
62760
62847
  if (stat !== void 0) {
62761
62848
  try {
62762
- const res = await stat(listSessionId, props.path);
62849
+ const res = await stat(listSessionId, props.path, token.signal);
62850
+ if (!token.current())
62851
+ return;
62763
62852
  const abs = typeof res.absolutePath === "string" ? res.absolutePath : null;
62764
62853
  if (abs !== null) {
62765
- parent = dirnameOf(abs);
62854
+ parentDir = dirnameOf(abs);
62766
62855
  learnRoot(rootCache, listSessionId, props.path, abs);
62767
62856
  }
62768
62857
  } catch {
62769
62858
  }
62770
62859
  }
62771
62860
  }
62772
- if (!alive)
62861
+ if (!token.current())
62773
62862
  return;
62774
- setDir(parent);
62863
+ setDir(parentDir);
62775
62864
  setViewing(props.path);
62776
62865
  setMode("file");
62777
- ensureRootLearned(parent);
62778
- props.workspaceFiles.list(listSessionId, listPathOf(parent)).then((pres) => {
62779
- if (!alive)
62866
+ ensureRootLearned(parentDir);
62867
+ props.workspaceFiles.list(listSessionId, listPathOf(parentDir), token.signal).then((pres) => {
62868
+ if (!token.current())
62780
62869
  return;
62781
62870
  const pl = listingOf(pres);
62782
62871
  noteOutside(pl);
@@ -62786,19 +62875,21 @@ function FileBrowser(props) {
62786
62875
  }
62787
62876
  }).catch(() => {
62788
62877
  });
62789
- }).catch(() => {
62790
- if (!alive)
62878
+ }).catch((error) => {
62879
+ if (!token.current() || isAborted(token.signal, error))
62791
62880
  return;
62792
- const parent = dirnameOf(props.path);
62793
- setDir(parent);
62881
+ const parentDir = dirnameOf(props.path);
62882
+ setDir(parentDir);
62794
62883
  setViewing(props.path);
62795
62884
  setMode("file");
62796
- ensureRootLearned(parent);
62885
+ ensureRootLearned(parentDir);
62797
62886
  });
62798
62887
  return () => {
62799
- alive = false;
62888
+ listGate.abort();
62889
+ rootGate.abort();
62800
62890
  };
62801
- }, [props.workspaceFiles, props.path, rootCache, listSessionId]);
62891
+ }, [abortChildren, listGate, listSessionId, noteOutside, props.workspaceFiles, props.path, revision, rootCache, rootGate]);
62892
+ (0, import_react70.useEffect)(() => () => abortChildren(), [abortChildren]);
62802
62893
  (0, import_react70.useLayoutEffect)(() => {
62803
62894
  const region = regionRef.current;
62804
62895
  const measure = measureRef.current;
@@ -62842,15 +62933,25 @@ function FileBrowser(props) {
62842
62933
  return next;
62843
62934
  });
62844
62935
  if (!(path in childCache)) {
62936
+ childAbortsRef.current.get(path)?.abort();
62937
+ const controller = new AbortController();
62938
+ childAbortsRef.current.set(path, controller);
62845
62939
  setChildCache((prev) => ({ ...prev, [path]: { status: "loading" } }));
62846
- props.workspaceFiles.list(listSessionId, listPathOf(path)).then((result) => {
62940
+ props.workspaceFiles.list(listSessionId, listPathOf(path), controller.signal).then((result) => {
62941
+ if (controller.signal.aborted)
62942
+ return;
62847
62943
  const parsed = listingOf(result);
62848
62944
  setChildCache((prev) => ({
62849
62945
  ...prev,
62850
62946
  [path]: isFailed(parsed) || parsed === null ? { status: "error", error: errView(isFailed(parsed) ? parsed.failed : void 0) } : { status: "ready", entries: parsed.entries, truncated: parsed.truncated }
62851
62947
  }));
62852
62948
  }).catch((error) => {
62949
+ if (isAborted(controller.signal, error))
62950
+ return;
62853
62951
  setChildCache((prev) => ({ ...prev, [path]: { status: "error", error: errView(error) } }));
62952
+ }).finally(() => {
62953
+ if (childAbortsRef.current.get(path) === controller)
62954
+ childAbortsRef.current.delete(path);
62854
62955
  });
62855
62956
  }
62856
62957
  }, [childCache, props.workspaceFiles, listSessionId]);
@@ -63098,6 +63199,11 @@ function PreviewBody(props) {
63098
63199
  const anchors = options.workspaceAnchors ?? hostWorkspaces;
63099
63200
  const entryTitle = workspaceAnchorForPath(options.path ?? "", anchors)?.title ?? options.rootName ?? "";
63100
63201
  const [picked, setPicked] = (0, import_react71.useState)(null);
63202
+ const [seenRevision, setSeenRevision] = (0, import_react71.useState)(props.revision);
63203
+ if (seenRevision !== props.revision) {
63204
+ setSeenRevision(props.revision);
63205
+ setPicked(null);
63206
+ }
63101
63207
  const wsTitle = picked ?? entryTitle;
63102
63208
  const sessionId = anchorSessionForTitle(anchors, wsTitle) ?? options.sessionId ?? pickWorkspaceAnchor(anchors)?.sessionId ?? "";
63103
63209
  const switchable = anchors.filter((a) => (a.sessionIds?.length ?? 0) > 0).map((a) => a.title);
@@ -63109,6 +63215,8 @@ function PreviewBody(props) {
63109
63215
  sessionId,
63110
63216
  // 点过工作区就从它的根列(原 path 属于旧工作区,带着只会 404 / 跳回入口文件)。
63111
63217
  path: picked === null ? options.path : "",
63218
+ // 重开令牌:同 path 再点一次也要回到该文件 / 重读内容(只重跑初始 effect,不重挂)。
63219
+ revision: props.revision,
63112
63220
  rootName: wsTitle === "" ? options.rootName : wsTitle,
63113
63221
  workspaces: switchable.length > 0 ? switchable : options.workspaces,
63114
63222
  onSelectWorkspace: (name2) => {
@@ -63227,7 +63335,7 @@ function openFilePreview(options) {
63227
63335
  if (dock.isCollapsed(PREVIEW_PANEL_ID))
63228
63336
  dock.expand(PREVIEW_PANEL_ID);
63229
63337
  const internalSwitch = o.onSelectWorkspace === void 0;
63230
- const contentKey = `${o.path ?? ""}#${++openSeq}`;
63338
+ const revision = ++openSeq;
63231
63339
  root.render((0, import_react71.createElement)(
63232
63340
  "div",
63233
63341
  // 高度吃调用方给的 --dshpc-dock-h(demo 的页面行给 100%);退化成视口高是整页场景。
@@ -63244,12 +63352,12 @@ function openFilePreview(options) {
63244
63352
  width: pinnedWidth ?? o.width ?? 460,
63245
63353
  minWidth: o.minWidth ?? 320,
63246
63354
  maxWidth: o.maxWidth
63247
- }, o.content !== void 0 ? o.content() : internalSwitch ? (0, import_react71.createElement)(PreviewBody, { key: contentKey, options: o, onClose: close }) : (0, import_react71.createElement)(FileBrowser, {
63248
- key: contentKey,
63355
+ }, o.content !== void 0 ? (0, import_react71.createElement)(import_react71.Fragment, { key: `custom:${revision}` }, o.content()) : internalSwitch ? (0, import_react71.createElement)(PreviewBody, { options: o, onClose: close, revision }) : (0, import_react71.createElement)(FileBrowser, {
63249
63356
  workspaceFiles: o.workspaceFiles,
63250
63357
  officeToPdf: o.officeToPdf ?? null,
63251
63358
  sessionId: o.sessionId,
63252
63359
  path: o.path,
63360
+ revision,
63253
63361
  rootName: o.rootName,
63254
63362
  workspaces: o.workspaces,
63255
63363
  workspaceAnchors: o.workspaceAnchors,
@@ -64270,9 +64378,9 @@ function ReferencePage() {
64270
64378
  "tbody",
64271
64379
  null,
64272
64380
  [
64273
- [t3("buildCore"), `v${"0.14.0"}`],
64274
- [t3("buildDemo"), `v${"0.14.0"}`],
64275
- [t3("buildStamp"), "261031-065805-349"]
64381
+ [t3("buildCore"), `v${"0.14.2"}`],
64382
+ [t3("buildDemo"), `v${"0.14.2"}`],
64383
+ [t3("buildStamp"), "261031-122353-196"]
64276
64384
  ].map(
64277
64385
  ([label, value]) => (0, import_react75.createElement)(
64278
64386
  "tr",
@@ -64595,9 +64703,9 @@ function DemoPage() {
64595
64703
  lineHeight: "14px"
64596
64704
  }
64597
64705
  },
64598
- (0, import_react77.createElement)("span", null, `core v${"0.14.0"}`),
64599
- (0, import_react77.createElement)("span", null, `demo v${"0.14.0"}`),
64600
- (0, import_react77.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261031-065805-349")
64706
+ (0, import_react77.createElement)("span", null, `core v${"0.14.2"}`),
64707
+ (0, import_react77.createElement)("span", null, `demo v${"0.14.2"}`),
64708
+ (0, import_react77.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261031-122353-196")
64601
64709
  )
64602
64710
  )
64603
64711
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-core-demo",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
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": [