EpubScriptSession

constructor(document: EpubDocument, engineFor: (chapter: Int) -> KiteScriptEngine, onConsole: (level: String, message: String) -> Unit = { _, _ -> }, clock: () -> Long? = null, liveChapters: Int = Int.MAX_VALUE, instanceKey: String? = null, fontOutlines: (text: String, font: FontSpec) -> KitePath?? = null)(source)

Parameters

engineFor

opens the engine of one chapter's scripts, the first time it opens. The session closes it in close, or when it makes room for another chapter. An engine that will not open is a failure of that chapter, whose scripts then do not run. The first script the session evaluates in it is always the session's own DOM, before any of the book's, so a host that limits how long the book's scripts run can leave that one out (#554).

liveChapters

how many chapters' engines may be open at once, at least one. One suits engines that cannot share a thread with another open engine.

onConsole

gets what scripts print with console, and what alert, confirm and prompt would have shown, with the level or the dialog's name.

clock

milliseconds on a clock that only goes forward, for the timers and performance.now(). Leave it unset for the system's own.

instanceKey

a value the app keeps for its reader, such as an install id, which goes into the book's origin. EPUB 3.3 asks for an origin of each reader's copy, so another reader's copy of the book cannot reach this one's storage. Without one the session makes a random key, and the origin lasts as long as the session.

fontOutlines

the outline of a run of text in a host font, in glyph space as KiteCanvas.hostGlyphOutline answers it. A canvas's getImageData and toDataURL draw text with it. Without it, text reads back as blank.