@tiuxo/opencode-openrgb 0.1.0 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.1] - 2026-11-10
11
+
12
+ ### Fixed
13
+
14
+ - Opened one OpenRGB connection per location rather than one per machine, so a
15
+ single opencode server could run several controllers writing to the same
16
+ devices at once. The shared controller registry was module-level state, but
17
+ opencode gives each location its own module instance, making that scope
18
+ per-location rather than per-process. It now lives on a `globalThis` symbol,
19
+ which is the scope the hardware actually has.
20
+
21
+ 0.1.0 was staged but never released, so no published version carries this bug.
22
+
10
23
  ## [0.1.0] - 2026-11-10
11
24
 
12
25
  Initial release, targeting the opencode 2 plugin API.
@@ -39,5 +52,6 @@ Initial release, targeting the opencode 2 plugin API.
39
52
  plugin's own status colors, which indicates a previous run exited without
40
53
  restoring.
41
54
 
42
- [Unreleased]: https://git.tiuxo.com/brian/opencode-openrgb/compare/v0.1.0...HEAD
55
+ [Unreleased]: https://git.tiuxo.com/brian/opencode-openrgb/compare/v0.1.1...HEAD
56
+ [0.1.1]: https://git.tiuxo.com/brian/opencode-openrgb/releases/tag/v0.1.1
43
57
  [0.1.0]: https://git.tiuxo.com/brian/opencode-openrgb/releases/tag/v0.1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiuxo/opencode-openrgb",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Ambient status lighting for opencode via OpenRGB. Mirrors session state onto your RGB hardware.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
package/src/index.ts CHANGED
@@ -26,13 +26,27 @@ const LOG_PREFIX = "[opencode-openrgb]"
26
26
  * it. Instances share one controller and refcount it: the first caller builds
27
27
  * it, the last one to leave shuts it down. Shutting down on the first unload
28
28
  * instead would darken the lights for every location still running.
29
+ *
30
+ * The registry lives on `globalThis`, not in a module-level variable. opencode
31
+ * loads the plugin once per location and each load gets its own module
32
+ * instance, so module scope is per-location, not per-process: every location
33
+ * would build its own controller and open its own OpenRGB connection.
29
34
  */
30
- let shared: { controller: Controller; refs: number } | null = null
35
+ const SHARED_KEY = Symbol.for("opencode-openrgb.shared")
36
+
37
+ interface Shared {
38
+ controller: Controller
39
+ refs: number
40
+ }
41
+
42
+ type SharedHost = typeof globalThis & { [SHARED_KEY]?: Shared | null }
31
43
 
32
44
  function acquire(options: unknown): Controller | null {
33
- if (shared) {
34
- shared.refs++
35
- return shared.controller
45
+ const host = globalThis as SharedHost
46
+ const existing = host[SHARED_KEY]
47
+ if (existing) {
48
+ existing.refs++
49
+ return existing.controller
36
50
  }
37
51
 
38
52
  const resolved = resolveOptions(options, (message) =>
@@ -41,17 +55,19 @@ function acquire(options: unknown): Controller | null {
41
55
  if (!resolved.enabled) return null
42
56
 
43
57
  const controller = new Controller(resolved)
44
- shared = { controller, refs: 1 }
58
+ host[SHARED_KEY] = { controller, refs: 1 }
45
59
  controller.start()
46
60
  return controller
47
61
  }
48
62
 
49
63
  function release(): void {
64
+ const host = globalThis as SharedHost
65
+ const shared = host[SHARED_KEY]
50
66
  if (!shared) return
51
67
  shared.refs--
52
68
  if (shared.refs > 0) return
53
69
  shared.controller.shutdown()
54
- shared = null
70
+ host[SHARED_KEY] = null
55
71
  }
56
72
 
57
73
  /*