@linxin666/dsh-remote-bridge 0.4.7 → 0.4.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 (78) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +93 -26
  3. package/README.zh.md +91 -26
  4. package/icon.svg +3 -0
  5. package/lib/client.js +274 -253
  6. package/lib/client.js.map +1 -1
  7. package/lib/index.js +8891 -2433
  8. package/lib/types/client/PairEntry.d.ts +2 -2
  9. package/lib/types/client/PairPanel.d.ts +10 -2
  10. package/lib/types/client/icons.d.ts +5 -13
  11. package/lib/types/client/locales.d.ts +10 -14
  12. package/lib/types/client/semantic.d.ts +9 -5
  13. package/lib/types/core/approvals.d.ts +24 -0
  14. package/lib/types/core/commands.d.ts +59 -0
  15. package/lib/types/core/connection.d.ts +124 -5
  16. package/lib/types/core/delta.d.ts +101 -0
  17. package/lib/types/core/devices.d.ts +98 -2
  18. package/lib/types/core/dsh-frames.d.ts +155 -4
  19. package/lib/types/core/envelope.d.ts +34 -0
  20. package/lib/types/core/extension.d.ts +144 -0
  21. package/lib/types/core/hub.d.ts +96 -20
  22. package/lib/types/core/jobs.d.ts +204 -0
  23. package/lib/types/core/liveactivity.d.ts +324 -0
  24. package/lib/types/core/protocol.d.ts +491 -2
  25. package/lib/types/core/push.d.ts +178 -0
  26. package/lib/types/core/questions.d.ts +109 -9
  27. package/lib/types/core/session-meta.d.ts +55 -1
  28. package/lib/types/core/squads.d.ts +130 -0
  29. package/lib/types/core/usage-stats.d.ts +160 -0
  30. package/lib/types/core/usage.d.ts +294 -0
  31. package/lib/types/core/wire.d.ts +1 -1
  32. package/lib/types/core/ws-frames.d.ts +11 -0
  33. package/lib/types/host/apns.d.ts +151 -0
  34. package/lib/types/host/squads-ledger.d.ts +39 -0
  35. package/lib/types/host/squads.d.ts +77 -0
  36. package/lib/types/host/usage-stats.d.ts +75 -0
  37. package/lib/types/host/watchers.d.ts +88 -0
  38. package/lib/types/host/websocket.d.ts +8 -1
  39. package/lib/types/index.d.ts +34 -3
  40. package/lib/types/mount-once.d.ts +55 -0
  41. package/locale/en.json +6 -0
  42. package/locale/ru.json +6 -0
  43. package/locale/zh.json +6 -0
  44. package/package.json +20 -14
  45. package/src/client/PairEntry.tsx +58 -31
  46. package/src/client/PairPanel.tsx +181 -97
  47. package/src/client/icons.tsx +17 -60
  48. package/src/client/locales.ts +15 -23
  49. package/src/client/panel.module.css +239 -186
  50. package/src/client/semantic.ts +10 -6
  51. package/src/core/approvals.ts +32 -1
  52. package/src/core/commands.ts +95 -0
  53. package/src/core/connection.ts +1483 -31
  54. package/src/core/delta.ts +204 -0
  55. package/src/core/devices.ts +221 -3
  56. package/src/core/dsh-frames.ts +365 -8
  57. package/src/core/envelope.ts +46 -0
  58. package/src/core/extension.ts +197 -0
  59. package/src/core/hub.ts +441 -49
  60. package/src/core/jobs.ts +372 -0
  61. package/src/core/liveactivity.ts +833 -0
  62. package/src/core/protocol.ts +556 -2
  63. package/src/core/push.ts +354 -0
  64. package/src/core/questions.ts +264 -17
  65. package/src/core/session-meta.ts +73 -1
  66. package/src/core/squads.ts +345 -0
  67. package/src/core/usage-stats.ts +424 -0
  68. package/src/core/usage.ts +937 -0
  69. package/src/core/wire.ts +13 -1
  70. package/src/core/ws-frames.ts +14 -0
  71. package/src/host/apns.ts +320 -0
  72. package/src/host/squads-ledger.ts +105 -0
  73. package/src/host/squads.ts +206 -0
  74. package/src/host/usage-stats.ts +155 -0
  75. package/src/host/watchers.ts +272 -0
  76. package/src/host/websocket.ts +37 -3
  77. package/src/index.ts +310 -9
  78. package/src/mount-once.ts +142 -0
@@ -1,20 +1,30 @@
1
1
  /**
2
- * The protocol v1 pairing panel body: the QR symbol, the same secret in
3
- * plaintext, the 30 s countdown with its expiry state, the refresh action, and
4
- * the two facts the reader must not miss — the phone's origin is the public
5
- * relay (never this machine's loopback address), and the code is one-shot.
2
+ * The protocol v1 pairing panel: the QR symbol, the countdown with its expiry
3
+ * state, the one address fact the reader must not miss, and the two actions that
4
+ * keep a fresh code on screen.
6
5
  *
7
- * Pure presentation: every state and action arrives through props, and the
8
- * clock is a prop, so the expiry flip is deterministic instead of read from
9
- * `Date.now()` here.
6
+ * The shell is the official headless `Modal` and every action is the official
7
+ * `Button`, so the overlay, the mask, the card, the focus trap, the Escape
8
+ * command and the interaction states belong to the library. This file owns the
9
+ * information order and the state presentation only: every state and action
10
+ * arrives through props, and the clock is a prop, so the expiry flip is
11
+ * deterministic instead of read from `Date.now()` here.
10
12
  */
11
- import { memo } from 'react'
13
+ import { memo, useLayoutEffect, useRef } from 'react'
12
14
  import { QRCodeSVG } from 'qrcode.react'
15
+ import {
16
+ Button, IconCheckOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,
17
+ IconRefreshOutlineRegular, IconWarningOutlineRegular, Modal,
18
+ } from '@deepseek-ai/dsh-client-ui-primitives'
13
19
  import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
14
- import { CheckIcon, CloseIcon, CopyIcon, RefreshIcon } from './icons.tsx'
15
- import { PART_COPY, PART_NOTICE, PART_PANEL, PART_QR, PART_REFRESH, PART_TOKEN, PLUGIN_ATTR, QR_VALUE_ATTR } from './semantic.ts'
20
+ import {
21
+ EXPIRED_ATTR, PART_COPY, PART_NOTICE, PART_PANEL, PART_QR, PART_REFRESH, PLUGIN_ATTR, QR_VALUE_ATTR,
22
+ } from './semantic.ts'
16
23
  import css from './panel.module.css'
17
24
 
25
+ /** The custom property carrying the dialog's own enter keyframe name. */
26
+ const EXIT_NAME_VAR = '--pair-exit-name'
27
+
18
28
  /** What the panel is currently showing. */
19
29
  export type PairPanelState =
20
30
  /** A read is in flight. */
@@ -45,9 +55,17 @@ export interface PairPanelProps {
45
55
  /** This page's own `host:port`, named in the origin warning. */
46
56
  host: string
47
57
  copy: PairCopyState
58
+ /** Whether the modal is mounted at all (the entry keeps it for the leave leg). */
59
+ showing: boolean
60
+ /** Whether the leave leg is running; the card stays mounted until it ends. */
61
+ closing: boolean
62
+ /** The panel element's id, so the seat trigger can name what it expands. */
63
+ id: string
48
64
  onClose(): void
65
+ /** The leave leg reported completion: the entry may unmount the modal now. */
66
+ onExited(): void
49
67
  onRefresh(): void
50
- onCopy(token: string): void
68
+ onCopy(payload: string): void
51
69
  }
52
70
 
53
71
  /**
@@ -62,14 +80,9 @@ const PairQrCode = memo(function PairQrCode({ value, label }: { value: string; l
62
80
  return <QRCodeSVG value={value} size={184} level="M" marginSize={1} aria-label={label} />
63
81
  })
64
82
 
65
- /** One state notice: a title and, when there is one, the sentence explaining it. */
66
- function Notice({ tone, title, body }: { tone: 'plain' | 'warning' | 'alert'; title: string; body?: string }) {
67
- return (
68
- <div className={css.notice} data-dsh-part={PART_NOTICE} data-tone={tone} role={tone === 'plain' ? 'status' : 'alert'}>
69
- <p className={css.noticeTitle}>{title}</p>
70
- {body !== undefined && <p className={css.noticeBody}>{body}</p>}
71
- </div>
72
- )
83
+ /** The one string the panel hands out: what the symbol encodes, what copy copies. */
84
+ function payloadOf(state: PairPanelState): string {
85
+ return state.kind === 'ready' ? (state.pairingUrl ?? state.token) : ''
73
86
  }
74
87
 
75
88
  /**
@@ -77,107 +90,178 @@ function Notice({ tone, title, body }: { tone: 'plain' | 'warning' | 'alert'; ti
77
90
  * @param props - locale seat, view state, clock, page host and actions.
78
91
  * @returns the panel element tree.
79
92
  */
80
- export function PairPanel({ t, state, now, host, copy, onClose, onRefresh, onCopy }: PairPanelProps) {
81
- const remainingMs = state.kind === 'ready' ? Math.max(0, state.expiresAt - now) : 0
82
- const expired = state.kind === 'ready' && remainingMs <= 0
93
+ export function PairPanel({
94
+ t, state, now, host, copy, showing, closing, id, onClose, onExited, onRefresh, onCopy,
95
+ }: PairPanelProps) {
96
+ const panel = useRef<HTMLDivElement | null>(null)
97
+ const ready = state.kind === 'ready'
98
+ const remainingMs = ready ? Math.max(0, state.expiresAt - now) : 0
99
+ const expired = ready && remainingMs <= 0
83
100
  const seconds = Math.ceil(remainingMs / 1000)
84
- const windowMs = state.kind === 'ready' ? Math.max(1, state.expiresAt - state.issuedAt) : 1
101
+ const windowMs = ready ? Math.max(1, state.expiresAt - state.issuedAt) : 1
85
102
  const percent = Math.min(100, Math.max(0, Math.round((remainingMs / windowMs) * 100)))
86
- // What the QR encodes and what the copy button hands over: the same string,
87
- // so a human can paste exactly what a camera would have read.
88
- const payload = state.kind === 'ready' ? (state.pairingUrl ?? state.token) : ''
103
+ const payload = payloadOf(state)
104
+ // Only a live code can be handed out. An expired one is still on screen, so
105
+ // its button stays put and reports that it is switched off.
106
+ const canCopy = !expired && payload !== ''
107
+ // A refusal the host raised is retried; a live or expired code is minted again.
108
+ const primaryLabel = state.kind === 'failed' || state.kind === 'unreachable' ? t('action.retry') : t('pair.refresh')
109
+ const located = ready && state.pairingUrl !== null
110
+
111
+ // The library owns the enter animation and the bundler scopes its keyframe
112
+ // name, so the leave leg cannot name it in CSS. Read the mounted dialog's own
113
+ // animation at the moment closing starts and hand it to the card: the exit
114
+ // then plays that exact keyframe backwards (M2, same path reversed). Clearing
115
+ // it on reopen is what lets the same card come back to full opacity.
116
+ useLayoutEffect(() => {
117
+ const element = panel.current
118
+ if (element === null) return
119
+ if (!closing) {
120
+ element.style.removeProperty(EXIT_NAME_VAR)
121
+ return
122
+ }
123
+ const dialog = element.parentElement
124
+ const enter = dialog === null ? '' : window.getComputedStyle(dialog).animationName
125
+ if (enter !== '' && enter !== 'none') element.style.setProperty(EXIT_NAME_VAR, enter)
126
+ }, [closing])
89
127
 
90
128
  return (
91
- <div className={css.overlay} role="presentation">
92
- <div className={css.mask} aria-hidden="true" onClick={onClose} />
129
+ <Modal open={showing} onClose={onClose} title={t('title')} headless className={css.dialog}>
93
130
  <div
131
+ ref={panel}
132
+ id={id}
94
133
  className={css.panel}
95
- role="dialog"
96
- aria-modal="true"
97
- aria-label={t('title')}
98
134
  data-dsh-plugin={PLUGIN_ATTR}
99
135
  data-dsh-part={PART_PANEL}
136
+ data-closing={closing || undefined}
137
+ onAnimationEnd={(event) => {
138
+ if (closing && event.target === event.currentTarget) onExited()
139
+ }}
140
+ onTransitionEnd={(event) => {
141
+ if (closing && event.target === event.currentTarget && event.propertyName === 'opacity') onExited()
142
+ }}
100
143
  >
101
- <div className={css.header}>
144
+ <header className={css.header}>
102
145
  <div className={css.heading}>
103
146
  <h2 className={css.title}>{t('title')}</h2>
104
147
  <p className={css.subtitle}>{t('subtitle')}</p>
105
148
  </div>
106
- <button type="button" className={css.closeButton} aria-label={t('action.close')} onClick={onClose}>
107
- <CloseIcon />
108
- </button>
109
- </div>
110
-
111
- {state.kind === 'reading' && <Notice tone="plain" title={t('state.reading')} />}
112
-
113
- {state.kind === 'forbidden' && (
114
- <Notice tone="alert" title={t('forbidden.title')} body={t('forbidden.body')} />
115
- )}
116
-
117
- {state.kind === 'failed' && (
118
- <Notice tone="alert" title={t('failed.title')} body={t('failed.body', { status: String(state.status) })} />
119
- )}
149
+ <Button
150
+ className={css.close}
151
+ variant="ghost"
152
+ size="sm"
153
+ aria-label={t('action.close')}
154
+ icon={<IconCloseOutlineRegular />}
155
+ onClick={onClose}
156
+ />
157
+ </header>
120
158
 
121
- {state.kind === 'unreachable' && (
122
- <Notice tone="alert" title={t('unreachable.title')} body={t('unreachable.body')} />
123
- )}
124
-
125
- {state.kind === 'ready' && (
126
- <>
127
- <div className={css.qrCard}>
128
- <div className={css.qrWrap} data-dsh-part={PART_QR} {...{ [QR_VALUE_ATTR]: payload }}>
129
- <PairQrCode value={payload} label={t('pair.qrLabel')} />
159
+ <div className={css.body}>
160
+ {(state.kind === 'forbidden' || state.kind === 'failed' || state.kind === 'unreachable') && (
161
+ <div className={css.notice} data-dsh-part={PART_NOTICE} data-tone="alert" role="alert">
162
+ <span className={css.noticeIcon} aria-hidden="true"><IconWarningOutlineRegular /></span>
163
+ <div className={css.noticeCopy}>
164
+ <p className={css.noticeTitle}>
165
+ {state.kind === 'forbidden' && t('forbidden.title')}
166
+ {state.kind === 'failed' && t('failed.title')}
167
+ {state.kind === 'unreachable' && t('unreachable.title')}
168
+ </p>
169
+ <p className={css.noticeText}>
170
+ {state.kind === 'forbidden' && t('forbidden.body')}
171
+ {state.kind === 'failed' && t('failed.body', { status: String(state.status) })}
172
+ {state.kind === 'unreachable' && t('unreachable.body')}
173
+ </p>
130
174
  </div>
131
- {expired ? (
132
- <Notice tone="alert" title={t('pair.expired')} body={t('pair.expiredHint')} />
133
- ) : (
134
- <div className={css.countdown}>
135
- <span className={css.countdownText}>{t('pair.countdown', { s: String(seconds) })}</span>
136
- <span className={css.bar}>
137
- <span className={css.barFill} style={{ width: `${String(percent)}%` }} />
138
- </span>
139
- </div>
140
- )}
141
175
  </div>
176
+ )}
142
177
 
143
- <div className={css.tokenRow} data-dsh-part={PART_TOKEN}>
144
- <span className={css.tokenLabel}>{t('pair.payloadLabel')}</span>
145
- <code className={css.token}>{payload}</code>
146
- </div>
178
+ {(state.kind === 'reading' || ready) && (
179
+ <>
180
+ <div className={css.qrCard}>
181
+ <div
182
+ className={css.qrSlot}
183
+ data-dsh-part={PART_QR}
184
+ {...{ [QR_VALUE_ATTR]: payload }}
185
+ {...{ [EXPIRED_ATTR]: expired || undefined }}
186
+ >
187
+ {ready ? (
188
+ <PairQrCode value={payload} label={t('pair.qrLabel')} />
189
+ ) : (
190
+ <span className={css.skeleton} aria-hidden="true" />
191
+ )}
192
+ </div>
193
+ <div className={css.status}>
194
+ {!ready && <p className={css.statusText}>{t('state.reading')}</p>}
195
+ {ready && expired && <p className={css.statusText} role="status">{t('pair.expired')}</p>}
196
+ {ready && !expired && (
197
+ <>
198
+ <p className={css.statusText}>{t('pair.countdown', { s: String(seconds) })}</p>
199
+ <span className={css.bar} aria-hidden="true">
200
+ <span className={css.barFill} style={{ width: `${String(percent)}%` }} />
201
+ </span>
202
+ </>
203
+ )}
204
+ </div>
205
+ </div>
147
206
 
148
- <button
149
- type="button"
150
- className={css.copyButton}
151
- data-dsh-part={PART_COPY}
152
- data-copied={copy === 'copied'}
153
- data-failed={copy === 'failed'}
154
- onClick={() => { onCopy(payload) }}
155
- >
156
- {copy === 'copied' ? <CheckIcon /> : <CopyIcon />}
157
- {copy === 'copied' ? t('action.copied') : copy === 'failed' ? t('action.copyFailed') : t('action.copy')}
158
- </button>
207
+ <p className={css.address} data-tone={located ? 'plain' : 'warning'}>
208
+ {ready && located && t('origin.located', { origin: state.origin ?? '' })}
209
+ {ready && !located && t('origin.missing', { host })}
210
+ </p>
211
+ <p className={css.hint}>{t('pair.usedHint')}</p>
212
+ </>
213
+ )}
214
+ </div>
159
215
 
160
- {state.pairingUrl === null ? (
161
- <Notice tone="warning" title={t('origin.title')} body={t('origin.body', { host })} />
162
- ) : (
163
- <Notice
164
- tone="plain"
165
- title={t('origin.located.title')}
166
- body={t('origin.located.body', { origin: state.origin ?? '' })}
167
- />
216
+ {/* The row exists only while it holds an action: a refusal offers
217
+ nothing to press, and copy itself needs a code to hand out. An
218
+ actionless row would still spend the panel's own gap. */}
219
+ {state.kind !== 'forbidden' && (
220
+ <footer className={css.actions}>
221
+ {ready && (
222
+ <Button
223
+ variant="outline"
224
+ size="sm"
225
+ data-dsh-part={PART_COPY}
226
+ disabled={!canCopy}
227
+ icon={copy === 'copied' ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}
228
+ onClick={() => { onCopy(payload) }}
229
+ >
230
+ <span className={css.labels}>
231
+ <span className={css.label} data-visible={copy === 'idle'} aria-hidden={copy !== 'idle'}>
232
+ {t('action.copy')}
233
+ </span>
234
+ <span className={css.label} data-visible={copy === 'copied'} aria-hidden={copy !== 'copied'}>
235
+ {t('action.copied')}
236
+ </span>
237
+ <span className={css.label} data-visible={copy === 'failed'} aria-hidden={copy !== 'failed'}>
238
+ {t('action.copyFailed')}
239
+ </span>
240
+ </span>
241
+ </Button>
168
242
  )}
169
- </>
243
+ <Button
244
+ variant="primary"
245
+ size="sm"
246
+ data-dsh-part={PART_REFRESH}
247
+ disabled={state.kind === 'reading'}
248
+ icon={<IconRefreshOutlineRegular />}
249
+ onClick={onRefresh}
250
+ >
251
+ {primaryLabel}
252
+ </Button>
253
+ </footer>
170
254
  )}
171
255
 
172
- <div className={css.actions}>
173
- {state.kind !== 'reading' && state.kind !== 'forbidden' && (
174
- <button type="button" className={css.refresh} data-dsh-part={PART_REFRESH} onClick={onRefresh}>
175
- <RefreshIcon />
176
- {t('pair.refresh')}
177
- </button>
178
- )}
256
+ {/* Renaming the button under the pointer is not announced: a control's
257
+ label is reported when focus lands on it, not when it changes. The
258
+ outcome is said once from this region instead, and said as nothing
259
+ while there is no outcome to report. */}
260
+ <div className={css.announce} role="status">
261
+ {copy === 'copied' && t('action.copied')}
262
+ {copy === 'failed' && t('action.copyFailed')}
179
263
  </div>
180
264
  </div>
181
- </div>
265
+ </Modal>
182
266
  )
183
267
  }
@@ -1,72 +1,29 @@
1
1
  /**
2
- * Inline SVG icons for the pairing panel (16px stroke style matching the
3
- * shell's nav icons). Held here rather than imported from
4
- * `@deepseek-ai/dsh-client-ui-primitives` so the panel's rendered tree carries
5
- * no closure-factory bundle import: the component stays renderable under the
6
- * package's own test runner.
2
+ * The pairing seat's QR glyph. It is the one icon this package draws itself
3
+ * (I4 exception, recorded here): the official icon set in
4
+ * `@deepseek-ai/dsh-client-ui-primitives` ships no QR or scan metaphor, and a
5
+ * text or emoji stand-in is not an icon (I1). Every other glyph this panel
6
+ * needs — close, copy, check, refresh, warning — comes from that set.
7
7
  */
8
8
  import type { SVGProps } from 'react'
9
9
 
10
- /** Shared svg attrs for the 16px stroke icon family. */
11
- function iconProps(props: SVGProps<SVGSVGElement>): SVGProps<SVGSVGElement> {
12
- return {
13
- width: 16,
14
- height: 16,
15
- viewBox: '0 0 16 16',
16
- fill: 'none',
17
- stroke: 'currentColor',
18
- strokeWidth: 1.3,
19
- strokeLinecap: 'round',
20
- strokeLinejoin: 'round',
21
- 'aria-hidden': true,
22
- ...props,
23
- }
24
- }
25
-
26
10
  /** A QR-symbol glyph: three finder squares plus a payload dot. */
27
11
  export function QrIcon(props: SVGProps<SVGSVGElement>) {
28
12
  return (
29
- <svg {...iconProps(props)}>
13
+ <svg
14
+ width={16}
15
+ height={16}
16
+ viewBox="0 0 16 16"
17
+ fill="none"
18
+ stroke="currentColor"
19
+ strokeWidth={1.3}
20
+ strokeLinecap="round"
21
+ strokeLinejoin="round"
22
+ aria-hidden="true"
23
+ {...props}
24
+ >
30
25
  <path d="M2.5 2.5h4v4h-4zM9.5 2.5h4v4h-4zM2.5 9.5h4v4h-4z" />
31
26
  <path d="M9.5 9.5h1.6v1.6H9.5zM12.4 9.5h1.1M9.5 12.4v1.1M12 13.5h1.5v-1.5h-1.5z" />
32
27
  </svg>
33
28
  )
34
29
  }
35
-
36
- /** Copy glyph. */
37
- export function CopyIcon(props: SVGProps<SVGSVGElement>) {
38
- return (
39
- <svg {...iconProps(props)}>
40
- <rect x="5.5" y="5.5" width="9" height="9" rx="1.5" />
41
- <path d="M2.5 10.5v-7A1.5 1.5 0 0 1 4 2h5.5" />
42
- </svg>
43
- )
44
- }
45
-
46
- /** Check glyph for the transient copied state. */
47
- export function CheckIcon(props: SVGProps<SVGSVGElement>) {
48
- return (
49
- <svg {...iconProps(props)}>
50
- <path d="M3 8.5 6.5 12l6.5-8" />
51
- </svg>
52
- )
53
- }
54
-
55
- /** Close glyph for the panel header. */
56
- export function CloseIcon(props: SVGProps<SVGSVGElement>) {
57
- return (
58
- <svg {...iconProps(props)}>
59
- <path d="M4 4l8 8M12 4l-8 8" />
60
- </svg>
61
- )
62
- }
63
-
64
- /** Refresh glyph for the mint-again action. */
65
- export function RefreshIcon(props: SVGProps<SVGSVGElement>) {
66
- return (
67
- <svg {...iconProps(props)}>
68
- <path d="M13 8a5 5 0 1 1-1.8-3.85" />
69
- <path d="M13.2 2.4V5.6H10" />
70
- </svg>
71
- )
72
- }
@@ -1,30 +1,26 @@
1
1
  /**
2
2
  * `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy.
3
3
  *
4
- * The panel has one job — show the operator the one-shot bootstrap token as a
5
- * QR symbol plus its plaintext — so the copy is dominated by the two facts a
6
- * reader has to get right: where the phone's origin points (the public relay,
7
- * never this machine's loopback address) and why the token vanished (30 s, one
8
- * use, or a fresh mint).
4
+ * The panel has one job — put the live one-shot code in front of the operator as
5
+ * a QR symbol — so the copy carries exactly four things: what to do with the
6
+ * symbol, how long it lives, which address the phone will actually dial, and why
7
+ * the code is single-use. No key states how the host finds its public address:
8
+ * that is an implementation fact the reader cannot act on.
9
9
  */
10
10
 
11
11
  /** Simplified Chinese dictionary (the key-set source of truth). */
12
12
  export const zh = {
13
13
  'entry.label': '配对手机(协议 v1)',
14
14
  'title': '协议 v1 配对',
15
- 'subtitle': '用手机 App 扫描下方二维码,即可以协议 v1 配对这台宿主。配对码由本机签发,仅在本机可读。',
15
+ 'subtitle': '用手机 App 扫描二维码,即可让手机以协议 v1 连上这台宿主。配对码由本机签发,只在本机显示。',
16
16
  'state.reading': '正在取配对码…',
17
17
  'pair.qrLabel': '配对二维码',
18
- 'pair.payloadLabel': '二维码内容(可复制后粘贴到手机)',
19
18
  'pair.countdown': '剩余 {s} 秒',
20
- 'pair.expired': '配对码已过期(30 秒)',
21
- 'pair.expiredHint': '过期的配对码不会被手机接受,请重新取码。',
22
- 'pair.usedHint': '配对码一次性:手机调用 pair.begin 的瞬间即作废,重新取码也会作废上一张。',
19
+ 'pair.expired': '配对码已过期',
23
20
  'pair.refresh': '重新取码',
24
- 'origin.title': '没能自动定位公网地址,二维码只装裸配对码',
25
- 'origin.body': '这台机器既没有 DSH_REMOTE_PUBLIC_BASE_URL,也没有中继注册表记录,因此无法把地址写进二维码。请先在手机 App 里把连接地址设成你的公网中继(形如 wss://<id>.dsh-market.com),再扫上面的码;本页所在的 {host} 只有本机能连,手机连不上。',
26
- 'origin.located.title': '手机将直接连到公网中继(地址已写进二维码)',
27
- 'origin.located.body': '二维码里已经带上 {origin}:手机扫一次就同时设好连接地址与配对码,不需要手填任何东西。',
21
+ 'pair.usedHint': '配对码一次性有效:手机一开始配对即作废,重新取码也会作废上一张。',
22
+ 'origin.located': '手机将连到 {origin}',
23
+ 'origin.missing': '没有找到公网地址:请先在手机里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。',
28
24
  'forbidden.title': '这个页面不是从本机打开的',
29
25
  'forbidden.body': '配对码只能在本机 Web UI 上取。请在本机浏览器打开 http://127.0.0.1:<端口> 后重试。',
30
26
  'failed.title': '取配对码失败',
@@ -42,19 +38,15 @@ export const zh = {
42
38
  export const en: Record<RemoteBridgeKey, string> = {
43
39
  'entry.label': 'Pair a phone (protocol v1)',
44
40
  'title': 'Protocol v1 pairing',
45
- 'subtitle': 'Scan the QR code with the phone app to pair it with this host over protocol v1. The code is minted by this machine and only readable here.',
41
+ 'subtitle': 'Scan the QR code with the phone app to let the phone reach this host over protocol v1. The code is minted by this machine and shown only here.',
46
42
  'state.reading': 'Requesting a pairing code…',
47
43
  'pair.qrLabel': 'Pairing QR code',
48
- 'pair.payloadLabel': 'What the QR encodes (copy it to paste on the phone)',
49
44
  'pair.countdown': '{s} s left',
50
- 'pair.expired': 'The pairing code expired (30 s)',
51
- 'pair.expiredHint': 'An expired code is never accepted; request a new one.',
52
- 'pair.usedHint': 'The code is single-use: the phone spends it the moment it calls pair.begin, and requesting a new one voids the previous code.',
45
+ 'pair.expired': 'The pairing code expired',
53
46
  'pair.refresh': 'New code',
54
- 'origin.title': 'No public address could be located, so the QR carries the bare code',
55
- 'origin.body': 'This machine has neither DSH_REMOTE_PUBLIC_BASE_URL nor a relay registry row, so the address cannot go into the QR. Set the phone app to your public relay first (such as wss://<id>.dsh-market.com), then scan the code above; {host} (this page) is reachable only from this machine and never from the phone.',
56
- 'origin.located.title': 'The phone dials the public relay directly (address is in the QR)',
57
- 'origin.located.body': 'The QR carries {origin}: one scan sets both the connection address and the pairing code, with nothing to type.',
47
+ 'pair.usedHint': 'The code is single-use: pairing spends it, and a new code voids the previous one.',
48
+ 'origin.located': 'The phone will dial {origin}',
49
+ 'origin.missing': 'No public address found: set the phone app to your public relay first, then scan. {host} (this page) is reachable only from this machine.',
58
50
  'forbidden.title': 'This page is not open on this machine',
59
51
  'forbidden.body': 'Pairing codes can only be read from the machine itself. Open http://127.0.0.1:<port> in a browser on this machine and retry.',
60
52
  'failed.title': 'Could not read a pairing code',