@adonis-agora/media
Version:
Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a
45 lines • 2.65 kB
TypeScript
/**
* Pure helpers for mounting/serving the `@adonis-agora/media-dashboard` React SPA — split out so
* they're unit-testable without booting AdonisJS. `dashboard_provider.ts` is a thin HTTP shell around
* these. Ported byte-for-byte (same placeholder, same content-type table, same `renderIndexHtml`
* contract) from `@adonis-agora/media-dashboard`'s own `provider/serve.ts`, which is now this
* package's copy of record — mirrors `@adonis-agora/durable`'s `src/dashboard/spa.ts`, so the two
* packages' "serve a Vite SPA from an AdonisJS provider" story stays one pattern across the Agora
* ecosystem.
*/
/** Placeholder base Vite bakes into asset URLs (`packages/dashboard/vite.config.ts`); rewritten to
* the configured `basePath` at serve time — the SAME built bundle mounts at any path with no rebuild. */
export declare const BASE_PLACEHOLDER = "/__MEDIA_DASHBOARD__/";
export declare const CONTENT_TYPES: Record<string, string>;
export interface DashboardBootstrap {
apiBase: string;
uploadsBase: string;
tusBase: string;
actions: boolean;
/** The console switcher, present only when other Agora consoles are registered in the app. */
switcher?: SwitcherConfig;
}
/** Where the SPA asks which other consoles the viewer may open, and how many are registered. */
export interface SwitcherConfig {
/** `GET` it for the consoles the viewer may open; `<endpoint>/search?q=` searches them. */
endpoint: string;
/** Registered consoles other than this one (before any `authorize` runs). */
others: number;
}
/** Normalise a mount path: leading slash, collapsed slashes, no trailing slash (root stays `/`). */
export declare function normalizePath(path: string): string;
/** Content type for a served asset filename, defaulting to octet-stream. */
export declare function contentTypeFor(file: string): string;
/** `id` of the JSON data block `renderIndexHtml` injects; the SPA's `readBootstrap()` reads it. */
export declare const CONFIG_ELEMENT_ID = "media-dashboard-config";
/**
* Rewrite the built `index.html` for serving: point Vite's placeholder base at `basePath` and hand
* the SPA its runtime bootstrap.
*
* The bootstrap goes in as a JSON DATA BLOCK (`<script type="application/json">`), the only place
* the SPA reads it from. A data block is never executed, so no Content-Security-Policy can refuse it;
* an inline script is, and a host with `script-src 'self' 'nonce-…'` (`@adonisjs/shield`'s `@nonce`)
* drops it silently.
*/
export declare function renderIndexHtml(html: string, basePath: string, bootstrap: DashboardBootstrap): string;
//# sourceMappingURL=spa.d.ts.map