/** * Share-export fetching (ticket 05, PLAN §5.3): the ONE typed fetch over * GET /_dsh/mobile-nav/share-export, shared by the real share flow * (MobileSessionInfo) and the debug preview (?mobile-nav-share-preview=1) * so query assembly and error handling never fork into two copies. * * Module-shape rules (same reason as rasterize.ts): the share-image check * script imports this file through Node type stripping, which rejects JSX * and runs no browser API — so every import of a JSX-bearing module is * `import type` (fully erased) and browser globals appear only inside * function bodies. The query builder and the error taxonomy below are pure * and pinned there. */ import type { ShareTurn } from './share-card.tsx'; /** Route the host registers (mirror of src/share-export.ts — the client cannot import host code). */ export declare const SHARE_EXPORT_ROUTE = "/_dsh/mobile-nav/share-export"; /** * Which slice of the transcript to export — exactly the `range`/`turns` pair * the route validates (src/share-export.ts: `turns` next to `range=all` is a * 400, so it is only ever appended for `range=last`). */ export type ShareRange = { kind: 'all'; } | { kind: 'last'; turns: number; }; /** Preset turn counts the range sheet offers (PLAN §6: presets, no free input). */ export declare const SHARE_TURNS_PRESETS: readonly number[]; /** * Machine-readable fetch failure. `code` picks the localized copy; `status` * is the HTTP status when a response existed (undefined = the request never * completed). Fields are assigned in the constructor body, not declared as * parameter properties — Node type stripping rejects that syntax (same * reason as ShareRasterizeError / ShareExportError). */ export type ShareFetchErrorCode = /** 404 without the route's JSON envelope: this DSH never mounted the route (too old). */ 'route-missing' /** 404 + the route's own session-not-found code: the session is gone. */ | 'session-not-found' /** 400: malformed query the client should not have built. */ | 'bad-request' /** Any other non-ok status (route error, gateway 502, …). */ | 'server' /** fetch() itself threw (offline, connection reset). */ | 'network' /** 2xx but the body is not the agreed shape. */ | 'bad-body'; /** Localizable fetch failure; ticket 05 maps `code` to locales shareErr*. */ export declare class ShareFetchError extends Error { readonly code: ShareFetchErrorCode; readonly status: number | undefined; constructor(code: ShareFetchErrorCode, status: number | undefined, detail: string); } /** A validated export payload (the route's 200 body minus the envelope). */ export interface ShareExportData { turns: ShareTurn[]; createdAt: number | undefined; } /** * Pure: assemble the route query. The session id arrives in its branded * `session-` form (useSessions row / session-scoped slot prop) and is * passed through encodeURIComponent — a bare uuid would 404 (PLAN §2 note). */ export declare function buildShareExportQuery(session: string, range: ShareRange): string; /** * Fetch one export and classify every failure. * * Error mapping (the reason a 404 is split in two): this plugin's route * answers 404 + `{error:{code:'session-not-found'}}` for an unknown session, * while a DSH old enough to lack the route answers the web server's own 404 * — a different copy (“需要新版 DSH”) than “会话不存在”, decided by whether * our envelope is present. */ export declare function fetchShareExport(session: string, range: ShareRange): Promise; //# sourceMappingURL=fetch-share.d.ts.map