Skip to content

API reference / @docmentis/udoc-node / UDocNode

Class: UDocNode ​

The udoc engine in this process: the host's identity, and the compiled engine every session instantiates. Build one per host identity and open as many documents through it as needed — each is a session of its own, on a thread of its own.

Methods ​

create() ​

ts
static create(options?): Promise<UDocNode>;

Compile the bundled engine (once per process) and return a UDocNode for it.

Parameters ​

ParameterType
options?UDocNodeOptions

open() ​

ts
open(
   bytes, 
   format?, 
   delimiter?
): Promise<UDocSession>;

Open a document from its bytes in a session of its own — as format when given, which skips detection; otherwise the format is detected, and a .udoc zip opens as a package. delimiter is the character a CSV's fields are split by; without it, a comma, or a semicolon where the first record is split by more of them. No other format takes one.

Starts the session first, so this is where a license is checked and, without one, where a permit is spent — on this document, whether or not it then parses. Rejects with a UDocError: a licensing code when the engine refuses, or the engine's own when the bytes don't open.

A PDF that needs a password opens waiting for one: the session's needsPassword says so, and its authenticate takes the password.

Parameters ​

ParameterType
bytesUint8Array
format?FileFormat
delimiter?string

openRemote() ​

ts
openRemote(url, fetch?): Promise<UDocSession>;

Open the package a server keeps at url in a session of its own, without downloading it — url is its package resource, udoc-server's …/documents/{id}/package, and absolute. Each part is fetched the first time the document needs it: the open fetches the few it starts from, and a call that composes a page fetches that page's, rejecting if one can't be fetched.

A remote open is an open: this is where a license is checked and, without one, where a permit is spent. Rejects with a UDocError: a licensing code when the engine refuses, or the engine's own when the package can't be fetched or read.

Each URL is fetched with the global fetch, unless fetch answers it — the whole body, as the route serves it — which is how udoc-server opens a session over the store it keeps, with no request to itself.

Parameters ​

ParameterType
urlstring
fetch?(url) => Promise<Uint8Array<ArrayBufferLike>>