@sirenodeck/sirenodeck 0.1.1-alpha.0 → 0.2.2
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/LICENSE +674 -21
- package/bin/dev.js +12 -2
- package/dist/main.mjs +3655 -1657
- package/package.json +18 -16
- package/src/api/protocol-internal.ts +16 -1
- package/src/assets/logo.png +0 -0
- package/src/assets/logo72x72.png +0 -0
- package/src/builtin-addons/brightness/buttons/brightness/config.ts +12 -2
- package/src/builtin-addons/coding-agents/buttons/agent/config.ts +5 -1
- package/src/builtin-addons/coding-agents/buttons/summary/config.ts +15 -3
- package/src/builtin-addons/coding-agents/buttons/summary/frontend.tsx +3 -3
- package/src/builtin-addons/coding-agents/global/backend.ts +56 -34
- package/src/builtin-addons/coding-agents/providers/opencode.ts +4 -5
- package/src/builtin-addons/core/buttons/action/config.ts +5 -2
- package/src/builtin-addons/core/buttons/change-deck/config.ts +6 -3
- package/src/builtin-addons/core/buttons/media-sample/config.ts +2 -2
- package/src/builtin-addons/core/buttons/toggle/config.ts +26 -9
- package/src/builtin-addons/date-time/buttons/custom/config.ts +5 -1
- package/src/builtin-addons/date-time/buttons/date/config.ts +2 -2
- package/src/builtin-addons/date-time/buttons/time/config.ts +5 -1
- package/src/builtin-addons/emoji-selector/buttons/category/config.ts +3 -3
- package/src/builtin-addons/emoji-selector/buttons/emoji/config.ts +5 -2
- package/src/builtin-addons/emoji-selector/support.ts +5 -2
- package/src/builtin-addons/global-services.ts +23 -0
- package/src/builtin-addons/internal-settings/buttons/app-info/config.ts +2 -1
- package/src/builtin-addons/internal-settings/buttons/brightness-down/config.ts +6 -1
- package/src/builtin-addons/internal-settings/buttons/brightness-up/config.ts +6 -1
- package/src/builtin-addons/media/backend.ts +54 -0
- package/src/builtin-addons/media/buttons/volume/volume-down/config.ts +1 -1
- package/src/builtin-addons/media/buttons/volume/volume-up/config.ts +1 -1
- package/src/builtin-addons/session/buttons/time/config.ts +1 -1
- package/src/builtin-addons/system-status/buttons/system-status/schemas.ts +32 -6
- package/src/builtin-addons/system-status/manifest.ts +49 -0
- package/src/builtin-addons/value-display/buttons/value-display/config.ts +23 -9
- package/src/builtin-addons/weather/buttons/weather/config.ts +11 -6
- package/src/cli/coding-agents-onboarding.ts +181 -34
- package/src/cli/commands/command-executor.ts +61 -0
- package/src/cli/commands/emulator-mode.ts +17 -2
- package/src/cli/commands/network-bind.ts +13 -9
- package/src/cli/commands/restart.ts +15 -5
- package/src/cli/commands/run.ts +174 -317
- package/src/cli/commands/service/render-template.ts +10 -0
- package/src/cli/commands/skills.ts +106 -0
- package/src/cli/commands/start.ts +39 -9
- package/src/cli/commands/stop.ts +3 -2
- package/src/cli/commands/system-requirements.ts +1 -0
- package/src/cli/index.ts +16 -3
- package/src/cli/main.ts +15 -2
- package/src/cli/package-manager.ts +6 -0
- package/src/cli/skills-first-run.ts +46 -0
- package/src/cli/startup-display.ts +35 -17
- package/src/config/mutation.ts +13 -1
- package/src/config/schemas.ts +3 -3
- package/src/config/validation.ts +7 -1
- package/src/core/icon-asset-registry.ts +11 -6
- package/src/deck/addon-handler-bridge.ts +246 -176
- package/src/deck/deck-config.ts +11 -2
- package/src/deck/deck-presentation-publisher.ts +116 -0
- package/src/deck/index.ts +13 -0
- package/src/deck/inject-config-ui-button.ts +23 -0
- package/src/deck/methods.ts +23 -0
- package/src/deck/position-settings-version-button.ts +20 -0
- package/src/deck/runtime/host-policy-coordinator.ts +186 -0
- package/src/deck/runtime/runtime.ts +123 -250
- package/src/deck/system-back-injection.ts +2 -1
- package/src/device/reconnecting.ts +8 -1
- package/src/index.ts +1 -2
- package/src/outputClient/emulator.ts +13 -0
- package/src/outputClient/index.ts +8 -0
- package/src/outputClient/real.ts +40 -45
- package/src/outputClient/remote-mirror.ts +77 -0
- package/src/outputClient/types.ts +2 -0
- package/src/render/editor-handler.ts +12 -1
- package/src/render/frontend-bridge-url.ts +10 -0
- package/src/render/push-startup-screen.ts +76 -0
- package/src/render/ws-bridge.ts +2 -0
- package/src/system/providers/active-app/capture-file.ts +61 -0
- package/src/system/providers/active-app/wayland-gnome.ts +26 -10
- package/src/system/providers/active-app.ts +6 -0
- package/src/system/providers/clipboard/darwin.ts +28 -4
- package/src/system/providers/url.ts +57 -0
- package/src/util/logger.ts +19 -3
- package/src/version.ts +3 -1
- package/src/vite/virtual-modules.ts +12 -6
package/src/cli/commands/run.ts
CHANGED
|
@@ -34,6 +34,8 @@ import {
|
|
|
34
34
|
validatePerDeck,
|
|
35
35
|
} from "@/config/validation"
|
|
36
36
|
import {
|
|
37
|
+
createDeckPresentationPublisher,
|
|
38
|
+
createHostPolicyCoordinator,
|
|
37
39
|
createDeckRuntime,
|
|
38
40
|
injectSystemButtons,
|
|
39
41
|
type Methods,
|
|
@@ -43,6 +45,8 @@ import {
|
|
|
43
45
|
type Store,
|
|
44
46
|
} from "@/deck"
|
|
45
47
|
import { paginateDeck } from "@/deck/paginate-deck"
|
|
48
|
+
import { injectConfigUiButton } from "@/deck/inject-config-ui-button"
|
|
49
|
+
import { positionSettingsVersionButton } from "@/deck/position-settings-version-button"
|
|
46
50
|
import { positionButtons } from "@/deck/position-buttons"
|
|
47
51
|
import { subscribeNavigateDeck } from "@/deck/runtime-subscriptions"
|
|
48
52
|
import {
|
|
@@ -51,6 +55,7 @@ import {
|
|
|
51
55
|
} from "@/system/providers/active-app"
|
|
52
56
|
import { createKeyMacroProvider } from "@/system/providers/key-macro"
|
|
53
57
|
import { createNotificationProvider } from "@/system/providers/notification"
|
|
58
|
+
import { createUrlProvider } from "@/system/providers/url"
|
|
54
59
|
import {
|
|
55
60
|
createNullSessionProvider,
|
|
56
61
|
createSessionProvider,
|
|
@@ -61,12 +66,18 @@ import {
|
|
|
61
66
|
formatCapabilityWarning,
|
|
62
67
|
type SystemCapability,
|
|
63
68
|
} from "@/system/requirements"
|
|
64
|
-
import {
|
|
69
|
+
import {
|
|
70
|
+
copyThemeAssets,
|
|
71
|
+
readAndValidateManifest,
|
|
72
|
+
resolveActiveTheme,
|
|
73
|
+
} from "@/themes/loader"
|
|
65
74
|
import { resolveAddonCacheDir } from "@/util/cache-paths"
|
|
66
75
|
import { probeGlobalPackageRoots } from "../package-manager"
|
|
67
76
|
import { installPackage } from "./install"
|
|
77
|
+
import { DEFAULT_CONFIG_UI_PORT } from "./emulator-mode"
|
|
68
78
|
import { isNpmAddonSpec } from "@/addon/spec"
|
|
69
79
|
import { confirm } from "@/cli/prompt"
|
|
80
|
+
import { createCommandExecutor } from "./command-executor"
|
|
70
81
|
|
|
71
82
|
import { createActionExecutor } from "@/action/executor"
|
|
72
83
|
import {
|
|
@@ -78,7 +89,6 @@ import {
|
|
|
78
89
|
import { ConfigWatcher } from "@/core/watcher"
|
|
79
90
|
import { bridgeAddonServices } from "@/deck/addon-handler-bridge"
|
|
80
91
|
import {
|
|
81
|
-
buildDeckConfigMessage,
|
|
82
92
|
buildDeckTree,
|
|
83
93
|
buildResolverOptions,
|
|
84
94
|
type AddonFrontendRef,
|
|
@@ -86,6 +96,7 @@ import {
|
|
|
86
96
|
import { getHostContext } from "@/deck/host-context"
|
|
87
97
|
import { StatePublisher } from "@/render/state-publisher"
|
|
88
98
|
import { startWsBridge, type WsBridge } from "@/render/ws-bridge"
|
|
99
|
+
import { DEFAULT_BRIDGE_PORT } from "./emulator-mode"
|
|
89
100
|
import { createConfigMutationService } from "@/config/mutation"
|
|
90
101
|
import {
|
|
91
102
|
createEditorMessageHandler,
|
|
@@ -176,7 +187,10 @@ export interface SetupAddonServicesOptions {
|
|
|
176
187
|
"registerChannel" | "setActiveDeck"
|
|
177
188
|
>
|
|
178
189
|
readonly bridge: Pick<WsBridge, "broadcast" | "registerCacheablePoller">
|
|
190
|
+
/** Retained for callers using the pre-publisher setup contract. */
|
|
179
191
|
readonly isCompact: boolean
|
|
192
|
+
/** Retained for callers using the pre-publisher setup contract. */
|
|
193
|
+
readonly keyCount: number
|
|
180
194
|
readonly initialDeck?: RuntimeDeck
|
|
181
195
|
readonly signal: AbortSignal
|
|
182
196
|
readonly store: Store
|
|
@@ -191,6 +205,7 @@ export interface SetupAddonServicesOptions {
|
|
|
191
205
|
|
|
192
206
|
export interface SetupAddonServicesResult {
|
|
193
207
|
readonly dispose: () => void
|
|
208
|
+
readonly reconcile: (decks: ReadonlyArray<RuntimeDeck>) => Promise<void>
|
|
194
209
|
}
|
|
195
210
|
|
|
196
211
|
const collectActiveDeckAddonNames = (
|
|
@@ -218,17 +233,15 @@ export const setupAddonServices = (
|
|
|
218
233
|
executor,
|
|
219
234
|
statePublisher,
|
|
220
235
|
bridge,
|
|
221
|
-
isCompact,
|
|
222
236
|
initialDeck,
|
|
223
237
|
signal,
|
|
224
238
|
store,
|
|
225
239
|
methods,
|
|
226
240
|
logger,
|
|
227
|
-
resolverOptions,
|
|
228
241
|
requestDeckRebuild,
|
|
229
242
|
} = options
|
|
230
243
|
|
|
231
|
-
|
|
244
|
+
const addonBridge = bridgeAddonServices({
|
|
232
245
|
runtime,
|
|
233
246
|
decks,
|
|
234
247
|
scanned,
|
|
@@ -269,114 +282,6 @@ export const setupAddonServices = (
|
|
|
269
282
|
})
|
|
270
283
|
})
|
|
271
284
|
|
|
272
|
-
let lastBroadcastedDeckId: string | undefined = initialDeck?.id
|
|
273
|
-
const unsubscribeDeckBroadcast = pubSub.subscribe(
|
|
274
|
-
"runtime:activeDeck",
|
|
275
|
-
(payload: unknown) => {
|
|
276
|
-
const deckId =
|
|
277
|
-
typeof payload === "object" && payload !== null && "deckId" in payload
|
|
278
|
-
? String((payload as { deckId: unknown }).deckId)
|
|
279
|
-
: undefined
|
|
280
|
-
if (deckId === undefined) return
|
|
281
|
-
if (deckId === lastBroadcastedDeckId) return
|
|
282
|
-
lastBroadcastedDeckId = deckId
|
|
283
|
-
const deck = decks.find((d) => d.id === deckId)
|
|
284
|
-
if (deck === undefined) return
|
|
285
|
-
const msg = buildDeckConfigMessage(
|
|
286
|
-
deck,
|
|
287
|
-
addonByType,
|
|
288
|
-
resolverOptions,
|
|
289
|
-
{
|
|
290
|
-
navStackDepth: runtime.navStackDepth(),
|
|
291
|
-
hasOverlayDeckAvailable: runtime.hasOverlayDeckAvailable(),
|
|
292
|
-
inOverlayMode: runtime.getOverlay() !== null,
|
|
293
|
-
},
|
|
294
|
-
undefined,
|
|
295
|
-
isCompact,
|
|
296
|
-
(fullPath) => getAssetByPath(fullPath)?.id,
|
|
297
|
-
runtime.getAvailableOverlayDeckIcon(),
|
|
298
|
-
runtime.getAvailableOverlayDeckName(),
|
|
299
|
-
{ lockActive: runtime.isLockActive() },
|
|
300
|
-
)
|
|
301
|
-
bridge.broadcast(msg)
|
|
302
|
-
},
|
|
303
|
-
)
|
|
304
|
-
|
|
305
|
-
const unsubscribeOverlayAvailableBroadcast = pubSub.subscribe(
|
|
306
|
-
"runtime:overlay-available",
|
|
307
|
-
() => {
|
|
308
|
-
const activeDeck = runtime.getActiveDeck()
|
|
309
|
-
if (activeDeck === undefined) return
|
|
310
|
-
const msg = buildDeckConfigMessage(
|
|
311
|
-
activeDeck,
|
|
312
|
-
addonByType,
|
|
313
|
-
resolverOptions,
|
|
314
|
-
{
|
|
315
|
-
navStackDepth: runtime.navStackDepth(),
|
|
316
|
-
hasOverlayDeckAvailable: runtime.hasOverlayDeckAvailable(),
|
|
317
|
-
inOverlayMode: runtime.getOverlay() !== null,
|
|
318
|
-
},
|
|
319
|
-
undefined,
|
|
320
|
-
isCompact,
|
|
321
|
-
(fullPath) => getAssetByPath(fullPath)?.id,
|
|
322
|
-
runtime.getAvailableOverlayDeckIcon(),
|
|
323
|
-
runtime.getAvailableOverlayDeckName(),
|
|
324
|
-
{ lockActive: runtime.isLockActive() },
|
|
325
|
-
)
|
|
326
|
-
logger.info(
|
|
327
|
-
{
|
|
328
|
-
deckId: msg.deckId,
|
|
329
|
-
hasOverlayDeckAvailable: msg.hasOverlayDeckAvailable,
|
|
330
|
-
overlayDeckIcon: msg.overlayDeckIcon,
|
|
331
|
-
},
|
|
332
|
-
"orchestrator: broadcasting overlay-available update",
|
|
333
|
-
)
|
|
334
|
-
bridge.broadcast(msg)
|
|
335
|
-
},
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
// ponytail: periodic heartbeat — ensures the frontend's overlay state
|
|
339
|
-
// stays in sync after a transient disconnect or missed event. Fires every
|
|
340
|
-
// 2s, cheap (one deck-config per cycle), and idempotent on the frontend.
|
|
341
|
-
// Skip the broadcast when nothing observable changed since the last tick:
|
|
342
|
-
// an unconditional tick at 1s forced every client to re-render twice a
|
|
343
|
-
// second even with identical state, which drowned the emulator shell and
|
|
344
|
-
// starved the bridge's event loop during the 5s handshake window.
|
|
345
|
-
let lastHeartbeatKey = ""
|
|
346
|
-
const heartbeat = setInterval(() => {
|
|
347
|
-
const activeDeck = runtime.getActiveDeck()
|
|
348
|
-
if (activeDeck === undefined) return
|
|
349
|
-
const key = [
|
|
350
|
-
activeDeck.id,
|
|
351
|
-
runtime.navStackDepth(),
|
|
352
|
-
runtime.hasOverlayDeckAvailable(),
|
|
353
|
-
runtime.getAvailableOverlayDeckIcon(),
|
|
354
|
-
runtime.getAvailableOverlayDeckName(),
|
|
355
|
-
isCompact,
|
|
356
|
-
runtime.getOverlay() !== null,
|
|
357
|
-
].join("|")
|
|
358
|
-
if (key === lastHeartbeatKey) return
|
|
359
|
-
lastHeartbeatKey = key
|
|
360
|
-
const msg = buildDeckConfigMessage(
|
|
361
|
-
activeDeck,
|
|
362
|
-
addonByType,
|
|
363
|
-
resolverOptions,
|
|
364
|
-
{
|
|
365
|
-
navStackDepth: runtime.navStackDepth(),
|
|
366
|
-
hasOverlayDeckAvailable: runtime.hasOverlayDeckAvailable(),
|
|
367
|
-
inOverlayMode: runtime.getOverlay() !== null,
|
|
368
|
-
},
|
|
369
|
-
undefined,
|
|
370
|
-
isCompact,
|
|
371
|
-
(fullPath) => getAssetByPath(fullPath)?.id,
|
|
372
|
-
runtime.getAvailableOverlayDeckIcon(),
|
|
373
|
-
runtime.getAvailableOverlayDeckName(),
|
|
374
|
-
{ lockActive: runtime.isLockActive() },
|
|
375
|
-
)
|
|
376
|
-
bridge.broadcast(msg)
|
|
377
|
-
}, 2000)
|
|
378
|
-
signal.addEventListener("abort", () => clearInterval(heartbeat))
|
|
379
|
-
|
|
380
285
|
const unsubscribeNavigate = subscribeNavigateDeck(pubSub, runtime)
|
|
381
286
|
|
|
382
287
|
const unsubscribeDispatch = pubSub.subscribe(
|
|
@@ -440,14 +345,14 @@ export const setupAddonServices = (
|
|
|
440
345
|
|
|
441
346
|
return {
|
|
442
347
|
dispose: () => {
|
|
348
|
+
void addonBridge.then((handle) => handle.dispose())
|
|
443
349
|
unsubscribeDeck()
|
|
444
|
-
unsubscribeDeckBroadcast()
|
|
445
|
-
unsubscribeOverlayAvailableBroadcast()
|
|
446
350
|
unsubscribeBrightnessBridge()
|
|
447
351
|
unsubscribeNavigate()
|
|
448
352
|
unsubscribeDispatch()
|
|
449
353
|
unsubscribeButtonError()
|
|
450
354
|
},
|
|
355
|
+
reconcile: async (nextDecks) => (await addonBridge).reconcile(nextDecks),
|
|
451
356
|
}
|
|
452
357
|
}
|
|
453
358
|
|
|
@@ -555,12 +460,22 @@ const loadExternalAddonsIntoRegistry = async (
|
|
|
555
460
|
}
|
|
556
461
|
for (const issue of result.issues) {
|
|
557
462
|
const payload = { source: issue.source, message: issue.message }
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
else
|
|
463
|
+
if (issue.level === "error") {
|
|
464
|
+
logger.warn(
|
|
465
|
+
payload,
|
|
466
|
+
`Configured addon '${issue.source}' was skipped; its buttons and decks are unavailable. ${issue.message} Fix the addon entry or remove it from addons[].`,
|
|
467
|
+
)
|
|
468
|
+
} else if (issue.level === "warning") {
|
|
469
|
+
logger.warn(
|
|
470
|
+
payload,
|
|
471
|
+
`addon load warning — ${issue.source}: ${issue.message}`,
|
|
472
|
+
)
|
|
473
|
+
} else {
|
|
474
|
+
logger.info(
|
|
475
|
+
payload,
|
|
476
|
+
`addon load info — ${issue.source}: ${issue.message}`,
|
|
477
|
+
)
|
|
478
|
+
}
|
|
564
479
|
}
|
|
565
480
|
for (const loaded of result.addons) {
|
|
566
481
|
try {
|
|
@@ -639,12 +554,14 @@ export const validateAndLoadConfig = async (
|
|
|
639
554
|
// Per-button config errors are non-fatal: each broken button is replaced
|
|
640
555
|
// with a `core:temporary-error` cell at its position and logged in full
|
|
641
556
|
// (the incorrect config + the schema issues) so the operator can see
|
|
642
|
-
// exactly what went wrong without restarting the daemon.
|
|
643
|
-
//
|
|
644
|
-
//
|
|
557
|
+
// exactly what went wrong without restarting the daemon. Unknown button
|
|
558
|
+
// types are also per-button failures: this lets the rest of the deck run
|
|
559
|
+
// when an optional addon is missing or a type has a typo.
|
|
645
560
|
const validation = validateFull(config, registry)
|
|
646
561
|
const structuralErrors = validation.issues.filter(
|
|
647
|
-
(i) =>
|
|
562
|
+
(i) =>
|
|
563
|
+
!i.path.includes(".config.") &&
|
|
564
|
+
!(i.reason === "unknown-type" && i.deckId !== undefined),
|
|
648
565
|
)
|
|
649
566
|
if (structuralErrors.some((i) => i.level === "error")) {
|
|
650
567
|
throw new Error(
|
|
@@ -837,6 +754,7 @@ const buildRuntime = (
|
|
|
837
754
|
...(typeof b.config === "object" && b.config !== null
|
|
838
755
|
? { config: b.config }
|
|
839
756
|
: {}),
|
|
757
|
+
...(b.icon !== undefined ? { icon: b.icon } : {}),
|
|
840
758
|
...(b.actions !== undefined ? { actions: b.actions } : {}),
|
|
841
759
|
...(b.variant !== undefined && b.variant.length > 0
|
|
842
760
|
? { variant: b.variant }
|
|
@@ -965,7 +883,7 @@ const buildRuntime = (
|
|
|
965
883
|
decks.length > 0
|
|
966
884
|
? decks
|
|
967
885
|
: [{ id: "main", name: "Main", isMain: true, buttons: [] }]
|
|
968
|
-
const
|
|
886
|
+
const materializedDecks = materializeAddonDecks(
|
|
969
887
|
registry,
|
|
970
888
|
effectiveDecks,
|
|
971
889
|
logger,
|
|
@@ -973,6 +891,7 @@ const buildRuntime = (
|
|
|
973
891
|
config.lock?.buttons,
|
|
974
892
|
addonConfigOverrides,
|
|
975
893
|
)
|
|
894
|
+
const sourceDecks = positionSettingsVersionButton(materializedDecks, keyCount)
|
|
976
895
|
const allDecsWithSystemButtons = injectSystemButtons(sourceDecks, keyCount, {
|
|
977
896
|
lockActive,
|
|
978
897
|
})
|
|
@@ -982,8 +901,13 @@ const buildRuntime = (
|
|
|
982
901
|
registry,
|
|
983
902
|
logger,
|
|
984
903
|
)
|
|
904
|
+
const token = process.env["SIRENO_TOKEN"] ?? ""
|
|
905
|
+
const configUiUrl = new URL(`http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`)
|
|
906
|
+
if (token.length > 0) configUiUrl.searchParams.set("token", token)
|
|
907
|
+
configUiUrl.hash = "/config"
|
|
908
|
+
const runtimeDecks = injectConfigUiButton(allDecks, configUiUrl.toString())
|
|
985
909
|
const { runtime, methods, pubSub, store } = createDeckRuntime({
|
|
986
|
-
decks:
|
|
910
|
+
decks: runtimeDecks,
|
|
987
911
|
logger,
|
|
988
912
|
})
|
|
989
913
|
|
|
@@ -996,7 +920,7 @@ const buildRuntime = (
|
|
|
996
920
|
uiOverridesPath: theme.uiOverridesPath,
|
|
997
921
|
},
|
|
998
922
|
themeDir,
|
|
999
|
-
decks:
|
|
923
|
+
decks: runtimeDecks,
|
|
1000
924
|
sourceDecks,
|
|
1001
925
|
pubSub,
|
|
1002
926
|
runtime,
|
|
@@ -1122,67 +1046,15 @@ interface SystemProviders {
|
|
|
1122
1046
|
readonly session: import("@/system/providers/session").SessionProvider
|
|
1123
1047
|
readonly keyMacro: import("@/system/providers/key-macro").KeyMacroProvider
|
|
1124
1048
|
readonly notification: import("@/system/providers/notification").NotificationProvider
|
|
1049
|
+
readonly url: import("@/system/providers/url").UrlProvider
|
|
1125
1050
|
}
|
|
1126
1051
|
|
|
1127
1052
|
const startSystemProviders = async (
|
|
1128
1053
|
options: RunOptions,
|
|
1129
|
-
runtime: Runtime,
|
|
1130
1054
|
methods: Methods,
|
|
1131
1055
|
): Promise<SystemProviders> => {
|
|
1132
1056
|
const { logger } = options
|
|
1133
|
-
const
|
|
1134
|
-
const executor: CommandExecutor = {
|
|
1135
|
-
async run(
|
|
1136
|
-
command: string,
|
|
1137
|
-
args: ReadonlyArray<string>,
|
|
1138
|
-
execOptions?: { timeoutMs?: number },
|
|
1139
|
-
) {
|
|
1140
|
-
// Uses 'exit' (not 'close') so tools that keep stdio fds open after their
|
|
1141
|
-
// main exits — notably wl-copy — don't hang the runtime. Streams are
|
|
1142
|
-
// drained via 'data' events until 'exit' fires; once the process exits,
|
|
1143
|
-
// no further writes are possible.
|
|
1144
|
-
const timeoutMs = execOptions?.timeoutMs
|
|
1145
|
-
const start = Date.now()
|
|
1146
|
-
return await new Promise((resolve) => {
|
|
1147
|
-
const proc = spawn(command, [...args], {
|
|
1148
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
1149
|
-
})
|
|
1150
|
-
let stdout = ""
|
|
1151
|
-
let stderr = ""
|
|
1152
|
-
let timedOut = false
|
|
1153
|
-
let killTimer: ReturnType<typeof setTimeout> | undefined
|
|
1154
|
-
proc.stdout.on("data", (chunk: Buffer) => {
|
|
1155
|
-
stdout += chunk.toString()
|
|
1156
|
-
})
|
|
1157
|
-
proc.stderr.on("data", (chunk: Buffer) => {
|
|
1158
|
-
stderr += chunk.toString()
|
|
1159
|
-
})
|
|
1160
|
-
const onExit = (code: number | null): void => {
|
|
1161
|
-
if (killTimer !== undefined) clearTimeout(killTimer)
|
|
1162
|
-
resolve({
|
|
1163
|
-
exitCode: timedOut ? -1 : (code ?? -1),
|
|
1164
|
-
stdout,
|
|
1165
|
-
stderr,
|
|
1166
|
-
})
|
|
1167
|
-
}
|
|
1168
|
-
proc.on("error", (err) => {
|
|
1169
|
-
if (killTimer !== undefined) clearTimeout(killTimer)
|
|
1170
|
-
resolve({
|
|
1171
|
-
exitCode: -1,
|
|
1172
|
-
stdout,
|
|
1173
|
-
stderr: stderr ? `${stderr}\n${err.message}` : err.message,
|
|
1174
|
-
})
|
|
1175
|
-
})
|
|
1176
|
-
proc.on("exit", onExit)
|
|
1177
|
-
if (timeoutMs !== undefined && timeoutMs > 0) {
|
|
1178
|
-
killTimer = setTimeout(() => {
|
|
1179
|
-
timedOut = true
|
|
1180
|
-
proc.kill("SIGKILL")
|
|
1181
|
-
}, timeoutMs)
|
|
1182
|
-
}
|
|
1183
|
-
})
|
|
1184
|
-
},
|
|
1185
|
-
}
|
|
1057
|
+
const executor: CommandExecutor = createCommandExecutor()
|
|
1186
1058
|
|
|
1187
1059
|
const env = { ...process.env } as Readonly<Record<string, string>>
|
|
1188
1060
|
const platform = process.platform
|
|
@@ -1225,13 +1097,25 @@ const startSystemProviders = async (
|
|
|
1225
1097
|
const [activeApp, session, keyMacro, notification] = await Promise.all([
|
|
1226
1098
|
createActiveAppProvider({ platform, executor, logger }),
|
|
1227
1099
|
options.emulator === true
|
|
1228
|
-
?
|
|
1100
|
+
? // Emulator mode intentionally does not follow the host lock screen;
|
|
1101
|
+
// this is an expected transport choice, not an unavailable OS feature.
|
|
1102
|
+
createNullSessionProvider()
|
|
1229
1103
|
: createSessionProvider({
|
|
1230
1104
|
platform,
|
|
1231
1105
|
executor,
|
|
1232
1106
|
logger,
|
|
1233
1107
|
}),
|
|
1234
|
-
|
|
1108
|
+
// ponytail: capture mode must not type emoji or Meet shortcuts into the
|
|
1109
|
+
// operator's active desktop while the emulator records their gestures.
|
|
1110
|
+
env["SIRENO_CAPTURE_DISABLE_KEYBOARD"] === "1"
|
|
1111
|
+
? Promise.resolve({ sendKey: async () => {}, stop: async () => {} })
|
|
1112
|
+
: createKeyMacroProvider({
|
|
1113
|
+
platform,
|
|
1114
|
+
executor,
|
|
1115
|
+
env,
|
|
1116
|
+
logger,
|
|
1117
|
+
extraFsProbe,
|
|
1118
|
+
}),
|
|
1235
1119
|
createNotificationProvider({
|
|
1236
1120
|
platform,
|
|
1237
1121
|
executor,
|
|
@@ -1241,12 +1125,12 @@ const startSystemProviders = async (
|
|
|
1241
1125
|
}),
|
|
1242
1126
|
])
|
|
1243
1127
|
|
|
1244
|
-
runtime.setActiveAppProvider(activeApp)
|
|
1245
|
-
runtime.setSessionProvider(session)
|
|
1246
1128
|
methods.setKeyMacroProvider(keyMacro)
|
|
1247
1129
|
methods.setNotificationProvider(notification)
|
|
1130
|
+
const url = createUrlProvider(platform, executor)
|
|
1131
|
+
methods.setUrlProvider(url)
|
|
1248
1132
|
|
|
1249
|
-
return { activeApp, session, keyMacro, notification }
|
|
1133
|
+
return { activeApp, session, keyMacro, notification, url }
|
|
1250
1134
|
}
|
|
1251
1135
|
|
|
1252
1136
|
interface AddonRegistryBundle {
|
|
@@ -1306,6 +1190,7 @@ export const addonInventoryFromScanned = (
|
|
|
1306
1190
|
addonIndex = 0,
|
|
1307
1191
|
materializedDecks: ReadonlyArray<RuntimeDeck> = [],
|
|
1308
1192
|
defaultConfig?: unknown,
|
|
1193
|
+
registry?: AddonRegistry,
|
|
1309
1194
|
): AddonInventoryEntry => {
|
|
1310
1195
|
const generatedDecks = materializedDecks.filter(
|
|
1311
1196
|
(deck) => deck.addonOwner?.addonName === s.name,
|
|
@@ -1358,14 +1243,25 @@ export const addonInventoryFromScanned = (
|
|
|
1358
1243
|
...(s.path !== undefined ? { path: s.path } : {}),
|
|
1359
1244
|
internal: s.internal === true,
|
|
1360
1245
|
source: s.source,
|
|
1361
|
-
buttonTypes: Object.entries(s.buttonTypes).map(([type, info]) =>
|
|
1362
|
-
type
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1246
|
+
buttonTypes: Object.entries(s.buttonTypes).map(([type, info]) => {
|
|
1247
|
+
const service = registry?.getButtonType(type)?.def.service
|
|
1248
|
+
const gestureHandlers = service?.gestureHandlers?.filter((gesture) =>
|
|
1249
|
+
gesture === "tap"
|
|
1250
|
+
? service.onTap !== undefined
|
|
1251
|
+
: gesture === "dbl-tap"
|
|
1252
|
+
? service.onDblTap !== undefined
|
|
1253
|
+
: service.onHold !== undefined,
|
|
1254
|
+
)
|
|
1255
|
+
return {
|
|
1256
|
+
type,
|
|
1257
|
+
internal: info.internal || service?.internal === true,
|
|
1258
|
+
generated: false,
|
|
1259
|
+
...(info.defaultConfig !== undefined
|
|
1260
|
+
? { defaultConfig: info.defaultConfig }
|
|
1261
|
+
: {}),
|
|
1262
|
+
...(gestureHandlers?.length ? { gestureHandlers } : {}),
|
|
1263
|
+
}
|
|
1264
|
+
}),
|
|
1369
1265
|
defaultButton: s.defaultButton ?? null,
|
|
1370
1266
|
...(defaultConfig !== undefined ? { defaultConfig } : {}),
|
|
1371
1267
|
decks,
|
|
@@ -1592,6 +1488,9 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1592
1488
|
let addonBundle: Awaited<ReturnType<typeof buildAddonBundle>> | null = null
|
|
1593
1489
|
let bridge: Awaited<ReturnType<typeof startWsBridge>> | null = null
|
|
1594
1490
|
let addonServices: ReturnType<typeof setupAddonServices> | null = null
|
|
1491
|
+
let hostPolicy: ReturnType<typeof createHostPolicyCoordinator> | null = null
|
|
1492
|
+
let presentation: ReturnType<typeof createDeckPresentationPublisher> | null =
|
|
1493
|
+
null
|
|
1595
1494
|
let runtime: ReturnType<typeof buildRuntime>["runtime"] | null = null
|
|
1596
1495
|
let methods: ReturnType<typeof buildRuntime>["methods"] | null = null
|
|
1597
1496
|
let decks: ReadonlyArray<RuntimeDeck> | null = null
|
|
@@ -1629,6 +1528,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1629
1528
|
outputClient = selectOutputClient({
|
|
1630
1529
|
emulator: options.emulator === true,
|
|
1631
1530
|
xdgConfigHome,
|
|
1531
|
+
...(options.remote === true ? { remote: true } : {}),
|
|
1632
1532
|
})
|
|
1633
1533
|
const devices = await outputClient.listDevices()
|
|
1634
1534
|
const savedDevice = loadDeviceConfig({ xdgConfigHome })
|
|
@@ -1647,7 +1547,15 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1647
1547
|
methods = loaded.methods
|
|
1648
1548
|
store = loaded.store
|
|
1649
1549
|
|
|
1650
|
-
providers = await startSystemProviders(options,
|
|
1550
|
+
providers = await startSystemProviders(options, methods)
|
|
1551
|
+
hostPolicy = createHostPolicyCoordinator({
|
|
1552
|
+
runtime,
|
|
1553
|
+
activeApp: providers.activeApp,
|
|
1554
|
+
session: providers.session,
|
|
1555
|
+
decks,
|
|
1556
|
+
logger,
|
|
1557
|
+
})
|
|
1558
|
+
hostPolicy.start()
|
|
1651
1559
|
|
|
1652
1560
|
const isCompact = outputClient.kind === "real"
|
|
1653
1561
|
|
|
@@ -1659,9 +1567,10 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1659
1567
|
: []
|
|
1660
1568
|
const lanHost = remote ? lanAddresses[0]?.address : undefined
|
|
1661
1569
|
const bridgeHost: "127.0.0.1" | "0.0.0.0" = remote ? "0.0.0.0" : "127.0.0.1"
|
|
1570
|
+
const bridgePort = options.port ?? DEFAULT_BRIDGE_PORT
|
|
1662
1571
|
|
|
1663
1572
|
bridge = await startWsBridge({
|
|
1664
|
-
port:
|
|
1573
|
+
port: bridgePort,
|
|
1665
1574
|
host: bridgeHost,
|
|
1666
1575
|
...(lanHost !== undefined ? { lanHost } : {}),
|
|
1667
1576
|
expectedToken: process.env["SIRENO_TOKEN"] ?? "",
|
|
@@ -1691,47 +1600,11 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1691
1600
|
injectSystemButtons(loaded.sourceDecks, descriptor!.keyCount, {
|
|
1692
1601
|
lockActive: isLocked,
|
|
1693
1602
|
})
|
|
1694
|
-
const broadcastActiveDeck = (): void => {
|
|
1695
|
-
const activeDeck = runtime!.getActiveDeck()
|
|
1696
|
-
if (activeDeck === undefined) return
|
|
1697
|
-
const msg = buildDeckConfigMessage(
|
|
1698
|
-
activeDeck,
|
|
1699
|
-
runtimeAddonByType,
|
|
1700
|
-
resolverOptions,
|
|
1701
|
-
{
|
|
1702
|
-
navStackDepth: runtime!.navStackDepth(),
|
|
1703
|
-
hasOverlayDeckAvailable: runtime!.hasOverlayDeckAvailable(),
|
|
1704
|
-
inOverlayMode: runtime!.getOverlay() !== null,
|
|
1705
|
-
},
|
|
1706
|
-
descriptor!.keyCount,
|
|
1707
|
-
outputClient!.kind === "real",
|
|
1708
|
-
(fullPath) => getAssetByPath(fullPath)?.id,
|
|
1709
|
-
runtime!.getAvailableOverlayDeckIcon(),
|
|
1710
|
-
runtime!.getAvailableOverlayDeckName(),
|
|
1711
|
-
{ lockActive: runtime!.isLockActive() },
|
|
1712
|
-
)
|
|
1713
|
-
bridge!.broadcast(msg)
|
|
1714
|
-
}
|
|
1715
1603
|
if (providers.session.getState() === "locked") {
|
|
1716
1604
|
const reInjected = reInjectedDecks(true)
|
|
1717
1605
|
runtime.setDecks(reInjected)
|
|
1718
1606
|
decks = reInjected
|
|
1719
|
-
broadcastActiveDeck()
|
|
1720
1607
|
}
|
|
1721
|
-
unsubscribeLockMode = pubSub.subscribe("runtime:lock-mode", (payload) => {
|
|
1722
|
-
const isLocked =
|
|
1723
|
-
typeof payload === "object" &&
|
|
1724
|
-
payload !== null &&
|
|
1725
|
-
(payload as { active?: unknown }).active === true
|
|
1726
|
-
const reInjected = reInjectedDecks(isLocked)
|
|
1727
|
-
runtime!.setDecks(reInjected)
|
|
1728
|
-
decks = reInjected
|
|
1729
|
-
// ponytail: runtime:setDecks publishes runtime:activeDeck, but the
|
|
1730
|
-
// deck-id-equality dedup in the bridge subscriber skips the
|
|
1731
|
-
// re-broadcast when the active deck id is unchanged. Force a fresh
|
|
1732
|
-
// broadcast so the wire filter sees the lock state on the new decks.
|
|
1733
|
-
broadcastActiveDeck()
|
|
1734
|
-
})
|
|
1735
1608
|
|
|
1736
1609
|
bridgeSignal = new AbortController()
|
|
1737
1610
|
statePublisher = new StatePublisher({
|
|
@@ -1771,6 +1644,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1771
1644
|
addonIndex,
|
|
1772
1645
|
decks ?? [],
|
|
1773
1646
|
defaultConfigs.get(addon.name),
|
|
1647
|
+
loadedConfig!.registry,
|
|
1774
1648
|
),
|
|
1775
1649
|
)
|
|
1776
1650
|
})(),
|
|
@@ -1787,6 +1661,43 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1787
1661
|
addonBundle.addonByType,
|
|
1788
1662
|
externalScanned,
|
|
1789
1663
|
)
|
|
1664
|
+
bridge.onConnection((socket) => {
|
|
1665
|
+
const allAssets = getUnsentAssets(new Set())
|
|
1666
|
+
if (allAssets.length === 0) return
|
|
1667
|
+
bridge!.sendToCaller?.(socket, {
|
|
1668
|
+
type: "assets",
|
|
1669
|
+
deckId: runtime!.getActiveDeckId(),
|
|
1670
|
+
assets: allAssets.map((asset) => ({
|
|
1671
|
+
id: asset.id,
|
|
1672
|
+
filename: asset.fullPath,
|
|
1673
|
+
src: asset.src,
|
|
1674
|
+
})),
|
|
1675
|
+
})
|
|
1676
|
+
})
|
|
1677
|
+
presentation = createDeckPresentationPublisher({
|
|
1678
|
+
runtime,
|
|
1679
|
+
pubSub,
|
|
1680
|
+
bridge,
|
|
1681
|
+
addonByType: runtimeAddonByType,
|
|
1682
|
+
resolverOptions,
|
|
1683
|
+
keyCount: descriptor.keyCount,
|
|
1684
|
+
isCompact,
|
|
1685
|
+
assetLookup: (fullPath) => getAssetByPath(fullPath)?.id,
|
|
1686
|
+
logger,
|
|
1687
|
+
})
|
|
1688
|
+
presentation.start()
|
|
1689
|
+
unsubscribeLockMode = pubSub.subscribe("runtime:lock-mode", (payload) => {
|
|
1690
|
+
const isLocked =
|
|
1691
|
+
typeof payload === "object" &&
|
|
1692
|
+
payload !== null &&
|
|
1693
|
+
(payload as { active?: unknown }).active === true
|
|
1694
|
+
const reInjected = reInjectedDecks(isLocked)
|
|
1695
|
+
runtime!.setDecks(reInjected)
|
|
1696
|
+
decks = reInjected
|
|
1697
|
+
hostPolicy?.updateDecks(reInjected)
|
|
1698
|
+
presentation?.refresh({ force: true })
|
|
1699
|
+
})
|
|
1700
|
+
|
|
1790
1701
|
const serviceDecks: RuntimeDeck[] = [...decks]
|
|
1791
1702
|
let currentLoadedConfig = loadedConfig
|
|
1792
1703
|
const nextMainDeckId = (
|
|
@@ -1795,7 +1706,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1795
1706
|
config.decks["main"] !== undefined
|
|
1796
1707
|
? "main"
|
|
1797
1708
|
: (Object.keys(config.decks)[0] ?? "main")
|
|
1798
|
-
const requestDeckRebuild = (): void => {
|
|
1709
|
+
const requestDeckRebuild = async (): Promise<void> => {
|
|
1799
1710
|
if (
|
|
1800
1711
|
runtime === null ||
|
|
1801
1712
|
descriptor === null ||
|
|
@@ -1813,9 +1724,11 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1813
1724
|
descriptor.keyCount,
|
|
1814
1725
|
providers.session.getState() === "locked",
|
|
1815
1726
|
).decks
|
|
1727
|
+
await addonServices?.reconcile(rebuilt)
|
|
1816
1728
|
decks = rebuilt
|
|
1817
1729
|
serviceDecks.splice(0, serviceDecks.length, ...rebuilt)
|
|
1818
1730
|
runtime.setDecks(rebuilt)
|
|
1731
|
+
hostPolicy?.updateDecks(rebuilt)
|
|
1819
1732
|
const activeId = runtime.getActiveDeckId()
|
|
1820
1733
|
if (!rebuilt.some((d) => d.id === activeId)) {
|
|
1821
1734
|
const fallback = rebuilt.some((d) => d.id === "main")
|
|
@@ -1830,31 +1743,9 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1830
1743
|
bridge.setDeckTree(
|
|
1831
1744
|
buildDeckTree(rebuilt, nextMainDeckId(currentLoadedConfig.config)),
|
|
1832
1745
|
)
|
|
1833
|
-
|
|
1834
|
-
const msg = buildDeckConfigMessage(
|
|
1835
|
-
activeDeck,
|
|
1836
|
-
runtimeAddonByType,
|
|
1837
|
-
resolverOptions,
|
|
1838
|
-
{
|
|
1839
|
-
navStackDepth: runtime.navStackDepth(),
|
|
1840
|
-
hasOverlayDeckAvailable: runtime.hasOverlayDeckAvailable(),
|
|
1841
|
-
inOverlayMode: runtime.getOverlay() !== null,
|
|
1842
|
-
},
|
|
1843
|
-
descriptor.keyCount,
|
|
1844
|
-
outputClient.kind === "real",
|
|
1845
|
-
(fullPath) => getAssetByPath(fullPath)?.id,
|
|
1846
|
-
runtime.getAvailableOverlayDeckIcon(),
|
|
1847
|
-
runtime.getAvailableOverlayDeckName(),
|
|
1848
|
-
{ lockActive: runtime.isLockActive() },
|
|
1849
|
-
)
|
|
1850
|
-
bridge.broadcast(msg)
|
|
1746
|
+
presentation?.refresh({ force: true })
|
|
1851
1747
|
logger.info(
|
|
1852
|
-
{
|
|
1853
|
-
deckId: msg.deckId,
|
|
1854
|
-
buttonCount: (
|
|
1855
|
-
msg.surfaces[msg.deckId] as { buttons?: unknown[] } | undefined
|
|
1856
|
-
)?.buttons?.length,
|
|
1857
|
-
},
|
|
1748
|
+
{ deckId: runtime.getActiveDeckId() },
|
|
1858
1749
|
"addon requested deck rebuild",
|
|
1859
1750
|
)
|
|
1860
1751
|
}
|
|
@@ -1875,6 +1766,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1875
1766
|
statePublisher,
|
|
1876
1767
|
bridge,
|
|
1877
1768
|
isCompact,
|
|
1769
|
+
keyCount: descriptor.keyCount,
|
|
1878
1770
|
resolverOptions,
|
|
1879
1771
|
requestDeckRebuild,
|
|
1880
1772
|
...(mainDeck !== undefined ? { initialDeck: mainDeck } : {}),
|
|
@@ -1889,59 +1781,6 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1889
1781
|
registerIconForDeck(deck.buttons ?? [], resolverOptions, logger)
|
|
1890
1782
|
}
|
|
1891
1783
|
|
|
1892
|
-
bridge.onConnection((socket) => {
|
|
1893
|
-
// Send the full asset bundle to every new connection. The previous
|
|
1894
|
-
// dedupe-by-id approach caused the React frontend to render the
|
|
1895
|
-
// fallback icon after a hot-reload or page refresh: the FIRST
|
|
1896
|
-
// connection consumed the assets, every subsequent connection got
|
|
1897
|
-
// an empty list, and the new client started with an empty cache.
|
|
1898
|
-
// Assets are tiny (a 1.4KB chrome.svg), so re-sending them on
|
|
1899
|
-
// reconnect is cheaper than the bug.
|
|
1900
|
-
const allAssets = getUnsentAssets(new Set())
|
|
1901
|
-
if (allAssets.length > 0) {
|
|
1902
|
-
socket.send(
|
|
1903
|
-
JSON.stringify({
|
|
1904
|
-
type: "assets",
|
|
1905
|
-
deckId: mainDeck?.id ?? "",
|
|
1906
|
-
assets: allAssets.map((a) => ({
|
|
1907
|
-
id: a.id,
|
|
1908
|
-
filename: a.fullPath,
|
|
1909
|
-
src: a.src,
|
|
1910
|
-
})),
|
|
1911
|
-
}),
|
|
1912
|
-
)
|
|
1913
|
-
}
|
|
1914
|
-
const activeDeck = runtime!.getActiveDeck()
|
|
1915
|
-
if (activeDeck !== undefined) {
|
|
1916
|
-
const msg = buildDeckConfigMessage(
|
|
1917
|
-
activeDeck,
|
|
1918
|
-
runtimeAddonByType,
|
|
1919
|
-
resolverOptions,
|
|
1920
|
-
{
|
|
1921
|
-
navStackDepth: runtime!.navStackDepth(),
|
|
1922
|
-
hasOverlayDeckAvailable: runtime!.hasOverlayDeckAvailable(),
|
|
1923
|
-
inOverlayMode: runtime!.getOverlay() !== null,
|
|
1924
|
-
},
|
|
1925
|
-
descriptor!.keyCount,
|
|
1926
|
-
outputClient!.kind === "real",
|
|
1927
|
-
(fullPath) => getAssetByPath(fullPath)?.id,
|
|
1928
|
-
runtime!.getAvailableOverlayDeckIcon(),
|
|
1929
|
-
runtime!.getAvailableOverlayDeckName(),
|
|
1930
|
-
{ lockActive: runtime!.isLockActive() },
|
|
1931
|
-
)
|
|
1932
|
-
logger.info(
|
|
1933
|
-
{
|
|
1934
|
-
deckId: msg.deckId,
|
|
1935
|
-
buttonCount: (
|
|
1936
|
-
msg.surfaces[msg.deckId] as { buttons?: unknown[] } | undefined
|
|
1937
|
-
)?.buttons?.length,
|
|
1938
|
-
},
|
|
1939
|
-
"orchestrator: sending deck-config",
|
|
1940
|
-
)
|
|
1941
|
-
socket.send(JSON.stringify(msg))
|
|
1942
|
-
}
|
|
1943
|
-
})
|
|
1944
|
-
|
|
1945
1784
|
const onServiceLog = (entry: {
|
|
1946
1785
|
level: string
|
|
1947
1786
|
msg: string
|
|
@@ -2045,16 +1884,17 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2045
1884
|
if (!configChanged(currentLoadedConfig.config, nextLoaded.config)) return
|
|
2046
1885
|
|
|
2047
1886
|
const previousConfig = currentLoadedConfig.config
|
|
2048
|
-
const wasActive = runtime!.getActiveDeckId()
|
|
2049
1887
|
const nextRuntime = buildRuntime(
|
|
2050
1888
|
options,
|
|
2051
1889
|
nextLoaded,
|
|
2052
1890
|
descriptor!.keyCount,
|
|
2053
1891
|
providers?.session.getState() === "locked",
|
|
2054
1892
|
)
|
|
1893
|
+
await addonServices?.reconcile(nextRuntime.decks)
|
|
2055
1894
|
runtime!.setDecks(nextRuntime.decks)
|
|
2056
1895
|
decks = nextRuntime.decks
|
|
2057
1896
|
serviceDecks.splice(0, serviceDecks.length, ...nextRuntime.decks)
|
|
1897
|
+
hostPolicy?.updateDecks(nextRuntime.decks)
|
|
2058
1898
|
currentLoadedConfig = nextLoaded
|
|
2059
1899
|
|
|
2060
1900
|
const nextExternal = buildExternalScannedAddons(
|
|
@@ -2083,6 +1923,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2083
1923
|
nextLoaded.addonEntryPaths,
|
|
2084
1924
|
),
|
|
2085
1925
|
)
|
|
1926
|
+
presentation?.updateResolverOptions(resolverOptions)
|
|
2086
1927
|
bridge!.setActiveTheme?.({ name: nextLoaded.theme.name })
|
|
2087
1928
|
bridge!.setAddonInventory(
|
|
2088
1929
|
[...addonBundle!.scanned, ...nextExternal].map((addon, addonIndex) =>
|
|
@@ -2095,6 +1936,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2095
1936
|
nextRuntime.decks,
|
|
2096
1937
|
logger,
|
|
2097
1938
|
).get(addon.name),
|
|
1939
|
+
nextLoaded.registry,
|
|
2098
1940
|
),
|
|
2099
1941
|
),
|
|
2100
1942
|
)
|
|
@@ -2106,9 +1948,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2106
1948
|
registerIconForDeck(deck.buttons ?? [], resolverOptions, logger)
|
|
2107
1949
|
}
|
|
2108
1950
|
|
|
2109
|
-
|
|
2110
|
-
// is the one normal deck-config frame for the refresh.
|
|
2111
|
-
if (runtime!.getActiveDeckId() === wasActive) broadcastActiveDeck()
|
|
1951
|
+
presentation?.refresh({ force: true })
|
|
2112
1952
|
if (
|
|
2113
1953
|
JSON.stringify(previousConfig.theme) !==
|
|
2114
1954
|
JSON.stringify(nextLoaded.config.theme) ||
|
|
@@ -2177,6 +2017,23 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2177
2017
|
name: theme.name,
|
|
2178
2018
|
active: theme.name === currentLoadedConfig.theme.name,
|
|
2179
2019
|
})),
|
|
2020
|
+
themeVariants: (() => {
|
|
2021
|
+
try {
|
|
2022
|
+
const variants = readAndValidateManifest(
|
|
2023
|
+
currentLoadedConfig.theme.manifestPath,
|
|
2024
|
+
).variants
|
|
2025
|
+
return Object.fromEntries(
|
|
2026
|
+
Object.entries(variants).map(
|
|
2027
|
+
([name, { background, border, foreground }]) => [
|
|
2028
|
+
name,
|
|
2029
|
+
{ background, border, foreground },
|
|
2030
|
+
],
|
|
2031
|
+
),
|
|
2032
|
+
)
|
|
2033
|
+
} catch {
|
|
2034
|
+
return {}
|
|
2035
|
+
}
|
|
2036
|
+
})(),
|
|
2180
2037
|
buttonSchemas: serializeButtonSchemas(currentLoadedConfig.registry),
|
|
2181
2038
|
surfaces: runtime!.getEditorSurfaces({
|
|
2182
2039
|
keyCount: descriptor!.keyCount,
|
|
@@ -2229,6 +2086,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2229
2086
|
if (unregisterReload !== null) unregisterReload()
|
|
2230
2087
|
if (bridgeSignal !== null) bridgeSignal.abort()
|
|
2231
2088
|
if (addonServicesDispose !== null) addonServicesDispose()
|
|
2089
|
+
if (presentation !== null) presentation.dispose()
|
|
2232
2090
|
if (unsubscribeLockMode !== null) unsubscribeLockMode()
|
|
2233
2091
|
if (statePublisher !== null) statePublisher.stopAll()
|
|
2234
2092
|
if (
|
|
@@ -2254,8 +2112,7 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2254
2112
|
currentOutputHandle !== null
|
|
2255
2113
|
? currentOutputHandle.stop()
|
|
2256
2114
|
: Promise.resolve(),
|
|
2257
|
-
|
|
2258
|
-
providers !== null ? providers.activeApp.stop() : Promise.resolve(),
|
|
2115
|
+
hostPolicy !== null ? hostPolicy.dispose() : Promise.resolve(),
|
|
2259
2116
|
providers !== null ? providers.session.stop() : Promise.resolve(),
|
|
2260
2117
|
providers !== null ? providers.keyMacro.stop() : Promise.resolve(),
|
|
2261
2118
|
bridge !== null ? bridge.close() : Promise.resolve(),
|