// The plugin entry — the default export the runner discovers. Everything is Effect inside // definePluginKit's async-main boundary (see @punktfunk/plugin-kit): start the sync engine, // serve the console UI, park until interruption. // // Provider entries are deliberately LEFT in the host library on shutdown, so the games // survive plugin restarts and host reboots; a clean uninstall is the explicit CLI command. import { definePluginKit, serveUi } from "@punktfunk/plugin-kit"; import { Effect } from "effect"; import pkg from "../package.json" with { type: "json" }; import { PLUGIN_NAME, UI_ICON, UI_TITLE } from "./const.js"; import { playniteLayer } from "./layer.js"; import { makeApi } from "./services/api.js"; import { PlayniteConfig } from "./services/config.js"; import { PlayniteSync } from "./services/engine.js"; export { PLUGIN_NAME, PROVIDER_ID, UI_ICON, UI_TITLE } from "./const.js"; const plugin = definePluginKit({ name: PLUGIN_NAME, version: pkg.version, layer: playniteLayer, main: Effect.gen(function* () { const sync = yield* PlayniteSync; const config = yield* PlayniteConfig; // Headless sync first — the library reconciles even if the UI can't come up. yield* sync.engine.start; yield* serveUi({ title: UI_TITLE, icon: UI_ICON, staticDir: new URL("./ui/", import.meta.url), api: makeApi({ sync, config }), }).pipe( Effect.catch((e) => Effect.logWarning( `ui: could not serve the console surface (${e.cause}) — engine continues headless`, ), ), ); yield* Effect.never; }), }); export default plugin;