@quario/docx 0.1.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/CHANGELOG.md +32 -0
- package/LICENSE +219 -0
- package/README.md +100 -0
- package/lib/body.js +340 -0
- package/lib/furniture.js +214 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.js +289 -0
- package/lib/pack.js +35 -0
- package/lib/page.js +111 -0
- package/lib/picture.js +91 -0
- package/lib/style.js +270 -0
- package/lib/stylepart.js +72 -0
- package/lib/table.js +180 -0
- package/lib/text.js +141 -0
- package/lib/xml.js +30 -0
- package/package.json +64 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @quario/docx
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **A Word target.** `@quario/docx` renders the same report definition every other target reads into
|
|
8
|
+
the bytes of a `.docx` — real Word tables, inline pictures, and a grouping that becomes the
|
|
9
|
+
navigation pane.
|
|
10
|
+
|
|
11
|
+
It is a **flow** target rather than a painter: it states the geometry and the typography and lets
|
|
12
|
+
Word paginate, so the promise is the preview's look rather than the preview's page breaks. Page
|
|
13
|
+
bands become a section's header and footer, and a bare `{{ page.number }}` or `{{ page.total }}`
|
|
14
|
+
becomes a live field the reader's own application recomputes.
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { docx } from "@quario/docx";
|
|
18
|
+
import { quario } from "quario";
|
|
19
|
+
|
|
20
|
+
const bytes = await quario()
|
|
21
|
+
.report(schema)
|
|
22
|
+
.render(docx({ page: { size: "A4" }, meta: { title: "Sales 2026" } }), data);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Its one runtime dependency is `fflate`, confined to the module that writes the zip — pure
|
|
26
|
+
JavaScript, so the same schema, data and options produce byte-identical output on every supported
|
|
27
|
+
runtime. SCHEMA.md's "The DOCX target" states the full contract.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- quario@0.8.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Quario License Agreement
|
|
2
|
+
|
|
3
|
+
> **In short:** Quario is commercial software with visible source.
|
|
4
|
+
> Evaluate it free for as long as you like. Evaluation output is
|
|
5
|
+
> watermarked. Anything else needs a per-developer license, after
|
|
6
|
+
> which deployment is unlimited and royalty-free. This summary is not
|
|
7
|
+
> the license; the full terms below govern.
|
|
8
|
+
|
|
9
|
+
Version 1.0, August 2026
|
|
10
|
+
|
|
11
|
+
This agreement is between you and Webstronauts, trading as Quario,
|
|
12
|
+
established in the Netherlands ("we", "us"), and governs the Software
|
|
13
|
+
defined below.
|
|
14
|
+
|
|
15
|
+
Quario is commercial software. Its packages ship with readable source
|
|
16
|
+
code, but it is not open source. No rights are granted beyond those in
|
|
17
|
+
this agreement.
|
|
18
|
+
|
|
19
|
+
## 1. Definitions
|
|
20
|
+
|
|
21
|
+
- The **Software** is any software we publish under the Quario name,
|
|
22
|
+
including the `quario` and `@quario/*` packages, except where a
|
|
23
|
+
product states its own terms. Each release states the edition of this
|
|
24
|
+
agreement that governs it.
|
|
25
|
+
- **You** means the individual exercising rights under this agreement
|
|
26
|
+
and, where that individual acts for a company or other organization,
|
|
27
|
+
that organization. In that case the organization is the licensee, and
|
|
28
|
+
the rights and limits in this agreement apply to it as a whole.
|
|
29
|
+
- An **Application** is software you create that incorporates the
|
|
30
|
+
Software and adds substantial functionality beyond it. A
|
|
31
|
+
licensee-operated service that embeds the Software and renders
|
|
32
|
+
reports for your End Users is an Application under this agreement,
|
|
33
|
+
even if it does little more than render.
|
|
34
|
+
- A **Developer** is any individual (employee or contractor working on
|
|
35
|
+
your behalf) who writes or maintains code that uses the Software's
|
|
36
|
+
APIs, or who creates or maintains report definitions for use with the
|
|
37
|
+
Software. That includes people who never install or run the Software
|
|
38
|
+
themselves, when their definitions are rendered by a service that
|
|
39
|
+
embeds it.
|
|
40
|
+
- A **Seat** is a paid license for one named Developer, purchased from
|
|
41
|
+
us or an authorized reseller.
|
|
42
|
+
- **End Users** are people who interact with the Software only through
|
|
43
|
+
an Application: running it, viewing the reports it produces, or
|
|
44
|
+
supplying parameters or other input to existing report definitions
|
|
45
|
+
the Application provides. Creating or maintaining report definitions
|
|
46
|
+
makes someone a Developer. End Users do not purchase a license; their
|
|
47
|
+
rights come from section 5.
|
|
48
|
+
|
|
49
|
+
## 2. Acceptance
|
|
50
|
+
|
|
51
|
+
This file is our standing offer. Anyone who exercises the evaluation
|
|
52
|
+
rights in section 3 accepts them, subject to their conditions. All
|
|
53
|
+
other rights arise when Seats are purchased. Where a purchase is made
|
|
54
|
+
for an organization, the person completing it confirms that they are
|
|
55
|
+
authorized to accept this agreement on the organization's behalf, and
|
|
56
|
+
acceptance covers the whole organization. If you do not accept this
|
|
57
|
+
agreement, do not use the Software.
|
|
58
|
+
|
|
59
|
+
## 3. Evaluation
|
|
60
|
+
|
|
61
|
+
You may download, install, and use the Software free of charge to
|
|
62
|
+
evaluate it: assessing whether it suits your purposes, and building
|
|
63
|
+
prototypes or proofs of concept. Evaluation covers the full feature
|
|
64
|
+
set, needs no key, and has no fixed time limit. The Software marks
|
|
65
|
+
evaluation output as described in section 6.
|
|
66
|
+
|
|
67
|
+
Evaluation is limited to assessment: you may not distribute any
|
|
68
|
+
Application containing the Software, use the Software in live business
|
|
69
|
+
operations, or expose it in services offered to third parties. The
|
|
70
|
+
moment your use goes beyond evaluating the Software, it requires Seats
|
|
71
|
+
under section 4.
|
|
72
|
+
|
|
73
|
+
## 4. Developer licenses
|
|
74
|
+
|
|
75
|
+
Any use of the Software beyond section 3 requires a Seat for every
|
|
76
|
+
Developer, whether or not an Application has shipped. With those Seats
|
|
77
|
+
in place:
|
|
78
|
+
|
|
79
|
+
- Each licensed Developer may install and use the Software on any number
|
|
80
|
+
of machines for developing Applications.
|
|
81
|
+
- Automated build, test, and CI systems do not consume Seats.
|
|
82
|
+
- Seats are per named individual. They may be reassigned when a
|
|
83
|
+
Developer stops working with the Software, but not shared or pooled
|
|
84
|
+
between concurrently active Developers. Contractors' work for you is
|
|
85
|
+
covered by your Seats; work they do for other clients is not.
|
|
86
|
+
|
|
87
|
+
## 5. Distribution and runtime
|
|
88
|
+
|
|
89
|
+
With Seats under section 4 in place, you may deploy and operate your
|
|
90
|
+
Applications yourself, and distribute the Software as an embedded part
|
|
91
|
+
of them, **royalty-free**: no additional fees or per-deployment
|
|
92
|
+
licenses are required for any number of servers, copies, or End Users.
|
|
93
|
+
You may embed your license key in an Application and ship it at no
|
|
94
|
+
charge, so section 6 does not mark that Application's output.
|
|
95
|
+
|
|
96
|
+
For that purpose, we grant you the right to pass through to each End
|
|
97
|
+
User, and to anyone who distributes or operates your Application on your
|
|
98
|
+
behalf, a limited, non-exclusive, non-transferable right to execute the
|
|
99
|
+
Software only as embedded in the Application. You must not permit them
|
|
100
|
+
to extract the Software from the Application or use it to develop
|
|
101
|
+
software of their own.
|
|
102
|
+
|
|
103
|
+
If you operate a service that embeds the Software and renders reports
|
|
104
|
+
for your End Users, that service is an Application under section 1. You
|
|
105
|
+
may run it royalty-free under this section, and you may put your license
|
|
106
|
+
key in it as in any Application. Calling applications that only request
|
|
107
|
+
renders from it need not incorporate the Software. People who use those
|
|
108
|
+
applications only as End Users under section 1 get the pass-through
|
|
109
|
+
rights above.
|
|
110
|
+
|
|
111
|
+
You may not:
|
|
112
|
+
|
|
113
|
+
- distribute the Software on its own, or as part of a product whose
|
|
114
|
+
primary purpose is to provide report-engine, report-design, or
|
|
115
|
+
document-generation capability to third-party developers;
|
|
116
|
+
- expose the Software's APIs to third parties as a development tool or
|
|
117
|
+
service that substitutes for those parties buying their own Seats. A
|
|
118
|
+
licensee-operated service that embeds the Software and renders for
|
|
119
|
+
your own End Users falls outside that ban;
|
|
120
|
+
- fork, mirror, repackage, rename, or wrap the Software, or republish
|
|
121
|
+
it on any package registry or code-hosting platform, other than as
|
|
122
|
+
embedded in an Application.
|
|
123
|
+
|
|
124
|
+
For as long as this agreement is in force, you may not create any tool,
|
|
125
|
+
library, product, or service that competes with the Software or any
|
|
126
|
+
other Quario product, whether the competition is direct or indirect;
|
|
127
|
+
this restriction does not survive termination. You may not remove or
|
|
128
|
+
alter copyright or license notices in the Software. If your Application
|
|
129
|
+
is itself a closed development product for third-party developers (OEM
|
|
130
|
+
redistribution), contact us for separate terms.
|
|
131
|
+
|
|
132
|
+
## 6. License keys and output marking
|
|
133
|
+
|
|
134
|
+
The Software accepts a license key that evidences your Seats under
|
|
135
|
+
section 4. Key checks run offline.
|
|
136
|
+
|
|
137
|
+
Without a valid key, or with a key whose validity period does not cover
|
|
138
|
+
the installed version's release date, the Software runs with its full
|
|
139
|
+
feature set but marks its output as unlicensed. Using a key you are not
|
|
140
|
+
entitled to is a material breach of this agreement.
|
|
141
|
+
|
|
142
|
+
You may not remove, disable, or circumvent the key check or the output
|
|
143
|
+
marking, or distribute anything that does.
|
|
144
|
+
|
|
145
|
+
## 7. Term, updates, and perpetual fallback
|
|
146
|
+
|
|
147
|
+
Seats are sold as an annual subscription. While the subscription is
|
|
148
|
+
active, licensed Developers receive all Software versions we release,
|
|
149
|
+
and support for the Software through our issue tracker and by email. We
|
|
150
|
+
provide support with commercially reasonable effort; we do not guarantee
|
|
151
|
+
specific response times.
|
|
152
|
+
|
|
153
|
+
If the subscription lapses, your license to the versions released during
|
|
154
|
+
your subscription is **perpetual, for the number of Seats held at the
|
|
155
|
+
lapse**: up to that many Developers may keep using those versions, and
|
|
156
|
+
your Applications may keep shipping them, forever, at no further cost.
|
|
157
|
+
Versions released after the lapse require renewal. We encode this rule
|
|
158
|
+
in purchased keys: a key remains valid for every version released
|
|
159
|
+
during its validity period, with no end date.
|
|
160
|
+
|
|
161
|
+
## 8. Source availability
|
|
162
|
+
|
|
163
|
+
The Software's packages ship with readable source code so that you can
|
|
164
|
+
review and debug what you run. Readable source does not grant extra
|
|
165
|
+
rights: this agreement governs all use of the source, and you may
|
|
166
|
+
publish the Software (modified or not) only as part of an Application
|
|
167
|
+
under section 5.
|
|
168
|
+
|
|
169
|
+
## 9. Ownership, trademarks, and feedback
|
|
170
|
+
|
|
171
|
+
We license the Software; we retain all intellectual property rights in
|
|
172
|
+
it. Report definitions, data, and output you create with the Software
|
|
173
|
+
are yours. "Quario" and the Quario logo are our trademarks; this
|
|
174
|
+
agreement grants no rights to use them beyond identifying the Software.
|
|
175
|
+
If you send us feedback or suggestions, we may use them without
|
|
176
|
+
obligation.
|
|
177
|
+
|
|
178
|
+
## 10. Warranty and liability
|
|
179
|
+
|
|
180
|
+
We provide the Software as is. To the fullest extent the law allows, we
|
|
181
|
+
disclaim all warranties and conditions, express or implied, including
|
|
182
|
+
merchantability, fitness for a particular purpose, and non-infringement.
|
|
183
|
+
|
|
184
|
+
To the fullest extent the law allows: we are not liable for indirect or
|
|
185
|
+
consequential damages, loss of profits, loss of data, or business
|
|
186
|
+
interruption; and our total aggregate liability under this agreement is
|
|
187
|
+
limited to the greater of EUR 100 and the fees you paid us in the
|
|
188
|
+
twelve months preceding the event giving rise to the claim. These
|
|
189
|
+
limitations do not apply where the damage results from the intent or
|
|
190
|
+
deliberate recklessness (opzet of bewuste roekeloosheid) of us or our
|
|
191
|
+
management, or where mandatory law does not permit them.
|
|
192
|
+
|
|
193
|
+
## 11. Termination and survival
|
|
194
|
+
|
|
195
|
+
If you materially breach this agreement, we may terminate it by notice.
|
|
196
|
+
If the breach can be remedied, we will first allow 30 days from that
|
|
197
|
+
notice to remedy it, and termination takes effect only if the breach
|
|
198
|
+
remains. On termination, the licenses granted here end.
|
|
199
|
+
Perpetual-fallback rights under section 7 survive termination only if
|
|
200
|
+
they arose from a lapse that predates the breach, and section 5
|
|
201
|
+
survives with them to the extent needed to keep exercising them.
|
|
202
|
+
Sections 8 through 12 survive any termination.
|
|
203
|
+
|
|
204
|
+
## 12. General
|
|
205
|
+
|
|
206
|
+
Dutch law governs this agreement. Disputes go to the competent court for
|
|
207
|
+
our registered office. You may not assign this agreement without our
|
|
208
|
+
consent, except to a successor of your whole business; we may assign it
|
|
209
|
+
to a successor of ours. If a provision is unenforceable, the remainder
|
|
210
|
+
stays in force. Failure to enforce a provision does not waive it. This
|
|
211
|
+
agreement, together with your order for Seats, is the entire agreement
|
|
212
|
+
about the Software, unless we agree otherwise in writing.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
**Purchasing and contact:** <contact@getquario.com> ·
|
|
217
|
+
<https://getquario.com>
|
|
218
|
+
|
|
219
|
+
Copyright © 2026 Webstronauts. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @quario/docx
|
|
2
|
+
|
|
3
|
+
**The Word render target for [quario](https://www.npmjs.com/package/quario).** Renders a report
|
|
4
|
+
definition to the bytes of a `.docx` package: a flow document, so the geometry and the typography
|
|
5
|
+
are quario's and the pagination is Word's.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install quario @quario/docx
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The engine is a peer dependency, installed beside the target. ESM-only, Node 22+, and
|
|
14
|
+
browser-ready through any standards-based ESM bundler. The renderer resolves a `Uint8Array`; you
|
|
15
|
+
write the file.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { writeFileSync } from "node:fs";
|
|
21
|
+
import { docx } from "@quario/docx";
|
|
22
|
+
import { quario } from "quario";
|
|
23
|
+
|
|
24
|
+
const schema = {
|
|
25
|
+
data: "$.orders[*]",
|
|
26
|
+
detail: {
|
|
27
|
+
columns: [
|
|
28
|
+
{ header: "Product", value: "{{ @.product }}" },
|
|
29
|
+
{ header: "Price", value: "{{ @.price }}" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const data = { orders: [{ product: "Desk", price: 250 }] };
|
|
35
|
+
|
|
36
|
+
const bytes = await quario().report(schema).render(docx(), data);
|
|
37
|
+
writeFileSync("orders.docx", bytes);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
Both are optional, and both are validated at the factory call — an unknown option, or one of the
|
|
43
|
+
wrong type, throws there rather than at the first render.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
docx({
|
|
47
|
+
// Page geometry in PostScript points: "A4" (the default), "letter", or a
|
|
48
|
+
// [width, height] pair. The margin defaults to 54 pt, and a report that
|
|
49
|
+
// declares `page.margin` itself sets it instead — declaring both is an error.
|
|
50
|
+
page: { size: "A4", margin: 54 },
|
|
51
|
+
// Document properties. Strings only: no dates ride along, so rendering the
|
|
52
|
+
// same report twice produces the same bytes.
|
|
53
|
+
meta: { title: "Orders", author: "Acme BV", subject: "Q1" },
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## What it renders
|
|
58
|
+
|
|
59
|
+
A report's bands become paragraphs; a table detail becomes a **real Word table** carrying the
|
|
60
|
+
author's column shares as a fixed grid, with `span` as `gridSpan` and a header row that repeats
|
|
61
|
+
after every page break. A split is a borderless one-row table, and an image is an inline picture at its natural size, capped at the text
|
|
62
|
+
column, carrying its `alt` as the drawing's description.
|
|
63
|
+
|
|
64
|
+
The grouping becomes the **navigation pane**: a group header's first item takes `Heading{depth+1}`
|
|
65
|
+
from this package's own `styles.xml`, so no theme typography leaks in. Everything a report declares
|
|
66
|
+
is direct formatting on the runs and paragraphs that wear it — `Normal` stays empty, because a look
|
|
67
|
+
that depends on a style lookup is a look three readers may resolve three ways.
|
|
68
|
+
|
|
69
|
+
Page bands become a section's header and footer. A bare `{{ page.number }}` or `{{ page.total }}`
|
|
70
|
+
becomes a live `PAGE` / `NUMPAGES` field the reader's own application recomputes; anything computed
|
|
71
|
+
from them is frozen at the value the render saw. A group's `reset: "page"` opens a section that
|
|
72
|
+
restarts the numbering, and `break: "page"` starts the instance on a fresh page.
|
|
73
|
+
|
|
74
|
+
## Determinism
|
|
75
|
+
|
|
76
|
+
Two renders of one report are byte-identical, on **every supported runtime**: `fflate` is pure
|
|
77
|
+
JavaScript, so its deflate output does not vary by engine. Every entry in the package is stamped
|
|
78
|
+
1980-01-01 and nothing in the document carries a clock, so a digest over the bytes is a fair test.
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
[The quario documentation](https://getquario.com/docs/) is the reference.
|
|
83
|
+
The [report schema](https://getquario.com/docs/reference/report-schema/) is the normative
|
|
84
|
+
specification of what a report may declare, and the
|
|
85
|
+
[support matrix](https://getquario.com/docs/reference/support-matrix/) says what each target makes
|
|
86
|
+
of a declaration.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
Commercial software with readable source. Free, unlimited, watermarked evaluation; per-developer
|
|
91
|
+
licenses at [getquario.com](https://getquario.com). See the bundled LICENSE.
|
|
92
|
+
|
|
93
|
+
Pass your license key once, on the instance; it is verified offline:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
const q = quario({ license: "quario_..." });
|
|
97
|
+
await q.license; // { licensed: true, licensee: "Acme BV", id: "1-ACME" }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
An unlicensed render carries the marking as the first paragraph of every footer.
|