@open-orpheus/plugin-api 0.0.0 → 0.21.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 (174) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +192 -0
  3. package/dist/client/index.d.ts +37 -0
  4. package/dist/client/index.js +53 -0
  5. package/dist/client/index.js.map +1 -0
  6. package/dist/configuration/host/src/shared/plugin/configuration/index.d.ts +21 -0
  7. package/dist/configuration/index.d.ts +5 -0
  8. package/dist/host/_native/open-orpheus__window.d.ts +35 -17
  9. package/dist/host/src/main/assets.d.ts +2 -0
  10. package/dist/host/src/main/audio/DownloadScheduler.d.ts +2 -2
  11. package/dist/host/src/main/audio/MediaEngine.d.ts +1 -1
  12. package/dist/host/src/main/audio.d.ts +1 -1
  13. package/dist/host/src/main/av3a/Av3aEngine.d.ts +1 -1
  14. package/dist/host/src/main/av3a/Av3aM4aSession.d.ts +1 -1
  15. package/dist/host/src/main/av3a/Av3aPlaybackProcess.d.ts +1 -1
  16. package/dist/host/src/main/av3a/sources.d.ts +2 -2
  17. package/dist/host/src/main/av3a/types.d.ts +1 -1
  18. package/dist/host/src/main/bridge/ipc-main-bridge.d.ts +24 -0
  19. package/dist/host/src/main/bridge/window.d.ts +7 -0
  20. package/dist/host/src/main/cache.d.ts +3 -3
  21. package/dist/host/src/main/calls/desktop.d.ts +1 -1
  22. package/dist/host/src/main/calls/index.d.ts +16 -16
  23. package/dist/host/src/main/calls.d.ts +1 -1
  24. package/dist/host/src/main/channel.d.ts +1 -1
  25. package/dist/host/src/main/database/KeyvSqliteDriver.d.ts +1 -1
  26. package/dist/host/src/main/database.d.ts +1 -1
  27. package/dist/host/src/main/lifecycle.d.ts +15 -6
  28. package/dist/host/src/main/lyrics/DbusLyricsService.d.ts +2 -2
  29. package/dist/host/src/main/lyrics/LyricsDispatcher.d.ts +1 -1
  30. package/dist/host/src/main/lyrics/dbus.d.ts +1 -1
  31. package/dist/host/src/main/lyrics/parse.d.ts +1 -1
  32. package/dist/host/src/main/lyrics.d.ts +1 -1
  33. package/dist/host/src/main/mediaSession.d.ts +1 -1
  34. package/dist/host/src/main/menu/AppMenu.d.ts +3 -3
  35. package/dist/host/src/main/menu/backend/DesktopWindowBackend.d.ts +2 -2
  36. package/dist/host/src/main/menu/backend/MenuBackend.d.ts +3 -3
  37. package/dist/host/src/main/menu/backend/WaylandLayerShellBackend.d.ts +35 -0
  38. package/dist/host/src/main/menu/backend/WaylandOverlayBackend.d.ts +1 -1
  39. package/dist/host/src/main/menu/backend/WaylandPopupBackend.d.ts +2 -2
  40. package/dist/host/src/main/menu/constants.d.ts +2 -0
  41. package/dist/host/src/main/menu/index.d.ts +2 -2
  42. package/dist/host/src/main/menu/patch.d.ts +1 -1
  43. package/dist/host/src/main/menu/skin.d.ts +1 -1
  44. package/dist/host/src/main/menu/surface/BaseWindowMenuSurface.d.ts +15 -3
  45. package/dist/host/src/main/menu/surface/CaptureLayerSurface.d.ts +22 -0
  46. package/dist/host/src/main/menu/surface/MenuSurface.d.ts +1 -1
  47. package/dist/host/src/main/menu/surface/MenuSurfacePath.d.ts +2 -2
  48. package/dist/host/src/main/menu/surface/SurfacePool.d.ts +1 -1
  49. package/dist/host/src/main/menu/workaround.d.ts +9 -3
  50. package/dist/host/src/main/ncae.d.ts +1 -1
  51. package/dist/host/src/main/network/handler.d.ts +1 -1
  52. package/dist/host/src/main/network/interceptor.d.ts +1 -1
  53. package/dist/host/src/main/network/interceptors/anonymous.d.ts +1 -1
  54. package/dist/host/src/main/network/pipeline.d.ts +1 -1
  55. package/dist/host/src/main/pack.d.ts +1 -1
  56. package/dist/host/src/main/packs/SkinPack.d.ts +1 -1
  57. package/dist/host/src/main/packs/WebPack.d.ts +1 -1
  58. package/dist/host/src/main/playback/PlaybackController.d.ts +2 -2
  59. package/dist/host/src/main/playback/PlayerCommandRouter.d.ts +2 -2
  60. package/dist/host/src/main/playback/adapters/MediaSessionAdapter.d.ts +2 -2
  61. package/dist/host/src/main/playback/adapters/MprisAdapter.d.ts +3 -3
  62. package/dist/host/src/main/playback/adapters/NowPlayingAdapter.d.ts +2 -2
  63. package/dist/host/src/main/playback/adapters/SmtcAdapter.d.ts +2 -2
  64. package/dist/host/src/main/playback/modes.d.ts +1 -1
  65. package/dist/host/src/main/playback/types.d.ts +31 -11
  66. package/dist/host/src/main/plugin/assets.d.ts +8 -0
  67. package/dist/host/src/main/plugin/catalog.d.ts +42 -0
  68. package/dist/host/src/main/plugin/discover.d.ts +4 -7
  69. package/dist/host/src/main/plugin/index.d.ts +5 -2
  70. package/dist/host/src/main/plugin/loader.d.ts +68 -21
  71. package/dist/host/src/main/plugin/manager.d.ts +53 -7
  72. package/dist/host/src/main/plugin/metadata.d.ts +13 -3
  73. package/dist/host/src/main/plugin/state.d.ts +16 -6
  74. package/dist/host/src/main/settings.d.ts +17 -2
  75. package/dist/host/src/main/shutdown.d.ts +28 -10
  76. package/dist/host/src/main/skin/dui.d.ts +1 -1
  77. package/dist/host/src/main/update.d.ts +1 -1
  78. package/dist/host/src/main/util/color.d.ts +7 -0
  79. package/dist/host/src/main/window.d.ts +26 -4
  80. package/dist/host/src/main/windows/color-picker.d.ts +3 -0
  81. package/dist/host/src/main/windows/desktop-lyrics.d.ts +2 -2
  82. package/dist/host/src/main/windows/desktop-pet.d.ts +1 -1
  83. package/dist/host/src/main/windows/main.d.ts +1 -1
  84. package/dist/host/src/main/windows/mini-player.d.ts +2 -2
  85. package/dist/host/src/main/windows/music-desktop.d.ts +1 -1
  86. package/dist/host/src/main/windows/package-download.d.ts +1 -1
  87. package/dist/host/src/main/windows/plugin-manager-events.d.ts +7 -0
  88. package/dist/host/src/main/windows/plugin-manager.d.ts +1 -1
  89. package/dist/host/src/main/xeapi.d.ts +1 -6
  90. package/dist/host/src/preload/PlaybackBackend.d.ts +1 -1
  91. package/dist/host/src/preload/Player.d.ts +14 -6
  92. package/dist/host/src/preload/av3a/Av3aPcmPlayer.d.ts +2 -2
  93. package/dist/host/src/preload/av3a/bridge.d.ts +2 -2
  94. package/dist/host/src/preload/av3a/channel.d.ts +2 -2
  95. package/dist/host/src/preload/backends/Av3aPlaybackBackend.d.ts +2 -2
  96. package/dist/host/src/preload/backends/MediaPlaybackBackend.d.ts +1 -1
  97. package/dist/host/src/shared/bridge/constants.d.ts +2 -0
  98. package/dist/host/src/shared/bridge/endpoint.d.ts +29 -0
  99. package/dist/host/src/shared/bridge/hub.d.ts +136 -0
  100. package/dist/host/src/shared/bridge/protocol.d.ts +91 -0
  101. package/dist/host/src/shared/bridge/realm.d.ts +14 -0
  102. package/dist/host/src/shared/bridge/routes.d.ts +37 -0
  103. package/dist/host/src/shared/contracts/av3a-api.d.ts +1 -1
  104. package/dist/host/src/shared/contracts/av3a-process.d.ts +1 -1
  105. package/dist/host/src/shared/contracts/color-picker-api.d.ts +17 -0
  106. package/dist/host/src/shared/contracts/desktop-lyrics-api.d.ts +1 -2
  107. package/dist/host/src/shared/contracts/input-region-api.d.ts +1 -2
  108. package/dist/host/src/shared/contracts/lyrics-api.d.ts +1 -1
  109. package/dist/host/src/shared/contracts/manage-api.d.ts +2 -4
  110. package/dist/host/src/shared/contracts/menu-surface-api.d.ts +35 -0
  111. package/dist/host/src/shared/contracts/mini-player-api.d.ts +1 -1
  112. package/dist/host/src/shared/contracts/plugin-manager-api.d.ts +201 -12
  113. package/dist/host/src/shared/playbackMode.d.ts +1 -1
  114. package/dist/host/src/shared/plugin/cache-bust.d.ts +8 -0
  115. package/dist/host/src/shared/plugin/lifecycle.d.ts +217 -0
  116. package/dist/host/src/{main/plugin/types.d.ts → shared/plugin/realms/main/index.d.ts} +1 -1
  117. package/dist/host/src/shared/plugin/registry.d.ts +42 -5
  118. package/dist/host/src/shared/plugin/runtime-state.d.ts +4 -0
  119. package/dist/host/src/shared/settings/defaults.d.ts +35 -0
  120. package/dist/host/src/shared/settings/index.d.ts +3 -0
  121. package/dist/host/src/shared/settings/keys.d.ts +21 -0
  122. package/dist/host/src/shared/settings/values.d.ts +13 -0
  123. package/dist/host/src/shared/types/desktop-lyrics.d.ts +28 -11
  124. package/dist/host/src/shared/types/menu-surface.d.ts +2 -2
  125. package/dist/host/src/shared/types/menu.d.ts +1 -1
  126. package/dist/host/src/shared/types/mini-player.d.ts +12 -5
  127. package/dist/host/src/shared/types/ncae.d.ts +11 -3
  128. package/dist/host/src/shared/types/package-download.d.ts +13 -5
  129. package/dist/index.d.ts +3 -3
  130. package/dist/plugin-manager/host/src/preload/logger.d.ts +10 -0
  131. package/dist/plugin-manager/host/src/preload/util.d.ts +1 -0
  132. package/dist/plugin-manager/host/src/shared/bridge/constants.d.ts +2 -0
  133. package/dist/plugin-manager/host/src/shared/bridge/endpoint.d.ts +29 -0
  134. package/dist/plugin-manager/host/src/shared/bridge/hub.d.ts +136 -0
  135. package/dist/plugin-manager/host/src/shared/bridge/protocol.d.ts +91 -0
  136. package/dist/plugin-manager/host/src/shared/bridge/routes.d.ts +37 -0
  137. package/dist/plugin-manager/host/src/shared/contracts/plugin-manager-api.d.ts +223 -0
  138. package/dist/plugin-manager/host/src/shared/plugin/lifecycle.d.ts +217 -0
  139. package/dist/plugin-manager/host/src/shared/plugin/realms/common/index.d.ts +34 -0
  140. package/dist/plugin-manager/host/src/shared/plugin/realms/plugin-manager/index.d.ts +11 -0
  141. package/dist/plugin-manager/host/src/shared/plugin/registry.d.ts +69 -0
  142. package/dist/plugin-manager/host/src/shared/util.d.ts +22 -0
  143. package/dist/plugin-manager/index.d.ts +7 -0
  144. package/dist/plugin-manager/registry-map.d.ts +16 -0
  145. package/dist/preload/host/src/preload/PlaybackBackend.d.ts +1 -1
  146. package/dist/preload/host/src/preload/Player.d.ts +14 -6
  147. package/dist/preload/host/src/preload/audioplayer.d.ts +1 -1
  148. package/dist/preload/host/src/preload/av3a/Av3aPcmPlayer.d.ts +2 -2
  149. package/dist/preload/host/src/preload/av3a/bridge.d.ts +2 -2
  150. package/dist/preload/host/src/preload/av3a/channel.d.ts +2 -2
  151. package/dist/preload/host/src/preload/backends/Av3aPlaybackBackend.d.ts +2 -2
  152. package/dist/preload/host/src/preload/backends/MediaPlaybackBackend.d.ts +1 -1
  153. package/dist/preload/host/src/preload/calls/index.d.ts +6 -6
  154. package/dist/preload/host/src/preload/calls.d.ts +1 -1
  155. package/dist/preload/host/src/preload/logger.d.ts +10 -0
  156. package/dist/preload/host/src/preload/playbackMode.d.ts +1 -1
  157. package/dist/preload/host/src/shared/bridge/endpoint.d.ts +29 -0
  158. package/dist/preload/host/src/shared/bridge/hub.d.ts +136 -0
  159. package/dist/preload/host/src/shared/bridge/protocol.d.ts +91 -0
  160. package/dist/preload/host/src/shared/bridge/routes.d.ts +37 -0
  161. package/dist/preload/host/src/shared/contracts/av3a-api.d.ts +1 -1
  162. package/dist/preload/host/src/shared/contracts/av3a-process.d.ts +1 -1
  163. package/dist/preload/host/src/shared/contracts/plugin-manager-api.d.ts +223 -0
  164. package/dist/preload/host/src/shared/playbackMode.d.ts +1 -1
  165. package/dist/preload/host/src/shared/plugin/lifecycle.d.ts +217 -0
  166. package/dist/preload/host/src/shared/plugin/realms/common/index.d.ts +34 -0
  167. package/dist/preload/host/src/shared/plugin/realms/preload/index.d.ts +11 -0
  168. package/dist/preload/host/src/shared/plugin/registry.d.ts +42 -5
  169. package/dist/preload/host/src/shared/types/ncae.d.ts +11 -3
  170. package/dist/preload/index.d.ts +3 -3
  171. package/dist/preload/registry-map.d.ts +38 -31
  172. package/dist/registry-map.d.ts +159 -140
  173. package/package.json +24 -8
  174. package/dist/preload/host/src/preload/plugin/types.d.ts +0 -18
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 YUCLing
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # @open-orpheus/plugin-api
2
+
3
+ Type and runtime API for [Open Orpheus](https://github.com/YUCLing/open-orpheus)
4
+ plugins. The declarations are generated from the host; the `./client` entry is a
5
+ small runtime client that plugin scripts bundle to call an API they published.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install --save-dev @open-orpheus/plugin-api
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Main realm:
16
+
17
+ ```ts
18
+ import type { PluginModule, PluginRuntime } from "@open-orpheus/plugin-api";
19
+
20
+ export const activate: PluginModule["activate"] = async (runtime: PluginRuntime) => {
21
+ const { default: logger } = await runtime.registry.load("@main/logger");
22
+ logger.info("plugin activated");
23
+ };
24
+ ```
25
+
26
+ Client runtime for plugin scripts:
27
+
28
+ ```ts
29
+ import { connect } from "@open-orpheus/plugin-api/client";
30
+
31
+ const api = connect<MyApi>("myPlugin");
32
+ await api.refresh();
33
+ ```
34
+
35
+ Keep `@open-orpheus/plugin-api` in `devDependencies` and bundle this import into
36
+ the plugin's assets; `assets://` scripts cannot resolve bare specifiers, and the
37
+ client has no runtime install step. The surface exists once the plugin's preload
38
+ realm has mounted an API.
39
+
40
+ Use `LoadedModule` when a host module's type is needed without loading it:
41
+
42
+ ```ts
43
+ import type { LoadedModule } from "@open-orpheus/plugin-api";
44
+
45
+ type Logger = LoadedModule<"@main/logger">;
46
+ // same as Awaited<ReturnType<RegistryLoad["@main/logger"]>>
47
+ ```
48
+
49
+ Preload realm:
50
+
51
+ ```ts
52
+ import type { PluginModule, PluginRuntime } from "@open-orpheus/plugin-api/preload";
53
+ ```
54
+
55
+ Plugin-manager realm:
56
+
57
+ ```ts
58
+ import type { PluginModule, PluginRuntime } from "@open-orpheus/plugin-api/plugin-manager";
59
+ ```
60
+
61
+ The plugin-manager realm runs only in the plugin manager window. Declare it in
62
+ `metadata.json` as a `plugin-manager` entry; it is optional and separate from
63
+ the main and preload entries.
64
+
65
+ ## Deep imports and stability
66
+
67
+ The generated tree mirrors the host's module graph, so implementation types can
68
+ be imported directly through the package wildcard:
69
+
70
+ ```ts
71
+ import type { PlaybackMode } from "@open-orpheus/plugin-api/host/src/shared/types/playback-mode.js";
72
+ import type PlaybackController from "@open-orpheus/plugin-api/host/src/main/playback/PlaybackController.js";
73
+ ```
74
+
75
+ Include the `.js` extension: the package is ESM and the emitted declarations use
76
+ explicit specifiers. These are type-only imports; the package ships no runtime
77
+ code.
78
+
79
+ Deep imports are **not** part of the supported plugin API. Declarations tagged
80
+ `@internal` in the host, and implementation modules such as
81
+ `host/src/main/plugin/**`, are published only because the tree is generated from
82
+ the host source. The tag is a stability marker, not access control: the
83
+ declaration remains importable. These entries are **more unstable than the rest
84
+ of the generated surface** — the package entry points and registry keys. They
85
+ can change, move, or disappear in any release without a deprecation cycle.
86
+ Prefer `PluginModule`, `PluginRuntime`, `Registry`, `LoadedModule`, and the
87
+ generated registry keys for anything a plugin depends on.
88
+
89
+ In the generated declarations, enums are literal union types, so host
90
+ signatures accept their values directly:
91
+
92
+ ```ts
93
+ import type { PlaybackStatus } from "@open-orpheus/plugin-api/host/src/main/playback/types.js";
94
+
95
+ const status: PlaybackStatus = "playing";
96
+ ```
97
+
98
+ Normal enums also keep a `declare const` object and a namespace of member type
99
+ aliases, so values loaded from the registry retain their literal types and
100
+ `Enum.Member` still works in type positions; the package still ships no runtime
101
+ code. Numeric enums keep their reverse index, so `Enum[value]` remains valid.
102
+ `const enum`s are union-only; neither their values nor their `Enum.Member` type
103
+ names are available.
104
+
105
+ ## Lifecycle
106
+
107
+ `activate` runs for each realm instance. `deactivate` is optional, but should be
108
+ idempotent and undo everything that `activate` registered.
109
+
110
+ Activation and cleanup are serialized: the host never calls `deactivate` while
111
+ the matching `activate` is still running. If activation exceeds the host's
112
+ deadline the plugin is reported as hung; cleanup starts only after activation
113
+ settles. A disable received during activation is applied immediately after that
114
+ activation finishes.
115
+
116
+ Main-realm entries (and renderer configuration modules) are imported with a
117
+ cache-busting `?t=<timestamp>-<rand>` query, so each enable/disable cycle
118
+ evaluates the entry afresh. Within one enable epoch, activation and cross-plugin
119
+ `load()` share a single evaluation. Top-level code therefore runs again on every
120
+ enable: keep it declarative and put setup in `activate()` and teardown in
121
+ `deactivate()`.
122
+
123
+ Only the entry is cache-busted. Modules the entry imports resolve without the
124
+ query and keep their first evaluation for the life of the process (main realm) or
125
+ window document (configuration UI). So:
126
+
127
+ - Module-level state in an imported helper survives disable/enable. Keep
128
+ per-activation state in the entry or in `activate()`.
129
+ - Never create listeners, timers, IPC handlers, or `contextBridge` APIs at the
130
+ top level of an imported module; that code does not run again, while the entry
131
+ that owns it does.
132
+ - `deactivate()` must clean up explicitly; do not rely on imported modules being
133
+ reset.
134
+ - Build output matters: shared chunks or separate lazy-import chunks are exactly
135
+ these uncached modules. Inlining each entry (no code splitting) makes all of
136
+ its code re-evaluate, at the cost of bundle size; otherwise treat every emitted
137
+ chunk as a process-lifetime singleton.
138
+
139
+ Preload and plugin-manager bundles are CommonJS evaluated by the host and are
140
+ re-evaluated after a full disable, but not on retry. Editing plugin files
141
+ requires restarting the realm or application.
142
+
143
+ ## Cross-plugin exports
144
+
145
+ `runtime.plugins` exposes two distinct operations:
146
+
147
+ ```ts
148
+ await runtime.plugins.load("other-plugin"); // evaluate and return exports
149
+ await runtime.plugins.whenActive("other-plugin"); // wait until it is running
150
+ ```
151
+
152
+ `load` does not wait for the other plugin's `activate`. Use `whenActive` when
153
+ your plugin needs the other plugin to be fully initialized. Readiness cycles
154
+ fail immediately with an `Activation readiness cycle` error instead of timing
155
+ out.
156
+
157
+ ## Configuration UI
158
+
159
+ Declare the panel in `metadata.json`, relative to the plugin's `assets/`
160
+ directory and as an `.mjs` file:
161
+
162
+ ```json
163
+ "configuration": "configuration/index.mjs"
164
+ ```
165
+
166
+ That module is browser ESM the host imports and owns. Export `mount()` and return
167
+ a cleanup function, or nothing:
168
+
169
+ ```ts
170
+ import type { ConfigurationModule } from "@open-orpheus/plugin-api/configuration";
171
+
172
+ export const mount: ConfigurationModule["mount"] = (root, context) => {
173
+ root.textContent = "Settings";
174
+ return () => {
175
+ root.replaceChildren();
176
+ };
177
+ };
178
+ ```
179
+
180
+ There is no registration API. `context` provides `pluginId`, `assetsBaseUrl`
181
+ (the plugin's `assets/` root), and an `AbortSignal`. The host awaits the returned
182
+ cleanup and reports failures per plugin. If you need host data, expose it from the
183
+ plugin-manager preload realm through `contextBridge`; the host activates that
184
+ realm before mounting the panel.
185
+
186
+ ## Versioning
187
+
188
+ The package version matches the Open Orpheus release it was generated from.
189
+
190
+ ## Publishing
191
+
192
+ Releases are staged on npm by the release workflow, synchorized with Open Orpheus's release.
@@ -0,0 +1,37 @@
1
+ export interface BridgeSerializedError {
2
+ readonly name: string;
3
+ readonly message: string;
4
+ readonly code?: string;
5
+ readonly data?: unknown;
6
+ }
7
+ export type BridgeResult = {
8
+ readonly ok: true;
9
+ readonly value: unknown;
10
+ } | {
11
+ readonly ok: false;
12
+ readonly error: BridgeSerializedError;
13
+ };
14
+ /** The subset of `window.__ooBridge` a plugin client needs. */
15
+ export interface BridgeSurface {
16
+ request(route: string, args: unknown[]): Promise<BridgeResult>;
17
+ }
18
+ /** The API a plugin published, as seen from the renderer. */
19
+ export type BridgeEndpoint<T> = {
20
+ [K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> : T[K] extends object ? BridgeEndpoint<T[K]> : T[K];
21
+ };
22
+ export declare class BridgeRequestError extends Error {
23
+ readonly code?: string;
24
+ readonly data?: unknown;
25
+ constructor(error: BridgeSerializedError);
26
+ }
27
+ export interface BridgeClient {
28
+ connect<T>(route: string): BridgeEndpoint<T>;
29
+ }
30
+ export declare function createClient(surface: BridgeSurface): BridgeClient;
31
+ /**
32
+ * Connect to a route on the current window's surface.
33
+ *
34
+ * The plugin must have mounted an API from its preload realm first; that mount
35
+ * is what creates and exposes `window.__ooBridge`.
36
+ */
37
+ export declare function connect<T>(route: string, surface?: BridgeSurface): BridgeEndpoint<T>;
@@ -0,0 +1,53 @@
1
+ // Runtime client for plugin scripts. Bundled by plugins; no host imports.
2
+ //
3
+ // The surface is installed by the plugin's preload realm when it publishes an
4
+ // API with `runtime.mainWorld.mount(...)`.
5
+ export class BridgeRequestError extends Error {
6
+ code;
7
+ data;
8
+ constructor(error) {
9
+ super(error.message);
10
+ this.name = error.name || "BridgeRequestError";
11
+ this.code = error.code;
12
+ this.data = error.data;
13
+ }
14
+ }
15
+ export function createClient(surface) {
16
+ return {
17
+ connect(route) {
18
+ return endpoint(surface, route);
19
+ },
20
+ };
21
+ }
22
+ /**
23
+ * Connect to a route on the current window's surface.
24
+ *
25
+ * The plugin must have mounted an API from its preload realm first; that mount
26
+ * is what creates and exposes `window.__ooBridge`.
27
+ */
28
+ export function connect(route, surface) {
29
+ return createClient(surface ?? windowSurface()).connect(route);
30
+ }
31
+ function windowSurface() {
32
+ const surface = globalThis.__ooBridge;
33
+ if (!surface) {
34
+ throw new Error("No __ooBridge surface is exposed in this window; the plugin's preload realm has not mounted an API.");
35
+ }
36
+ return surface;
37
+ }
38
+ function endpoint(surface, route, path = []) {
39
+ return new Proxy(function bridgeMethod() { }, {
40
+ get(_target, property) {
41
+ if (typeof property === "symbol" || property === "then")
42
+ return undefined;
43
+ return endpoint(surface, route, [...path, property]);
44
+ },
45
+ async apply(_target, _thisArg, args) {
46
+ const result = await surface.request([route, ...path].join("."), args);
47
+ if (!result.ok)
48
+ throw new BridgeRequestError(result.error);
49
+ return result.value;
50
+ },
51
+ });
52
+ }
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../runtime/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,8EAA8E;AAC9E,2CAA2C;AA2B3C,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAU;IACd,IAAI,CAAW;IAExB,YAAY,KAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,oBAAoB,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAMD,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,OAAO;QACL,OAAO,CAAI,KAAa;YACtB,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAsB,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAI,KAAa,EAAE,OAAuB;IAC/D,OAAO,YAAY,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC,CAAC,OAAO,CAAI,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,OAAO,GAAI,UAA6C,CAAC,UAAU,CAAC;IAC1E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,OAAsB,EAAE,KAAa,EAAE,OAAiB,EAAE;IAC1E,OAAO,IAAI,KAAK,CAAC,SAAS,YAAY,KAAI,CAAC,EAAE;QAC3C,GAAG,CAAC,OAAO,EAAE,QAAQ;YACnB,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM;gBAAE,OAAO,SAAS,CAAC;YAC1E,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAe;YAC5C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,CAAC,EAAE;gBAAE,MAAM,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3D,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** Everything a plugin's configuration module is handed when it mounts. */
2
+ export interface ConfigurationContext {
3
+ readonly pluginId: string;
4
+ /** `assets://` base URL for this plugin's assets, for resolving relative resources. */
5
+ readonly assetsBaseUrl: string;
6
+ /** Aborted when the host closes or invalidates this mount. */
7
+ readonly signal: AbortSignal;
8
+ }
9
+ /** Cleanup returned by `mount()`, if the plugin needs one. */
10
+ export type ConfigurationUnmount = () => void | Promise<void>;
11
+ /**
12
+ * The named exports a plugin's configuration entry must provide.
13
+ *
14
+ * Entries are browser ESM modules served from the plugin's `assets/`
15
+ * directory. The host imports, mounts, and unmounts them. Module top-level
16
+ * code must only define exports: ESM evaluation cannot be undone when the host
17
+ * invalidates an attempt, so lifecycle work belongs in `mount()`.
18
+ */
19
+ export interface ConfigurationModule {
20
+ mount(root: HTMLDivElement, context: ConfigurationContext): void | ConfigurationUnmount | Promise<void | ConfigurationUnmount>;
21
+ }
@@ -0,0 +1,5 @@
1
+ // AUTO-GENERATED by packages/plugin-api/scripts/build.ts. Do not edit.
2
+ // The plugin-facing type surface. Generated from the host; contains no
3
+ // references back to the host repository.
4
+
5
+ export type { ConfigurationContext, ConfigurationModule, ConfigurationUnmount } from "./host/src/shared/plugin/configuration/index.js";
@@ -36,13 +36,7 @@ export declare function clearWindowPopupPolicy(targetWindowId: string): boolean
36
36
  */
37
37
  export declare function decorateWindowTitle(id: string, title: string): string
38
38
 
39
- export declare const enum DesktopEnvironment {
40
- Wayland = 0,
41
- X11 = 1,
42
- Windows = 2,
43
- Darwin = 3,
44
- Unknown = 4,
45
- }
39
+ export type DesktopEnvironment = 0 | 1 | 2 | 3 | 4;
46
40
 
47
41
  export declare function dragWindow(hwnd: Buffer): void
48
42
 
@@ -90,15 +84,27 @@ export declare function getPopupCapability(): PopupCapability
90
84
  export declare function getUniqueDisplayId(displayId: number): string | null
91
85
 
92
86
  /**
93
- * Whether the compositor advertises `zwlr_layer_shell_v1`.
87
+ * The `Display.id` of the output a managed window's surface entered.
94
88
  *
95
- * Only meaningful for Wayland on Linux; everywhere else it is `false`.
89
+ * Wayland does not report a window's global position, but it does report which
90
+ * outputs its surface entered. This maps that back to the `Display.id` Electron
91
+ * uses. `null` when the window has no surface, has not entered an output yet,
92
+ * or the compositor is too old to expose the mapping.
96
93
  */
97
- export declare function isLayerShellAvailable(): boolean
94
+ export declare function getWindowOutputDisplayId(windowId: string): number | null
98
95
 
99
96
  /** Whether the compositor currently reports the window's toplevel as activated. */
100
97
  export declare function isWindowActivated(windowId: string): boolean
101
98
 
99
+ /**
100
+ * Whether the compositor currently gives this window keyboard focus.
101
+ *
102
+ * This is the authoritative `wl_keyboard.enter`/`leave` state, not Electron's
103
+ * xdg-activation-based `isFocused()`. Layer surfaces can be keyboard-focused
104
+ * without ever receiving an xdg `activated` state.
105
+ */
106
+ export declare function isWindowKeyboardFocused(windowId: string): boolean
107
+
102
108
  /** Whether a pointer is currently over this window's surface. */
103
109
  export declare function isWindowPointerInside(windowId: string): boolean
104
110
 
@@ -117,12 +123,7 @@ export interface LatestWindowPress {
117
123
  }
118
124
 
119
125
  /** The stacking layer a layer surface is placed in, bottom-most first. */
120
- export declare const enum LayerShellLayer {
121
- Background = 0,
122
- Bottom = 1,
123
- Top = 2,
124
- Overlay = 3,
125
- }
126
+ export type LayerShellLayer = 0 | 1 | 2 | 3;
126
127
 
127
128
  /**
128
129
  * Layer-shell state for a window the application is about to create.
@@ -163,6 +164,15 @@ export interface LayerShellOptions {
163
164
  keyboardInteractivity?: number
164
165
  }
165
166
 
167
+ /**
168
+ * The layer-shell version advertised by a live compositor, or `null`.
169
+ *
170
+ * `null` means no live connection advertises `zwlr_layer_shell_v1`. A version
171
+ * of 4 or higher supports `on_demand` keyboard focus, which menus require for
172
+ * focus-loss dismissal.
173
+ */
174
+ export declare function layerShellVersion(): number | null
175
+
166
176
  /**
167
177
  * Listen for windows whose layer-shell role was refused.
168
178
  *
@@ -210,6 +220,14 @@ export declare function setWindowAsBackground(hwnd: Buffer, displayId?: number |
210
220
  */
211
221
  export declare function setWindowLayerShell(windowId: string, options?: LayerShellOptions | undefined | null): boolean
212
222
 
223
+ /**
224
+ * Resize an existing layer surface, keeping its anchors and margins.
225
+ *
226
+ * The request is applied at the surface's next commit, because layer state is
227
+ * double-buffered. Returns whether the window currently is a layer surface.
228
+ */
229
+ export declare function setWindowLayerShellSize(windowId: string, width: number, height: number): boolean
230
+
213
231
  /**
214
232
  * Register the intent to present `target_window_id` as an xdg_popup of
215
233
  * `parent_window_id`, with the size the renderer measured.
@@ -246,7 +264,7 @@ export declare function transferWindowState(fromId: string, toId: string): boole
246
264
  * settings UI can check a choice before anything is created.
247
265
  *
248
266
  * This answers for the options only, never for the compositor: whether it
249
- * takes layer surfaces at all is `isLayerShellAvailable()`, and a caller that
267
+ * takes layer surfaces at all is `layerShellVersion()`, and a caller that
250
268
  * needs both asks both.
251
269
  */
252
270
  export declare function validateLayerShellOptions(options: LayerShellOptions): boolean
@@ -0,0 +1,2 @@
1
+ import { Protocol } from "electron";
2
+ export default function registerAssetsScheme(protocol: Protocol): void;
@@ -1,5 +1,5 @@
1
- import type ChunkTracker from "./ChunkTracker";
2
- import type StorageManager from "./StorageManager";
1
+ import type ChunkTracker from "./ChunkTracker.js";
2
+ import type StorageManager from "./StorageManager.js";
3
3
  type DownloadSchedulerOptions = {
4
4
  url: string;
5
5
  toleranceThreshold: number;
@@ -1,4 +1,4 @@
1
- import type { AudioPlayInfo } from "../../preload/Player";
1
+ import type { AudioPlayInfo } from "../../preload/Player.js";
2
2
  /**
3
3
  * Main-process engine for media-element playback. It never decodes — Chromium
4
4
  * plays the `<audio>` element — it only serves that element over `audio://audio`
@@ -2,5 +2,5 @@ import { Protocol } from "electron";
2
2
  export declare function readEffect(pathInfo: {
3
3
  path: string;
4
4
  pathtype: number;
5
- }): Promise<string | import("../shared/types/ncae").Ncae>;
5
+ }): Promise<string | import("../shared/types/ncae.js").Ncae>;
6
6
  export default function registerAudioStreamerScheme(protocol: Protocol): void;
@@ -1,4 +1,4 @@
1
- import type { AudioPlayInfo } from "../../preload/Player";
1
+ import type { AudioPlayInfo } from "../../preload/Player.js";
2
2
  /**
3
3
  * Main-process manager for AV3A playback: a decode utility process plus the
4
4
  * file it reads (a streamed temp file or a local one). Distinct from
@@ -1,4 +1,4 @@
1
- import type { Av3aDecodeExecutor, Av3aDecodedFrame, Av3aTrackInfo } from "./types";
1
+ import type { Av3aDecodeExecutor, Av3aDecodedFrame, Av3aTrackInfo } from "./types.js";
2
2
  /**
3
3
  * Source abstraction over anything that can supply an AV3A-in-M4A file that
4
4
  * may still be downloading. `OnlineStreamer` satisfies this interface: the
@@ -1,5 +1,5 @@
1
1
  import type { WebContents } from "electron";
2
- import type { Av3aM4aSource } from "./Av3aM4aSession";
2
+ import type { Av3aM4aSource } from "./Av3aM4aSession.js";
3
3
  /**
4
4
  * Main-process side of the AV3A decode utility process.
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { OnlineStreamer } from "../audio/OnlineStreamer";
2
- import type { Av3aM4aSource } from "./Av3aM4aSession";
1
+ import type { OnlineStreamer } from "../audio/OnlineStreamer.js";
2
+ import type { Av3aM4aSource } from "./Av3aM4aSession.js";
3
3
  /**
4
4
  * `Av3aM4aSource` for a fully-present local file: the whole file is always
5
5
  * available, so the frontier is the full size and `ensureRange` is a no-op.
@@ -4,7 +4,7 @@
4
4
  * exposes the same async surface (a worker-thread RPC, direct native calls in
5
5
  * a utility process, ...); the session only depends on this interface.
6
6
  */
7
- import type { Av3aTrackInfo } from "../../shared/contracts/av3a-api";
7
+ import type { Av3aTrackInfo } from "../../shared/contracts/av3a-api.js";
8
8
  export type { Av3aTrackInfo };
9
9
  /** Byte range of the next sample (`done: true` at the end of the track). */
10
10
  export type Av3aSampleRange = {
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Main-process side of the IPC bridge.
3
+ *
4
+ * One `IpcMainBridge` exists per `WebContents`; frames from a renderer are
5
+ * dispatched to the bridge registered for that sender. Outbound frames are
6
+ * addressed to the owning `WebContents`.
7
+ */
8
+ import type { Bridge, BridgeInfo } from "../../shared/bridge/hub.js";
9
+ import type { Realm } from "../../shared/bridge/realm.js";
10
+ import type { Frame } from "../../shared/bridge/protocol.js";
11
+ export declare class IpcMainBridge implements Bridge<Realm> {
12
+ private readonly contents;
13
+ readonly info: BridgeInfo<Realm>;
14
+ private readonly handlers;
15
+ private readonly seenSessions;
16
+ private session;
17
+ private destroyed;
18
+ constructor(contents: Electron.WebContents);
19
+ send(frame: Frame): void;
20
+ onFrame(handler: (frame: Frame) => void): () => void;
21
+ close(): void;
22
+ /** Called by the shared IPC listener when a frame arrives from this sender. */
23
+ receive(frame: Frame): void;
24
+ }
@@ -0,0 +1,7 @@
1
+ import type { WebContents } from "electron";
2
+ import { type Handlers, type HubImpl, type Mount } from "../../shared/bridge/hub.js";
3
+ import type { Realm } from "../../shared/bridge/realm.js";
4
+ /** The bridge hub for a window, created on first mount and disposed with it. */
5
+ export declare function windowHub(contents: WebContents): HubImpl<Realm>;
6
+ /** Mount a typed contract for one window. */
7
+ export declare function mountIpcHandlers<T>(contents: WebContents, prefix: string, impl: Handlers<T, Realm>): Mount<T>;
@@ -1,6 +1,6 @@
1
- import LyricCacheManager from "./cache/LyricCahceManager";
2
- import PlayCacheManager from "./cache/PlayCacheManager";
3
- import HttpCacheStorage from "./cache/HttpCacheStorage";
1
+ import LyricCacheManager from "./cache/LyricCahceManager.js";
2
+ import PlayCacheManager from "./cache/PlayCacheManager.js";
3
+ import HttpCacheStorage from "./cache/HttpCacheStorage.js";
4
4
  export declare let lyricCacheManager: LyricCacheManager | null;
5
5
  export declare let playCacheManager: PlayCacheManager | null;
6
6
  export declare let httpCacheStorage: HttpCacheStorage | null;
@@ -1,2 +1,2 @@
1
- import MusicDesktopWindow from "../windows/music-desktop";
1
+ import MusicDesktopWindow from "../windows/music-desktop.js";
2
2
  export declare let musicDesktopWindow: MusicDesktopWindow | null;
@@ -1,16 +1,16 @@
1
- import "./app";
2
- import "./audioeffect";
3
- import "./winhelper";
4
- import "./browser";
5
- import "./desktop";
6
- import "./desktoppet";
7
- import "./storage";
8
- import "./musiclibrary";
9
- import "./os";
10
- import "./trayicon";
11
- import "./network";
12
- import "./download";
13
- import "./rtc";
14
- import "./update";
15
- import "./player";
16
- import "./process";
1
+ import "./app.js";
2
+ import "./audioeffect.js";
3
+ import "./winhelper.js";
4
+ import "./browser.js";
5
+ import "./desktop.js";
6
+ import "./desktoppet.js";
7
+ import "./storage.js";
8
+ import "./musiclibrary.js";
9
+ import "./os.js";
10
+ import "./trayicon.js";
11
+ import "./network.js";
12
+ import "./download.js";
13
+ import "./rtc.js";
14
+ import "./update.js";
15
+ import "./player.js";
16
+ import "./process.js";
@@ -1,5 +1,5 @@
1
1
  import type { IpcMainInvokeEvent } from "electron";
2
- import CallDispatcher, { CallbackHandlerFunction, HandlerFunction } from "../shared/CallDispatcher";
2
+ import CallDispatcher, { CallbackHandlerFunction, HandlerFunction } from "../shared/CallDispatcher.js";
3
3
  export declare const dispatcher: CallDispatcher;
4
4
  export declare function registerCallHandler<Args extends unknown[], Return extends unknown[] | void>(cmd: string, handler: HandlerFunction<[IpcMainInvokeEvent, ...Args], Return>): void;
5
5
  export declare function registerCallbackHandler<Args extends unknown[]>(cmd: string, handler: CallbackHandlerFunction<[IpcMainInvokeEvent, ...Args]>): void;
@@ -1 +1 @@
1
- import "./calls/index";
1
+ import "./calls/index.js";
@@ -1,4 +1,4 @@
1
- import type { Database } from "../../../_native/open-orpheus__database";
1
+ import type { Database } from "../../../_native/open-orpheus__database.js";
2
2
  import { SqliteDriver } from "@keyv/sqlite";
3
3
  export type DatabaseSqliteDriver = SqliteDriver & {
4
4
  db: Database;
@@ -1,4 +1,4 @@
1
- import { Database } from "../../_native/open-orpheus__database";
1
+ import { Database } from "../../_native/open-orpheus__database.js";
2
2
  export declare let webDb: Database;
3
3
  export declare let musicLibraryDb: Database;
4
4
  export declare let nativeDb: Database;
@@ -9,12 +9,21 @@ export type StartupTask = {
9
9
  };
10
10
  export declare let startupTask: StartupTask | null;
11
11
  export declare function setStartupTask(task: StartupTask): void;
12
- export declare enum LifecycleState {
13
- Starting = 0,
14
- MainWindowCreated = 1,
15
- MainWindowLoaded = 2,
16
- Started = 3,
17
- Quitting = 4
12
+ export declare const LifecycleState: {
13
+ readonly Starting: 0;
14
+ readonly MainWindowCreated: 1;
15
+ readonly MainWindowLoaded: 2;
16
+ readonly Started: 3;
17
+ readonly Quitting: 4;
18
+ readonly [x: number]: string;
19
+ };
20
+ export type LifecycleState = 0 | 1 | 2 | 3 | 4;
21
+ export declare namespace LifecycleState {
22
+ type Starting = 0;
23
+ type MainWindowCreated = 1;
24
+ type MainWindowLoaded = 2;
25
+ type Started = 3;
26
+ type Quitting = 4;
18
27
  }
19
28
  export type LifecycleEvents = {
20
29
  /**
@@ -1,5 +1,5 @@
1
- import type { LyricsStore } from "../../shared/types/lyrics";
2
- import type { TrackInfo } from "../playback/types";
1
+ import type { LyricsStore } from "../../shared/types/lyrics.js";
2
+ import type { TrackInfo } from "../playback/types.js";
3
3
  /**
4
4
  * The shape NAPI expects for a single timed word.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import Emittery from "emittery";
2
- import { LyricsStore } from "../../shared/types/lyrics";
2
+ import { LyricsStore } from "../../shared/types/lyrics.js";
3
3
  export type LyricsDispatcherEvents = {
4
4
  lyricsupdate: LyricsStore | null;
5
5
  sloganupdate: string | null;