Import lib/index.js

This commit is contained in:
QQ 2026-11-12 14:54:54 +08:00
parent f961e1d7df
commit d5cafbf1a8
1 changed files with 16 additions and 8 deletions

View File

@ -14,10 +14,16 @@
* relies on the DSH-branch schemastery `.volatile()` marker, which a
* bundled private copy would not share with the Loader.
*
* Row config nests per plugin: { remoteSsh: { ... } } reaches the
* remote-ssh plugin; the groups half takes no row config. (Remote-ssh
* connection profiles live in the DSH settings namespace `dsh-remote-ssh`
* either way — merging changes nothing about stored data.)
* The bundle row's config IS the remote-ssh prefs object: the composed
* plugin exports remote-ssh's Config schema (below), so this row owns the
* settings entry the remote-ssh settings face reads and writes (its entry
* id resolves to this bundle's row — see the settings patch in
* scripts/patch-remote-ssh.mjs). The groups half takes no row config.
* (Pre-1.0.2 the row config nested under a `remoteSsh` key and the face
* looked for a `dsh-remote-ssh` entry that a merged install does not
* have, so saving any connection failed with "No configurable plugin
* entry". No bundle-era data was ever stored in the nested shape —
* saving was impossible — so flattening loses nothing.)
*/
import * as groups from './groups.js'
import * as remoteSsh from './remote-ssh/index.js'
@ -31,12 +37,14 @@ export const name = 'workspace-groups-remote'
/** Services required before mounting (union of both halves). */
export const inject = ['webServer', 'subprocess', 'tools', 'workspaceRegistry']
/** The row's settings schema: remote-ssh's own Config (prefs object). */
export const Config = remoteSsh.Config
/** Plugin body: mount both halves on this fiber. */
export function apply(ctx, config = {}) {
const remoteSshConfig = config?.remoteSsh ?? {}
if (typeof remoteSshConfig !== 'object' || remoteSshConfig === null || Array.isArray(remoteSshConfig)) {
throw new Error('workspace-groups-remote: the remoteSsh row config must be an object (it is passed through to @zhangfengshun/dsh-remote-ssh)')
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
throw new Error('workspace-groups-remote: the row config must be an object (it is the @zhangfengshun/dsh-remote-ssh prefs object)')
}
ctx.plugin(groupsPlugin)
ctx.plugin(remoteSshPlugin, remoteSshConfig)
ctx.plugin(remoteSshPlugin, config)
}