@vmprint/preview 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ export type FontRegistryEntry = {
2
+ name: string;
3
+ family: string;
4
+ weight: number;
5
+ style: 'normal' | 'italic';
6
+ src: string;
7
+ unicodeRange?: string;
8
+ enabled: boolean;
9
+ fallback: boolean;
10
+ };
11
+ export declare const FONT_ALIASES: Record<string, string>;
12
+ export declare const FONT_REGISTRY: FontRegistryEntry[];
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Common font configuration used by VMPrint components.
3
+ */
4
+ export interface FontConfig {
5
+ name: string;
6
+ family: string;
7
+ weight: number;
8
+ style: 'normal' | 'italic';
9
+ src: string;
10
+ unicodeRange?: string;
11
+ enabled: boolean;
12
+ fallback: boolean;
13
+ }
14
+ /**
15
+ * Stream-like target for VMPrint output contexts.
16
+ */
17
+ export interface VmprintOutputStream {
18
+ write(chunk: Uint8Array | string): void;
19
+ end(): void;
20
+ }
21
+ /**
22
+ * Status event emitted during web font loading.
23
+ */
24
+ export interface WebFontProgressEvent {
25
+ src: string;
26
+ resolvedSrc: string;
27
+ loadedBytes: number;
28
+ totalBytes?: number;
29
+ percent?: number;
30
+ phase: 'cache-hit' | 'downloading' | 'finalizing' | 'caching' | 'complete';
31
+ }
32
+ export type CanvasTarget = HTMLCanvasElement | OffscreenCanvas | CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
33
+ export type RenderPageToCanvasOptions = {
34
+ scale?: number;
35
+ dpi?: number;
36
+ clear?: boolean;
37
+ backgroundColor?: string;
38
+ };
39
+ export type PreviewFontSource = {
40
+ name: string;
41
+ family: string;
42
+ weight?: number;
43
+ style?: 'normal' | 'italic';
44
+ src: string;
45
+ enabled?: boolean;
46
+ fallback?: boolean;
47
+ unicodeRange?: string;
48
+ };
49
+ export type PreviewFontsOptions = {
50
+ catalogUrl?: string;
51
+ repositoryBaseUrl?: string;
52
+ cache?: boolean | {
53
+ persistent?: boolean;
54
+ dbName?: string;
55
+ storeName?: string;
56
+ namespace?: string;
57
+ };
58
+ aliases?: Record<string, string>;
59
+ fonts?: PreviewFontSource[];
60
+ };
61
+ export type PreviewOptions = {
62
+ fonts?: PreviewFontsOptions;
63
+ onFontProgress?: (event: WebFontProgressEvent) => void;
64
+ };
65
+ export type SvgExportOptions = {
66
+ textMode?: 'glyph-path' | 'text';
67
+ };
68
+ export type PreviewSession = {
69
+ getPageCount(): number;
70
+ getPageSize(): {
71
+ width: number;
72
+ height: number;
73
+ };
74
+ isDestroyed(): boolean;
75
+ renderPageToCanvas(pageIndex: number, target: CanvasTarget, options?: RenderPageToCanvasOptions): Promise<void>;
76
+ exportPdf(): Promise<Uint8Array>;
77
+ exportSvgPage(pageIndex: number, options?: SvgExportOptions): Promise<string>;
78
+ exportSvgPages(options?: SvgExportOptions): Promise<string[]>;
79
+ updateDocument(nextDocumentInput: unknown): Promise<void>;
80
+ destroy(): void;
81
+ };
82
+ export declare const createVMPrintPreview: (documentInput?: unknown, options?: PreviewOptions) => Promise<PreviewSession>;
83
+ export default createVMPrintPreview;
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@vmprint/preview",
3
+ "version": "1.0.0",
4
+ "description": "Script-first browser preview controller for VMPrint. Renders document pages to caller-owned canvases and supports PDF/SVG export.",
5
+ "author": "cosmiciron",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/cosmiciron/vmprint.git",
10
+ "directory": "preview"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/cosmiciron/vmprint/issues"
14
+ },
15
+ "homepage": "https://github.com/cosmiciron/vmprint/tree/main/preview#readme",
16
+ "keywords": [
17
+ "pdf",
18
+ "canvas",
19
+ "preview",
20
+ "svg",
21
+ "document",
22
+ "layout",
23
+ "typesetting",
24
+ "vmprint",
25
+ "browser"
26
+ ],
27
+ "sideEffects": false,
28
+ "main": "dist/index.cjs",
29
+ "module": "dist/index.mjs",
30
+ "types": "dist/types/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/types/index.d.ts",
34
+ "import": "./dist/index.mjs",
35
+ "require": "./dist/index.cjs"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "LICENSE"
41
+ ],
42
+ "scripts": {
43
+ "build": "npm run clean && node scripts/build.mjs",
44
+ "clean": "rimraf dist",
45
+ "demo:build": "node scripts/build-demo.mjs",
46
+ "demo:serve": "node scripts/serve-demo.mjs"
47
+ },
48
+ "dependencies": {},
49
+ "devDependencies": {
50
+ "@types/node": "^22.13.1",
51
+ "@vmprint/context-canvas": "^1.0.0",
52
+ "@vmprint/context-pdf-lite": "^1.0.0",
53
+ "@vmprint/engine": "^1.0.0",
54
+ "@vmprint/web-fonts": "^1.0.0",
55
+ "@vmprint/contracts": "^1.0.0",
56
+ "esbuild": "^0.25.10",
57
+ "rimraf": "^6.1.3",
58
+ "tsx": "^4.20.5",
59
+ "typescript": "^5.7.3"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ }
64
+ }