dsh-over-ssh 0.1.0 → 0.2.0

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 (250) hide show
  1. package/README.md +19 -17
  2. package/agents/agent-manifest.json +6 -6
  3. package/agents/linux-amd64/dsh-over-ssh-agent +0 -0
  4. package/agents/linux-arm64/dsh-over-ssh-agent +0 -0
  5. package/lib/client.js +422 -337
  6. package/lib/file-references.js +92 -35
  7. package/lib/fs.js +295 -113
  8. package/lib/index.js +6912 -4330
  9. package/lib/terminal-wrapper.js +9 -4
  10. package/lib/types/src/config.d.ts +156 -9
  11. package/lib/types/src/file-references.d.ts +0 -1
  12. package/lib/types/src/host/app/backend.d.ts +44 -3
  13. package/lib/types/src/host/app/recycle-bin/recycle-bin-contract.d.ts +0 -1
  14. package/lib/types/src/host/app/recycle-bin/recycle-bin-service.d.ts +0 -1
  15. package/lib/types/src/host/app/session-admin/session-admin-contract.d.ts +12 -1
  16. package/lib/types/src/host/app/session-admin/session-admin-service.d.ts +0 -1
  17. package/lib/types/src/host/app/transport/transport-selector.d.ts +0 -1
  18. package/lib/types/src/host/app/transport/transport-service.d.ts +0 -1
  19. package/lib/types/src/host/domain/capability.d.ts +0 -1
  20. package/lib/types/src/host/domain/errors.d.ts +0 -1
  21. package/lib/types/src/host/domain/roots/connection.d.ts +0 -1
  22. package/lib/types/src/host/domain/roots/root.d.ts +24 -9
  23. package/lib/types/src/host/domain/roots/session-roots.d.ts +23 -1
  24. package/lib/types/src/host/domain/roots/ssh-config.d.ts +0 -1
  25. package/lib/types/src/host/domain/session/session-admin.d.ts +0 -1
  26. package/lib/types/src/host/domain/transfer/recycle-bin.d.ts +0 -1
  27. package/lib/types/src/host/domain/transfer/transfer.d.ts +0 -1
  28. package/lib/types/src/host/infra/transport/agent/agent-installer.d.ts +0 -1
  29. package/lib/types/src/host/infra/transport/forward.d.ts +75 -0
  30. package/lib/types/src/host/infra/transport/ssh/ssh2-transport.d.ts +5 -1
  31. package/lib/types/src/host/infra/transport/transport-base.d.ts +0 -1
  32. package/lib/types/src/host/infra/transport/transport.d.ts +42 -2
  33. package/lib/types/src/host/integration/agent/agent-preflight.d.ts +0 -1
  34. package/lib/types/src/host/integration/fs/file-reference-provider.d.ts +0 -1
  35. package/lib/types/src/host/integration/fs/fs-provider.d.ts +18 -3
  36. package/lib/types/src/host/integration/transfer/transfer-service.d.ts +0 -1
  37. package/lib/types/src/index.d.ts +23 -1
  38. package/lib/types/src/local-bridge-refs.d.ts +0 -1
  39. package/lib/types/src/local-bridge.d.ts +0 -1
  40. package/lib/types/src/shared/root-keys.d.ts +120 -0
  41. package/lib/types/src/wiring/helpers.d.ts +0 -1
  42. package/package.json +5 -3
  43. package/lib/types/src/client/controls.d.ts +0 -131
  44. package/lib/types/src/client/core/card-focus-trap.d.ts +0 -45
  45. package/lib/types/src/client/core/controls.d.ts +0 -164
  46. package/lib/types/src/client/core/latest.d.ts +0 -48
  47. package/lib/types/src/client/core/locale.d.ts +0 -38
  48. package/lib/types/src/client/core/message.d.ts +0 -37
  49. package/lib/types/src/client/core/panel-model.d.ts +0 -134
  50. package/lib/types/src/client/core/portal.d.ts +0 -266
  51. package/lib/types/src/client/core/remote.d.ts +0 -84
  52. package/lib/types/src/client/core/styles.d.ts +0 -458
  53. package/lib/types/src/client/file-tree-io.d.ts +0 -19
  54. package/lib/types/src/client/file-tree.d.ts +0 -271
  55. package/lib/types/src/client/flows/directory-browser.d.ts +0 -587
  56. package/lib/types/src/client/flows/session-directory.d.ts +0 -415
  57. package/lib/types/src/client/flows/workspace-directory-flow.d.ts +0 -480
  58. package/lib/types/src/client/locale.d.ts +0 -31
  59. package/lib/types/src/client/panel-model.d.ts +0 -37
  60. package/lib/types/src/client/panel.d.ts +0 -77
  61. package/lib/types/src/client/roots/connection-test.d.ts +0 -69
  62. package/lib/types/src/client/roots/roots-panel-state.d.ts +0 -307
  63. package/lib/types/src/client/roots/roots-panel-view.d.ts +0 -280
  64. package/lib/types/src/client/roots/roots-panel.d.ts +0 -364
  65. package/lib/types/src/client/roots/transfer-panel-view.d.ts +0 -35
  66. package/lib/types/src/client/roots/transfer-panel.d.ts +0 -241
  67. package/lib/types/src/client/roots/transfer-progress.d.ts +0 -67
  68. package/lib/types/src/client/roots-panel-view.d.ts +0 -236
  69. package/lib/types/src/client/roots-panel.d.ts +0 -347
  70. package/lib/types/src/client/session/session-panel-view.d.ts +0 -336
  71. package/lib/types/src/client/session/session-panel.d.ts +0 -322
  72. package/lib/types/src/client/session/session-remote-mark.d.ts +0 -110
  73. package/lib/types/src/client/session/session-row-actions.d.ts +0 -398
  74. package/lib/types/src/client/session-panel.d.ts +0 -152
  75. package/lib/types/src/client/styles.d.ts +0 -252
  76. package/lib/types/src/client/workspace-directory-flow.d.ts +0 -342
  77. package/lib/types/src/fs.d.ts +0 -46
  78. package/lib/types/src/host/app/recycle-bin/recycle-bin-move.d.ts +0 -18
  79. package/lib/types/src/host/app/recycle-bin/recycle-bin-world.d.ts +0 -38
  80. package/lib/types/src/host/app/recycle-bin-contract.d.ts +0 -215
  81. package/lib/types/src/host/app/recycle-bin-move.d.ts +0 -18
  82. package/lib/types/src/host/app/recycle-bin-service.d.ts +0 -45
  83. package/lib/types/src/host/app/recycle-bin-world.d.ts +0 -35
  84. package/lib/types/src/host/app/roots/roots-api-connections.d.ts +0 -49
  85. package/lib/types/src/host/app/roots/roots-api-contract.d.ts +0 -369
  86. package/lib/types/src/host/app/roots/roots-api-directories.d.ts +0 -13
  87. package/lib/types/src/host/app/roots/roots-api-http.d.ts +0 -77
  88. package/lib/types/src/host/app/roots/roots-api-long-poll.d.ts +0 -130
  89. package/lib/types/src/host/app/roots/roots-api-projections.d.ts +0 -102
  90. package/lib/types/src/host/app/roots/roots-api-roots.d.ts +0 -13
  91. package/lib/types/src/host/app/roots/roots-api-state.d.ts +0 -22
  92. package/lib/types/src/host/app/roots/roots-api-transfers.d.ts +0 -26
  93. package/lib/types/src/host/app/roots/roots-api.d.ts +0 -55
  94. package/lib/types/src/host/app/roots/user-roots.d.ts +0 -552
  95. package/lib/types/src/host/app/roots-api-connections.d.ts +0 -49
  96. package/lib/types/src/host/app/roots-api-contract.d.ts +0 -339
  97. package/lib/types/src/host/app/roots-api-directories.d.ts +0 -13
  98. package/lib/types/src/host/app/roots-api-http.d.ts +0 -77
  99. package/lib/types/src/host/app/roots-api-projections.d.ts +0 -102
  100. package/lib/types/src/host/app/roots-api-roots.d.ts +0 -13
  101. package/lib/types/src/host/app/roots-api-state.d.ts +0 -22
  102. package/lib/types/src/host/app/roots-api-support.d.ts +0 -182
  103. package/lib/types/src/host/app/roots-api-transfers.d.ts +0 -13
  104. package/lib/types/src/host/app/roots-api.d.ts +0 -55
  105. package/lib/types/src/host/app/routed-fs.d.ts +0 -239
  106. package/lib/types/src/host/app/serialize.d.ts +0 -37
  107. package/lib/types/src/host/app/session-admin/session-admin-context.d.ts +0 -36
  108. package/lib/types/src/host/app/session-admin/session-admin-delete.d.ts +0 -34
  109. package/lib/types/src/host/app/session-admin-context.d.ts +0 -36
  110. package/lib/types/src/host/app/session-admin-contract.d.ts +0 -214
  111. package/lib/types/src/host/app/session-admin-delete.d.ts +0 -34
  112. package/lib/types/src/host/app/session-admin-service.d.ts +0 -38
  113. package/lib/types/src/host/app/takeover/takeover-plan.d.ts +0 -227
  114. package/lib/types/src/host/app/takeover/takeover-rows.d.ts +0 -55
  115. package/lib/types/src/host/app/transport-selector.d.ts +0 -98
  116. package/lib/types/src/host/app/transport-service.d.ts +0 -75
  117. package/lib/types/src/host/app/user-roots.d.ts +0 -461
  118. package/lib/types/src/host/domain/bin-location.d.ts +0 -79
  119. package/lib/types/src/host/domain/connection.d.ts +0 -95
  120. package/lib/types/src/host/domain/glob-pattern.d.ts +0 -62
  121. package/lib/types/src/host/domain/literal-text.d.ts +0 -63
  122. package/lib/types/src/host/domain/path-grammar.d.ts +0 -84
  123. package/lib/types/src/host/domain/recycle-bin.d.ts +0 -337
  124. package/lib/types/src/host/domain/root.d.ts +0 -74
  125. package/lib/types/src/host/domain/roots/bin-location.d.ts +0 -91
  126. package/lib/types/src/host/domain/roots/route-table.d.ts +0 -102
  127. package/lib/types/src/host/domain/route-table.d.ts +0 -80
  128. package/lib/types/src/host/domain/session/terminal-target.d.ts +0 -136
  129. package/lib/types/src/host/domain/session-admin.d.ts +0 -330
  130. package/lib/types/src/host/domain/shell.d.ts +0 -47
  131. package/lib/types/src/host/domain/ssh-config.d.ts +0 -73
  132. package/lib/types/src/host/domain/terminal-target.d.ts +0 -132
  133. package/lib/types/src/host/domain/tool-requests.d.ts +0 -369
  134. package/lib/types/src/host/domain/transfer.d.ts +0 -260
  135. package/lib/types/src/host/infra/backend/local-backend.d.ts +0 -84
  136. package/lib/types/src/host/infra/backend/local-version.d.ts +0 -43
  137. package/lib/types/src/host/infra/backend/platform-local-backend.d.ts +0 -89
  138. package/lib/types/src/host/infra/backend/remote-backend.d.ts +0 -239
  139. package/lib/types/src/host/infra/cache/lru.d.ts +0 -52
  140. package/lib/types/src/host/infra/cache/versioned.d.ts +0 -77
  141. package/lib/types/src/host/infra/temp-name.d.ts +0 -19
  142. package/lib/types/src/host/infra/transport/agent/agent-protocol-client.d.ts +0 -132
  143. package/lib/types/src/host/infra/transport/agent/agent-protocol-codec.d.ts +0 -140
  144. package/lib/types/src/host/infra/transport/agent/agent-protocol-errors.d.ts +0 -41
  145. package/lib/types/src/host/infra/transport/agent/agent-protocol-frames.d.ts +0 -197
  146. package/lib/types/src/host/infra/transport/agent/agent-protocol-types.d.ts +0 -564
  147. package/lib/types/src/host/infra/transport/agent/agent-transport.d.ts +0 -418
  148. package/lib/types/src/host/infra/transport/agent-installer.d.ts +0 -121
  149. package/lib/types/src/host/infra/transport/agent-protocol-client.d.ts +0 -123
  150. package/lib/types/src/host/infra/transport/agent-protocol-codec.d.ts +0 -131
  151. package/lib/types/src/host/infra/transport/agent-protocol-errors.d.ts +0 -41
  152. package/lib/types/src/host/infra/transport/agent-protocol-frames.d.ts +0 -197
  153. package/lib/types/src/host/infra/transport/agent-protocol-types.d.ts +0 -509
  154. package/lib/types/src/host/infra/transport/agent-transport.d.ts +0 -353
  155. package/lib/types/src/host/infra/transport/alias-transport.d.ts +0 -206
  156. package/lib/types/src/host/infra/transport/askpass-fs.d.ts +0 -20
  157. package/lib/types/src/host/infra/transport/askpass.d.ts +0 -133
  158. package/lib/types/src/host/infra/transport/command-pool.d.ts +0 -61
  159. package/lib/types/src/host/infra/transport/fs-commands.d.ts +0 -140
  160. package/lib/types/src/host/infra/transport/git-status-route.d.ts +0 -63
  161. package/lib/types/src/host/infra/transport/git-status.d.ts +0 -101
  162. package/lib/types/src/host/infra/transport/node-spawn.d.ts +0 -26
  163. package/lib/types/src/host/infra/transport/session-window.d.ts +0 -51
  164. package/lib/types/src/host/infra/transport/shell-quote.d.ts +0 -59
  165. package/lib/types/src/host/infra/transport/ssh/alias-transport.d.ts +0 -206
  166. package/lib/types/src/host/infra/transport/ssh/askpass-fs.d.ts +0 -20
  167. package/lib/types/src/host/infra/transport/ssh/askpass.d.ts +0 -133
  168. package/lib/types/src/host/infra/transport/ssh/shell-quote.d.ts +0 -62
  169. package/lib/types/src/host/infra/transport/ssh/ssh-argv.d.ts +0 -43
  170. package/lib/types/src/host/infra/transport/ssh-argv.d.ts +0 -43
  171. package/lib/types/src/host/infra/transport/ssh2-transport.d.ts +0 -302
  172. package/lib/types/src/host/integration/agent/agent-install-io.d.ts +0 -33
  173. package/lib/types/src/host/integration/agent/askpass-registry.d.ts +0 -66
  174. package/lib/types/src/host/integration/agent-install-io.d.ts +0 -33
  175. package/lib/types/src/host/integration/agent-preflight.d.ts +0 -56
  176. package/lib/types/src/host/integration/anchor-directory.d.ts +0 -56
  177. package/lib/types/src/host/integration/askpass-registry.d.ts +0 -59
  178. package/lib/types/src/host/integration/bin-root-resolver.d.ts +0 -81
  179. package/lib/types/src/host/integration/connection-test.d.ts +0 -73
  180. package/lib/types/src/host/integration/file-reference-provider.d.ts +0 -115
  181. package/lib/types/src/host/integration/fs/git-status-wiring.d.ts +0 -21
  182. package/lib/types/src/host/integration/fs/platform-errors.d.ts +0 -94
  183. package/lib/types/src/host/integration/fs/remote-file-tools.d.ts +0 -369
  184. package/lib/types/src/host/integration/fs/remote-index.d.ts +0 -177
  185. package/lib/types/src/host/integration/fs-provider.d.ts +0 -226
  186. package/lib/types/src/host/integration/lsp/lsp-framing.d.ts +0 -38
  187. package/lib/types/src/host/integration/lsp/lsp-registry.d.ts +0 -67
  188. package/lib/types/src/host/integration/lsp/lsp-session.d.ts +0 -130
  189. package/lib/types/src/host/integration/management-tools.d.ts +0 -64
  190. package/lib/types/src/host/integration/recycle-bin-service.d.ts +0 -247
  191. package/lib/types/src/host/integration/remote/connection-test.d.ts +0 -73
  192. package/lib/types/src/host/integration/remote/remote-face.d.ts +0 -127
  193. package/lib/types/src/host/integration/remote/remote-tool-backend.d.ts +0 -108
  194. package/lib/types/src/host/integration/remote-face.d.ts +0 -127
  195. package/lib/types/src/host/integration/remote-file-tools.d.ts +0 -241
  196. package/lib/types/src/host/integration/remote-home.d.ts +0 -69
  197. package/lib/types/src/host/integration/remote-index.d.ts +0 -165
  198. package/lib/types/src/host/integration/remote-job-tools.d.ts +0 -295
  199. package/lib/types/src/host/integration/remote-tool-backend.d.ts +0 -97
  200. package/lib/types/src/host/integration/remote-tools.d.ts +0 -206
  201. package/lib/types/src/host/integration/root-registry.d.ts +0 -115
  202. package/lib/types/src/host/integration/roots/anchor-directory.d.ts +0 -56
  203. package/lib/types/src/host/integration/roots/bin-root-resolver.d.ts +0 -81
  204. package/lib/types/src/host/integration/roots/remote-home.d.ts +0 -69
  205. package/lib/types/src/host/integration/roots/root-registry.d.ts +0 -144
  206. package/lib/types/src/host/integration/roots/roots-wiring.d.ts +0 -219
  207. package/lib/types/src/host/integration/roots/session-root-index.d.ts +0 -52
  208. package/lib/types/src/host/integration/roots-api.d.ts +0 -407
  209. package/lib/types/src/host/integration/roots-wiring.d.ts +0 -211
  210. package/lib/types/src/host/integration/session/session-api.d.ts +0 -88
  211. package/lib/types/src/host/integration/session/session-bin-lock.d.ts +0 -80
  212. package/lib/types/src/host/integration/session/session-header.d.ts +0 -151
  213. package/lib/types/src/host/integration/session/session-labels.d.ts +0 -56
  214. package/lib/types/src/host/integration/session/session-route-wiring.d.ts +0 -50
  215. package/lib/types/src/host/integration/session-admin-service.d.ts +0 -236
  216. package/lib/types/src/host/integration/session-api.d.ts +0 -81
  217. package/lib/types/src/host/integration/session-bin-lock.d.ts +0 -80
  218. package/lib/types/src/host/integration/session-header.d.ts +0 -118
  219. package/lib/types/src/host/integration/session-labels.d.ts +0 -56
  220. package/lib/types/src/host/integration/session-route-wiring.d.ts +0 -50
  221. package/lib/types/src/host/integration/session-scope.d.ts +0 -113
  222. package/lib/types/src/host/integration/session-tools.d.ts +0 -44
  223. package/lib/types/src/host/integration/strict-arguments.d.ts +0 -79
  224. package/lib/types/src/host/integration/takeover/takeover-api.d.ts +0 -62
  225. package/lib/types/src/host/integration/takeover/takeover-route-wiring.d.ts +0 -60
  226. package/lib/types/src/host/integration/takeover/takeover-service.d.ts +0 -167
  227. package/lib/types/src/host/integration/terminal-manifest.d.ts +0 -94
  228. package/lib/types/src/host/integration/tools/management-tools.d.ts +0 -245
  229. package/lib/types/src/host/integration/tools/remote-job-tools.d.ts +0 -316
  230. package/lib/types/src/host/integration/tools/remote-lsp-tools.d.ts +0 -43
  231. package/lib/types/src/host/integration/tools/remote-tools.d.ts +0 -236
  232. package/lib/types/src/host/integration/tools/session-target.d.ts +0 -52
  233. package/lib/types/src/host/integration/tools/session-tools.d.ts +0 -46
  234. package/lib/types/src/host/integration/tools/strict-arguments.d.ts +0 -79
  235. package/lib/types/src/host/integration/tools/terminal-manifest.d.ts +0 -94
  236. package/lib/types/src/host/integration/transfer/remote-copy.d.ts +0 -66
  237. package/lib/types/src/host/integration/transfer/transfer-adapters.d.ts +0 -48
  238. package/lib/types/src/host/integration/transfer/transfer-tracker.d.ts +0 -106
  239. package/lib/types/src/host/integration/transfer-adapters.d.ts +0 -44
  240. package/lib/types/src/host/integration/transfer-service.d.ts +0 -164
  241. package/lib/types/src/host/integration/transfer-tracker.d.ts +0 -106
  242. package/lib/types/src/host/integration/user-roots.d.ts +0 -461
  243. package/lib/types/src/wiring/connections.d.ts +0 -189
  244. package/lib/types/src/wiring/fs.d.ts +0 -13
  245. package/lib/types/src/wiring/install-memo.d.ts +0 -32
  246. package/lib/types/src/wiring/legacy-dirs.d.ts +0 -62
  247. package/lib/types/src/wiring/package-paths.d.ts +0 -35
  248. package/lib/types/src/wiring/roots.d.ts +0 -21
  249. package/lib/types/src/wiring/state-dir.d.ts +0 -29
  250. package/lib/types/src/wiring/tools.d.ts +0 -35
@@ -1,271 +0,0 @@
1
- /**
2
- * The remote file tree (FR-2.2.1 / FR-2.2.2).
3
- *
4
- * Why this is a pure module plus a thin view: the interesting behaviour is not the markup, it is **which
5
- * level is loaded, what is expanded, what the last failure was, and what a mutation invalidates**. That is a
6
- * state machine, and a state machine that lives inside a component cannot be tested in this repository (the
7
- * view tests call the section functions directly, outside a React render — see `controls.ts`).
8
- *
9
- * Three rules it inherits from the rest of the client half:
10
- *
11
- * - **Every call is injected** (红线 3): the tests drive the tree with a scripted IO and no server.
12
- * - **Nothing is assumed about the wire**: rows are narrowed field by field, and an unknown kind is a file.
13
- * - **A mutation refreshes what it invalidated** rather than guessing: after a rename or a delete the parent
14
- * directory is re-listed from the host, because a locally patched tree is a second source of truth that
15
- * drifts the first time the user has another window open.
16
- *
17
- * @module dsh-remote-workspace/client/file-tree
18
- */
19
- import { type ReactNode } from 'react';
20
- import type { ApiResult } from './roots-panel.ts';
21
- /** One row of a remote directory, as this tree renders it. */
22
- export interface RemoteFileRow {
23
- readonly name: string;
24
- readonly kind: 'directory' | 'file' | 'symlink';
25
- }
26
- /** One loaded directory level. */
27
- export interface RemoteFileLevel {
28
- /** Absolute path the host actually listed (it resolves an empty request to the login user's home). */
29
- readonly path: string;
30
- readonly entries: readonly RemoteFileRow[];
31
- /** True when the host cut the listing at its own bound. */
32
- readonly truncated: boolean;
33
- }
34
- /** Where the tree is rooted. */
35
- export interface FileTreeRoot {
36
- readonly connectionId: string;
37
- readonly path: string;
38
- }
39
- /** What the tree asks the host for. Injected, so tests run with no server. */
40
- export interface FileTreeIo {
41
- list(input: {
42
- readonly connectionId: string;
43
- readonly path: string;
44
- }): Promise<ApiResult<RemoteFileLevel>>;
45
- mkdir(input: {
46
- readonly connectionId: string;
47
- readonly path: string;
48
- readonly recursive: boolean;
49
- }): Promise<ApiResult<unknown>>;
50
- rename(input: {
51
- readonly connectionId: string;
52
- readonly from: string;
53
- readonly to: string;
54
- readonly createParents: boolean;
55
- }): Promise<ApiResult<unknown>>;
56
- remove(input: {
57
- readonly connectionId: string;
58
- readonly path: string;
59
- readonly recursive: boolean;
60
- }): Promise<ApiResult<unknown>>;
61
- }
62
- /** A mutation the tree can ask for; `undefined` means nothing is being edited. */
63
- export type FileTreeDraft = {
64
- readonly kind: 'new-directory';
65
- readonly parent: string;
66
- readonly name: string;
67
- } | {
68
- readonly kind: 'new-file';
69
- readonly parent: string;
70
- readonly name: string;
71
- } | {
72
- readonly kind: 'rename';
73
- readonly path: string;
74
- readonly name: string;
75
- } | {
76
- readonly kind: 'remove';
77
- readonly path: string;
78
- readonly recursive: boolean;
79
- };
80
- /** Everything the tree renders from. */
81
- export interface FileTreeState {
82
- readonly root: FileTreeRoot;
83
- /** Loaded levels, keyed by absolute path. */
84
- readonly levels: ReadonlyMap<string, RemoteFileLevel>;
85
- /** Paths whose children are shown. */
86
- readonly expanded: ReadonlySet<string>;
87
- /** Levels with a request in flight. */
88
- readonly loading: ReadonlySet<string>;
89
- /** Per-level failures, keyed by the level that failed. */
90
- readonly errors: ReadonlyMap<string, string>;
91
- /** The open mutation form, if any. */
92
- readonly draft?: FileTreeDraft;
93
- /** The last mutation failure, shown above the tree. */
94
- readonly actionError?: string;
95
- /** True while a mutation is in flight. */
96
- readonly busy: boolean;
97
- }
98
- /** Start a tree at a root; nothing is loaded yet. */
99
- export declare function initialFileTreeState(root: FileTreeRoot): FileTreeState;
100
- /** Load a level (the root, or a directory the user opened). */
101
- export declare function fileTreeLoading(state: FileTreeState, path: string): FileTreeState;
102
- /** A level arrived. */
103
- export declare function fileTreeLoaded(state: FileTreeState, path: string, level: RemoteFileLevel): FileTreeState;
104
- /** A level failed; the message is kept **per level**, so one unreadable directory does not blank the tree. */
105
- export declare function fileTreeFailed(state: FileTreeState, path: string, error: string): FileTreeState;
106
- /** Open or close a directory. */
107
- export declare function fileTreeToggled(state: FileTreeState, path: string): FileTreeState;
108
- /** Open a mutation form. */
109
- export declare function fileTreeDraftOpened(state: FileTreeState, draft: FileTreeDraft): FileTreeState;
110
- /** Change the name being typed in an open form. */
111
- export declare function fileTreeDraftRenamed(state: FileTreeState, name: string): FileTreeState;
112
- /** Close the form without doing anything. */
113
- export declare function fileTreeDraftClosed(state: FileTreeState): FileTreeState;
114
- /** A mutation started. */
115
- export declare function fileTreeBusy(state: FileTreeState): FileTreeState;
116
- /**
117
- * A mutation succeeded.
118
- *
119
- * The form closes and the affected levels are **dropped**, so the next render re-lists them from the host.
120
- * Dropping rather than patching is deliberate: a locally edited tree would be a second source of truth.
121
- */
122
- export declare function fileTreeSettled(state: FileTreeState, invalidated: readonly string[]): FileTreeState;
123
- /** A mutation failed. */
124
- export declare function fileTreeActionFailed(state: FileTreeState, error: string): FileTreeState;
125
- /**
126
- * Narrow one `list-remote` answer.
127
- *
128
- * Same discipline as `parseRootsSnapshot`: an unknown kind is treated as a **file** rather than dropped, and a
129
- * row with no usable name is dropped. A directory the host reports as something this build does not know would
130
- * otherwise be silently missing from the tree.
131
- *
132
- * @param value - the parsed body.
133
- * @param requested - the path that was asked for, used when the answer names none.
134
- * @returns a level safe to render.
135
- */
136
- export declare function parseRemoteFileLevel(value: unknown, requested: string): RemoteFileLevel;
137
- /** Join a POSIX child onto a POSIX parent, without doubling or dropping the separator. */
138
- export declare function remoteJoin(parent: string, name: string): string;
139
- /** The parent of a POSIX path, or `undefined` at the root (so a caller cannot walk above it). */
140
- export declare function remoteParent(path: string): string | undefined;
141
- /**
142
- * The name a user typed, or the reason it cannot be used.
143
- *
144
- * Refused here rather than at the host because these are *shape* rules the tree can check for free: an empty
145
- * name, a name with a slash (which would silently mean "create a subdirectory"), `.`/`..`, and a leading `-`
146
- * (which some POSIX tools read as an option).
147
- *
148
- * @param name - the typed name.
149
- * @returns the trimmed name, or the reason.
150
- */
151
- export declare function validateRemoteName(name: string): {
152
- readonly ok: true;
153
- readonly value: string;
154
- } | {
155
- readonly ok: false;
156
- readonly reason: 'empty' | 'slash' | 'dot' | 'dash';
157
- };
158
- /**
159
- * The levels a mutation invalidates.
160
- *
161
- * Exported because it is the one piece of this module a reviewer should be able to check by reading: creating
162
- * or deleting `p` changes `p`'s **parent**, and renaming changes the parents of both ends.
163
- *
164
- * @param draft - the mutation.
165
- * @returns the absolute paths whose listings are now stale.
166
- */
167
- export declare function invalidatedBy(draft: FileTreeDraft): readonly string[];
168
- /** The rows of one level, directories first then files, each group by name. */
169
- export declare function sortRows(rows: readonly RemoteFileRow[]): readonly RemoteFileRow[];
170
- /** The stateful half. */
171
- export interface FileTreeController {
172
- readonly getState: () => FileTreeState;
173
- readonly subscribe: (listener: () => void) => () => void;
174
- /** Load the root if it has not been loaded. */
175
- readonly start: () => void;
176
- /** Re-list one level from the host. */
177
- readonly refresh: (path: string) => Promise<void>;
178
- /** Open or close a directory, loading it the first time. */
179
- readonly toggle: (path: string) => Promise<void>;
180
- /** Ask to create something inside a directory. */
181
- readonly askNewDirectory: (parent: string) => void;
182
- readonly askRename: (path: string) => void;
183
- readonly askRemove: (path: string) => void;
184
- /** Change the name in the open form. */
185
- readonly changeName: (name: string) => void;
186
- /** Close the open form. */
187
- readonly cancel: () => void;
188
- /** Commit the open form. */
189
- readonly submit: () => Promise<void>;
190
- readonly dispose: () => void;
191
- }
192
- /**
193
- * Build the tree's controller.
194
- *
195
- * @param options - the injected IO and the root to show.
196
- * @returns the controller a container subscribes to.
197
- */
198
- export declare function createFileTree(options: {
199
- readonly io: FileTreeIo;
200
- readonly root: FileTreeRoot;
201
- }): FileTreeController;
202
- /** The strings the tree renders; passed in so the view needs no dictionary import. */
203
- export interface FileTreeCopy {
204
- readonly title: string;
205
- readonly empty: string;
206
- readonly loading: string;
207
- readonly truncated: string;
208
- readonly newDirectory: string;
209
- readonly rename: string;
210
- readonly remove: string;
211
- readonly refresh: string;
212
- readonly confirmRemove: string;
213
- readonly confirmRemoveTree: string;
214
- readonly accept: string;
215
- readonly cancel: string;
216
- readonly nameLabel: string;
217
- readonly directoryBadge: string;
218
- readonly symlinkBadge: string;
219
- readonly errorEmptyName: string;
220
- readonly errorNameSlash: string;
221
- readonly errorNameDot: string;
222
- readonly errorNameDash: string;
223
- }
224
- /** What the view's controls call. */
225
- export interface FileTreeActions {
226
- readonly onToggle: (path: string) => void;
227
- readonly onRefresh: (path: string) => void;
228
- readonly onNewDirectory: (parent: string) => void;
229
- readonly onRename: (path: string) => void;
230
- readonly onRemove: (path: string) => void;
231
- readonly onNameChange: (name: string) => void;
232
- readonly onCancel: () => void;
233
- readonly onSubmit: () => void;
234
- }
235
- /** One rendered row. */
236
- export interface FileTreeRow {
237
- readonly path: string;
238
- readonly name: string;
239
- readonly depth: number;
240
- readonly isDirectory: boolean;
241
- readonly isSymlink: boolean;
242
- readonly expanded: boolean;
243
- readonly loading: boolean;
244
- readonly error?: string;
245
- }
246
- /**
247
- * Flatten the loaded levels into the rows to render.
248
- *
249
- * Depth-first, directories before files at each level, and a directory's children are only walked when it is
250
- * expanded. A level that is loading but has no cached entries still produces its row (with `loading`), which
251
- * is what makes the spinner appear where the user clicked rather than at the top of the tree.
252
- *
253
- * @param state - the tree state.
254
- * @returns the rows, in display order.
255
- */
256
- export declare function fileTreeRows(state: FileTreeState): readonly FileTreeRow[];
257
- /**
258
- * The tree's markup.
259
- *
260
- * A flat `<ul>` of rows with an indent per depth, because the platform ships no Tree primitive and a nested
261
- * list would make the row controls (rename/delete on hover) reach into parents. Depth is presentation.
262
- *
263
- * @param props - state, copy and callbacks.
264
- * @returns the tree section.
265
- */
266
- export declare function FileTreeSection(props: {
267
- readonly copy: FileTreeCopy;
268
- readonly state: FileTreeState;
269
- readonly actions: FileTreeActions;
270
- }): ReactNode;
271
- //# sourceMappingURL=file-tree.d.ts.map