/** * The contract shared between the plugin bundler and the renderers that load * its output. * * Kept in its own module with no imports on purpose. The bundler runs in Bun * and reaches the filesystem; the renderers that consume it are browser * contexts. Pulling these two constants from `bundle.ts` dragged the whole * bundler — and through it `plugins/loader.ts`, which reads `process.env.HOME` * at module scope — into the desktop view, where it threw on load. */ export const PLUGIN_HOST_GLOBAL = "__GLOOM_PLUGIN_HOST__"; /** * Specifiers a plugin may import that must resolve to the host's copy. Anything * else is a plugin's own dependency and gets bundled normally. * * Deliberately no `react-dom`: it is a renderer package, and plugins are * required to be renderer-neutral so the same code runs in the terminal. A * plugin reaching for it should fail to bundle rather than quietly work on the * desktop and break in the TUI. */ export const SHARED_SPECIFIERS = [ "react", "react/jsx-runtime", "react/jsx-dev-runtime", "gloomberb/types/plugin", "gloomberb/types/persistence", // Type modules also export runtime values (`TICKER_RESEARCH_PANE_ID`, // `resolvePaneInstance`, `DEFAULT_COLUMNS`) that plugins reach for. A bundled // copy would be harmless, but the compiled terminal binary and the packaged // desktop app have no host package on disk to bundle it from, so the host // serves these the same way it serves everything else. "gloomberb/types/broker", "gloomberb/types/config", "gloomberb/types/data-provider", "gloomberb/types/financials", "gloomberb/types/instrument", "gloomberb/types/ticker", "gloomberb/types/trading", "gloomberb/ui", "gloomberb/components", "gloomberb/theme", "gloomberb/capabilities", "gloomberb/utils", "gloomberb/react", // Modules below hold state or reach the host's services, so a bundled copy // is worse than a missing one. `gloomberb/broker` is the clearest case: it // owns the remote broker client the desktop view sets at startup, and a // plugin carrying its own copy reads an empty one and reports that the // broker host is unavailable. "gloomberb/broker", "gloomberb/dialog", "gloomberb/market-data", "gloomberb/time-series", // Layout placement reads and rewrites the app's own layout rules; a bundled // copy would drag the whole pane manager into every plugin that has a launch // command, and diverge from the host the next time those rules change. "gloomberb/layout", // Quote subscriptions live in host state; a bundled copy would open its own // feed and never see the host's updates. "gloomberb/quotes", // The ticker repository and the event bus behind it belong to the running // app: a plugin writing into its own copy would save tickers nothing else // can see. "gloomberb/tickers", // The selected language is host state, and a bundled copy of the tables // would answer in English no matter what the user picked. "gloomberb/i18n", ] as const; export type SharedSpecifier = (typeof SHARED_SPECIFIERS)[number];