export type ShareAudience = 'friend' | 'colleague' | 'public'; export type ShareAutoMode = 'auto' | 'force-file' | 'force-site' | 'force-zip'; export type ShareAutoKind = 'file' | 'site' | 'zip'; export interface ShareAutoDecision { kind: ShareAutoKind; isDirectory: boolean; reason: 'html-single-file' | 'html-with-assets' | 'small-image' | 'large-binary' | 'directory-zip' | 'directory-browse' | 'forced'; hint: string; } export interface ShareAutoProbe { absolutePath: string; kind: 'file' | 'directory'; size: number; mimeType: string; hasIndexHtml: boolean; } export interface ShareAutoDefaults { ttlMs: number; maxViews: number | null; } /** Convert an audience hint into TTL/maxViews defaults. */ export declare function audienceDefaults(audience: ShareAudience | undefined): ShareAutoDefaults; /** Run filesystem probes needed by the routing logic. */ export declare function probeShareTarget(workspaceRoot: string, relPath: string): Promise; /** Pure decision function — exported for tests. */ export declare function decideShareKind(probe: ShareAutoProbe, mode: ShareAutoMode | undefined): ShareAutoDecision; /** Build the user-facing title (trimmed, no extension). */ export declare function makeTitle(fileName: string, override?: string): string; /** Build the user-facing description (audience + TTL hint baked in). */ export declare function makeDescription(opts: { audience: ShareAudience | undefined; expiresAt: string; override?: string; }): string; /** Subfolder under the workspace where single-HTML site shares are staged. */ export declare const STAGING_DIR_NAME = ".xopc-share-staging"; export interface StagedSite { /** Absolute path of the freshly-created staging directory. */ stagingDir: string; /** Workspace-relative path to feed into SiteShareStore.create({ path }). */ relativePath: string; } /** * Copy a single HTML file into `/.xopc-share-staging//index.html` * so it can be served as a site (SiteShareStore needs a directory root). * * The caller must register a cleanup that calls `cleanupStagedSite(stagingDir)` * when the underlying site share is revoked / expires. */ export declare function stageSingleHtmlAsSite(workspaceRoot: string, absoluteHtmlPath: string): Promise; /** Best-effort cleanup; never throws. */ export declare function cleanupStagedSite(stagingDir: string): Promise; export declare function rememberStagedSite(recordId: string, stagingDir: string): void; export declare function forgetStagedSite(recordId: string): string | undefined; /** * Walk `/.xopc-share-staging/` and drop directories that are * no longer referenced by any live site-share record. Call at gateway boot. */ export declare function sweepOrphanedStagingDirs(workspaceRoot: string, liveStagingDirs: Set): Promise; /** * Boot-time housekeeping: * 1. Walk active static site shares whose source lives under STAGING_DIR_NAME * (i.e. created via `stageSingleHtmlAsSite`). * 2. Re-register them in the in-process registry so the SiteShareStore * cleanup hook still wipes the right directory on revoke/expire after a * restart. * 3. Sweep each workspace's `.xopc-share-staging/` for entries that are not * referenced by any live record — these are leftovers from a previous * process death between create-staging and persist. * * Safe to call multiple times; idempotent. Best invoked from gateway.start(). */ export declare function runStagingSweep(): Promise; export declare function resetStagedSiteRegistryForTests(): void;