dsh-zen-remote 1.1.16 → 2.0.1

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 (261) hide show
  1. package/AGENTS.md +54 -9
  2. package/README.md +249 -190
  3. package/README.zh-CN.md +247 -201
  4. package/assets/home.png +0 -0
  5. package/assets/info.png +0 -0
  6. package/assets/pairing.png +0 -0
  7. package/assets/session.png +0 -0
  8. package/assets/sheet.png +0 -0
  9. package/cordis.patch.yml +12 -11
  10. package/cordis.patch.yml.example +24 -9
  11. package/docs/interface.md +57 -2
  12. package/docs/remote-access.en.md +99 -58
  13. package/docs/remote-access.md +99 -42
  14. package/dsh-push.mjs +67 -54
  15. package/lan-gate.mjs +88 -20
  16. package/lib/activity.js +168 -0
  17. package/lib/activity.js.map +1 -0
  18. package/lib/admin-routes.js +526 -0
  19. package/lib/admin-routes.js.map +1 -0
  20. package/lib/client-pairing.js +224 -0
  21. package/lib/client-pairing.js.map +1 -0
  22. package/lib/client-routes.js +674 -0
  23. package/lib/client-routes.js.map +1 -0
  24. package/lib/client.js +11498 -5990
  25. package/lib/config.js +346 -0
  26. package/lib/config.js.map +1 -0
  27. package/lib/fetch-route-intercept.js +418 -0
  28. package/lib/fetch-route-intercept.js.map +1 -0
  29. package/lib/fingerprint.js +365 -0
  30. package/lib/fingerprint.js.map +1 -0
  31. package/lib/http.js +69 -0
  32. package/lib/http.js.map +1 -0
  33. package/lib/index.js +675 -54
  34. package/lib/index.js.map +1 -1
  35. package/lib/intercept-shape.js +81 -0
  36. package/lib/intercept-shape.js.map +1 -0
  37. package/lib/intercept.js +3181 -0
  38. package/lib/intercept.js.map +1 -0
  39. package/lib/lan-gate-server.cjs +532 -121
  40. package/lib/merge-streams.js +1172 -0
  41. package/lib/merge-streams.js.map +1 -0
  42. package/lib/relay-access.js +496 -0
  43. package/lib/relay-access.js.map +1 -0
  44. package/lib/relay-client.js +1303 -0
  45. package/lib/relay-client.js.map +1 -0
  46. package/lib/relay-filter.js +282 -0
  47. package/lib/relay-filter.js.map +1 -0
  48. package/lib/relay-server.js +1813 -0
  49. package/lib/relay-server.js.map +1 -0
  50. package/lib/restart-fields.js +34 -0
  51. package/lib/restart-fields.js.map +1 -0
  52. package/lib/restart-watcher.js +106 -0
  53. package/lib/restart-watcher.js.map +1 -0
  54. package/lib/session-reference.js +157 -0
  55. package/lib/session-reference.js.map +1 -0
  56. package/lib/share-export.js +16 -1
  57. package/lib/share-export.js.map +1 -1
  58. package/lib/share-ops.js +86 -0
  59. package/lib/share-ops.js.map +1 -0
  60. package/lib/share-store.js +294 -0
  61. package/lib/share-store.js.map +1 -0
  62. package/lib/types/activity.d.ts +99 -0
  63. package/lib/types/activity.d.ts.map +1 -0
  64. package/lib/types/admin-routes.d.ts +129 -0
  65. package/lib/types/admin-routes.d.ts.map +1 -0
  66. package/lib/types/client/MobileDrawerFooter.d.ts.map +1 -1
  67. package/lib/types/client/MobileHome.d.ts +1 -1
  68. package/lib/types/client/MobileHome.d.ts.map +1 -1
  69. package/lib/types/client/MobileHomeChips.d.ts +1 -1
  70. package/lib/types/client/MobileHomeChips.d.ts.map +1 -1
  71. package/lib/types/client/MobileSessionHeader.d.ts +13 -2
  72. package/lib/types/client/MobileSessionHeader.d.ts.map +1 -1
  73. package/lib/types/client/MobileSessionInfo.d.ts +20 -3
  74. package/lib/types/client/MobileSessionInfo.d.ts.map +1 -1
  75. package/lib/types/client/RemoteComposerBanner.d.ts +42 -0
  76. package/lib/types/client/RemoteComposerBanner.d.ts.map +1 -0
  77. package/lib/types/client/RemoteHeaderIcon.d.ts +37 -0
  78. package/lib/types/client/RemoteHeaderIcon.d.ts.map +1 -0
  79. package/lib/types/client/RemoteShareMenu.d.ts +28 -0
  80. package/lib/types/client/RemoteShareMenu.d.ts.map +1 -0
  81. package/lib/types/client/RemoteStatusIcon.d.ts +36 -0
  82. package/lib/types/client/RemoteStatusIcon.d.ts.map +1 -0
  83. package/lib/types/client/compat/desktop.d.ts +21 -0
  84. package/lib/types/client/compat/desktop.d.ts.map +1 -0
  85. package/lib/types/client/compat/types.d.ts +57 -0
  86. package/lib/types/client/compat/types.d.ts.map +1 -1
  87. package/lib/types/client/current-session-report.d.ts +37 -0
  88. package/lib/types/client/current-session-report.d.ts.map +1 -0
  89. package/lib/types/client/effects/header-status.d.ts.map +1 -1
  90. package/lib/types/client/effects/keyboard-guard.d.ts.map +1 -1
  91. package/lib/types/client/effects/model-group-side.d.ts +13 -0
  92. package/lib/types/client/effects/model-group-side.d.ts.map +1 -0
  93. package/lib/types/client/effects/permission-sheet.d.ts +39 -0
  94. package/lib/types/client/effects/permission-sheet.d.ts.map +1 -0
  95. package/lib/types/client/effects/remote-session.d.ts +25 -0
  96. package/lib/types/client/effects/remote-session.d.ts.map +1 -0
  97. package/lib/types/client/effects/turn-fold.d.ts +9 -0
  98. package/lib/types/client/effects/turn-fold.d.ts.map +1 -1
  99. package/lib/types/client/index.d.ts.map +1 -1
  100. package/lib/types/client/locales.d.ts +187 -2
  101. package/lib/types/client/locales.d.ts.map +1 -1
  102. package/lib/types/client/remote-fetch.d.ts +51 -0
  103. package/lib/types/client/remote-fetch.d.ts.map +1 -0
  104. package/lib/types/client/remote-group-expansion.d.ts +41 -0
  105. package/lib/types/client/remote-group-expansion.d.ts.map +1 -0
  106. package/lib/types/client/remote-share-css.d.ts +19 -0
  107. package/lib/types/client/remote-share-css.d.ts.map +1 -0
  108. package/lib/types/client/remote-share-register.d.ts +113 -0
  109. package/lib/types/client/remote-share-register.d.ts.map +1 -0
  110. package/lib/types/client/remote-status-css.d.ts +15 -0
  111. package/lib/types/client/remote-status-css.d.ts.map +1 -0
  112. package/lib/types/client/remote-status-register.d.ts +46 -0
  113. package/lib/types/client/remote-status-register.d.ts.map +1 -0
  114. package/lib/types/client/settings/SettingsSection.d.ts +46 -0
  115. package/lib/types/client/settings/SettingsSection.d.ts.map +1 -0
  116. package/lib/types/client/settings/register-settings.d.ts +58 -0
  117. package/lib/types/client/settings/register-settings.d.ts.map +1 -0
  118. package/lib/types/client/settings/settings-css.d.ts +10 -0
  119. package/lib/types/client/settings/settings-css.d.ts.map +1 -0
  120. package/lib/types/client/share/share-preview.d.ts.map +1 -1
  121. package/lib/types/client/styles/composer.css.d.ts +1 -1
  122. package/lib/types/client/styles/composer.css.d.ts.map +1 -1
  123. package/lib/types/client/styles/header.css.d.ts +1 -1
  124. package/lib/types/client/styles/header.css.d.ts.map +1 -1
  125. package/lib/types/client/styles/info.css.d.ts +1 -1
  126. package/lib/types/client/styles/info.css.d.ts.map +1 -1
  127. package/lib/types/client/styles/remote-session.css.d.ts +2 -0
  128. package/lib/types/client/styles/remote-session.css.d.ts.map +1 -0
  129. package/lib/types/client-data/current-session.d.ts +41 -0
  130. package/lib/types/client-data/current-session.d.ts.map +1 -0
  131. package/lib/types/client-data/model-group-side.d.ts +44 -0
  132. package/lib/types/client-data/model-group-side.d.ts.map +1 -0
  133. package/lib/types/client-data/remote-group-expansion.d.ts +76 -0
  134. package/lib/types/client-data/remote-group-expansion.d.ts.map +1 -0
  135. package/lib/types/client-data/remote-status.d.ts +148 -0
  136. package/lib/types/client-data/remote-status.d.ts.map +1 -0
  137. package/lib/types/client-data/settings-form.d.ts +774 -0
  138. package/lib/types/client-data/settings-form.d.ts.map +1 -0
  139. package/lib/types/client-data/shares.d.ts +211 -0
  140. package/lib/types/client-data/shares.d.ts.map +1 -0
  141. package/lib/types/client-pairing.d.ts +114 -0
  142. package/lib/types/client-pairing.d.ts.map +1 -0
  143. package/lib/types/client-routes.d.ts +112 -0
  144. package/lib/types/client-routes.d.ts.map +1 -0
  145. package/lib/types/config.d.ts +200 -0
  146. package/lib/types/config.d.ts.map +1 -0
  147. package/lib/types/fetch-route-intercept.d.ts +156 -0
  148. package/lib/types/fetch-route-intercept.d.ts.map +1 -0
  149. package/lib/types/fingerprint.d.ts +166 -0
  150. package/lib/types/fingerprint.d.ts.map +1 -0
  151. package/lib/types/http.d.ts +41 -0
  152. package/lib/types/http.d.ts.map +1 -0
  153. package/lib/types/index.d.ts +56 -24
  154. package/lib/types/index.d.ts.map +1 -1
  155. package/lib/types/intercept-shape.d.ts +32 -0
  156. package/lib/types/intercept-shape.d.ts.map +1 -0
  157. package/lib/types/intercept.d.ts +442 -0
  158. package/lib/types/intercept.d.ts.map +1 -0
  159. package/lib/types/merge-streams.d.ts +398 -0
  160. package/lib/types/merge-streams.d.ts.map +1 -0
  161. package/lib/types/relay-access.d.ts +310 -0
  162. package/lib/types/relay-access.d.ts.map +1 -0
  163. package/lib/types/relay-client.d.ts +274 -0
  164. package/lib/types/relay-client.d.ts.map +1 -0
  165. package/lib/types/relay-filter.d.ts +103 -0
  166. package/lib/types/relay-filter.d.ts.map +1 -0
  167. package/lib/types/relay-server.d.ts +208 -0
  168. package/lib/types/relay-server.d.ts.map +1 -0
  169. package/lib/types/restart-fields.d.ts +22 -0
  170. package/lib/types/restart-fields.d.ts.map +1 -0
  171. package/lib/types/restart-watcher.d.ts +83 -0
  172. package/lib/types/restart-watcher.d.ts.map +1 -0
  173. package/lib/types/session-reference.d.ts +66 -0
  174. package/lib/types/session-reference.d.ts.map +1 -0
  175. package/lib/types/share-export.d.ts +14 -1
  176. package/lib/types/share-export.d.ts.map +1 -1
  177. package/lib/types/share-ops.d.ts +79 -0
  178. package/lib/types/share-ops.d.ts.map +1 -0
  179. package/lib/types/share-store.d.ts +87 -0
  180. package/lib/types/share-store.d.ts.map +1 -0
  181. package/lib/types/virtual-id.d.ts +52 -0
  182. package/lib/types/virtual-id.d.ts.map +1 -0
  183. package/lib/virtual-id.js +66 -0
  184. package/lib/virtual-id.js.map +1 -0
  185. package/llms.txt +17 -14
  186. package/package.json +60 -50
  187. package/scripts/build-client.mjs +5 -3
  188. package/scripts/check-host-shadow.mjs +19 -2
  189. package/scripts/check-settings-form.mjs +933 -0
  190. package/scripts/check-shares.mjs +397 -0
  191. package/scripts/check-upload-endpoint.mjs +59 -3
  192. package/scripts/sync-doc-version.mjs +8 -15
  193. package/scripts/verify-fingerprint-live.mjs +111 -0
  194. package/src/activity.ts +218 -0
  195. package/src/admin-routes.ts +627 -0
  196. package/src/client/MobileAttachButton.tsx +2 -2
  197. package/src/client/MobileAttachChips.tsx +3 -3
  198. package/src/client/MobileDrawerFooter.tsx +7 -4
  199. package/src/client/MobileHome.tsx +20 -16
  200. package/src/client/MobileHomeChips.tsx +16 -16
  201. package/src/client/MobileNavOverlay.tsx +2 -2
  202. package/src/client/MobileNavToggle.tsx +3 -3
  203. package/src/client/MobileSessionHeader.tsx +63 -42
  204. package/src/client/MobileSessionInfo.tsx +118 -17
  205. package/src/client/RemoteComposerBanner.tsx +76 -0
  206. package/src/client/RemoteHeaderIcon.tsx +103 -0
  207. package/src/client/RemoteShareMenu.tsx +57 -0
  208. package/src/client/RemoteStatusIcon.tsx +91 -0
  209. package/src/client/compat/desktop.ts +22 -0
  210. package/src/client/compat/types.ts +62 -0
  211. package/src/client/current-session-report.ts +164 -0
  212. package/src/client/effects/header-status.ts +21 -17
  213. package/src/client/effects/keyboard-guard.ts +65 -1
  214. package/src/client/effects/model-group-side.ts +132 -0
  215. package/src/client/effects/permission-sheet.ts +149 -0
  216. package/src/client/effects/remote-session.ts +68 -0
  217. package/src/client/effects/turn-fold.ts +52 -0
  218. package/src/client/index.tsx +158 -36
  219. package/src/client/locales.ts +396 -2
  220. package/src/client/remote-fetch.ts +125 -0
  221. package/src/client/remote-group-expansion.ts +190 -0
  222. package/src/client/remote-share-css.ts +54 -0
  223. package/src/client/remote-share-register.ts +244 -0
  224. package/src/client/remote-status-css.ts +64 -0
  225. package/src/client/remote-status-register.ts +107 -0
  226. package/src/client/settings/SettingsSection.tsx +1229 -0
  227. package/src/client/settings/register-settings.ts +116 -0
  228. package/src/client/settings/settings-css.ts +236 -0
  229. package/src/client/share/share-preview.tsx +6 -3
  230. package/src/client/share/share-sheet.tsx +3 -3
  231. package/src/client/styles/composer.css.ts +119 -26
  232. package/src/client/styles/header.css.ts +7 -7
  233. package/src/client/styles/info.css.ts +74 -0
  234. package/src/client/styles/remote-session.css.ts +274 -0
  235. package/src/client-data/current-session.ts +57 -0
  236. package/src/client-data/model-group-side.ts +65 -0
  237. package/src/client-data/remote-group-expansion.ts +145 -0
  238. package/src/client-data/remote-status.ts +374 -0
  239. package/src/client-data/settings-form.ts +1371 -0
  240. package/src/client-data/shares.ts +467 -0
  241. package/src/client-pairing.ts +244 -0
  242. package/src/client-routes.ts +732 -0
  243. package/src/config.ts +447 -0
  244. package/src/fetch-route-intercept.ts +510 -0
  245. package/src/fingerprint.ts +410 -0
  246. package/src/http.ts +68 -0
  247. package/src/index.ts +719 -62
  248. package/src/intercept-shape.ts +87 -0
  249. package/src/intercept.ts +3510 -0
  250. package/src/merge-streams.ts +1279 -0
  251. package/src/relay-access.ts +672 -0
  252. package/src/relay-client.ts +1514 -0
  253. package/src/relay-filter.ts +291 -0
  254. package/src/relay-server.ts +2063 -0
  255. package/src/restart-fields.ts +36 -0
  256. package/src/restart-watcher.ts +140 -0
  257. package/src/session-reference.ts +156 -0
  258. package/src/share-export.ts +26 -1
  259. package/src/share-ops.ts +114 -0
  260. package/src/share-store.ts +373 -0
  261. package/src/virtual-id.ts +74 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * T62: the browser half's current-session parsing, as pure functions — the
3
+ * readable core of the reporter (src/client/current-session-report.ts) and
4
+ * the one place its rules are unit-tested without a DOM.
5
+ *
6
+ * The host DSH persists its selection (the session its UI has open) to
7
+ * localStorage under `dsh.sessions.current` as a JSON object carrying
8
+ * `sessionId` (dsh-client-ui-workspace's snapshot store, `replaceMain` /
9
+ * `clearMain`). The reporter re-reads that key and POSTs it to the backend
10
+ * whenever it CHANGES; the backend's intercept layer judges close frames
11
+ * against it — a closed session the user has open keeps its page and its
12
+ * 「远程已关闭」 banner, anything else hides. The vocabulary mirrors the
13
+ * intercept side's `CurrentSessionRead`:
14
+ * - `unavailable`: the key is absent or the value unreadable — NEVER
15
+ * report; the backend keeps its conservative tombstone behavior;
16
+ * - `none`: readable, no session open — report `{sessionId: null}`;
17
+ * - `open`: a session id — report `{sessionId}`.
18
+ */
19
+ export type CurrentSessionReport = {
20
+ kind: 'unavailable';
21
+ } | {
22
+ kind: 'none';
23
+ } | {
24
+ kind: 'open';
25
+ sessionId: string;
26
+ };
27
+ /** Mirror of src/intercept.ts's key (the client build cannot import the
28
+ * host file). The host's selection store persists under this exact name. */
29
+ export declare const CURRENT_SESSION_STORAGE_KEY = "dsh.sessions.current";
30
+ /** Parse one raw localStorage read. `null` / `undefined` (the key is absent
31
+ * — the host store only starts persisting with its first write) and any
32
+ * value that does not parse into an object with a usable shape are
33
+ * `unavailable`: no signal, never a guess. An object WITHOUT a `sessionId`
34
+ * (the host's `clearMain` writes `{}`) is a real, reportable "nothing is
35
+ * open". */
36
+ export declare function parseCurrentSessionStorage(raw: string | null | undefined): CurrentSessionReport;
37
+ /** Whether one report differs from another — the reporter posts only on a
38
+ * change, so this compares content, never object identity: kind first, then
39
+ * the session id. */
40
+ export declare function currentSessionReportEquals(a: CurrentSessionReport, b: CurrentSessionReport): boolean;
41
+ //# sourceMappingURL=current-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-session.d.ts","sourceRoot":"","sources":["../../../src/client-data/current-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvC;4EAC4E;AAC5E,eAAO,MAAM,2BAA2B,yBAAyB,CAAA;AAEjE;;;;;YAKY;AACZ,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB,CAa/F;AAED;;qBAEqB;AACrB,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAIpG"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * T74: which side of the pairing a model-menu GROUP belongs to, as pure
3
+ * functions — the readable core of the browser effect
4
+ * (src/client/effects/model-group-side.ts).
5
+ *
6
+ * WHY: the merged catalog (merge-streams.ts mergeModelCatalogs) appends the
7
+ * server's provider groups everywhere, but a selection only runs on the side
8
+ * the open session lives on — the interceptor refuses the other side. Through
9
+ * DSH 0.1.7 every menu group carried its id in `aria-labelledby`
10
+ * (`<useId>-<group.id>`), so CSS keyed the hiding on the `zr~` prefix (T52).
11
+ * DSH 0.2.0 renders the groups with the primitives' MenuGroup, whose
12
+ * `aria-labelledby` is a bare useId — the id is gone — and the same component
13
+ * renders OTHER menus' groups too, so attribute scoping misfires in both
14
+ * directions. Classification therefore moved to the one mark every version
15
+ * renders: virtual group NAMES start with VIRTUAL_GROUP_NAME_MARK
16
+ * (virtual-id.ts), read off each group's heading text.
17
+ *
18
+ * The container rule is what keeps the effect inert wherever it cannot be
19
+ * sure: a container with not ONE marked heading — the model menu of a
20
+ * sub-client with no shared models, every other menu on the page, the whole
21
+ * rest of the page — classifies as `undefined` for every group, which the
22
+ * effect reads as "leave the DOM alone". Only a container holding at least
23
+ * one marked heading is decided, and inside it the unmarked groups are
24
+ * exactly the LOCAL ones: the merged catalog only ever APPENDS virtual
25
+ * groups to the local list, never mixes them the other way.
26
+ *
27
+ * Defensive like the rest of client-data: an empty or missing heading never
28
+ * counts as a mark, so it can never decide a container by accident.
29
+ */
30
+ /** One group's display description, as the DOM shows it. */
31
+ export interface ModelGroupHeading {
32
+ /** Groups sharing one container share one key (the effect numbers the
33
+ * parent elements it scans). */
34
+ containerKey: number;
35
+ /** The group's heading text ('' when no heading could be found). */
36
+ headingText: string;
37
+ }
38
+ /** Per-group verdict, in input order: `remote` for marked headings, `local`
39
+ * for the rest of a container that has at least one, and `undefined` —
40
+ * "stamp nothing" — for every group of a container that holds no mark at
41
+ * all. */
42
+ export type ModelGroupSide = 'remote' | 'local' | undefined;
43
+ export declare function classifyModelGroups(groups: readonly ModelGroupHeading[]): ModelGroupSide[];
44
+ //# sourceMappingURL=model-group-side.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-group-side.d.ts","sourceRoot":"","sources":["../../../src/client-data/model-group-side.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC;oCACgC;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;UAGU;AACV,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAE3D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,GAAG,cAAc,EAAE,CAiB1F"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * T64: the server remote groups' expansion memory, as pure functions — the
3
+ * readable core of the keeper (src/client/remote-group-expansion.ts).
4
+ *
5
+ * WHY this exists: the host's own expansion memory
6
+ * (localStorage `dsh.workspace.view.v5`, key `groupExpansion`) is purged of
7
+ * every key not in the CURRENT workspace list the moment the workspace list
8
+ * goes ready (`retainAccountKeys` — dsh-client-ui-workspace). On a sub-client
9
+ * the LOCAL workspaces go ready before the server groups merge in, so the
10
+ * `zr~<serverId>~<workspaceId>` keys are dropped on every page load and every
11
+ * server group falls back to collapsed (`groupExpansion[key] ??
12
+ * ancestorKeys.has(key)` — unrecorded means collapsed). The plugin therefore
13
+ * keeps its OWN record and re-applies it: while the host still has a record
14
+ * for a group, the host's value wins (the user's latest choice lives there)
15
+ * and syncs into the plugin record; for a group the host has NO record for
16
+ * (exactly the just-purged case) the plugin record — default EXPANDED — is
17
+ * what the group should show, applied by clicking the row once so the host
18
+ * writes its own state back.
19
+ *
20
+ * Everything here is defensive like the rest of client-data: a malformed
21
+ * storage value degrades to an empty record, never a throw.
22
+ */
23
+ /** The plugin's own storage key (`{ [virtualWorkspaceId]: boolean }`). */
24
+ export declare const REMOTE_GROUP_EXPANSION_KEY = "zr.remoteGroupExpansion.v1";
25
+ /** The HOST key this module reads (never writes) — dsh-client-ui-workspace's
26
+ * persisted view state. */
27
+ export declare const HOST_WORKSPACE_VIEW_KEY = "dsh.workspace.view.v5";
28
+ /** The record's key cap; past it the OLDEST entries (least recently written)
29
+ * are evicted. One server group is one key — 200 is far past any real
30
+ * sidebar, the cap bounds a long-lived stale record. */
31
+ export declare const REMOTE_GROUP_EXPANSION_LIMIT = 200;
32
+ /** One server group row's current state, as read from the sidebar DOM. */
33
+ export interface GroupRowState {
34
+ /** The group id (the `data-row-key`'s part after `workspace:`) — a virtual
35
+ * id `zr~<serverId>~<workspaceId>`. */
36
+ key: string;
37
+ /** The row's current `aria-expanded`. */
38
+ expanded: boolean;
39
+ }
40
+ export interface ExpansionPlan {
41
+ /** Group ids to click, in row order — the rows whose `aria-expanded`
42
+ * disagrees with the wanted state and that the host holds no record for. */
43
+ clicks: string[];
44
+ /** The next plugin record: the host-recorded `zr~` keys synced in (host
45
+ * value wins, recency touched), capped at the limit. Write it back only
46
+ * when it differs from the current one. */
47
+ record: Record<string, boolean>;
48
+ }
49
+ /** Parse one raw read of the plugin record (or the host's `groupExpansion`
50
+ * map): a JSON object whose values are booleans survives; anything else —
51
+ * absent key, broken JSON, non-object, non-boolean values — degrades to an
52
+ * empty record. */
53
+ export declare function parseExpansionRecord(raw: string | null | undefined): Record<string, boolean>;
54
+ /** Parse one raw read of the HOST view state (`dsh.workspace.view.v5`) down
55
+ * to just its `groupExpansion` map — same defensiveness as
56
+ * {@link parseExpansionRecord}. */
57
+ export declare function parseHostGroupExpansion(raw: string | null | undefined): Record<string, boolean>;
58
+ /** One plan step: sync the host-recorded `zr~` keys into the plugin record,
59
+ * then plan the clicks. The four rules the sidebar depends on:
60
+ * - a group the HOST has a record for is the user's latest choice — never
61
+ * clicked, its value syncs into the plugin record;
62
+ * - a group with no host record and no plugin record defaults to EXPANDED
63
+ * (the group was showing its sessions before the purge);
64
+ * - a plugin-recorded COLLAPSED group stays collapsed — no click;
65
+ * - non-`zr~` rows are the host's own groups — never touched, never
66
+ * recorded. */
67
+ export declare function planRemoteGroupExpansion(options: {
68
+ /** The host's current `groupExpansion` map (originals and `zr~` keys
69
+ * mixed — only `zr~` keys matter here). */
70
+ hostRecord: Record<string, boolean>;
71
+ /** The plugin's own record, as last persisted. */
72
+ pluginRecord: Record<string, boolean>;
73
+ /** The server group rows currently in the sidebar, in DOM order. */
74
+ rows: GroupRowState[];
75
+ }): ExpansionPlan;
76
+ //# sourceMappingURL=remote-group-expansion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-group-expansion.d.ts","sourceRoot":"","sources":["../../../src/client-data/remote-group-expansion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,+BAA+B,CAAA;AAEtE;2BAC2B;AAC3B,eAAO,MAAM,uBAAuB,0BAA0B,CAAA;AAE9D;;wDAEwD;AACxD,eAAO,MAAM,4BAA4B,MAAM,CAAA;AAE/C,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B;2CACuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,yCAAyC;IACzC,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B;gFAC4E;IAC5E,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB;;+CAE2C;IAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAED;;;mBAGmB;AACnB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAc5F;AAED;;mCAEmC;AACnC,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgB/F;AAED;;;;;;;;iBAQiB;AACjB,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD;+CAC2C;IAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,oEAAoE;IACpE,IAAI,EAAE,aAAa,EAAE,CAAA;CACtB,GAAG,aAAa,CAgChB"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Remote-session status data for the browser half (T34): the poll store
3
+ * behind the two sub-client parts — the title-row connection icon and the
4
+ * composer's readonly banner. Built as a mirror of shares.ts (T33b):
5
+ * browser-import-free so the desktop-gate test and check scripts drive it
6
+ * with a fake fetch.
7
+ *
8
+ * - `parseRemoteStatusBody(body, now)` maps the
9
+ * `GET /_dsh/zen-remote/client/remote-status` body
10
+ * (`{ state, versionMismatch, serverName, closed }`) into a tolerant view;
11
+ * - `describeRemoteStatus(view)` maps one view to the icon's three states —
12
+ * online (lit) / offline (grey; `revoked` / `unpaired` count as offline —
13
+ * the link is not serving either way) / mismatch (yellow, only ever while
14
+ * online) — plus the hover line;
15
+ * - `bannerText(view, sessionId)` picks the composer banner copy for one
16
+ * session: the closed reason (idle / manual / client) outranks the offline
17
+ * line — a closed session stays closed even while the server is down;
18
+ * - `createRemoteStatusStore(fetchImpl, visibility?, pollMs?)` is the
19
+ * subscription store both parts share. There is NO role gate here (unlike
20
+ * shares.ts): both roles register the parts, and the parts subscribe only
21
+ * while a VIRTUAL-id session is on screen — a host page (local sessions
22
+ * only) never opens a subscription, so nothing polls. A failed GET fails
23
+ * exactly its own round; the poll cadence is visibility-shaped like the
24
+ * shares store's;
25
+ * - `subscribeIfVirtual(store, sessionId, listener)` is the subscribe face
26
+ * the parts hand `useSyncExternalStore`: the virtual-id gate lives HERE,
27
+ * so a local session mounts without ever opening a subscription;
28
+ * - `getRemoteStatusStore()` is the page-wide singleton.
29
+ */
30
+ /** Same-origin client route feeding this store (host half: T34,
31
+ * src/client-routes.ts). */
32
+ export declare const REMOTE_STATUS_ROUTE = "/_dsh/zen-remote/client/remote-status";
33
+ /** Same-origin client route closing one remote session from this machine. */
34
+ export declare const CLIENT_UNSHARE_ROUTE = "/_dsh/zen-remote/client/unshare";
35
+ /** The relay's serving state, as the route words it. */
36
+ export type RemoteStatusState = 'online' | 'offline' | 'revoked' | 'unpaired';
37
+ /** Why the server closed a session's remote access. */
38
+ export type RemoteClosedReason = 'manual' | 'client' | 'idle';
39
+ /** One parsed status body, stamped with the parse time for future decay. */
40
+ export interface RemoteStatusView {
41
+ state: RemoteStatusState;
42
+ versionMismatch: boolean;
43
+ serverName: string;
44
+ closed: Readonly<Record<string, RemoteClosedReason>>;
45
+ /** When this view was parsed off a GET body. */
46
+ asOf: number;
47
+ }
48
+ /** Everything the parts read off the store, one frozen object per change. */
49
+ export interface RemoteStatusSnapshot {
50
+ /** One GET has answered ok — parts render nothing before this. */
51
+ ready: boolean;
52
+ view: RemoteStatusView | undefined;
53
+ }
54
+ /** Parse one GET body tolerantly: a garbage shape is "not online yet", a
55
+ * garbage field degrades to its default — never a throw into the polling
56
+ * loop. */
57
+ export declare function parseRemoteStatusBody(body: unknown, now: number): RemoteStatusView;
58
+ /** The locale keys `describeRemoteStatus` needs. */
59
+ export type RemoteStatusTextKey = 'remoteStatusOnline' | 'remoteStatusOffline' | 'remoteStatusMismatch' | 'remoteStatusRevoked' | 'remoteStatusUnpaired';
60
+ /** Minimal shape of the framework `t` seat over the plugin's namespace. */
61
+ export type RemoteStatusFormatter = (key: RemoteStatusTextKey) => string;
62
+ /** Default formatter: the plugin's Chinese dictionary. Components pass their
63
+ * real framework `t`; this serves the pure-function callers (tests, check
64
+ * scripts). */
65
+ export declare function createZhRemoteStatusFormatter(): RemoteStatusFormatter;
66
+ /** The icon's states and its hover line (T34, refined by T34-fix): online
67
+ * (lit), offline (grey, reconnecting), mismatch (yellow, only ever while
68
+ * online — an offline link outranks it), and `revoked` / `unpaired` as
69
+ * states of their OWN (T34-fix) — the hover and the click say the precise
70
+ * word, never "reconnecting", because neither recovers on its own. */
71
+ export interface RemoteStatusDescription {
72
+ state: 'online' | 'offline' | 'mismatch' | 'revoked' | 'unpaired';
73
+ hoverText: string;
74
+ }
75
+ export declare function describeRemoteStatus(view: RemoteStatusView | undefined | null, t?: RemoteStatusFormatter): RemoteStatusDescription;
76
+ /** The locale keys `bannerText` needs. */
77
+ export type RemoteBannerTextKey = 'remoteBannerOffline' | 'remoteBannerRevoked' | 'remoteBannerUnpaired' | 'remoteBannerClosedIdle' | 'remoteBannerClosedManual' | 'remoteBannerClosedClient';
78
+ export type RemoteBannerFormatter = (key: RemoteBannerTextKey) => string;
79
+ /**
80
+ * The composer banner copy for one virtual session (T34): the session's
81
+ * closed reason — if the server closed this session — outranks the
82
+ * link-level lines (offline, T41a-fix2's revoked / unpaired); a merely
83
+ * offline link reads the temporarily-readonly copy, and a revoked token or
84
+ * an unpaired client reads the "not coming back on its own" copy — both
85
+ * stand a banner AND disable the input (the component raises its composer
86
+ * block from whatever this returns), since neither recovers without the
87
+ * settings page. `undefined` when nothing applies (online and not closed):
88
+ * no banner.
89
+ */
90
+ export declare function bannerText(view: RemoteStatusView | undefined | null, sessionId: string, t?: RemoteBannerFormatter): string | undefined;
91
+ /** Whether the page is currently visible — the same seam shares.ts uses to
92
+ * keep the poll cadence visibility-shaped (testable via injection). */
93
+ export interface VisibilitySource {
94
+ visible(): boolean;
95
+ subscribe(listener: () => void): () => void;
96
+ }
97
+ /** The real source: `visibilitychange` off `document` (Node: always visible,
98
+ * never notifying). */
99
+ export declare const documentVisibility: VisibilitySource;
100
+ /** How one `client/unshare` POST ended. A refused action carries the
101
+ * backend's error `code` when it sent one (`not-shared`, `remote-mismatch`,
102
+ * …). */
103
+ export type RemoteUnshareOutcome = {
104
+ ok: true;
105
+ } | {
106
+ ok: false;
107
+ code?: string;
108
+ message?: string;
109
+ };
110
+ /** The store face the two T34 parts share. */
111
+ export interface RemoteStatusStore {
112
+ /** The current snapshot — a stable frozen reference until the next change. */
113
+ getSnapshot(): RemoteStatusSnapshot;
114
+ /** Observe snapshot replacements; polling runs while at least one listener
115
+ * is attached AND the page is visible. */
116
+ subscribe(listener: () => void): () => void;
117
+ /** GET now (latest-wins). @returns whether an ok body landed. */
118
+ refresh(): Promise<boolean>;
119
+ /** POST client/unshare for one VIRTUAL session id, then refresh.
120
+ * @returns the action's outcome. */
121
+ unshare(sessionId: string): Promise<RemoteUnshareOutcome>;
122
+ }
123
+ /** Poll cadence while the page is visible and at least one part is mounted
124
+ * (T34: 15 秒). */
125
+ export declare const REMOTE_STATUS_POLL_MS = 15000;
126
+ /**
127
+ * Build one store over an injectable fetch and visibility source — the
128
+ * shares-store discipline: latest-wins (an earlier request answering late
129
+ * never overwrites a newer table), every GET failure fails its own round,
130
+ * the timer is real while visible and gone while hidden, and becoming
131
+ * visible pulls once immediately. `pollMs` exists for tests: the shipped
132
+ * cadence is far too slow to observe.
133
+ */
134
+ export declare function createRemoteStatusStore(fetchImpl: typeof fetch, visibility?: VisibilitySource, pollMs?: number): RemoteStatusStore;
135
+ /**
136
+ * The subscribe face both T34 parts hand `useSyncExternalStore`: a VIRTUAL-id
137
+ * session subscribes to the store — the subscription is what keeps it
138
+ * polling — while a local session gets a no-op, so a page showing only local
139
+ * sessions (a host's own view of itself) never opens a subscription and never
140
+ * sends a remote-status request. Pure over (store, sessionId) so the
141
+ * desktop-gate test drives it with a counting fake fetch.
142
+ */
143
+ export declare function subscribeIfVirtual(store: RemoteStatusStore, sessionId: string, listener: () => void): () => void;
144
+ /** The page-wide store every registered part reads — one poll loop no
145
+ * matter how many of the icon and banner parts are mounted at once. Created
146
+ * lazily over the real fetch, so check scripts never construct it. */
147
+ export declare function getRemoteStatusStore(): RemoteStatusStore;
148
+ //# sourceMappingURL=remote-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-status.d.ts","sourceRoot":"","sources":["../../../src/client-data/remote-status.ts"],"names":[],"mappings":"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"}