dsh-multi-device-config-sync 0.0.0-stage → 1.6.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.
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-profile-gist-sync-plus
3
+ name: dsh-multi-device-config-sync
package/icon.svg ADDED
@@ -0,0 +1,19 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Multi-device config sync">
2
+ <defs>
3
+ <linearGradient id="dcsx-sky" x1="0" y1="0" x2="0" y2="1">
4
+ <stop offset="0" stop-color="#4f8ff7"/>
5
+ <stop offset="1" stop-color="#2b62d6"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="4" y="4" width="56" height="56" rx="14" fill="url(#dcsx-sky)"/>
9
+ <path d="M22 27a9 9 0 0 1 17.6-2.6A7.2 7.2 0 0 1 44 38.4H23.4A6.2 6.2 0 0 1 22 27Z"
10
+ fill="#ffffff" opacity="0.95"/>
11
+ <g stroke="#1f4fb0" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round" fill="none">
12
+ <path d="M32 52V40"/>
13
+ <path d="M27 45.5 32 40l5 5.5"/>
14
+ </g>
15
+ <g stroke="#ffffff" stroke-width="3" stroke-linecap="round" fill="none" opacity="0.9">
16
+ <path d="M18 46h6"/>
17
+ <path d="M40 46h6"/>
18
+ </g>
19
+ </svg>
package/index.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Host half of dsh-multi-device-config-sync.
3
+ *
4
+ * The settings page and the `config_backup_plus` agent tool share the backup
5
+ * format and Gist transport. The combined restore-and-install flow belongs to
6
+ * the settings page; the agent tool never installs packages.
7
+ *
8
+ * `webServer` is a hard dependency — without it there is no settings page to
9
+ * serve. `tools` and `connection` are read optionally, so the plugin still
10
+ * activates on a host that publishes neither.
11
+ */
12
+ import { registerRoutes } from './lib/routes.js'
13
+ import { registerTool } from './lib/tool.js'
14
+ import { rememberProfile } from './lib/backup.js'
15
+
16
+ export const inject = ['webServer']
17
+
18
+ /**
19
+ * The profile this process is actually working on.
20
+ *
21
+ * A plugin cannot assume the profile is in the environment: DSH Desktop starts
22
+ * the host as `... dsh-desktop-host ... <profile directory> ...` with no
23
+ * profile variables at all (the `DSH_*` a shell tool sees are injected per
24
+ * call). The launcher does publish `profileContext`, whose `name`/`dir` are
25
+ * read defensively here — undocumented extras, so every field is checked and a
26
+ * bad shape is ignored rather than trusted. `lib/backup.js` falls back to the
27
+ * environment, the host's argument list, and the profile that has this plugin
28
+ * installed.
29
+ */
30
+ function reportProfile(ctx) {
31
+ let context = null
32
+ try {
33
+ context = ctx.get('profileContext')
34
+ } catch {
35
+ // A host without this service is normal: lib/backup.js has other sources.
36
+ return null
37
+ }
38
+ if (context === null || typeof context !== 'object') return null
39
+ const name = typeof context.name === 'string' ? context.name.trim() : ''
40
+ const dir = typeof context.dir === 'string' ? context.dir.trim() : ''
41
+ if (dir === '') return null
42
+ return rememberProfile({ name, dir })
43
+ }
44
+
45
+ export function apply(ctx) {
46
+ // A plain call, NOT ctx.effect: remembering where the profile is creates no
47
+ // resource, and an effect callback must return a disposer — Cordis fails the
48
+ // whole activation with "Invalid effect" when one returns anything else.
49
+ reportProfile(ctx)
50
+ ctx.effect(() => registerRoutes(ctx), 'dsh-multi-device-config-sync: HTTP routes')
51
+ ctx.effect(() => registerTool(ctx), 'dsh-multi-device-config-sync: config_backup_plus tool')
52
+ }