@docmentis/udoc-node 0.0.1 → 0.8.1
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 +51 -0
- 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 +246 -0
- package/dist/worker.js.map +1 -0
- package/package.json +61 -5
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 docMentis LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @docmentis/udoc-node
|
|
2
|
+
|
|
3
|
+
**Document processing for Node.js, powered by the udoc engine.**
|
|
4
|
+
|
|
5
|
+
Use docMentis document capabilities programmatically in Node.js applications and services. Open documents, render pages, export images, and save document content without embedding a browser-based viewer.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@docmentis/udoc-node)
|
|
8
|
+
[](https://github.com/docMentis/docmentis-udoc#open-source-packages-shared-runtime)
|
|
9
|
+
|
|
10
|
+
**[Docs](https://www.docmentis.com/docs)** · **[API Reference](https://www.docmentis.com/docs/api/udoc-node)** · **[Changelog](https://github.com/docMentis/docmentis-udoc/blob/main/CHANGELOG.md)** · **[Report Issue](https://github.com/docMentis/docmentis-udoc/issues)**
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## When to use it
|
|
15
|
+
|
|
16
|
+
- **Backend document workflows.** Inspect and process documents inside your existing Node.js application.
|
|
17
|
+
- **Rendering and previews.** Export document pages as images for thumbnails, previews, or other workflows.
|
|
18
|
+
- **Document operations.** Read and save supported document formats, including udoc document packages.
|
|
19
|
+
- **Custom integrations.** Build document functionality into your own services and automation tools.
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install @docmentis/udoc-node
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
29
|
+
import { UDocNode } from "@docmentis/udoc-node";
|
|
30
|
+
|
|
31
|
+
const udoc = await UDocNode.create({ license: "YOUR_LICENSE", domain: "example.com" });
|
|
32
|
+
const session = await udoc.open(await readFile("report.docx"));
|
|
33
|
+
try {
|
|
34
|
+
const png = await session.exportPageToBytes(0, { png: { scale: 2 } });
|
|
35
|
+
await writeFile("page-1.png", png);
|
|
36
|
+
} finally {
|
|
37
|
+
await session.close();
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
A commercial license is shown for illustration; the runtime also supports online-authorized free use. See the API documentation for session management, supported formats, and licensing options. Requires a supported Node.js version.
|
|
42
|
+
|
|
43
|
+
## Related packages
|
|
44
|
+
|
|
45
|
+
Use [`@docmentis/udoc-cli`](https://www.npmjs.com/package/@docmentis/udoc-cli) for ready-made commands, or [`@docmentis/udoc-server`](https://www.npmjs.com/package/@docmentis/udoc-server) to expose document operations and collaboration through a hosted service.
|
|
46
|
+
|
|
47
|
+
## Licensing
|
|
48
|
+
|
|
49
|
+
The Node.js integration is open source under **MIT OR Apache-2.0**. The underlying [`@docmentis/udoc-wasm`](https://www.npmjs.com/package/@docmentis/udoc-wasm) runtime is proprietary and separately licensed. Free use requires online authorization; commercial licensing is available for offline use.
|
|
50
|
+
|
|
51
|
+
[Source and documentation](https://github.com/docMentis/docmentis-udoc)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FetchChannel } from "./protocol.js";
|
|
2
|
+
/**
|
|
3
|
+
* The engine's fetch over `channel`: post the URL, block this thread until the
|
|
4
|
+
* session's side counts an answer in, and take that answer off the port — the
|
|
5
|
+
* bytes, or a throw saying why they didn't come.
|
|
6
|
+
*/
|
|
7
|
+
export declare function blockingFetch({ port, answered }: FetchChannel): (url: string) => Uint8Array;
|
|
8
|
+
//# sourceMappingURL=blocking-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocking-fetch.d.ts","sourceRoot":"","sources":["../src/blocking-fetch.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU,CAY3F"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The worker's side of a remote open: the engine's fetch, made synchronous.
|
|
2
|
+
//
|
|
3
|
+
// The engine asks for a part the moment it needs one, and waits for it; Node
|
|
4
|
+
// has no synchronous HTTP. So this thread posts the part's URL to the session's
|
|
5
|
+
// side, which fetches it on the embedder's thread, and blocks until the answer
|
|
6
|
+
// is counted in.
|
|
7
|
+
//
|
|
8
|
+
// Nothing here imports a sibling at runtime, so the tests run it from `src`.
|
|
9
|
+
import { receiveMessageOnPort } from "node:worker_threads";
|
|
10
|
+
/**
|
|
11
|
+
* The engine's fetch over `channel`: post the URL, block this thread until the
|
|
12
|
+
* session's side counts an answer in, and take that answer off the port — the
|
|
13
|
+
* bytes, or a throw saying why they didn't come.
|
|
14
|
+
*/
|
|
15
|
+
export function blockingFetch({ port, answered }) {
|
|
16
|
+
return (url) => {
|
|
17
|
+
// Read before posting, so an answer counted before the wait begins
|
|
18
|
+
// still ends it.
|
|
19
|
+
const seen = Atomics.load(answered, 0);
|
|
20
|
+
port.postMessage(url);
|
|
21
|
+
Atomics.wait(answered, 0, seen);
|
|
22
|
+
const answer = receiveMessageOnPort(port)?.message;
|
|
23
|
+
if (answer === undefined)
|
|
24
|
+
throw new Error("the session's side answered nothing");
|
|
25
|
+
if (!answer.ok)
|
|
26
|
+
throw new Error(answer.message);
|
|
27
|
+
return new Uint8Array(answer.body);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=blocking-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocking-fetch.js","sourceRoot":"","sources":["../src/blocking-fetch.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,iBAAiB;AACjB,EAAE;AACF,6EAA6E;AAE7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI3D;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAgB;IAC1D,OAAO,CAAC,GAAG,EAAE,EAAE;QACX,mEAAmE;QACnE,iBAAiB;QACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,EAAE,OAAkC,CAAC;QAC9E,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACjF,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAcA,qEAAqE;AACrE,wBAAgB,aAAa,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAO3D"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The bundled engine, compiled once per process.
|
|
2
|
+
//
|
|
3
|
+
// Compiling the ~30 MB binary is most of what loading it costs, and a compiled
|
|
4
|
+
// `WebAssembly.Module` can be handed to a worker thread as is. So the module is
|
|
5
|
+
// compiled here, on whichever thread builds the `UDocNode`, and every session's
|
|
6
|
+
// worker instantiates that one module rather than reading and compiling its own.
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
import { UDocError } from "@docmentis/udoc-wasm/error";
|
|
9
|
+
import { bundledWasmUrl } from "@docmentis/udoc-wasm/meta-url";
|
|
10
|
+
let compiled;
|
|
11
|
+
/** The engine binary bundled in `@docmentis/udoc-wasm`, compiled. */
|
|
12
|
+
export function compileEngine() {
|
|
13
|
+
// `bundledWasmUrl` is resolved against the wasm package's own module URL,
|
|
14
|
+
// which under Node is a `file:` URL that `readFile` takes directly.
|
|
15
|
+
compiled ??= readFile(new URL(bundledWasmUrl))
|
|
16
|
+
.then((bytes) => WebAssembly.compile(bytes))
|
|
17
|
+
.catch((error) => Promise.reject(UDocError.from(error)));
|
|
18
|
+
return compiled;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AAEjF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,IAAI,QAAiD,CAAC;AAEtD,qEAAqE;AACrE,MAAM,UAAU,aAAa;IACzB,0EAA0E;IAC1E,oEAAoE;IACpE,QAAQ,KAAK,QAAQ,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;SACzC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC3C,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font files fetched by URL, kept up to `limit` bytes; the least recently used
|
|
3
|
+
* goes first.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FontCache {
|
|
6
|
+
#private;
|
|
7
|
+
/** Keep up to `limit` bytes of what `fetch` downloads. */
|
|
8
|
+
constructor(limit: number, fetch: (url: string) => Promise<Uint8Array>);
|
|
9
|
+
/**
|
|
10
|
+
* The file at `url`: kept, or fetched, kept and the oldest dropped until
|
|
11
|
+
* it fits. A failed fetch rejects and is not kept, so the next ask tries
|
|
12
|
+
* again; a file larger than `limit` is not kept.
|
|
13
|
+
*/
|
|
14
|
+
get(url: string): Promise<Uint8Array>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=font-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-cache.d.ts","sourceRoot":"","sources":["../src/font-cache.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,qBAAa,SAAS;;IAUlB,0DAA0D;gBAC9C,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC;IAKtE;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAkCxC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The font files every session a `UDocNode` opens shares.
|
|
2
|
+
//
|
|
3
|
+
// Each document runs in a worker and a wasm instance of its own, so what one
|
|
4
|
+
// document downloaded goes when it closes, and the next document naming the
|
|
5
|
+
// same family downloads it again. The files are kept here instead, on the
|
|
6
|
+
// embedder's thread, where each session's worker asks for them by URL.
|
|
7
|
+
//
|
|
8
|
+
// Only files are kept. A css2 stylesheet is fetched each time — it is small,
|
|
9
|
+
// and what it names is what gets downloaded.
|
|
10
|
+
/**
|
|
11
|
+
* Font files fetched by URL, kept up to `limit` bytes; the least recently used
|
|
12
|
+
* goes first.
|
|
13
|
+
*/
|
|
14
|
+
export class FontCache {
|
|
15
|
+
#limit;
|
|
16
|
+
#fetch;
|
|
17
|
+
/** The bytes of every file in {@link #files}. */
|
|
18
|
+
#size = 0;
|
|
19
|
+
/** Oldest use first: a hit moves its file to the end. */
|
|
20
|
+
#files = new Map();
|
|
21
|
+
/** Downloads in flight, so two documents asking at once download once. */
|
|
22
|
+
#fetching = new Map();
|
|
23
|
+
/** Keep up to `limit` bytes of what `fetch` downloads. */
|
|
24
|
+
constructor(limit, fetch) {
|
|
25
|
+
this.#limit = limit;
|
|
26
|
+
this.#fetch = fetch;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The file at `url`: kept, or fetched, kept and the oldest dropped until
|
|
30
|
+
* it fits. A failed fetch rejects and is not kept, so the next ask tries
|
|
31
|
+
* again; a file larger than `limit` is not kept.
|
|
32
|
+
*/
|
|
33
|
+
get(url) {
|
|
34
|
+
const kept = this.#files.get(url);
|
|
35
|
+
if (kept) {
|
|
36
|
+
this.#files.delete(url);
|
|
37
|
+
this.#files.set(url, kept);
|
|
38
|
+
return Promise.resolve(kept);
|
|
39
|
+
}
|
|
40
|
+
const fetching = this.#fetching.get(url);
|
|
41
|
+
if (fetching)
|
|
42
|
+
return fetching;
|
|
43
|
+
const fetched = this.#fetch(url).then((bytes) => {
|
|
44
|
+
this.#keep(url, bytes);
|
|
45
|
+
return bytes;
|
|
46
|
+
});
|
|
47
|
+
this.#fetching.set(url, fetched);
|
|
48
|
+
// Settled either way: a failure is not remembered.
|
|
49
|
+
void fetched.then(() => this.#fetching.delete(url), () => this.#fetching.delete(url));
|
|
50
|
+
return fetched;
|
|
51
|
+
}
|
|
52
|
+
/** Keep `bytes` as the newest file, dropping the oldest until all fit. */
|
|
53
|
+
#keep(url, bytes) {
|
|
54
|
+
if (bytes.byteLength > this.#limit)
|
|
55
|
+
return;
|
|
56
|
+
this.#files.set(url, bytes);
|
|
57
|
+
this.#size += bytes.byteLength;
|
|
58
|
+
for (const [oldest, file] of this.#files) {
|
|
59
|
+
if (this.#size <= this.#limit)
|
|
60
|
+
break;
|
|
61
|
+
this.#files.delete(oldest);
|
|
62
|
+
this.#size -= file.byteLength;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=font-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-cache.js","sourceRoot":"","sources":["../src/font-cache.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,uEAAuE;AACvE,EAAE;AACF,6EAA6E;AAC7E,6CAA6C;AAE7C;;;GAGG;AACH,MAAM,OAAO,SAAS;IACT,MAAM,CAAS;IACf,MAAM,CAAuC;IACtD,iDAAiD;IACjD,KAAK,GAAG,CAAC,CAAC;IACV,yDAAyD;IAChD,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAChD,0EAA0E;IACjE,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;IAE5D,0DAA0D;IAC1D,YAAY,KAAa,EAAE,KAA2C;QAClE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,GAAW;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACP,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAE9B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YAC5C,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACvB,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,mDAAmD;QACnD,KAAK,OAAO,CAAC,IAAI,CACb,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAChC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CACnC,CAAC;QACF,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,0EAA0E;IAC1E,KAAK,CAAC,GAAW,EAAE,KAAiB;QAChC,IAAI,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM;YAAE,OAAO;QAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC;QAC/B,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM;gBAAE,MAAM;YACrC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC;QAClC,CAAC;IACL,CAAC;CACJ"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAuBvD,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAE/D"}
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The file formats at run time. The schema's `FileFormat` is a type only, so a
|
|
2
|
+
// host that receives one as text — a query parameter, a command-line flag —
|
|
3
|
+
// checks it here.
|
|
4
|
+
//
|
|
5
|
+
// Nothing here imports a sibling at runtime, so the tests can load it from `src`.
|
|
6
|
+
/** Every file format, held to the engine's `FileFormat`: a format added there
|
|
7
|
+
* or dropped from it fails to typecheck here. */
|
|
8
|
+
const FILE_FORMATS = {
|
|
9
|
+
pdf: true,
|
|
10
|
+
docx: true,
|
|
11
|
+
pptx: true,
|
|
12
|
+
xlsx: true,
|
|
13
|
+
csv: true,
|
|
14
|
+
tsv: true,
|
|
15
|
+
psv: true,
|
|
16
|
+
jpg: true,
|
|
17
|
+
png: true,
|
|
18
|
+
gif: true,
|
|
19
|
+
bmp: true,
|
|
20
|
+
tiff: true,
|
|
21
|
+
webp: true,
|
|
22
|
+
svg: true,
|
|
23
|
+
emf: true,
|
|
24
|
+
wmf: true,
|
|
25
|
+
};
|
|
26
|
+
/** Whether `value` is a file format's name (`"pdf"`, `"pptx"`, `"jpg"`, …). */
|
|
27
|
+
export function isFileFormat(value) {
|
|
28
|
+
return Object.hasOwn(FILE_FORMATS, value);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4EAA4E;AAC5E,kBAAkB;AAClB,EAAE;AACF,kFAAkF;AAIlF;kDACkD;AAClD,MAAM,YAAY,GAAG;IACjB,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACuB,CAAC;AAErC,+EAA+E;AAC/E,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { UDocNode } from "./node.js";
|
|
2
|
+
export type { UDocNodeOptions } from "./node.js";
|
|
3
|
+
export type { RemoteCheckpointResponse, UDocSession } from "./session.js";
|
|
4
|
+
export { UDocError } from "@docmentis/udoc-wasm/error";
|
|
5
|
+
export type { UDocErrorCode, UDocErrorDetail } from "@docmentis/udoc-wasm/error";
|
|
6
|
+
export type { ExportFormat, FileFormat, PageExportFormat, SaveStrategy, UDocType } from "@docmentis/udoc-wasm";
|
|
7
|
+
export type { Entitlements, Feature } from "@docmentis/udoc-wasm";
|
|
8
|
+
export { isFileFormat } from "./format.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,YAAY,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGjF,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE/G,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIrC,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAOvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { FileFormat, GoogleFontFamily, UrlFont } from "@docmentis/udoc-wasm";
|
|
2
|
+
import { UDocSession } from "./session.js";
|
|
3
|
+
/**
|
|
4
|
+
* What the engine is told about who is running it, under what license, and
|
|
5
|
+
* which fonts it may draw with beyond a document's own. Every session started
|
|
6
|
+
* through the same {@link UDocNode} carries it.
|
|
7
|
+
*/
|
|
8
|
+
export interface UDocNodeOptions {
|
|
9
|
+
/** Commercial license key. Absent is free usage, which is metered: every
|
|
10
|
+
* {@link UDocNode.open} then needs a permit from the docMentis service. */
|
|
11
|
+
license?: string;
|
|
12
|
+
/** The domain the license is issued for. A browser host has a page to read
|
|
13
|
+
* it from and a Node host does not, so here it is declared. Defaults to
|
|
14
|
+
* `"unknown"`. */
|
|
15
|
+
domain?: string;
|
|
16
|
+
/** Ask for usage not to be reported. Honored only with a license;
|
|
17
|
+
* otherwise ignored. */
|
|
18
|
+
disableTelemetry?: boolean;
|
|
19
|
+
/** Anonymous per-user id, so usage attributes to one user across sessions.
|
|
20
|
+
* Without one, usage attributes to the domain. */
|
|
21
|
+
distinctId?: string;
|
|
22
|
+
/** The docMentis component embedding the engine, reported with every
|
|
23
|
+
* permit request and usage event. Defaults to this package; `udoc-cli`
|
|
24
|
+
* and `udoc-server` name themselves. */
|
|
25
|
+
wrapper?: {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
};
|
|
29
|
+
/** Fonts of the host's own, offered to every document — each a font
|
|
30
|
+
* file's bytes or a {@link UrlFont}, fetched once a document's text asks
|
|
31
|
+
* for it; a `file:` URL is read from disk. Default none. */
|
|
32
|
+
fonts?: ReadonlyArray<Uint8Array | UrlFont>;
|
|
33
|
+
/** Fetch from Google Fonts the families a document names that no font of
|
|
34
|
+
* its own or the host's ({@link fonts}) covers. `false` offers no Google
|
|
35
|
+
* font family at all, so nothing is ever asked of Google. Default `true`. */
|
|
36
|
+
enableGoogleFonts?: boolean;
|
|
37
|
+
/** The Google font families offered, each its name, the `[bold, italic]`
|
|
38
|
+
* faces Google serves for it and its subsets — to narrow the catalog
|
|
39
|
+
* `@docmentis/udoc-wasm` ships (`GOOGLE_FONT_CATALOG`), extend it or keep it
|
|
40
|
+
* current. Ignored when {@link enableGoogleFonts} is `false`. Default that
|
|
41
|
+
* catalog. */
|
|
42
|
+
googleFontFamilies?: GoogleFontFamily[];
|
|
43
|
+
/** Where the Google Fonts css2 API is asked for a family's faces — a
|
|
44
|
+
* mirror's, for a host that can't or won't reach Google. The font files
|
|
45
|
+
* are fetched from the URLs its `@font-face` blocks give, so a mirror that
|
|
46
|
+
* also stands in for `fonts.gstatic.com` rewrites them. An absolute URL.
|
|
47
|
+
* Ignored when {@link enableGoogleFonts} is `false`. Default
|
|
48
|
+
* `https://fonts.googleapis.com/css2`. */
|
|
49
|
+
googleFontEndpoint?: string | URL;
|
|
50
|
+
/** Bytes of downloaded font files kept for every session to reuse — a
|
|
51
|
+
* Google font's files and each {@link UrlFont} fetched over the network —
|
|
52
|
+
* the least recently used dropped first. `0` keeps none. Default 64 MiB. */
|
|
53
|
+
fontCacheSize?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The udoc engine in this process: the host's identity, and the compiled
|
|
57
|
+
* engine every session instantiates. Build one per host identity and open as
|
|
58
|
+
* many documents through it as needed — each is a session of its own, on a
|
|
59
|
+
* thread of its own.
|
|
60
|
+
*/
|
|
61
|
+
export declare class UDocNode {
|
|
62
|
+
#private;
|
|
63
|
+
private constructor();
|
|
64
|
+
/** Compile the bundled engine (once per process) and return a `UDocNode` for it. */
|
|
65
|
+
static create(options?: UDocNodeOptions): Promise<UDocNode>;
|
|
66
|
+
/**
|
|
67
|
+
* Open a document from its bytes in a session of its own — as `format` when
|
|
68
|
+
* given, which skips detection; otherwise the format is detected, and a
|
|
69
|
+
* `.udoc` zip opens as a package. `delimiter` is the character a CSV's
|
|
70
|
+
* fields are split by; without it, a comma, or a semicolon where the first
|
|
71
|
+
* record is split by more of them. No other format takes one.
|
|
72
|
+
*
|
|
73
|
+
* Starts the session first, so this is where a license is checked and,
|
|
74
|
+
* without one, where a permit is spent — on this document, whether or not
|
|
75
|
+
* it then parses. Rejects with a `UDocError`: a licensing code when the
|
|
76
|
+
* engine refuses, or the engine's own when the bytes don't open.
|
|
77
|
+
*
|
|
78
|
+
* A PDF that needs a password opens waiting for one: the session's
|
|
79
|
+
* `needsPassword` says so, and its `authenticate` takes the password.
|
|
80
|
+
*/
|
|
81
|
+
open(bytes: Uint8Array, format?: FileFormat, delimiter?: string): Promise<UDocSession>;
|
|
82
|
+
/**
|
|
83
|
+
* Open the package a server keeps at `url` in a session of its own, without
|
|
84
|
+
* downloading it — `url` is its package resource, udoc-server's
|
|
85
|
+
* `…/documents/{id}/package`, and absolute. Each part is fetched the first
|
|
86
|
+
* time the document needs it: the open fetches the few it starts from, and a
|
|
87
|
+
* call that composes a page fetches that page's, rejecting if one can't be
|
|
88
|
+
* fetched.
|
|
89
|
+
*
|
|
90
|
+
* A remote open is an open: this is where a license is checked and, without
|
|
91
|
+
* one, where a permit is spent. Rejects with a `UDocError`: a licensing code
|
|
92
|
+
* when the engine refuses, or the engine's own when the package can't be
|
|
93
|
+
* fetched or read.
|
|
94
|
+
*
|
|
95
|
+
* Each URL is fetched with the global `fetch`, unless `fetch` answers it —
|
|
96
|
+
* the whole body, as the route serves it — which is how udoc-server opens
|
|
97
|
+
* a session over the store it keeps, with no request to itself.
|
|
98
|
+
*/
|
|
99
|
+
openRemote(url: string, fetch?: (url: string) => Promise<Uint8Array>): Promise<UDocSession>;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAiB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAMjG,OAAO,EAAE,WAAW,EAAc,MAAM,cAAc,CAAC;AAGvD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B;gFAC4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;uBAEmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;6BACyB;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;uDACmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;6CAEyC;IACzC,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAE5C;;iEAE6D;IAC7D,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC;IAC5C;;kFAE8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;mBAIe;IACf,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACxC;;;;;+CAK2C;IAC3C,kBAAkB,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IAClC;;iFAE6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAQD;;;;;GAKG;AACH,qBAAa,QAAQ;;IAUjB,OAAO;IAiBP,oFAAoF;WACvE,MAAM,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIrE;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAItF;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;CAc9F"}
|