Files
reverse-engineering-anything/src/desktop/DesktopCaptureProvider.ts
T
morluto 7af53a1b42 refactor(desktop): pass the desktop capture's observers, session runner and store through a port (#11676)
The desktop application capture workflow constructed the desktop provider's
X11 window observer and content store and called its session runner,
application inventory, program lookup and home-folder walker directly.
src/ports/DesktopApplicationSession.ts now names them as
DesktopCaptureProvider, with the plan, outcome, request and walk types they
exchange; src/desktop/DesktopCaptureProvider.ts implements it and the CLI
passes it in the capture host. application -> desktop entry imports: 20 -> 14.

Refs #11583
2026-11-15 22:28:05 -05:00

36 lines
1.3 KiB
TypeScript

import type { DesktopCaptureProvider } from "../ports/DesktopApplicationSession.js";
import {
runDesktopSession,
runningApplicationWindows,
} from "./DesktopApplicationSession.js";
import { DesktopContentStore } from "./DesktopContentStore.js";
import { walkHomeState } from "./HomeStateWalker.js";
import { inspectLinuxApplication } from "./LinuxApplicationInventory.js";
import { resolveProgram } from "./ProgramLookup.js";
import { X11WindowObserver } from "./X11WindowObserver.js";
/**
* The desktop provider's implementation of the capture port: `xprop` window
* observation, the supervised session runner, the home-folder walker and the
* content-addressed store under the capture directory.
*/
export const createDesktopCaptureProvider = (): DesktopCaptureProvider => ({
resolveProgram,
inspectApplication: (request, signal) =>
inspectLinuxApplication(request, signal),
observeWindows: (xprop, environment) =>
new X11WindowObserver(xprop, environment),
runningApplicationWindows,
runSession: runDesktopSession,
walkHome: walkHomeState,
openContentStore: async (directory, maxFileBytes, maxContentBytes) => {
const store = new DesktopContentStore(
directory,
maxFileBytes,
maxContentBytes,
);
await store.prepare();
return store;
},
});