dsh-remote 0.8.84 → 0.8.85

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/lib/client.js +58 -1
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -406,6 +406,14 @@ window.__ModuleLoader__.load({
406
406
  // Issue #55: a file link in a remote Session cannot be mapped onto the
407
407
  // remote host (no mirror for the Session's cwd), so say so instead of
408
408
  // rendering an empty editor.
409
+ // The host MarkdownText renders code blocks / footnotes with chrome
410
+ // strings from its `labels` prop and dereferences them unguarded.
411
+ 'file.markdown.copy': '复制',
412
+ 'file.markdown.copied': '已复制',
413
+ 'file.markdown.code': '代码块',
414
+ 'file.markdown.wrap': '自动换行',
415
+ 'file.markdown.unwrap': '取消换行',
416
+ 'file.markdown.footnotes': '脚注',
409
417
  'file.linkUnresolved': '这个文件链接无法对应到远端路径(该会话的工作区不是一个远程镜像目录)。请用侧栏「远程文件」打开,或用 rw_read_file 读取。',
410
418
  'common.refresh': '刷新',
411
419
  'common.close': '关闭',
@@ -710,6 +718,12 @@ window.__ModuleLoader__.load({
710
718
  'file.downloadedAt': ': {path}',
711
719
  'file.readFail': 'Failed to read remote: {msg}',
712
720
  'file.listFail': 'Failed to list remote directory: {msg}',
721
+ 'file.markdown.copy': 'Copy',
722
+ 'file.markdown.copied': 'Copied',
723
+ 'file.markdown.code': 'Code block',
724
+ 'file.markdown.wrap': 'Wrap lines',
725
+ 'file.markdown.unwrap': 'Unwrap lines',
726
+ 'file.markdown.footnotes': 'Footnotes',
713
727
  'file.linkUnresolved': 'This file link does not map onto a remote path (the Session workspace is not a remote mirror directory). Open it from the sidebar "Remote Files" tab, or read it with rw_read_file.',
714
728
  'common.refresh': 'Refresh',
715
729
  'common.close': 'Close',
@@ -3730,6 +3744,25 @@ window.__ModuleLoader__.load({
3730
3744
  }
3731
3745
 
3732
3746
  // ── Remote file tab (opened by the explorer; live read + explicit edit) ──
3747
+ /**
3748
+ * The host's MarkdownText reads chrome strings off `labels` while rendering
3749
+ * fenced code blocks (`labels.code.*`) and footnotes (`labels.footnotes`),
3750
+ * and those reads are NOT guarded. A caller that passes only `text` throws
3751
+ * inside the host renderer; the error boundary around the pane swallows it
3752
+ * and a `.md` containing a code fence opens to a blank page. Wrap the host
3753
+ * renderer so an unmet host expectation degrades to source instead.
3754
+ */
3755
+ const MarkdownGuard = React.Component
3756
+ ? class MarkdownGuard extends React.Component {
3757
+ constructor(props) { super(props); this.state = { failed: false } }
3758
+ static getDerivedStateFromError() { return { failed: true } }
3759
+ render() { return this.state.failed ? this.props.fallback : this.props.children }
3760
+ }
3761
+ // A partial React face (some registries/harnesses) has no `Component`.
3762
+ // Passing children through is the right degradation there: there is no
3763
+ // host renderer to guard in the first place.
3764
+ : (props) => props.children
3765
+
3733
3766
  function RemoteFileTab(props) {
3734
3767
  const { tab, scope } = props
3735
3768
  const path = tab.path || ''
@@ -3741,6 +3774,22 @@ window.__ModuleLoader__.load({
3741
3774
  const [draft, setDraft] = React.useState('')
3742
3775
  const [saving, setSaving] = React.useState(false)
3743
3776
  React.useEffect(() => { ensureChromeCss() }, [])
3777
+ // The host renderer takes its code-block / footnote chrome from here and
3778
+ // dereferences it without a guard (see MarkdownGuard). Rebuilt per render
3779
+ // on purpose: the pane re-renders only on load/edit, and a plain object
3780
+ // keeps this module loadable under harnesses that ship a partial React.
3781
+ const markdownLabels = {
3782
+ code: {
3783
+ copyLabel: tr('file.markdown.copy'),
3784
+ copiedLabel: tr('file.markdown.copied'),
3785
+ toolbarLabels: {
3786
+ codeLabel: tr('file.markdown.code'),
3787
+ wrapLabel: tr('file.markdown.wrap'),
3788
+ unwrapLabel: tr('file.markdown.unwrap'),
3789
+ },
3790
+ },
3791
+ footnotes: tr('file.markdown.footnotes'),
3792
+ }
3744
3793
 
3745
3794
  const originalText = (data && data.content != null ? data.content : '').replace(/\n…\[truncated:.*$/, '')
3746
3795
  const dirty = edit && draft !== originalText
@@ -3826,7 +3875,15 @@ window.__ModuleLoader__.load({
3826
3875
  // to die with ENOENT on the local mirror now shows the remote
3827
3876
  // file, rendered.
3828
3877
  ? React.createElement('div', { style: { padding: '10px 14px', flexShrink: 0, overflow: 'auto' } },
3829
- React.createElement(MarkdownText, { text: originalText, variant: 'body' }),
3878
+ React.createElement(MarkdownGuard, {
3879
+ fallback: React.createElement('div', {
3880
+ style: {
3881
+ fontSize: 13, lineHeight: 1.55, fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
3882
+ whiteSpace: 'pre-wrap', wordBreak: 'break-word', color: T.label,
3883
+ },
3884
+ }, originalText),
3885
+ },
3886
+ React.createElement(MarkdownText, { text: originalText, variant: 'body', labels: markdownLabels })),
3830
3887
  (data && data.truncated)
3831
3888
  ? React.createElement('div', { style: { color: T.warn, fontSize: 12, marginTop: 8 } }, tr('file.truncated'))
3832
3889
  : null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote",
3
- "version": "0.8.84",
3
+ "version": "0.8.85",
4
4
  "description": "Remote-work assistant for DeepSeek Harness: connect SSH (password/key/agent/keyboard-interactive, multi-hop ProxyJump), list hosts from ~/.ssh/config, pick a remote workspace, operate on it with 21 rw_* tools, conflict-aware mirror sync, an embedded PTY terminal, remote DSH web UI attach, port forwarding, host grouping, remote sandbox fencing, audit log, keychain passwords.",
5
5
  "license": "MIT",
6
6
  "author": "flymysql <flyphp@outlook.com>",