@paged-media/idml-viewer 0.1.0-canary.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.
- package/README.md +52 -0
- package/dist/bootstrap.d.ts +11 -0
- package/dist/bootstrap.js +30 -0
- package/dist/camera.d.ts +60 -0
- package/dist/camera.js +113 -0
- package/dist/events.d.ts +7 -0
- package/dist/events.js +37 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +16 -0
- package/dist/input.d.ts +31 -0
- package/dist/input.js +122 -0
- package/dist/session.d.ts +57 -0
- package/dist/session.js +14 -0
- package/dist/viewer.d.ts +80 -0
- package/dist/viewer.js +241 -0
- package/package.json +34 -0
- package/wasm/paged_sdk.d.ts +236 -0
- package/wasm/paged_sdk.js +1813 -0
- package/wasm/paged_sdk_bg.wasm +0 -0
package/dist/viewer.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* This file is part of paged (https://paged.media) and is additionally
|
|
7
|
+
* available under the Paged Media Enterprise License (PMEL). Full
|
|
8
|
+
* copyright and license information is available in LICENSE.md which is
|
|
9
|
+
* distributed with this source code.
|
|
10
|
+
*
|
|
11
|
+
* @copyright Copyright (c) And The Next GmbH
|
|
12
|
+
* @license MPL-2.0 OR Paged Media Enterprise License (PMEL)
|
|
13
|
+
*/
|
|
14
|
+
import { clampScroll, clampZoom, currentPageAt, fitPage, scrollToPage, zoomAt, } from "./camera.js";
|
|
15
|
+
import { Emitter } from "./events.js";
|
|
16
|
+
import { attachInput } from "./input.js";
|
|
17
|
+
export class ViewerError extends Error {
|
|
18
|
+
code;
|
|
19
|
+
diagnostics;
|
|
20
|
+
constructor(code, message, diagnostics) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "ViewerError";
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.diagnostics = diagnostics;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ZOOM_STEP = Math.SQRT2;
|
|
28
|
+
function mapDiagnostics(diags) {
|
|
29
|
+
const first = diags.messages.find((m) => m.severity === "error");
|
|
30
|
+
const code = first?.code === "no_gpu" || first?.code === "gpu_init"
|
|
31
|
+
? "GPU_UNAVAILABLE"
|
|
32
|
+
: first?.code === "open" || first?.code === "build"
|
|
33
|
+
? "PARSE_ERROR"
|
|
34
|
+
: "UNSUPPORTED";
|
|
35
|
+
return new ViewerError(code, first?.message ?? "load failed", diags);
|
|
36
|
+
}
|
|
37
|
+
async function sourceBytes(source) {
|
|
38
|
+
if (typeof source === "string") {
|
|
39
|
+
const res = await fetch(source);
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
throw new ViewerError("PARSE_ERROR", `fetch ${source}: ${res.status} ${res.statusText}`);
|
|
42
|
+
}
|
|
43
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
44
|
+
}
|
|
45
|
+
if (source instanceof Uint8Array)
|
|
46
|
+
return source;
|
|
47
|
+
if (source instanceof ArrayBuffer)
|
|
48
|
+
return new Uint8Array(source);
|
|
49
|
+
return new Uint8Array(await source.arrayBuffer());
|
|
50
|
+
}
|
|
51
|
+
export async function createViewer(options) {
|
|
52
|
+
const { canvas } = options;
|
|
53
|
+
let session;
|
|
54
|
+
try {
|
|
55
|
+
session =
|
|
56
|
+
typeof options.session === "function"
|
|
57
|
+
? await options.session()
|
|
58
|
+
: options.session;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
throw new ViewerError("GPU_UNAVAILABLE", e instanceof Error ? e.message : String(e));
|
|
62
|
+
}
|
|
63
|
+
const limits = {
|
|
64
|
+
min: options.zoomLimits?.min ?? 0.1,
|
|
65
|
+
max: options.zoomLimits?.max ?? 8,
|
|
66
|
+
};
|
|
67
|
+
const dpr = options.devicePixelRatio ??
|
|
68
|
+
(typeof window !== "undefined" ? window.devicePixelRatio : 1);
|
|
69
|
+
const schedule = options.schedule ??
|
|
70
|
+
(typeof requestAnimationFrame === "function"
|
|
71
|
+
? (frame) => void requestAnimationFrame(frame)
|
|
72
|
+
: (frame) => void queueMicrotask(frame));
|
|
73
|
+
const events = new Emitter();
|
|
74
|
+
let layout = { gapPt: 0, pages: [] };
|
|
75
|
+
let camera = { zoom: 1, x: 0, y: 0 };
|
|
76
|
+
let mode = options.layoutMode ?? "continuous";
|
|
77
|
+
let page = 0;
|
|
78
|
+
let bound = false;
|
|
79
|
+
let disposed = false;
|
|
80
|
+
let frameQueued = false;
|
|
81
|
+
function viewport() {
|
|
82
|
+
return {
|
|
83
|
+
width: canvas.clientWidth || canvas.width || 1,
|
|
84
|
+
height: canvas.clientHeight || canvas.height || 1,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Layout the camera works against — single mode sees one page at y=0. */
|
|
88
|
+
function activeLayout() {
|
|
89
|
+
if (mode === "continuous")
|
|
90
|
+
return layout;
|
|
91
|
+
const p = layout.pages[page];
|
|
92
|
+
return p
|
|
93
|
+
? { gapPt: layout.gapPt, pages: [{ ...p, yPt: 0, index: 0 }] }
|
|
94
|
+
: { gapPt: layout.gapPt, pages: [] };
|
|
95
|
+
}
|
|
96
|
+
function requestFrame() {
|
|
97
|
+
if (frameQueued || disposed || !bound)
|
|
98
|
+
return;
|
|
99
|
+
frameQueued = true;
|
|
100
|
+
schedule(() => {
|
|
101
|
+
frameQueued = false;
|
|
102
|
+
if (disposed)
|
|
103
|
+
return;
|
|
104
|
+
const diags = session.present(camera.zoom, camera.x, camera.y, dpr, mode === "single" ? page : null);
|
|
105
|
+
if (!diags.ok)
|
|
106
|
+
events.emit("error", mapDiagnostics(diags));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function applyCamera(next, force = false) {
|
|
110
|
+
const clamped = clampScroll(next, activeLayout(), viewport());
|
|
111
|
+
const zoomChanged = clamped.zoom !== camera.zoom;
|
|
112
|
+
const scrollChanged = clamped.x !== camera.x || clamped.y !== camera.y;
|
|
113
|
+
if (!zoomChanged && !scrollChanged && !force)
|
|
114
|
+
return;
|
|
115
|
+
camera = clamped;
|
|
116
|
+
if (zoomChanged)
|
|
117
|
+
events.emit("zoomChanged", { zoom: camera.zoom });
|
|
118
|
+
if (scrollChanged)
|
|
119
|
+
events.emit("scrollChanged", { x: camera.x, y: camera.y });
|
|
120
|
+
if (mode === "continuous") {
|
|
121
|
+
const now = currentPageAt(camera, layout, viewport());
|
|
122
|
+
if (now !== page) {
|
|
123
|
+
page = now;
|
|
124
|
+
session.set_page(page);
|
|
125
|
+
events.emit("pageChanged", { page });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
requestFrame();
|
|
129
|
+
}
|
|
130
|
+
function setPage(index) {
|
|
131
|
+
const clamped = Math.max(0, Math.min(layout.pages.length - 1, index));
|
|
132
|
+
if (clamped === page && layout.pages.length > 0)
|
|
133
|
+
return;
|
|
134
|
+
page = clamped;
|
|
135
|
+
session.set_page(page);
|
|
136
|
+
events.emit("pageChanged", { page });
|
|
137
|
+
if (mode === "continuous") {
|
|
138
|
+
applyCamera(scrollToPage(camera, layout, page, viewport()), true);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
applyCamera(fitPage(activeLayout(), 0, "page", viewport(), limits), true);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const detachInput = attachInput(canvas, options.input ?? {}, {
|
|
145
|
+
zoomAt: (factor, anchor) => applyCamera(zoomAt(camera, camera.zoom * factor, limits, viewport(), anchor)),
|
|
146
|
+
panBy: (dx, dy) => applyCamera({ zoom: camera.zoom, x: camera.x + dx, y: camera.y + dy }),
|
|
147
|
+
zoomStep: (dir, anchor) => applyCamera(zoomAt(camera, camera.zoom * (dir > 0 ? ZOOM_STEP : 1 / ZOOM_STEP), limits, viewport(), anchor)),
|
|
148
|
+
fit: () => viewer.fit("page"),
|
|
149
|
+
pageStep: (dir) => setPage(page + dir),
|
|
150
|
+
home: () => setPage(0),
|
|
151
|
+
end: () => setPage(layout.pages.length - 1),
|
|
152
|
+
});
|
|
153
|
+
const viewer = {
|
|
154
|
+
async load(source) {
|
|
155
|
+
const bytes = await sourceBytes(source);
|
|
156
|
+
const diags = session.load(bytes);
|
|
157
|
+
if (!diags.ok) {
|
|
158
|
+
const error = mapDiagnostics(diags);
|
|
159
|
+
events.emit("error", error);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
if (!bound) {
|
|
163
|
+
const bind = await session.render_to_canvas_main(canvas);
|
|
164
|
+
if (!bind.ok) {
|
|
165
|
+
const error = mapDiagnostics(bind);
|
|
166
|
+
events.emit("error", error);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
bound = true;
|
|
170
|
+
session.resize(viewport().width, viewport().height, dpr);
|
|
171
|
+
}
|
|
172
|
+
layout = session.page_layout();
|
|
173
|
+
page = 0;
|
|
174
|
+
session.set_page(0);
|
|
175
|
+
events.emit("loaded", { pageCount: layout.pages.length });
|
|
176
|
+
applyCamera(fitPage(activeLayout(), 0, "page", viewport(), limits), true);
|
|
177
|
+
},
|
|
178
|
+
get zoom() {
|
|
179
|
+
return camera.zoom;
|
|
180
|
+
},
|
|
181
|
+
setZoom(zoom, opts) {
|
|
182
|
+
applyCamera(zoomAt(camera, clampZoom(zoom, limits), limits, viewport(), opts?.anchor));
|
|
183
|
+
},
|
|
184
|
+
zoomIn() {
|
|
185
|
+
this.setZoom(camera.zoom * ZOOM_STEP);
|
|
186
|
+
},
|
|
187
|
+
zoomOut() {
|
|
188
|
+
this.setZoom(camera.zoom / ZOOM_STEP);
|
|
189
|
+
},
|
|
190
|
+
fit(fitMode) {
|
|
191
|
+
const idx = mode === "single" ? 0 : page;
|
|
192
|
+
applyCamera(fitPage(activeLayout(), idx, fitMode, viewport(), limits), true);
|
|
193
|
+
},
|
|
194
|
+
get minZoom() {
|
|
195
|
+
return limits.min;
|
|
196
|
+
},
|
|
197
|
+
get maxZoom() {
|
|
198
|
+
return limits.max;
|
|
199
|
+
},
|
|
200
|
+
get scroll() {
|
|
201
|
+
return { x: camera.x, y: camera.y };
|
|
202
|
+
},
|
|
203
|
+
scrollTo(x, y) {
|
|
204
|
+
applyCamera({ zoom: camera.zoom, x, y });
|
|
205
|
+
},
|
|
206
|
+
scrollBy(dx, dy) {
|
|
207
|
+
applyCamera({ zoom: camera.zoom, x: camera.x + dx, y: camera.y + dy });
|
|
208
|
+
},
|
|
209
|
+
get pageCount() {
|
|
210
|
+
return layout.pages.length;
|
|
211
|
+
},
|
|
212
|
+
get currentPage() {
|
|
213
|
+
return page;
|
|
214
|
+
},
|
|
215
|
+
goToPage(index) {
|
|
216
|
+
setPage(index);
|
|
217
|
+
},
|
|
218
|
+
layoutMode(next) {
|
|
219
|
+
if (next && next !== mode) {
|
|
220
|
+
mode = next;
|
|
221
|
+
applyCamera(fitPage(activeLayout(), mode === "single" ? 0 : page, "page", viewport(), limits), true);
|
|
222
|
+
}
|
|
223
|
+
return mode;
|
|
224
|
+
},
|
|
225
|
+
renderPageThumbnail(index, opts) {
|
|
226
|
+
return session.render_page_to_bytes(index, opts?.width ?? 160);
|
|
227
|
+
},
|
|
228
|
+
on(event, listener) {
|
|
229
|
+
return events.on(event, listener);
|
|
230
|
+
},
|
|
231
|
+
dispose() {
|
|
232
|
+
if (disposed)
|
|
233
|
+
return;
|
|
234
|
+
disposed = true;
|
|
235
|
+
detachInput();
|
|
236
|
+
events.clear();
|
|
237
|
+
session.free?.();
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
return viewer;
|
|
241
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paged-media/idml-viewer",
|
|
3
|
+
"version": "0.1.0-canary.0",
|
|
4
|
+
"description": "Standalone IDML viewer for the browser — camera, pages, input and events over the @paged-media/sdk WebGPU ViewerSession.",
|
|
5
|
+
"license": "MPL-2.0 OR LicenseRef-PMEL",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/paged-media/core.git",
|
|
9
|
+
"directory": "web/idml-viewer"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"wasm",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
28
|
+
"test": "vitest run"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.6.0",
|
|
32
|
+
"vitest": "^3.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Continuous-layout geometry for every page, so the TS wrapper
|
|
5
|
+
* computes fit / goToPage / currentPage / scroll extents without
|
|
6
|
+
* wasm round-trips. `y_pt` is the page top in doc space (vertical
|
|
7
|
+
* stack with `gap_pt` between pages — the same offsets
|
|
8
|
+
* `present()` uses).
|
|
9
|
+
*/
|
|
10
|
+
export interface PagesLayout {
|
|
11
|
+
gapPt: number;
|
|
12
|
+
pages: PageRect[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stable page identity, independent of position in the page vector.
|
|
17
|
+
*
|
|
18
|
+
* Derived from the IDML `<Page Self=\"...\">` attribute where present;
|
|
19
|
+
* synthesised as `\"page-<spread_idx>-<local_idx>\"` when missing
|
|
20
|
+
* (older / synthetic fixtures without `Self`). The canvas keys
|
|
21
|
+
* display-list caches and LOD tiles by `PageId`, so the value must
|
|
22
|
+
* stay stable across re-layouts — only document-structural edits
|
|
23
|
+
* (insert/delete page) should ever change the set of `PageId`s.
|
|
24
|
+
*/
|
|
25
|
+
export type PageId = string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Structured, JSON-serialisable result of `load` / `render_*`. Unlike
|
|
29
|
+
* the legacy free functions, recoverable parse/layout problems are
|
|
30
|
+
* reported here (so the docs preview can surface them inline) rather
|
|
31
|
+
* than thrown as an opaque `JsError`.
|
|
32
|
+
*/
|
|
33
|
+
export interface Diagnostics {
|
|
34
|
+
ok: boolean;
|
|
35
|
+
messages: Diagnostic[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Diagnostic {
|
|
39
|
+
/**
|
|
40
|
+
* `\"error\" | \"warning\" | \"info\"`.
|
|
41
|
+
*/
|
|
42
|
+
severity: string;
|
|
43
|
+
/**
|
|
44
|
+
* Short machine code, e.g. `\"open\"`, `\"build\"`, `\"no_gpu\"`.
|
|
45
|
+
*/
|
|
46
|
+
code: string;
|
|
47
|
+
message: string;
|
|
48
|
+
/**
|
|
49
|
+
* IDML part the problem originates from, when known.
|
|
50
|
+
*/
|
|
51
|
+
part?: string;
|
|
52
|
+
line?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface PageRect {
|
|
56
|
+
index: number;
|
|
57
|
+
yPt: number;
|
|
58
|
+
widthPt: number;
|
|
59
|
+
heightPt: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Headless readback result. `rgba` is tightly-packed RGBA8
|
|
65
|
+
* (`width * height * 4`), surfaced to JS as a `Uint8Array`.
|
|
66
|
+
*/
|
|
67
|
+
export class RenderedRaster {
|
|
68
|
+
private constructor();
|
|
69
|
+
free(): void;
|
|
70
|
+
[Symbol.dispose](): void;
|
|
71
|
+
height: number;
|
|
72
|
+
rgba: Uint8Array;
|
|
73
|
+
width: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Renderer-core session. Holds the parsed+laid-out document and a
|
|
78
|
+
* lazily-created WebGPU presenter (device + surface). One per viewer
|
|
79
|
+
* instance / preview component.
|
|
80
|
+
*/
|
|
81
|
+
export class ViewerSession {
|
|
82
|
+
private constructor();
|
|
83
|
+
free(): void;
|
|
84
|
+
[Symbol.dispose](): void;
|
|
85
|
+
/**
|
|
86
|
+
* Parse + build a complete IDML package. `font` is optional. Caches
|
|
87
|
+
* the built document and resets the current page to 0. Returns
|
|
88
|
+
* structured diagnostics; does not throw on recoverable problems.
|
|
89
|
+
*/
|
|
90
|
+
load(idml: Uint8Array, font?: Uint8Array | null): Diagnostics;
|
|
91
|
+
/**
|
|
92
|
+
* Acquire the session, gating on WebGPU availability. Rejects when
|
|
93
|
+
* `navigator.gpu` is absent so the consumer can map that to the
|
|
94
|
+
* WebGPU-absent note. Exposed to JS as `ViewerSession.new()`
|
|
95
|
+
* returning a `Promise`.
|
|
96
|
+
*/
|
|
97
|
+
static new(): Promise<ViewerSession>;
|
|
98
|
+
page_count(): number;
|
|
99
|
+
/**
|
|
100
|
+
* Continuous-layout page geometry (doc-space pt, vertical
|
|
101
|
+
* stack with `PAGE_GAP_PT` between pages). Empty until `load`
|
|
102
|
+
* succeeds. The TS wrapper derives fit zoom, scroll extents,
|
|
103
|
+
* `goToPage` targets and the current page from this — no
|
|
104
|
+
* per-frame wasm round-trips.
|
|
105
|
+
*/
|
|
106
|
+
page_layout(): PagesLayout;
|
|
107
|
+
/**
|
|
108
|
+
* Camera-transformed present of the continuous page stack —
|
|
109
|
+
* the viewer's per-frame paint (ports the editor canvas's
|
|
110
|
+
* `presentFrame`). `zoom` is CSS px per pt; `scroll_x` /
|
|
111
|
+
* `scroll_y` place the doc origin in CSS px (positive moves
|
|
112
|
+
* content right/down); `dpr` brings CSS px to device px.
|
|
113
|
+
* Off-viewport pages are culled; per-page scenes build once
|
|
114
|
+
* and cache. `only_page` restricts the pass to one page laid
|
|
115
|
+
* out at y = 0 (the wrapper's `"single"` layout mode).
|
|
116
|
+
*
|
|
117
|
+
* Requires a bound presenter (any `render_to_canvas*` call
|
|
118
|
+
* binds one).
|
|
119
|
+
*/
|
|
120
|
+
present(zoom: number, scroll_x: number, scroll_y: number, dpr: number, only_page?: number | null): Diagnostics;
|
|
121
|
+
/**
|
|
122
|
+
* Register a font for an IDML `AppliedFont` family (and optional
|
|
123
|
+
* style such as `"Bold"` / `"Italic"`). Accumulates across calls
|
|
124
|
+
* and is consulted on the next `load`; real documents reference
|
|
125
|
+
* many faces, so call this once per face before `load`. Mirrors
|
|
126
|
+
* the editor's `RegisterFont` and `paged-inspect`'s
|
|
127
|
+
* `--font-family "Family[/Style]=PATH"`.
|
|
128
|
+
*/
|
|
129
|
+
register_font(family: string, style: string | null | undefined, bytes: Uint8Array): void;
|
|
130
|
+
/**
|
|
131
|
+
* Headless render of ONE page scaled to `target_width_px`
|
|
132
|
+
* (thumbnails / page strips). Aspect ratio preserved.
|
|
133
|
+
*/
|
|
134
|
+
render_page_to_bytes(index: number, target_width_px: number): Promise<RenderedRaster>;
|
|
135
|
+
/**
|
|
136
|
+
* Headless path: render the current page off-surface and read it
|
|
137
|
+
* back as RGBA8 (replaces the legacy `render_to_png`). For
|
|
138
|
+
* screenshots / SSR. `dpi` controls resolution (72 = 1px per pt).
|
|
139
|
+
*/
|
|
140
|
+
render_to_bytes(dpi: number): Promise<RenderedRaster>;
|
|
141
|
+
/**
|
|
142
|
+
* Present the current page to a worker-owned `OffscreenCanvas` via
|
|
143
|
+
* WebGPU. The presenter is created (bound to `canvas`) on the first
|
|
144
|
+
* call; later calls reuse it and re-present — pass the same canvas.
|
|
145
|
+
*/
|
|
146
|
+
render_to_canvas(canvas: OffscreenCanvas): Promise<Diagnostics>;
|
|
147
|
+
/**
|
|
148
|
+
* Main-thread variant of [`Self::render_to_canvas`] for embedders
|
|
149
|
+
* that render on an `HtmlCanvasElement` instead of a worker
|
|
150
|
+
* `OffscreenCanvas`.
|
|
151
|
+
*/
|
|
152
|
+
render_to_canvas_main(canvas: HTMLCanvasElement): Promise<Diagnostics>;
|
|
153
|
+
/**
|
|
154
|
+
* Resize the bound GPU surface. `width`/`height` are CSS pixels;
|
|
155
|
+
* `device_pixel_ratio` brings them to device pixels. No-op until a
|
|
156
|
+
* presenter exists.
|
|
157
|
+
*/
|
|
158
|
+
resize(width: number, height: number, device_pixel_ratio: number): void;
|
|
159
|
+
set_page(index: number): void;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function on_start(): void;
|
|
163
|
+
|
|
164
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
165
|
+
|
|
166
|
+
export interface InitOutput {
|
|
167
|
+
readonly memory: WebAssembly.Memory;
|
|
168
|
+
readonly __wbg_get_renderedraster_height: (a: number) => number;
|
|
169
|
+
readonly __wbg_get_renderedraster_rgba: (a: number) => [number, number];
|
|
170
|
+
readonly __wbg_get_renderedraster_width: (a: number) => number;
|
|
171
|
+
readonly __wbg_renderedraster_free: (a: number, b: number) => void;
|
|
172
|
+
readonly __wbg_set_renderedraster_height: (a: number, b: number) => void;
|
|
173
|
+
readonly __wbg_set_renderedraster_rgba: (a: number, b: number, c: number) => void;
|
|
174
|
+
readonly __wbg_set_renderedraster_width: (a: number, b: number) => void;
|
|
175
|
+
readonly __wbg_viewersession_free: (a: number, b: number) => void;
|
|
176
|
+
readonly viewersession_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
177
|
+
readonly viewersession_new: () => any;
|
|
178
|
+
readonly viewersession_page_count: (a: number) => number;
|
|
179
|
+
readonly viewersession_page_layout: (a: number) => any;
|
|
180
|
+
readonly viewersession_present: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
181
|
+
readonly viewersession_register_font: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
182
|
+
readonly viewersession_render_page_to_bytes: (a: number, b: number, c: number) => any;
|
|
183
|
+
readonly viewersession_render_to_bytes: (a: number, b: number) => any;
|
|
184
|
+
readonly viewersession_render_to_canvas: (a: number, b: any) => any;
|
|
185
|
+
readonly viewersession_render_to_canvas_main: (a: number, b: any) => any;
|
|
186
|
+
readonly viewersession_resize: (a: number, b: number, c: number, d: number) => void;
|
|
187
|
+
readonly viewersession_set_page: (a: number, b: number) => void;
|
|
188
|
+
readonly on_start: () => void;
|
|
189
|
+
readonly qcms_enable_iccv4: () => void;
|
|
190
|
+
readonly qcms_profile_precache_output_transform: (a: number) => void;
|
|
191
|
+
readonly qcms_transform_data_bgra_out_lut: (a: number, b: number, c: number, d: number) => void;
|
|
192
|
+
readonly qcms_transform_data_bgra_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
|
|
193
|
+
readonly qcms_transform_data_rgb_out_lut: (a: number, b: number, c: number, d: number) => void;
|
|
194
|
+
readonly qcms_transform_data_rgb_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
|
|
195
|
+
readonly qcms_transform_data_rgba_out_lut: (a: number, b: number, c: number, d: number) => void;
|
|
196
|
+
readonly qcms_transform_data_rgba_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
|
|
197
|
+
readonly qcms_transform_release: (a: number) => void;
|
|
198
|
+
readonly qcms_profile_is_bogus: (a: number) => number;
|
|
199
|
+
readonly qcms_white_point_sRGB: (a: number) => void;
|
|
200
|
+
readonly lut_inverse_interp16: (a: number, b: number, c: number) => number;
|
|
201
|
+
readonly lut_interp_linear16: (a: number, b: number, c: number) => number;
|
|
202
|
+
readonly wasm_bindgen__convert__closures_____invoke__hf764a550e1162210: (a: number, b: number, c: any) => [number, number];
|
|
203
|
+
readonly wasm_bindgen__convert__closures_____invoke__h341ac0c8ce0fce2e: (a: number, b: number, c: any, d: any) => void;
|
|
204
|
+
readonly wasm_bindgen__convert__closures_____invoke__h2c89ab360f192403: (a: number, b: number, c: any) => void;
|
|
205
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
206
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
207
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
208
|
+
readonly __externref_table_alloc: () => number;
|
|
209
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
210
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
211
|
+
readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
212
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
213
|
+
readonly __wbindgen_start: () => void;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
220
|
+
* a precompiled `WebAssembly.Module`.
|
|
221
|
+
*
|
|
222
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
223
|
+
*
|
|
224
|
+
* @returns {InitOutput}
|
|
225
|
+
*/
|
|
226
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
230
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
231
|
+
*
|
|
232
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
233
|
+
*
|
|
234
|
+
* @returns {Promise<InitOutput>}
|
|
235
|
+
*/
|
|
236
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|