@docmentis/udoc-node 0.0.0-stage → 0.8.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/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +50 -2
- package/dist/blocking-fetch.d.ts +8 -0
- package/dist/blocking-fetch.d.ts.map +1 -0
- package/dist/blocking-fetch.js +30 -0
- package/dist/blocking-fetch.js.map +1 -0
- package/dist/engine.d.ts +3 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +20 -0
- package/dist/engine.js.map +1 -0
- package/dist/font-cache.d.ts +16 -0
- package/dist/font-cache.d.ts.map +1 -0
- package/dist/font-cache.js +66 -0
- package/dist/font-cache.js.map +1 -0
- package/dist/format.d.ts +4 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +30 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +101 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +96 -0
- package/dist/node.js.map +1 -0
- package/dist/protocol.d.ts +151 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +3 -0
- package/dist/protocol.js.map +1 -0
- package/dist/session.d.ts +168 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +458 -0
- package/dist/session.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +243 -0
- package/dist/worker.js.map +1 -0
- package/package.json +62 -5
package/dist/worker.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// The worker thread that holds one document's session.
|
|
2
|
+
//
|
|
3
|
+
// One document, one worker, one wasm instance. The session's calls are
|
|
4
|
+
// synchronous and CPU-bound — composing and rasterizing a page holds the thread
|
|
5
|
+
// for as long as it takes — so they run here, off the embedder's event loop.
|
|
6
|
+
// And since a trap leaves an instance unusable, an instance per document means
|
|
7
|
+
// a document that brings the engine down takes nothing else with it.
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
10
|
+
import { UDocError, createFontFetchMemory, fetchFontBinaries, initSync, officeCompatibleFontsAt, startSession, } from "@docmentis/udoc-wasm";
|
|
11
|
+
import { bundledFontUrls } from "@docmentis/udoc-wasm/meta-url";
|
|
12
|
+
import { blockingFetch } from "./blocking-fetch.js";
|
|
13
|
+
const init = workerData;
|
|
14
|
+
initSync({ module: init.module });
|
|
15
|
+
const port = parentPort;
|
|
16
|
+
/** The document's session, once `open` has started one. */
|
|
17
|
+
let session = null;
|
|
18
|
+
/** The page limit that composes every page: the largest wasm32 `usize`. */
|
|
19
|
+
const WHOLE_DOCUMENT = 2 ** 32 - 1;
|
|
20
|
+
/** What the fulfiller remembers across this document's font orders: the css2
|
|
21
|
+
* responses it has read, and the files it has handed over. */
|
|
22
|
+
const fontMemory = createFontFetchMemory();
|
|
23
|
+
/** Where a font file is asked for, once the open has carried it: the session's
|
|
24
|
+
* side, which keeps the files for every document of its `UDocNode`. */
|
|
25
|
+
let fontFiles = null;
|
|
26
|
+
/** The font files asked for and not answered yet, by their request's id. */
|
|
27
|
+
const fontFilesPending = new Map();
|
|
28
|
+
let nextFontFileId = 1;
|
|
29
|
+
/** The request being handled, which the next one waits behind. */
|
|
30
|
+
let handling = Promise.resolve();
|
|
31
|
+
port.on("message", (request) => {
|
|
32
|
+
// One at a time. A call that composes waits for its fonts partway through,
|
|
33
|
+
// and nothing else may touch the session while it does.
|
|
34
|
+
handling = handling.then(async () => {
|
|
35
|
+
const reply = await handle(request);
|
|
36
|
+
// Saved or exported bytes are a fresh copy out of wasm memory, so their
|
|
37
|
+
// buffer is this reply's alone to hand over.
|
|
38
|
+
const transfer = reply.ok && reply.result instanceof Uint8Array ? [reply.result.buffer] : [];
|
|
39
|
+
port.postMessage(reply, transfer);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
async function handle(request) {
|
|
43
|
+
const { id } = request;
|
|
44
|
+
try {
|
|
45
|
+
switch (request.type) {
|
|
46
|
+
case "open":
|
|
47
|
+
case "openRemote":
|
|
48
|
+
fontFiles = request.fontFiles;
|
|
49
|
+
fontFiles.on("message", settleFontFile);
|
|
50
|
+
// Permitted first, then the permit is spent on this document
|
|
51
|
+
// whether or not it parses: one session, one permit, one document.
|
|
52
|
+
session = await startSession(init.config, bundledFontUrls, init.googleFontFamilies);
|
|
53
|
+
// The host's own fonts first: of two faces on one descriptor,
|
|
54
|
+
// the first registered answers, so a host's face outranks the
|
|
55
|
+
// package's — as in a browser, where the package's go in by URL
|
|
56
|
+
// and every face given as bytes outranks those.
|
|
57
|
+
registerHostFonts(session);
|
|
58
|
+
// The office-compatible fonts are files beside the engine, not
|
|
59
|
+
// inside it. By URL, nearly every office document would compose
|
|
60
|
+
// once in a stand-in and again when they landed, so they go in
|
|
61
|
+
// as bytes, before the document opens.
|
|
62
|
+
for (const bytes of await officeCompatibleFonts())
|
|
63
|
+
session.registerLocalFont(bytes);
|
|
64
|
+
if (request.type === "open")
|
|
65
|
+
session.open(request.bytes, request.format, request.delimiter);
|
|
66
|
+
// The session keeps the fetch: a page composed later may need a
|
|
67
|
+
// part not fetched yet.
|
|
68
|
+
else
|
|
69
|
+
session.openRemote(request.url, blockingFetch(request.fetches));
|
|
70
|
+
return { id, ok: true, result: openedAs(session) };
|
|
71
|
+
case "authenticate":
|
|
72
|
+
// Not a second open: the permit was spent on this document by
|
|
73
|
+
// the open that found it needs a password.
|
|
74
|
+
if (!session)
|
|
75
|
+
throw new UDocError("invalidRequest", "no document is open");
|
|
76
|
+
return { id, ok: true, result: session.authenticate(request.password) };
|
|
77
|
+
case "pageCount": {
|
|
78
|
+
const s = opened();
|
|
79
|
+
// Nothing is known about a page until it is composed, so the
|
|
80
|
+
// count is known only once every page is: compose the whole
|
|
81
|
+
// primary plane. A pass that falls short had a page fail, and
|
|
82
|
+
// then the count is not known at all.
|
|
83
|
+
if (!(await updateLayoutSettled(s, WHOLE_DOCUMENT))) {
|
|
84
|
+
throw new UDocError("malformed", `the page count is unknown: a page failed to compose after ${s.composedPageCount()} page(s)`);
|
|
85
|
+
}
|
|
86
|
+
return { id, ok: true, result: s.composedPageCount() };
|
|
87
|
+
}
|
|
88
|
+
case "saveToBytes":
|
|
89
|
+
return {
|
|
90
|
+
id,
|
|
91
|
+
ok: true,
|
|
92
|
+
result: opened().saveToBytes(request.format, request.strategy, request.delimiter),
|
|
93
|
+
};
|
|
94
|
+
case "saveToPackage":
|
|
95
|
+
return { id, ok: true, result: opened().saveToPackage(request.version) };
|
|
96
|
+
case "exportToBytes":
|
|
97
|
+
return { id, ok: true, result: opened().exportToBytes(request.format) };
|
|
98
|
+
case "exportPageToBytes": {
|
|
99
|
+
const s = opened();
|
|
100
|
+
// A page is known only once composed, so compose through the
|
|
101
|
+
// one asked for — not the whole document. If the pass finishes
|
|
102
|
+
// the document short of it, the page doesn't exist.
|
|
103
|
+
const complete = await updateLayoutSettled(s, request.index);
|
|
104
|
+
const count = s.composedPageCount();
|
|
105
|
+
if (request.index >= count) {
|
|
106
|
+
if (complete) {
|
|
107
|
+
// Says what the document has, not which page was asked
|
|
108
|
+
// for: a host numbers pages its own way (the CLI from
|
|
109
|
+
// 1) and words the address itself.
|
|
110
|
+
const message = `the document has ${count} page(s)`;
|
|
111
|
+
return { id, ok: false, failure: { code: "notFound", message } };
|
|
112
|
+
}
|
|
113
|
+
throw new UDocError("malformed", `page index ${request.index} is not composed: the document composed ${count} page(s)`);
|
|
114
|
+
}
|
|
115
|
+
// Plane 0 — the document's primary plane (the deck for a
|
|
116
|
+
// presentation).
|
|
117
|
+
return { id, ok: true, result: s.exportPageToBytes(0, request.index, request.format) };
|
|
118
|
+
}
|
|
119
|
+
case "snapshot":
|
|
120
|
+
return { id, ok: true, result: opened().snapshot() };
|
|
121
|
+
case "versionVector":
|
|
122
|
+
return { id, ok: true, result: opened().versionVector() };
|
|
123
|
+
case "patchSince":
|
|
124
|
+
return { id, ok: true, result: opened().patchSince(request.peer) };
|
|
125
|
+
case "merge":
|
|
126
|
+
opened().mergePatch(request.patch);
|
|
127
|
+
return { id, ok: true, result: undefined };
|
|
128
|
+
case "presence":
|
|
129
|
+
return { id, ok: true, result: opened().presence() };
|
|
130
|
+
case "mergePresence":
|
|
131
|
+
opened().mergePresence(request.presence);
|
|
132
|
+
return { id, ok: true, result: undefined };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return { id, ok: false, failure: failureOf(error) };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function opened() {
|
|
140
|
+
if (!session)
|
|
141
|
+
throw new UDocError("invalidRequest", "no document is open");
|
|
142
|
+
// Said here, for every call, rather than as whichever call it was failing
|
|
143
|
+
// for want of a document.
|
|
144
|
+
if (session.needsPassword()) {
|
|
145
|
+
throw new UDocError("passwordRequired", "the document needs a password: authenticate it first");
|
|
146
|
+
}
|
|
147
|
+
return session;
|
|
148
|
+
}
|
|
149
|
+
/** The office-compatible fonts `@docmentis/udoc-wasm` ships, read from its
|
|
150
|
+
* `dist/fonts/` — `file:` URLs under Node. */
|
|
151
|
+
function officeCompatibleFonts() {
|
|
152
|
+
return Promise.all(officeCompatibleFontsAt(bundledFontUrls).map((font) => readFile(new URL(font.url))));
|
|
153
|
+
}
|
|
154
|
+
/** Offer `s` the host's own fonts: bytes as they are, the rest by URL. */
|
|
155
|
+
function registerHostFonts(s) {
|
|
156
|
+
const urlFonts = [];
|
|
157
|
+
for (const font of init.fonts) {
|
|
158
|
+
if (font instanceof Uint8Array)
|
|
159
|
+
s.registerLocalFont(font);
|
|
160
|
+
else
|
|
161
|
+
urlFonts.push(font);
|
|
162
|
+
}
|
|
163
|
+
s.registerUrlFonts(urlFonts);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Compose through page `index`, then fill every font order the composing
|
|
167
|
+
* placed and compose again, until none is left — so what a call answers with
|
|
168
|
+
* is drawn in the document's fonts, never in the stand-in a font still on order
|
|
169
|
+
* is drawn in. Whether the document composed to its end, as `updateLayout`
|
|
170
|
+
* says it.
|
|
171
|
+
*
|
|
172
|
+
* It ends: each settled order installs its font or retires its characters from
|
|
173
|
+
* that vendor, and a family's chain of vendors is finite.
|
|
174
|
+
*/
|
|
175
|
+
async function updateLayoutSettled(s, index) {
|
|
176
|
+
let complete = s.updateLayout(index);
|
|
177
|
+
for (let orders = s.takeFontRequests(); orders.length > 0; orders = s.takeFontRequests()) {
|
|
178
|
+
const settled = await Promise.all(orders.map(async (order) => [order.id, await fetchFontBinaries(order, fetchFont, fontMemory, init.googleFontEndpoint)]));
|
|
179
|
+
for (const [id, binaries] of settled)
|
|
180
|
+
s.completeFontRequest(BigInt(id), binaries);
|
|
181
|
+
// A refusal re-shapes too: re-resolving is what orders from the next
|
|
182
|
+
// vendor down the chain.
|
|
183
|
+
s.refreshFonts();
|
|
184
|
+
// Re-shaping can move page breaks, so the page asked for may sit
|
|
185
|
+
// beyond what is composed now.
|
|
186
|
+
complete = s.updateLayout(index);
|
|
187
|
+
}
|
|
188
|
+
return complete;
|
|
189
|
+
}
|
|
190
|
+
/** How the fulfiller fetches under Node: a `file:` URL — the package's fonts,
|
|
191
|
+
* or a host's — read from disk, which Node's `fetch` can't; a css2 stylesheet
|
|
192
|
+
* by `fetch`, each time; any other file from the cache every session of this
|
|
193
|
+
* document's `UDocNode` shares. */
|
|
194
|
+
async function fetchFont(url, requestInit) {
|
|
195
|
+
if (url.startsWith("file:"))
|
|
196
|
+
return new Response(await readFile(new URL(url)));
|
|
197
|
+
if (url.startsWith(`${init.googleFontEndpoint}?`))
|
|
198
|
+
return fetch(url, requestInit);
|
|
199
|
+
return new Response(await fetchCachedFont(url));
|
|
200
|
+
}
|
|
201
|
+
/** The font file at `url`, asked of the session's side, which keeps it. */
|
|
202
|
+
function fetchCachedFont(url) {
|
|
203
|
+
const files = fontFiles;
|
|
204
|
+
if (!files)
|
|
205
|
+
return Promise.reject(new Error("no document is open"));
|
|
206
|
+
const id = nextFontFileId++;
|
|
207
|
+
return new Promise((resolve, reject) => {
|
|
208
|
+
fontFilesPending.set(id, { resolve, reject });
|
|
209
|
+
files.postMessage({ id, url });
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** Settle the font file `answer` is for. */
|
|
213
|
+
function settleFontFile(answer) {
|
|
214
|
+
const pending = fontFilesPending.get(answer.id);
|
|
215
|
+
if (!pending)
|
|
216
|
+
return;
|
|
217
|
+
fontFilesPending.delete(answer.id);
|
|
218
|
+
if (answer.ok)
|
|
219
|
+
pending.resolve(answer.body);
|
|
220
|
+
else
|
|
221
|
+
pending.reject(new Error(answer.message));
|
|
222
|
+
}
|
|
223
|
+
/** What `s`, just opened, opened as. */
|
|
224
|
+
function openedAs(s) {
|
|
225
|
+
const docType = s.docType();
|
|
226
|
+
if (docType === undefined)
|
|
227
|
+
throw new UDocError("internal", "the document opened, but its doc type is unknown");
|
|
228
|
+
const sourceFormat = s.sourceFormat();
|
|
229
|
+
return {
|
|
230
|
+
docType,
|
|
231
|
+
...(sourceFormat !== undefined ? { sourceFormat } : {}),
|
|
232
|
+
fromPackage: s.fromPackage(),
|
|
233
|
+
needsPassword: s.needsPassword(),
|
|
234
|
+
entitlements: s.entitlements(),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** `error` as it crosses to the session's side. A panic aborts, and an abort
|
|
238
|
+
* in wasm is a trap, which `UDocError.from` reads as `crashed`. */
|
|
239
|
+
function failureOf(error) {
|
|
240
|
+
const { code, message, detail } = UDocError.from(error);
|
|
241
|
+
return { code, message, ...(detail && { detail }) };
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@docmentis/udoc-node",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Read, render, and process documents programmatically in Node.js.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"document",
|
|
7
|
+
"pdf",
|
|
8
|
+
"docx",
|
|
9
|
+
"pptx",
|
|
10
|
+
"xlsx",
|
|
11
|
+
"word",
|
|
12
|
+
"powerpoint",
|
|
13
|
+
"excel",
|
|
14
|
+
"office",
|
|
15
|
+
"csv",
|
|
16
|
+
"render",
|
|
17
|
+
"png",
|
|
18
|
+
"nodejs",
|
|
19
|
+
"worker-threads",
|
|
20
|
+
"docmentis",
|
|
21
|
+
"udoc",
|
|
22
|
+
"webassembly",
|
|
23
|
+
"wasm"
|
|
24
|
+
],
|
|
25
|
+
"homepage": "https://www.docmentis.com/docs",
|
|
26
|
+
"license": "MIT OR Apache-2.0",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/docMentis/docmentis-udoc.git",
|
|
30
|
+
"directory": "packages/udoc-node"
|
|
31
|
+
},
|
|
32
|
+
"type": "module",
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"LICENSE-MIT",
|
|
37
|
+
"LICENSE-APACHE"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"main": "./dist/index.js",
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"import": "./dist/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22.18"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
55
|
+
"build": "npm run clean && node scripts/check-version.mjs && tsc -p tsconfig.json",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json",
|
|
57
|
+
"test": "node --test",
|
|
58
|
+
"clean": "rm -rf dist"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@docmentis/udoc-wasm": "0.8.2"
|
|
62
|
+
}
|
|
63
|
+
}
|