@ko1265/file-preview-kit-core
v1.0.0
Published
Core preview registry and built-in plugins for file-preview-kit.
Maintainers
Readme
@ko1265/file-preview-kit-core
Core preview registry, request handling, and built-in preview plugins for file-preview-kit.
What it contains
FilePreviewServiceFilePreviewRegistry- built-in preview plugins for text, media, PDF, and Office formats
- request merging and request resolution helpers
Install
pnpm add @ko1265/file-preview-kit-coreUsage
import { FilePreviewService } from "@ko1265/file-preview-kit-core";
const service = new FilePreviewService();
const node = await service.render({
url: "https://example.com/readme.md"
});
document.body.append(node);With dynamic auth shaping:
const service = new FilePreviewService({
async resolveRequest(source, request) {
return {
...(request ?? {}),
headers: {
...(request?.headers ?? {}),
Authorization: `Bearer token-for-${source.normalizedName}`
}
};
}
});Notes
- Remote preview still depends on the browser being able to fetch the file source. For reliable production use, prefer same-origin files, controlled object storage/CDN with correct CORS, or a backend proxy.
- Request configuration applies to fetch-based previewers.
- Native media previewers still use the source URL directly.
- Office previews are readable browser previews, not fidelity-preserving Office renderers.
- Use
resolveRequestfor token refresh, per-file auth, or last-mile request shaping.
