@forevka/wordcanvas 0.7.0 → 0.7.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/README.md +48 -1
- package/dist-lib/assets/{worker-BsOsK39A.js → worker-D8rUOKfg.js} +9603 -9451
- package/dist-lib/assets/worker-wXuuyshQ.js +2258 -0
- package/dist-lib/{blockFactory-Bcy0U40y.js → blockFactory-CUI4Rqiq.js} +50 -42
- package/dist-lib/{browser-5Sv4CuNy.js → browser-DkKxreJM.js} +404 -383
- package/dist-lib/builder.js +364 -109
- package/dist-lib/editorApp-DLXMmtu5.js +8023 -0
- package/dist-lib/export.js +3820 -3768
- package/dist-lib/generate-toc.js +4 -4
- package/dist-lib/import.js +4 -1538
- package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
- package/dist-lib/pipeline-CbxmCE84.js +1705 -0
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/recalcToc-g1hFKSNs.js +3935 -0
- package/dist-lib/toc-B6VpkJge.js +213 -0
- package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-6WxRNKCc.js} +2 -2
- package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-CFqpDK0k.js} +1 -1
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-GXFDF7UY.js → chunk-22JHAERT.js} +95 -23
- package/dist-node/chunk-22JHAERT.js.map +7 -0
- package/dist-node/{chunk-2RCPB7UZ.js → chunk-6AJJMHKY.js} +1 -1
- package/dist-node/chunk-6AJJMHKY.js.map +7 -0
- package/dist-node/{chunk-XDUDPPJW.js → chunk-CDN6WU2P.js} +89 -26
- package/dist-node/chunk-CDN6WU2P.js.map +7 -0
- package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
- package/dist-node/chunk-EGSAVPCC.js.map +7 -0
- package/dist-node/{chunk-IJLL6IFJ.js → chunk-RNB336F3.js} +116 -5
- package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-RNB336F3.js.map} +2 -2
- package/dist-node/{engine-FRCX7PXF.js → engine-5FGDJD2H.js} +3 -3
- package/dist-node/export.js +92 -31
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +5 -5
- package/dist-node/import.js +3 -3
- package/dist-node/recalc-docx.js +4 -4
- package/dist-node/recalc-docx.js.map +1 -1
- package/package.json +1 -1
- package/types/model.d.ts +231 -225
- package/types/recalc-docx.d.ts +27 -27
- package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
- package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
- package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
- package/dist-lib/toc-CZel_Kk3.js +0 -127
- package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
- package/dist-node/chunk-GXFDF7UY.js.map +0 -7
- package/dist-node/chunk-TBSXA2I4.js.map +0 -7
- package/dist-node/chunk-XDUDPPJW.js.map +0 -7
- /package/dist-node/{engine-FRCX7PXF.js.map → engine-5FGDJD2H.js.map} +0 -0
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@ multi-user collaboration with presence.
|
|
|
8
8
|
The published bundle is **self-contained**: it has **zero runtime dependencies**
|
|
9
9
|
(the layout engine, font tooling, and DOCX/PDF pipelines are all inlined and
|
|
10
10
|
code-split). You can drop it onto a page with a plain `<script type="module">` or
|
|
11
|
-
import it from any bundler.
|
|
11
|
+
import it from any bundler. The same package also runs **headless on Node** for
|
|
12
|
+
server-side `.docx`/`.pdf` generation — see [Server-side (Node)](#server-side-node).
|
|
12
13
|
|
|
13
14
|
## How it compares
|
|
14
15
|
|
|
@@ -150,6 +151,52 @@ typing, paste, undo/redo, drag-resize, and the programmatic editing paths all
|
|
|
150
151
|
short-circuit. In an online session a read-only client still joins the
|
|
151
152
|
collaboration and receives live remote edits; it just can't author them.
|
|
152
153
|
|
|
154
|
+
## Server-side (Node)
|
|
155
|
+
|
|
156
|
+
The same package runs **headless on Node** — build or import a document, then
|
|
157
|
+
export it to `.docx`/`.pdf` with no browser and no DOM. This is the same pipeline
|
|
158
|
+
the editor uses, so a server-rendered file paginates identically to the on-screen
|
|
159
|
+
document. The pipeline subpaths are isomorphic via [conditional exports](https://nodejs.org/api/packages.html#conditional-exports):
|
|
160
|
+
the `node` condition resolves a self-contained Node build (bundled clone fonts +
|
|
161
|
+
PDF engine, still zero runtime dependencies), and a browser bundler gets the
|
|
162
|
+
browser build automatically — the same `import` works in both.
|
|
163
|
+
|
|
164
|
+
Compose a document with the fluent [builder](../BUILDER.md), install the
|
|
165
|
+
measurement host once (it loads the bundled fonts), then export:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { writeFile } from "node:fs/promises";
|
|
169
|
+
import { DocumentBuilder } from "@forevka/wordcanvas/builder";
|
|
170
|
+
import { installMeasureHost } from "@forevka/wordcanvas/export/measure";
|
|
171
|
+
import { runExport } from "@forevka/wordcanvas/export";
|
|
172
|
+
|
|
173
|
+
const doc = DocumentBuilder.create()
|
|
174
|
+
.paragraph("Quarterly report").withStyle("Heading1")
|
|
175
|
+
.paragraph("Generated on the server — no browser, no DOM.")
|
|
176
|
+
.build();
|
|
177
|
+
|
|
178
|
+
await installMeasureHost(); // once per process, before exporting
|
|
179
|
+
const { bytes } = await runExport(doc, "pdf"); // or "docx"
|
|
180
|
+
await writeFile("report.pdf", bytes);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Parse an uploaded `.docx` back into the editable model:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { runImport } from "@forevka/wordcanvas/import";
|
|
187
|
+
|
|
188
|
+
const { doc, warnings } = runImport(new Uint8Array(uploadedBytes));
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
| Subpath | Purpose |
|
|
192
|
+
| ------------------------------------ | ------------------------------------------------------------- |
|
|
193
|
+
| `@forevka/wordcanvas/builder` | Fluent, programmatic document composer (see [BUILDER.md](../BUILDER.md)). |
|
|
194
|
+
| `@forevka/wordcanvas/import` | `.docx` → document model. |
|
|
195
|
+
| `@forevka/wordcanvas/export` | Document model → `.docx`/`.pdf` bytes. |
|
|
196
|
+
| `@forevka/wordcanvas/export/measure` | Install the headless font/measurement host (await once first). |
|
|
197
|
+
| `@forevka/wordcanvas/recalc-docx` | Patch a `.docx`'s cached TOC page numbers in place. |
|
|
198
|
+
| `@forevka/wordcanvas/generate-toc` | Generate a Word TOC field result headless. |
|
|
199
|
+
|
|
153
200
|
## Notes & limitations
|
|
154
201
|
|
|
155
202
|
- **Multiple instances per page are supported** — the chrome is class-scoped under
|