@openpresentation/opf-render 0.30.0 → 0.32.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 +15 -3
- package/dist/chart-options.js +10 -10
- package/dist/charts.js +419 -127
- package/dist/deck-runtime.js +102 -25
- package/dist/element.d.ts +11 -1
- package/dist/element.js +63 -23
- package/dist/font-manifest.js +8 -8
- package/dist/fonts-browser.js +8 -2
- package/dist/fonts.d.ts +3 -2
- package/dist/index.d.ts +46 -1
- package/dist/index.js +2 -0
- package/dist/measure-pictures-node.js +22 -0
- package/dist/measure-pictures.js +185 -0
- package/dist/player.d.ts +22 -4
- package/dist/player.js +48 -33
- package/dist/svg.d.ts +46 -1
- package/dist/svg.js +219 -47
- package/package.json +12 -11
package/dist/deck-runtime.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// there is no second layout engine) behind a face-level font gate, and synchronizes windows over a BroadcastChannel.
|
|
4
4
|
// Nothing here fetches anything but the font files the host's font root serves.
|
|
5
5
|
import { resolveSlideVariables } from "@openpresentation/opf";
|
|
6
|
+
import { continuationPages, continueOverfull } from "@openpresentation/opf/pagination";
|
|
6
7
|
import { toSvg } from "./svg.js";
|
|
7
8
|
|
|
8
9
|
/** Error raised for a deck that cannot be read, rendered or loaded. */
|
|
@@ -66,9 +67,17 @@ export function slideInfo(document, index) {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* "Slide 3 of 8: Revenue grew" (the accessible name of a slide). LH-99: a slide that continues on further pages adds the page,
|
|
72
|
+
* "Slide 3 of 8, page 2 of 2: Revenue grew" (`page` counts from 1).
|
|
73
|
+
*/
|
|
74
|
+
export function slideLabel(info, position, total, page = 1, pages = 1) {
|
|
75
|
+
return `Slide ${position} of ${total}${pages > 1 ? `, page ${page} of ${pages}` : ""}${info.hasTitle ? `: ${info.title}` : ""}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** LH-99: the counter text, "3 / 8", or "3 / 8 · 2/2" on the second page of a slide that continues on two. */
|
|
79
|
+
export function counterText(position, total, page = 1, pages = 1) {
|
|
80
|
+
return `${position} / ${total}${pages > 1 ? ` · ${page}/${pages}` : ""}`;
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
/** Whole numbers only: "3", " 3 " and 3 are slide 3; "", "3.5", "x" and 0 are not slide numbers. */
|
|
@@ -78,34 +87,68 @@ export function parseSlideNumber(value) {
|
|
|
78
87
|
return Number.parseInt(value, 10);
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
/**
|
|
82
|
-
|
|
90
|
+
/**
|
|
91
|
+
* A position in a sequence of slides. Positions are 0-based here; the public `slide` number is position + 1.
|
|
92
|
+
*
|
|
93
|
+
* LH-99: `pagesOf(index)` (default: one page each) is how many pages the slide at a document index draws on (a slide the export
|
|
94
|
+
* continues draws on two or more). The pages are sub-steps of their slide: `next` and `previous` step through them, while the
|
|
95
|
+
* position, the slide number, `goto` and `gotoIndex` keep addressing source slides, and moving to another slide starts on its
|
|
96
|
+
* first page (`previous` from a slide's first page goes to the last page of the slide before, as reading backwards does).
|
|
97
|
+
*/
|
|
98
|
+
export function createCursor(sequence, position = 0, { pagesOf } = {}) {
|
|
83
99
|
let list = sequence.slice();
|
|
84
|
-
let at = 0;
|
|
100
|
+
let at = 0, page = 0;
|
|
85
101
|
const clamp = (value) => (list.length ? Math.min(Math.max(Math.trunc(value), 0), list.length - 1) : 0);
|
|
102
|
+
const count = (position) => { const value = list.length && pagesOf ? Math.trunc(Number(pagesOf(list[position]))) : 1; return value >= 1 ? value : 1; };
|
|
103
|
+
const clampPage = (value, position) => Math.min(Math.max(Math.trunc(Number(value) || 0), 0), count(position) - 1);
|
|
86
104
|
at = clamp(position);
|
|
105
|
+
const move = (nextAt, nextPage = 0) => {
|
|
106
|
+
const before = [at, page];
|
|
107
|
+
at = clamp(nextAt);
|
|
108
|
+
page = clampPage(nextPage, at);
|
|
109
|
+
return at !== before[0] || page !== before[1];
|
|
110
|
+
};
|
|
87
111
|
return {
|
|
88
112
|
get total() { return list.length; },
|
|
89
113
|
get position() { return at; },
|
|
90
114
|
get number() { return list.length ? at + 1 : 0; },
|
|
91
115
|
get index() { return list.length ? list[at] : -1; },
|
|
92
116
|
get sequence() { return list.slice(); },
|
|
93
|
-
|
|
94
|
-
|
|
117
|
+
/** The 0-based page of the showing slide, and how many pages it draws on. */
|
|
118
|
+
get page() { return page; },
|
|
119
|
+
get pages() { return count(at); },
|
|
120
|
+
/** Whether no step comes before or after this one. */
|
|
121
|
+
get atStart() { return at === 0 && page === 0; },
|
|
122
|
+
get atEnd() { return !list.length || (at === list.length - 1 && page === count(at) - 1); },
|
|
123
|
+
/** The slide at a sequence position, on its first page (or the given one). */
|
|
124
|
+
set(next, nextPage = 0) { return move(next, nextPage); },
|
|
125
|
+
/** The `{ position, index, page }` one step away (+1 or -1), or undefined past either end. Moves nothing. */
|
|
126
|
+
peek(step) {
|
|
127
|
+
if (!list.length) return undefined;
|
|
128
|
+
if (step > 0) {
|
|
129
|
+
if (page + 1 < count(at)) return { position: at, index: list[at], page: page + 1 };
|
|
130
|
+
return at + 1 < list.length ? { position: at + 1, index: list[at + 1], page: 0 } : undefined;
|
|
131
|
+
}
|
|
132
|
+
if (page > 0) return { position: at, index: list[at], page: page - 1 };
|
|
133
|
+
return at > 0 ? { position: at - 1, index: list[at - 1], page: count(at - 1) - 1 } : undefined;
|
|
134
|
+
},
|
|
135
|
+
/** Go to the 1-based slide number (clamped to the sequence), on its first page. */
|
|
95
136
|
goto(number) { return this.set(number - 1); },
|
|
96
|
-
next() {
|
|
97
|
-
previous() {
|
|
137
|
+
next() { const target = this.peek(1); return target ? move(target.position, target.page) : false; },
|
|
138
|
+
previous() { const target = this.peek(-1); return target ? move(target.position, target.page) : false; },
|
|
98
139
|
first() { return this.set(0); },
|
|
99
|
-
last
|
|
100
|
-
|
|
101
|
-
|
|
140
|
+
/** The last step: the last page of the last slide. */
|
|
141
|
+
last() { return this.set(list.length - 1, list.length ? count(list.length - 1) - 1 : 0); },
|
|
142
|
+
/** Go to the slide at a document index, or the nearest one after it that plays, on the given page (default the first). */
|
|
143
|
+
gotoIndex(index, nextPage = 0) {
|
|
102
144
|
const found = list.findIndex((candidate) => candidate >= index);
|
|
103
|
-
return
|
|
145
|
+
return move(found === -1 ? list.length - 1 : found, nextPage);
|
|
104
146
|
},
|
|
105
147
|
reset(nextSequence, keepIndex) {
|
|
106
148
|
list = nextSequence.slice();
|
|
107
149
|
const found = keepIndex === undefined ? -1 : list.findIndex((candidate) => candidate >= keepIndex);
|
|
108
150
|
at = clamp(found === -1 ? (keepIndex === undefined ? at : list.length - 1) : found);
|
|
151
|
+
page = clampPage(page, at);
|
|
109
152
|
},
|
|
110
153
|
};
|
|
111
154
|
}
|
|
@@ -210,11 +253,30 @@ export function createFontGate(fonts) {
|
|
|
210
253
|
*
|
|
211
254
|
* `fonts` is a browser fonts handle (or nothing: layout then uses estimated widths and the visitor's system sans-serif).
|
|
212
255
|
*/
|
|
213
|
-
export function createDeckStore({ document, fonts, renderOptions = {}, date } = {}) {
|
|
256
|
+
export function createDeckStore({ document, fonts, renderOptions = {}, date, continuation = true } = {}) {
|
|
214
257
|
const deck = parseDeckDocument(document);
|
|
215
258
|
const gate = fonts ? createFontGate(fonts) : undefined;
|
|
216
259
|
const cache = new Map();
|
|
217
260
|
const diagnostics = [];
|
|
261
|
+
// LH-99: the export's continuation (`continueOverfull`, LH-90), computed once with the measurement the slides draw with. Undefined
|
|
262
|
+
// until asked; null when no slide continues (or `continuation` is false), so such a deck draws exactly as before.
|
|
263
|
+
let plan;
|
|
264
|
+
const continued = () => {
|
|
265
|
+
if (plan !== undefined) return plan;
|
|
266
|
+
plan = null;
|
|
267
|
+
if (continuation === false) return plan;
|
|
268
|
+
try {
|
|
269
|
+
// The catalogs the renderer draws with, and no others: core's Node entry would register the gallery for `catalogs: undefined`.
|
|
270
|
+
const result = continueOverfull(deck, {
|
|
271
|
+
catalogs: renderOptions.catalogs ?? [],
|
|
272
|
+
...(fonts?.textMeasurement ? { fonts: { textMeasurement: fonts.textMeasurement } } : {}),
|
|
273
|
+
...((renderOptions.date ?? date) !== undefined ? { date: renderOptions.date ?? date } : {}),
|
|
274
|
+
...(renderOptions.strictReferences === true ? { strictReferences: true } : {}),
|
|
275
|
+
});
|
|
276
|
+
if (result.continued.length) plan = { presentation: result.presentation, continued: result.continued, pages: continuationPages(result, deck.slides.length) };
|
|
277
|
+
} catch { /* a deck the split cannot read draws as written; drawing it reports why */ }
|
|
278
|
+
return plan;
|
|
279
|
+
};
|
|
218
280
|
const options = () => ({
|
|
219
281
|
...renderOptions,
|
|
220
282
|
// Inline slides use the page's own faces (the registry added them to the document), so only the measurement is passed: nothing is embedded.
|
|
@@ -232,12 +294,26 @@ export function createDeckStore({ document, fonts, renderOptions = {}, date } =
|
|
|
232
294
|
ready ??= gate.ensure(deck, { signal, renderOptions: renderOptions }).catch((error) => { ready = undefined; throw error; });
|
|
233
295
|
return ready;
|
|
234
296
|
},
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
297
|
+
/**
|
|
298
|
+
* LH-99: how many pages the slide at a document index draws on (after `ready()`): 1, or 2 and more for a slide the export
|
|
299
|
+
* continues (LH-90). The pages are sub-steps of their source slide; no source index shifts.
|
|
300
|
+
*/
|
|
301
|
+
pages(index) { return continued()?.pages[index]?.length ?? 1; },
|
|
302
|
+
/** LH-99: the slides the export continues (`continueOverfull`'s `continued`, output indices of the whole continued deck). */
|
|
303
|
+
get continued() { return continued()?.continued ?? []; },
|
|
304
|
+
/**
|
|
305
|
+
* The renderer's SVG for the slide at a document index (after `ready()`), on its 0-based `page`. Rendered once. A continued
|
|
306
|
+
* deck draws every slide from the export's deck, so each page, and its slide number, is the page the PDF and the PPTX draw.
|
|
307
|
+
*/
|
|
308
|
+
svg(index, page = 0) {
|
|
309
|
+
const split = continued();
|
|
310
|
+
const pages = split?.pages[index];
|
|
311
|
+
const at = pages ? Math.min(Math.max(Math.trunc(Number(page) || 0), 0), pages.length - 1) : 0;
|
|
312
|
+
const key = `${index}:${at}`;
|
|
313
|
+
let svg = cache.get(key);
|
|
238
314
|
if (svg === undefined) {
|
|
239
315
|
try {
|
|
240
|
-
svg = toSvg(deck, index + 1, { ...options(), validate: !validated });
|
|
316
|
+
svg = split && pages ? toSvg(split.presentation, pages[at] + 1, { ...options(), validate: !validated }) : toSvg(deck, index + 1, { ...options(), validate: !validated });
|
|
241
317
|
} catch (cause) {
|
|
242
318
|
if (cause instanceof DeckError) throw cause;
|
|
243
319
|
// A document the schema rejects says where: the first finding's path and message.
|
|
@@ -246,13 +322,13 @@ export function createDeckStore({ document, fonts, renderOptions = {}, date } =
|
|
|
246
322
|
throw new DeckError(cause?.code === "invalid-opf" ? "invalid-document" : "render-failed", `${cause?.message ?? "The slide could not be drawn."}${where}`, { cause });
|
|
247
323
|
}
|
|
248
324
|
validated = true;
|
|
249
|
-
cache.set(
|
|
325
|
+
cache.set(key, svg);
|
|
250
326
|
}
|
|
251
327
|
return svg;
|
|
252
328
|
},
|
|
253
329
|
info(index) { return slideInfo(deck, index); },
|
|
254
|
-
/** Forget every drawn slide (after the fonts or options change). */
|
|
255
|
-
invalidate() { cache.clear(); },
|
|
330
|
+
/** Forget every drawn slide and the continuation (after the fonts or options change). */
|
|
331
|
+
invalidate() { cache.clear(); plan = undefined; },
|
|
256
332
|
};
|
|
257
333
|
return store;
|
|
258
334
|
}
|
|
@@ -286,18 +362,19 @@ export function stateWins(remote, local) {
|
|
|
286
362
|
|
|
287
363
|
/**
|
|
288
364
|
* A BroadcastChannel carrying the one thing windows share: which slide is showing and whether the screen is blanked.
|
|
289
|
-
* Messages are `{ v, type: "state" | "hello", from, rev, index, blank, reply? }`. A window ignores its own messages and keeps
|
|
365
|
+
* Messages are `{ v, type: "state" | "hello", from, rev, index, page, blank, reply? }`. A window ignores its own messages and keeps
|
|
290
366
|
* a state only when it wins (`stateWins`); a new window says hello and the others answer with their state (`reply`), which
|
|
291
367
|
* the newcomer takes. Malformed or foreign messages are ignored. Without BroadcastChannel it does nothing (`active` is false).
|
|
292
368
|
*/
|
|
293
369
|
export function createSync({ name, id, onState, BroadcastChannelImpl = globalThis.BroadcastChannel, getState }) {
|
|
294
370
|
if (typeof BroadcastChannelImpl !== "function" || !name) return { active: false, post() {}, hello() {}, close() {} };
|
|
295
371
|
const channel = new BroadcastChannelImpl(name);
|
|
296
|
-
|
|
372
|
+
// LH-99: `page` (0-based) is the page of a slide the export continues; a message without one (an older window) means the first.
|
|
373
|
+
const send = (state, reply) => channel.postMessage({ v: SYNC_VERSION, type: "state", from: id, rev: state.rev, index: state.index, page: state.page ?? 0, blank: state.blank, ...(reply ? { reply: true } : {}) });
|
|
297
374
|
channel.onmessage = (event) => {
|
|
298
375
|
const message = event.data;
|
|
299
376
|
if (!isObject(message) || message.v !== SYNC_VERSION || message.from === id) return;
|
|
300
|
-
if (message.type === "state" && Number.isInteger(message.index) && Number.isInteger(message.rev) && ["none", "black", "white"].includes(message.blank)) onState({ index: message.index, blank: message.blank, rev: message.rev, from: String(message.from), reply: message.reply === true });
|
|
377
|
+
if (message.type === "state" && Number.isInteger(message.index) && Number.isInteger(message.rev) && ["none", "black", "white"].includes(message.blank)) onState({ index: message.index, page: Number.isInteger(message.page) && message.page >= 0 ? message.page : 0, blank: message.blank, rev: message.rev, from: String(message.from), reply: message.reply === true });
|
|
301
378
|
else if (message.type === "hello") { const state = getState?.(); if (state) send(state, true); }
|
|
302
379
|
};
|
|
303
380
|
return {
|
package/dist/element.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface OpfDeckEventMap {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* `<opf-deck src="deck.opf.json" fonts="/opf-fonts/">`: an embedded OPF deck. Attributes: `src`, `slide` (1-based), `fonts`,
|
|
31
|
-
* `thumbnails`, `controls="none"`, `present`, `include-hidden`, `label`, `keyboard="off"`. It draws the renderer's own SVG.
|
|
31
|
+
* `thumbnails`, `controls="none"`, `present`, `include-hidden`, `label`, `keyboard="off"`, `continuation="off"`. It draws the renderer's own SVG.
|
|
32
32
|
*/
|
|
33
33
|
export interface OpfDeckElement extends HTMLElement {
|
|
34
34
|
src: string;
|
|
@@ -37,6 +37,14 @@ export interface OpfDeckElement extends HTMLElement {
|
|
|
37
37
|
/** The 1-based number of the showing slide in the sequence that plays; set it to navigate. */
|
|
38
38
|
slide: number;
|
|
39
39
|
readonly total: number;
|
|
40
|
+
/**
|
|
41
|
+
* LH-99: the 1-based page of the showing slide, and how many pages it draws on. A slide the export continues (LH-90) draws on two
|
|
42
|
+
* or more pages, shown as steps after it (`next`, `previous`, the arrow keys); `slide`, `goto` and the counter keep numbering source slides.
|
|
43
|
+
*/
|
|
44
|
+
readonly page: number;
|
|
45
|
+
readonly pages: number;
|
|
46
|
+
/** LH-99: show an overfull slide as its continuation pages. Default true; false sets `continuation="off"`. */
|
|
47
|
+
continuation: boolean;
|
|
40
48
|
/**
|
|
41
49
|
* The fonts the deck draws with: the URL of the self-hosted font root (the `fonts` attribute), or a browser fonts handle the page
|
|
42
50
|
* already has (`loadFonts` from `/fonts-browser`), which wins over the attribute. The getter returns the handle when one is set, else the
|
|
@@ -82,6 +90,8 @@ export interface ToHtmlOptions {
|
|
|
82
90
|
attributes?: Record<string, string | boolean | undefined>;
|
|
83
91
|
/** Put the document in an `application/opf+json` script child so the element upgrades without a request. */
|
|
84
92
|
embed?: boolean;
|
|
93
|
+
/** LH-99: draw a slide the export continues as its pages, one figure each (default true). */
|
|
94
|
+
continuation?: boolean;
|
|
85
95
|
/** Today's date (ISO) for `date: true` furniture. */
|
|
86
96
|
date?: string;
|
|
87
97
|
renderOptions?: Partial<ToSvgOptions>;
|
package/dist/element.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// the slide a page shows is the slide the preview, the editor and the PDF show. Importing this module touches no DOM, so it
|
|
3
3
|
// is safe on a server (Next.js); `defineOpfDeck()` registers the tag in a browser.
|
|
4
4
|
import {
|
|
5
|
-
DeckError, createCursor, createDeckStore, isRtlLanguage, localIsoDate, parseDeckDocument, parseSlideNumber, presentableIndexes,
|
|
5
|
+
DeckError, counterText, createCursor, createDeckStore, isRtlLanguage, localIsoDate, parseDeckDocument, parseSlideNumber, presentableIndexes,
|
|
6
6
|
prepareSlideSvg, sanitizeSvgTree, slideInfo, slideLabel, svgDimensions, plainText,
|
|
7
7
|
} from "./deck-runtime.js";
|
|
8
8
|
import { loadPreviewFonts } from "./preview-fonts.js";
|
|
9
9
|
import { toSvg } from "./svg.js";
|
|
10
10
|
import { drawnFaces } from "./drawn-faces.js";
|
|
11
11
|
import { selectSlides, slideArguments } from "./slide-sources.js";
|
|
12
|
+
import { continuationPages, continueOverfull } from "@openpresentation/opf/pagination";
|
|
12
13
|
|
|
13
14
|
export { DeckError } from "./deck-runtime.js";
|
|
14
15
|
export { loadPreviewFonts, previewBaseFaces, previewFontLayout } from "./preview-fonts.js";
|
|
@@ -42,6 +43,9 @@ button[aria-disabled="true"] { opacity: 0.45; cursor: default; }
|
|
|
42
43
|
.thumbs .frame svg.opf-slide { display: block; width: 100%; height: 100%; pointer-events: none; }
|
|
43
44
|
.thumb, .thumbs .thumb:hover { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; min-height: 0; background: transparent; }
|
|
44
45
|
.thumb[aria-current="true"] { outline: 3px solid var(--opf-deck-accent, Highlight); outline-offset: 0; }
|
|
46
|
+
.thumbs li[data-pages] .frame { box-shadow: 3px 3px 0 -1px var(--opf-deck-stage, #f1f1f1), 3px 3px 0 0 var(--opf-deck-border, rgb(128 128 128 / 0.6)), 6px 6px 0 -1px var(--opf-deck-stage, #f1f1f1), 6px 6px 0 0 var(--opf-deck-border, rgb(128 128 128 / 0.6)); }
|
|
47
|
+
.thumbs li[data-pages] { margin-right: 6px; margin-bottom: 6px; }
|
|
48
|
+
.thumbs .pages { position: absolute; right: 4px; bottom: 4px; padding: 0 5px; border-radius: 4px; font: 600 11px/16px system-ui, sans-serif; color: #fff; background: rgb(0 0 0 / 0.66); pointer-events: none; }
|
|
45
49
|
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
46
50
|
.flip { display: inline-block; }
|
|
47
51
|
.rtl .flip { transform: scaleX(-1); }
|
|
@@ -79,7 +83,7 @@ export function defineOpfDeck(tagName = OPF_DECK_TAG) {
|
|
|
79
83
|
function createElementClass() {
|
|
80
84
|
const Base = HTMLElement;
|
|
81
85
|
return class OpfDeckElement extends Base {
|
|
82
|
-
static get observedAttributes() { return ["src", "slide", "fonts", "thumbnails", "controls", "present", "include-hidden", "label", "keyboard"]; }
|
|
86
|
+
static get observedAttributes() { return ["src", "slide", "fonts", "thumbnails", "controls", "present", "include-hidden", "label", "keyboard", "continuation"]; }
|
|
83
87
|
|
|
84
88
|
#root; #parts = {}; #built = false; #store; #cursor; #deck; #generation = 0; #abort; #documentValue; #fonts; #renderOptions = {};
|
|
85
89
|
#readyPromise = Promise.resolve(); #state = "idle"; #error; #observer; #thumbsBuilt = false; #pointer; #session; #announce = false;
|
|
@@ -106,7 +110,7 @@ function createElementClass() {
|
|
|
106
110
|
|
|
107
111
|
attributeChangedCallback(name, before, after) {
|
|
108
112
|
if (before === after || !this.#built) return;
|
|
109
|
-
if (name === "src" || name === "fonts" || name === "include-hidden") { if (this.isConnected) this.#start(); return; }
|
|
113
|
+
if (name === "src" || name === "fonts" || name === "include-hidden" || name === "continuation") { if (this.isConnected) this.#start(); return; }
|
|
110
114
|
if (name === "slide") { this.#applySlideAttribute(); return; }
|
|
111
115
|
this.#sync();
|
|
112
116
|
}
|
|
@@ -131,6 +135,17 @@ function createElementClass() {
|
|
|
131
135
|
/** Number of slides in the sequence that plays. */
|
|
132
136
|
get total() { return this.#cursor?.total ?? 0; }
|
|
133
137
|
|
|
138
|
+
/**
|
|
139
|
+
* LH-99: the 1-based page of the showing slide, and how many pages it draws on. A slide the export continues (LH-90) draws on
|
|
140
|
+
* two or more; its pages are steps after it, and `slide`, `goto` and the counter keep numbering source slides.
|
|
141
|
+
*/
|
|
142
|
+
get page() { return this.#cursor ? this.#cursor.page + 1 : 1; }
|
|
143
|
+
get pages() { return this.#cursor?.pages ?? 1; }
|
|
144
|
+
|
|
145
|
+
/** LH-99: whether an overfull slide shows the export's continuation pages (default true; the `continuation="off"` attribute turns it off). */
|
|
146
|
+
get continuation() { return truthy(this.getAttribute("continuation") ?? "on"); }
|
|
147
|
+
set continuation(value) { if (value) this.removeAttribute("continuation"); else this.setAttribute("continuation", "off"); }
|
|
148
|
+
|
|
134
149
|
/**
|
|
135
150
|
* The fonts the deck draws with: the URL of the self-hosted font root (the `fonts` attribute; see the package README), or a
|
|
136
151
|
* browser fonts handle the page already has (`loadFonts` from `/fonts-browser`), which wins over the attribute. Without either,
|
|
@@ -160,7 +175,7 @@ function createElementClass() {
|
|
|
160
175
|
get ready() { return this.#readyPromise; }
|
|
161
176
|
|
|
162
177
|
/** What the showing slide is: id, title, plain-text notes, section. */
|
|
163
|
-
get currentSlide() { return this.#cursor && this.#deck ? { ...slideInfo(this.#deck, this.#cursor.index), slide: this.#cursor.number, total: this.#cursor.total } : undefined; }
|
|
178
|
+
get currentSlide() { return this.#cursor && this.#deck ? { ...slideInfo(this.#deck, this.#cursor.index), slide: this.#cursor.number, total: this.#cursor.total, page: this.#cursor.page + 1, pages: this.#cursor.pages } : undefined; }
|
|
164
179
|
|
|
165
180
|
next() { return this.#go(() => this.#cursor?.next()); }
|
|
166
181
|
previous() { return this.#go(() => this.#cursor?.previous()); }
|
|
@@ -183,10 +198,10 @@ function createElementClass() {
|
|
|
183
198
|
const { present } = await import("./player.js");
|
|
184
199
|
const session = await present(this.#deck, {
|
|
185
200
|
store: this.#store, fonts: this.#fonts ?? this.#resolvedFonts, renderOptions: this.#renderOptions,
|
|
186
|
-
includeHidden: this.includeHidden, startSlide: this.#cursor.number, ...options, returnFocus,
|
|
201
|
+
includeHidden: this.includeHidden, startSlide: this.#cursor.number, startPage: this.#cursor.page + 1, continuation: this.continuation, ...options, returnFocus,
|
|
187
202
|
});
|
|
188
203
|
this.#session = session;
|
|
189
|
-
session.addEventListener("slidechange", (event) => { if (this.#cursor && event.detail?.index !== undefined && this.#cursor.gotoIndex(event.detail.index)) { this.#show({ announce: false }); this.#emitChange(); } });
|
|
204
|
+
session.addEventListener("slidechange", (event) => { if (this.#cursor && event.detail?.index !== undefined && this.#cursor.gotoIndex(event.detail.index, (event.detail.page ?? 1) - 1)) { this.#show({ announce: false }); this.#emitChange(); } });
|
|
190
205
|
session.addEventListener("close", () => {
|
|
191
206
|
if (this.#session === session) this.#session = undefined;
|
|
192
207
|
this.#show({ announce: false });
|
|
@@ -229,13 +244,14 @@ function createElementClass() {
|
|
|
229
244
|
}
|
|
230
245
|
this.#resolvedFonts = registry;
|
|
231
246
|
const date = this.#renderOptions.date ?? localIsoDate();
|
|
232
|
-
|
|
247
|
+
const continuation = this.continuation;
|
|
248
|
+
let store = createDeckStore({ document: deck, fonts: registry, renderOptions: this.#renderOptions, date, continuation });
|
|
233
249
|
try { await store.ready(signal); } catch (cause) {
|
|
234
250
|
if (stale()) return;
|
|
235
251
|
if (!registry) throw cause;
|
|
236
252
|
this.#report(cause, false);
|
|
237
253
|
this.#resolvedFonts = undefined;
|
|
238
|
-
store = createDeckStore({ document: deck, renderOptions: this.#renderOptions, date });
|
|
254
|
+
store = createDeckStore({ document: deck, renderOptions: this.#renderOptions, date, continuation });
|
|
239
255
|
}
|
|
240
256
|
if (stale()) return;
|
|
241
257
|
// Draw the first slide before accepting the deck, so an invalid document fails here and not on the first click.
|
|
@@ -243,7 +259,7 @@ function createElementClass() {
|
|
|
243
259
|
if (sequence.length) store.svg(sequence[Math.min(Math.max((parseSlideNumber(this.getAttribute("slide")) ?? 1) - 1, 0), sequence.length - 1)]);
|
|
244
260
|
this.#deck = deck;
|
|
245
261
|
this.#store = store;
|
|
246
|
-
this.#cursor = createCursor(sequence, (parseSlideNumber(this.getAttribute("slide")) ?? 1) - 1);
|
|
262
|
+
this.#cursor = createCursor(sequence, (parseSlideNumber(this.getAttribute("slide")) ?? 1) - 1, { pagesOf: (index) => store.pages(index) });
|
|
247
263
|
this.#thumbsBuilt = false;
|
|
248
264
|
this.#state = "ready";
|
|
249
265
|
this.#show({ announce: false });
|
|
@@ -286,9 +302,9 @@ function createElementClass() {
|
|
|
286
302
|
#prefetch() {
|
|
287
303
|
const store = this.#store, cursor = this.#cursor;
|
|
288
304
|
if (!store || !cursor) return;
|
|
289
|
-
const next = cursor.
|
|
290
|
-
if (next
|
|
291
|
-
const run = () => { try { if (this.#store === store) store.svg(next); } catch { /* reported when the slide is shown */ } };
|
|
305
|
+
const next = cursor.peek(1);
|
|
306
|
+
if (!next) return;
|
|
307
|
+
const run = () => { try { if (this.#store === store) store.svg(next.index, next.page); } catch { /* reported when the slide is shown */ } };
|
|
292
308
|
if (typeof requestIdleCallback === "function") requestIdleCallback(run, { timeout: 500 }); else setTimeout(run, 0);
|
|
293
309
|
}
|
|
294
310
|
|
|
@@ -393,7 +409,7 @@ function createElementClass() {
|
|
|
393
409
|
#emitChange() {
|
|
394
410
|
if (!this.#cursor || !this.#deck) return;
|
|
395
411
|
const info = slideInfo(this.#deck, this.#cursor.index);
|
|
396
|
-
this.dispatchEvent(new CustomEvent("slidechange", { detail: { slide: this.#cursor.number, total: this.#cursor.total, index: info.index, id: info.id, title: info.title, notes: info.notes, section: info.section }, bubbles: true, composed: true }));
|
|
412
|
+
this.dispatchEvent(new CustomEvent("slidechange", { detail: { slide: this.#cursor.number, total: this.#cursor.total, index: info.index, page: this.#cursor.page + 1, pages: this.#cursor.pages, id: info.id, title: info.title, notes: info.notes, section: info.section }, bubbles: true, composed: true }));
|
|
397
413
|
}
|
|
398
414
|
|
|
399
415
|
#renderState() {
|
|
@@ -420,10 +436,10 @@ function createElementClass() {
|
|
|
420
436
|
parts.deck.classList.toggle("rtl", Boolean(rtl));
|
|
421
437
|
const info = store.info(cursor.index);
|
|
422
438
|
let svg;
|
|
423
|
-
try { svg = store.svg(cursor.index); } catch (error) {
|
|
439
|
+
try { svg = store.svg(cursor.index, cursor.page); } catch (error) {
|
|
424
440
|
this.#state = "error"; this.#error = error; this.#renderState(); this.#report(error, true); return;
|
|
425
441
|
}
|
|
426
|
-
const label = slideLabel(info, cursor.number, cursor.total);
|
|
442
|
+
const label = slideLabel(info, cursor.number, cursor.total, cursor.page + 1, cursor.pages);
|
|
427
443
|
const template = this.ownerDocument.createElement("template");
|
|
428
444
|
template.innerHTML = prepareSlideSvg(svg);
|
|
429
445
|
const node = template.content.firstElementChild;
|
|
@@ -431,10 +447,10 @@ function createElementClass() {
|
|
|
431
447
|
const { width, height } = svgDimensions(svg);
|
|
432
448
|
parts.deck.style.setProperty("--ratio", `${width} / ${height}`);
|
|
433
449
|
parts.viewport.setAttribute("aria-label", label);
|
|
434
|
-
parts.counterText.textContent =
|
|
450
|
+
parts.counterText.textContent = counterText(cursor.number, cursor.total, cursor.page + 1, cursor.pages);
|
|
435
451
|
parts.counterLabel.textContent = label;
|
|
436
|
-
parts.prev.setAttribute("aria-disabled", String(cursor.
|
|
437
|
-
parts.next.setAttribute("aria-disabled", String(cursor.
|
|
452
|
+
parts.prev.setAttribute("aria-disabled", String(cursor.atStart));
|
|
453
|
+
parts.next.setAttribute("aria-disabled", String(cursor.atEnd));
|
|
438
454
|
parts.bar.hidden = this.getAttribute("controls") === "none" || !cursor.total;
|
|
439
455
|
parts.present.hidden = !this.hasAttribute("present");
|
|
440
456
|
parts.thumbsWrap.hidden = !this.hasAttribute("thumbnails");
|
|
@@ -454,12 +470,15 @@ function createElementClass() {
|
|
|
454
470
|
const first = sequence.length ? svgDimensions(store.svg(sequence[0])) : { width: 16, height: 9 };
|
|
455
471
|
const items = sequence.map((index, position) => {
|
|
456
472
|
const info = store.info(index);
|
|
473
|
+
const pages = store.pages(index);
|
|
457
474
|
const li = doc.createElement("li");
|
|
458
475
|
const button = doc.createElement("button");
|
|
459
476
|
button.type = "button";
|
|
460
477
|
button.className = "thumb";
|
|
461
478
|
button.setAttribute("part", "thumbnail");
|
|
462
|
-
|
|
479
|
+
// LH-99: a slide the export continues is one thumbnail (its first page) drawn as a stack, with its page count.
|
|
480
|
+
const label = slideLabel(info, position + 1, sequence.length);
|
|
481
|
+
button.setAttribute("aria-label", `Go to ${pages > 1 ? label.replace(/^(Slide \d+ of \d+)/, `$1, ${pages} pages`) : label}`);
|
|
463
482
|
button.tabIndex = position === cursor.position ? 0 : -1;
|
|
464
483
|
// The drawing is a sibling under the button, not its content: the slide's own text is not the button's visible
|
|
465
484
|
// label (axe label-content-name-mismatch, WCAG 2.5.3), and the button's name is the slide's label. The button
|
|
@@ -470,6 +489,14 @@ function createElementClass() {
|
|
|
470
489
|
frame.setAttribute("aria-hidden", "true");
|
|
471
490
|
button.addEventListener("click", () => { this.#announce = true; this.#go(() => this.#cursor?.goto(position + 1)); });
|
|
472
491
|
li.append(button, frame);
|
|
492
|
+
if (pages > 1) {
|
|
493
|
+
li.dataset.pages = String(pages);
|
|
494
|
+
const badge = doc.createElement("span");
|
|
495
|
+
badge.className = "pages";
|
|
496
|
+
badge.setAttribute("aria-hidden", "true");
|
|
497
|
+
badge.textContent = `${pages} pages`;
|
|
498
|
+
li.append(badge);
|
|
499
|
+
}
|
|
473
500
|
li._frame = frame; li._index = index;
|
|
474
501
|
return li;
|
|
475
502
|
});
|
|
@@ -543,11 +570,24 @@ export function toHtml(input, slides, options) {
|
|
|
543
570
|
const attributeText = Object.entries(attributes).filter(([, value]) => value !== undefined && value !== false).map(([name, value]) => (value === true ? ` ${name}` : ` ${name}="${escapeHtml(value)}"`)).join("")
|
|
544
571
|
+ (options.thumbnails ? " thumbnails" : "") + (options.present ? " present" : "") + (options.includeHidden ? " include-hidden" : "");
|
|
545
572
|
const date = options.renderOptions?.date ?? options.date;
|
|
546
|
-
|
|
573
|
+
// LH-99: a slide the export continues (LH-90) is drawn as its pages, one figure each, numbered as sub-steps of the source slide.
|
|
574
|
+
let continued;
|
|
575
|
+
if (options.continuation !== false) {
|
|
576
|
+
try {
|
|
577
|
+
const measurement = renderFonts?.textMeasurement;
|
|
578
|
+
const result = continueOverfull(deck, { catalogs: options.renderOptions?.catalogs ?? [], ...(measurement ? { fonts: { textMeasurement: measurement } } : {}), ...(date ? { date } : {}), ...(options.renderOptions?.strictReferences === true ? { strictReferences: true } : {}) });
|
|
579
|
+
if (result.continued.length) continued = { presentation: result.presentation, pages: continuationPages(result, deck.slides.length) };
|
|
580
|
+
} catch { /* drawn as written; toSvg reports why */ }
|
|
581
|
+
}
|
|
582
|
+
const figures = shown.flatMap((position) => {
|
|
547
583
|
const index = sequence[position];
|
|
584
|
+
const pages = continued ? continued.pages[index] : [index];
|
|
585
|
+
return pages.map((output, page) => figure(continued ? continued.presentation : deck, output, index, position, page, pages.length));
|
|
586
|
+
});
|
|
587
|
+
function figure(drawnDeck, output, index, position, page, pages) {
|
|
548
588
|
// Shared rules are deduplicated across slides, so the slides embed whole faces and the shared set is cut below to what
|
|
549
589
|
// every slide draws (RR-65); per-slide subsets would differ and repeat each face once per slide.
|
|
550
|
-
let svg = toSvg(
|
|
590
|
+
let svg = toSvg(drawnDeck, output + 1, { ...options.renderOptions, fonts: renderFonts, ...(fontMode === "external" ? { text: "system" } : {}), ...(fontMode === "shared" ? { subsetFonts: false } : {}), ...(date ? { date } : {}) });
|
|
551
591
|
if (fontMode === "shared") {
|
|
552
592
|
drawnFaces(svg, sharedCharacters);
|
|
553
593
|
svg = svg.replace(/<style>(@font-face[\s\S]*?)<\/style>/g, (_, css) => {
|
|
@@ -558,9 +598,9 @@ export function toHtml(input, slides, options) {
|
|
|
558
598
|
}
|
|
559
599
|
const { width, height } = svgDimensions(svg);
|
|
560
600
|
const prepared = prepareSlideSvg(svg).replace(/^<svg\b/, `<svg style="display:block;width:100%;height:auto;aspect-ratio:${width} / ${height}"`);
|
|
561
|
-
const label = slideLabel(slideInfo(deck, index), position + 1, sequence.length);
|
|
601
|
+
const label = slideLabel(slideInfo(deck, index), position + 1, sequence.length, page + 1, pages);
|
|
562
602
|
return `<figure role="group" aria-roledescription="slide" aria-label="${escapeHtml(label)}" style="margin:0 0 8px">${prepared}</figure>`;
|
|
563
|
-
}
|
|
603
|
+
}
|
|
564
604
|
const titles = slides === undefined && sequence.length > 1
|
|
565
605
|
? `<nav aria-label="Slides"><ol>${sequence.map((index) => `<li>${escapeHtml(slideInfo(deck, index).title)}</li>`).join("")}</ol></nav>` : "";
|
|
566
606
|
const embedded = options.embed ? `<script type="application/opf+json">${JSON.stringify(deck).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029")}</script>` : "";
|
package/dist/font-manifest.js
CHANGED
|
@@ -1907,12 +1907,12 @@ export const BUNDLED_FONT_MANIFEST=freeze({
|
|
|
1907
1907
|
},
|
|
1908
1908
|
{
|
|
1909
1909
|
"name": "@expo-google-fonts/noto-sans-devanagari",
|
|
1910
|
-
"version": "0.4.
|
|
1910
|
+
"version": "0.4.2",
|
|
1911
1911
|
"pack": "scripts",
|
|
1912
1912
|
"scripts": [
|
|
1913
1913
|
"Deva"
|
|
1914
1914
|
],
|
|
1915
|
-
"source": "https://www.npmjs.com/package/@expo-google-fonts/noto-sans-devanagari/v/0.4.
|
|
1915
|
+
"source": "https://www.npmjs.com/package/@expo-google-fonts/noto-sans-devanagari/v/0.4.2",
|
|
1916
1916
|
"license": "OFL-1.1",
|
|
1917
1917
|
"licenseFile": "LICENSE_FONT",
|
|
1918
1918
|
"licenseSha256": "a216f6f8d85c7228093e0ee5e258d9d377e6671f68acb4db1930b29583d0f331",
|
|
@@ -1925,14 +1925,14 @@ export const BUNDLED_FONT_MANIFEST=freeze({
|
|
|
1925
1925
|
"family": "Noto Sans Devanagari",
|
|
1926
1926
|
"weight": 400,
|
|
1927
1927
|
"italic": false,
|
|
1928
|
-
"sha256": "
|
|
1928
|
+
"sha256": "30f20b135b2b7b8c370ea30dd8c88f5174c1209f0373534ad4c814717f375b9e"
|
|
1929
1929
|
},
|
|
1930
1930
|
{
|
|
1931
1931
|
"file": "700Bold/NotoSansDevanagari_700Bold.ttf",
|
|
1932
1932
|
"family": "Noto Sans Devanagari",
|
|
1933
1933
|
"weight": 700,
|
|
1934
1934
|
"italic": false,
|
|
1935
|
-
"sha256": "
|
|
1935
|
+
"sha256": "614d1bf087d082e88f0802a6259d96ec846351c0a6fb736294af01fadd09ebac"
|
|
1936
1936
|
}
|
|
1937
1937
|
]
|
|
1938
1938
|
},
|
|
@@ -2403,12 +2403,12 @@ export const BUNDLED_FONT_MANIFEST=freeze({
|
|
|
2403
2403
|
},
|
|
2404
2404
|
{
|
|
2405
2405
|
"name": "@expo-google-fonts/noto-sans-georgian",
|
|
2406
|
-
"version": "0.4.
|
|
2406
|
+
"version": "0.4.4",
|
|
2407
2407
|
"pack": "scripts",
|
|
2408
2408
|
"scripts": [
|
|
2409
2409
|
"Geor"
|
|
2410
2410
|
],
|
|
2411
|
-
"source": "https://www.npmjs.com/package/@expo-google-fonts/noto-sans-georgian/v/0.4.
|
|
2411
|
+
"source": "https://www.npmjs.com/package/@expo-google-fonts/noto-sans-georgian/v/0.4.4",
|
|
2412
2412
|
"license": "OFL-1.1",
|
|
2413
2413
|
"licenseFile": "LICENSE_FONT",
|
|
2414
2414
|
"licenseSha256": "8c02263c5d73d40544f9ed91e30c4e947407057a3cc430d7b786189aeceff6df",
|
|
@@ -2421,14 +2421,14 @@ export const BUNDLED_FONT_MANIFEST=freeze({
|
|
|
2421
2421
|
"family": "Noto Sans Georgian",
|
|
2422
2422
|
"weight": 400,
|
|
2423
2423
|
"italic": false,
|
|
2424
|
-
"sha256": "
|
|
2424
|
+
"sha256": "78783e9fe5330b28952ee2433340b3f0632974ba854fcbcf83efff1d9bad1574"
|
|
2425
2425
|
},
|
|
2426
2426
|
{
|
|
2427
2427
|
"file": "700Bold/NotoSansGeorgian_700Bold.ttf",
|
|
2428
2428
|
"family": "Noto Sans Georgian",
|
|
2429
2429
|
"weight": 700,
|
|
2430
2430
|
"italic": false,
|
|
2431
|
-
"sha256": "
|
|
2431
|
+
"sha256": "13e854391de82fcc9eb994558233d61de1b7d615883fd5bf87aa61b611c74b94"
|
|
2432
2432
|
}
|
|
2433
2433
|
]
|
|
2434
2434
|
},
|
package/dist/fonts-browser.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { diagramsPending, ensureDiagrams } from "@openpresentation/opf/composition";
|
|
1
2
|
import { createFontRegistry, OPFFontError } from "./font-registry.js";
|
|
2
3
|
import { lazyFontEntries, lazyFontList, normalizeExtraLazyFonts } from "./lazy-font-list.js";
|
|
3
4
|
import { createFontAnalysis, lazyFacesNeeded } from "./lazy-fonts.js";
|
|
@@ -330,7 +331,10 @@ export async function loadFonts({ faces = [], subsetWasm, shapeWasm, ...options
|
|
|
330
331
|
let embedded, stale = true;
|
|
331
332
|
const addFaces = registry.addFaces;
|
|
332
333
|
registry.addFaces = (added) => { const result = addFaces(added); stale = true; return result; };
|
|
334
|
+
// A diagram type the page has not loaded yet (core's browser engine loads each type on demand) is pending as `diagram:<type>`;
|
|
335
|
+
// `ensure` loads it first, since the font analysis measures a diagram's labels only once its type is loaded.
|
|
333
336
|
const pending = (presentation, renderOptions) => [
|
|
337
|
+
...diagramsPending(presentation).map((type) => `diagram:${type}`),
|
|
334
338
|
...registry.pendingLazyFonts(presentation, renderOptions).map((face) => face.file),
|
|
335
339
|
...registry.pendingScripts(presentation, renderOptions),
|
|
336
340
|
];
|
|
@@ -345,12 +349,14 @@ export async function loadFonts({ faces = [], subsetWasm, shapeWasm, ...options
|
|
|
345
349
|
manifest: BUNDLED_FONT_MANIFEST,
|
|
346
350
|
get substitutions() { return registry.substitutions; },
|
|
347
351
|
/**
|
|
348
|
-
* Load the
|
|
352
|
+
* Load the diagram types the presentation draws (core loads each on demand in a browser), then the vendored and script faces
|
|
353
|
+
* it draws, each hash-verified, all or nothing, and repeat while loading
|
|
349
354
|
* changes what is needed (a script face can need a vendored one). Cheap when nothing is needed. Besides `signal`, the call
|
|
350
355
|
* takes the `toSvg` options the document resolves with (`catalogs`, ...) over the loader's `renderOptions`. A document that
|
|
351
356
|
* does not resolve rejects with what `toSvg` throws for it. After `dispose()` it rejects with `font-registry-disposed`.
|
|
352
357
|
*/
|
|
353
358
|
async ensure(presentation, callOptions = {}) {
|
|
359
|
+
const diagrams = await ensureDiagrams(presentation);
|
|
354
360
|
const lazy = [], scripts = [];
|
|
355
361
|
let uncovered = [];
|
|
356
362
|
for (let round = 0; round < MAX_ENSURE_ROUNDS; round++) {
|
|
@@ -360,7 +366,7 @@ export async function loadFonts({ faces = [], subsetWasm, shapeWasm, ...options
|
|
|
360
366
|
if (needLazy) lazy.push(...(await registry.ensureLazyFonts(presentation, callOptions)));
|
|
361
367
|
if (needScripts) { const result = await registry.ensureScripts(presentation, callOptions); scripts.push(...result.loaded); uncovered = result.uncovered; }
|
|
362
368
|
}
|
|
363
|
-
return { scripts, lazy, uncovered };
|
|
369
|
+
return { scripts, lazy, uncovered, ...(diagrams.length ? { diagrams } : {}) };
|
|
364
370
|
},
|
|
365
371
|
/** Synchronous: the files and script packages `ensure` would fetch. Empty means a render can start now. Throws what `toSvg` throws for a document that does not resolve. */
|
|
366
372
|
pending,
|
package/dist/fonts.d.ts
CHANGED
|
@@ -67,7 +67,8 @@ export interface TextOutlines {
|
|
|
67
67
|
shape?(face: { hash: string; data: Uint8Array }, text: string, options?: { direction?: "ltr" | "rtl"; lang?: string; features?: Record<string, boolean> }): { gid: number; codePoints: number[]; advance: number; xOffset: number; yOffset: number }[];
|
|
68
68
|
}
|
|
69
69
|
/** What `fonts.ensure(presentation)` loaded: the script packages and vendored faces that were missing, and drawn CJK characters no face covers. */
|
|
70
|
-
|
|
70
|
+
/** What `ensure` loaded. `diagrams`: the diagram types it loaded (in a browser, core loads each type on demand; Node has them all). */
|
|
71
|
+
export interface EnsureResult { scripts: string[]; lazy: LazyFont[]; uncovered: string[]; diagrams?: string[] }
|
|
71
72
|
/** The fonts handle `loadFonts()` returns from `/fonts-node` and `/fonts-browser`: pass it as `{ fonts }` to every deck-level function. */
|
|
72
73
|
export interface FontsHandle extends RenderFonts {
|
|
73
74
|
readonly textMeasurement: FontRegistry["textMeasurement"];
|
|
@@ -82,7 +83,7 @@ export interface FontsHandle extends RenderFonts {
|
|
|
82
83
|
readonly substitutions: FontResolution[];
|
|
83
84
|
/** Load the script (and, in a browser, vendored) faces the presentation's text needs. Cheap when nothing is missing. */
|
|
84
85
|
ensure(presentation: unknown, options?: object): Promise<EnsureResult>;
|
|
85
|
-
/** Synchronous: the files and script packages `ensure` would load. Empty means a render can start now. */
|
|
86
|
+
/** Synchronous: the files and script packages `ensure` would load, and in a browser the diagram types (`diagram:<type>`). Empty means a render can start now. */
|
|
86
87
|
pending(presentation: unknown, renderOptions?: object): string[];
|
|
87
88
|
/** Remove the faces this handle added to the document (a browser handle). */
|
|
88
89
|
dispose?(): void;
|