/** * Server-side utilities for roy-plugin-task-show. * * Task #2979: Display the plugin version in the page title and top * heading so users can immediately tell which build the plugin host * actually loaded (root-cause aid for browser-cache / npm-global * stale / plugin-host in-memory stale confusion — see Task #2978). * * Design choices: * * - Version is read from `package.json` at module-load time and * cached in a module-level variable. We deliberately do NOT * read it on every request (filesystem hit per render is * wasteful) and we deliberately do NOT expose a setter (the * value must reflect the on-disk package.json that the plugin * host installed). * * - We walk up from `import.meta.dir` until we find a * `package.json` whose `name` field matches the plugin's * expected package name. This handles both dev runs (src is * the module dir, package.json is at the repo root above) and * production runs (the package is installed by npm so * package.json sits next to src/). * * - If `package.json` cannot be read for any reason, we fall back * to the string `"unknown"` rather than throwing. This matches * the project-wide convention (the plugin keeps serving even * when a meta file is malformed) and avoids masking the actual * page-rendering bug with an unrelated crash. * * - The cached value is exported as both `getPluginVersion()` and * `PLUGIN_VERSION` so call sites can pick the style they prefer * (function call for testability, constant for inline use in * templates). */ /** * Read the plugin version from the on-disk `package.json` and cache * it. Returns the string `"unknown"` if the file is missing or * malformed. */ export declare function getPluginVersion(): string; /** * Synchronous, lazy-initialised constant mirror of `getPluginVersion()`. * Useful in template literals where calling a function is awkward. */ export declare const PLUGIN_VERSION: string; /** * Format the version for display in titles/headings. * * formatVersionLabel('2.5.14') === 'v2.5.14' * formatVersionLabel('unknown') === 'unknown' // no v prefix on unknown * * The `unknown` branch is intentional: showing `vunknown` would be * more confusing than helpful and the absence of a `v` makes it * obvious that something is wrong with the install. */ export declare function formatVersionLabel(version?: string): string; //# sourceMappingURL=server-utils.d.ts.map