@quillmark/quiver 0.5.0 → 0.6.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 +21 -201
- package/PROGRAM.md +55 -31
- package/README.md +33 -12
- package/dist/bundle.js +8 -2
- package/dist/node.d.ts +20 -5
- package/dist/node.js +11 -5
- package/dist/quiver.d.ts +12 -12
- package/dist/quiver.js +13 -13
- package/dist/transports/fs-built-transport.d.ts +14 -0
- package/dist/transports/fs-built-transport.js +34 -0
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,201 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nibs
|
|
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/PROGRAM.md
CHANGED
|
@@ -37,24 +37,26 @@ Loaders are paired 1:1 with what they load:
|
|
|
37
37
|
|
|
38
38
|
- `Quiver.fromPackage(specifier)` and `Quiver.fromDir(path)` load the
|
|
39
39
|
**source** layout (Node only).
|
|
40
|
-
- `Quiver.
|
|
40
|
+
- `Quiver.fromBuiltUrl(url)` loads the **build output** over HTTP/HTTPS
|
|
41
41
|
(browser-safe; works in Node too).
|
|
42
|
+
- `Quiver.fromBuiltDir(path)` loads the **build output** from a local
|
|
43
|
+
directory (Node only).
|
|
42
44
|
|
|
43
45
|
There is no auto-detection: each loader's name commits to what it expects.
|
|
44
46
|
|
|
45
47
|
**Naming decisions:**
|
|
46
|
-
- The verb is `build()`. Pairs with `fromBuilt
|
|
47
|
-
built one"). Avoids collision with `npm pack`, JS bundler
|
|
48
|
-
and the internal "bundle zips" term.
|
|
48
|
+
- The verb is `build()`. Pairs with the `fromBuilt*` family (past participle
|
|
49
|
+
= "the built one"). Avoids collision with `npm pack`, JS bundler
|
|
50
|
+
vocabulary, and the internal "bundle zips" term.
|
|
49
51
|
- Loaders for source layouts are named by **where the source lives**
|
|
50
|
-
(`Package` / `Dir`).
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
(`Package` / `Dir`). Loaders for build output are named by **what** they
|
|
53
|
+
load (`Built`) plus **where** they load it from (`Url` / `Dir`). The
|
|
54
|
+
artifact type stays in the name; the transport disambiguates.
|
|
55
|
+
- Server-side runtime (Node) reads packed artifacts from disk via
|
|
56
|
+
`fromBuiltDir`. This is the recommended shape when the runtime artifact
|
|
57
|
+
ships in the deployment image: source quivers stay as devDependencies,
|
|
58
|
+
there is no self-fetch over a load balancer / CDN, and serverless bundle
|
|
59
|
+
sizes are minimised.
|
|
58
60
|
|
|
59
61
|
### 2) `Quiver.yaml` Is Required in Source Quivers
|
|
60
62
|
|
|
@@ -72,16 +74,19 @@ Unknown fields in `Quiver.yaml` are a **validation error** (`quiver_invalid`). S
|
|
|
72
74
|
### 3) `QuillSource` Becomes Quiver-Centric
|
|
73
75
|
|
|
74
76
|
- Re-express `QuillSource` concepts around Quivers
|
|
75
|
-
-
|
|
77
|
+
- Four loaders, each with one input shape and one shape-of-thing-loaded:
|
|
76
78
|
- `Quiver.fromPackage(specifier)` — Node-only; resolves an npm specifier
|
|
77
79
|
against `node_modules` and loads the source layout at the package root
|
|
78
80
|
- `Quiver.fromDir(path)` — Node-only; loads source layout from a local
|
|
79
81
|
directory. Also accepts `import.meta.url`-style `file://` URLs as a
|
|
80
82
|
convenience for tests (the URL's parent directory is used)
|
|
81
|
-
- `Quiver.
|
|
83
|
+
- `Quiver.fromBuiltUrl(url)` — browser-safe; loads build output from an
|
|
82
84
|
`http(s)://` or origin-relative URL
|
|
85
|
+
- `Quiver.fromBuiltDir(path)` — Node-only; loads build output from a
|
|
86
|
+
local directory (the output of `Quiver.build`)
|
|
83
87
|
- "Transport" is not a first-class concept; HTTP fetching is an internal
|
|
84
|
-
detail of `
|
|
88
|
+
detail of `fromBuiltUrl`, filesystem access is an internal detail of
|
|
89
|
+
`fromBuiltDir`
|
|
85
90
|
|
|
86
91
|
### 4) Single-Quiver Scope (V1)
|
|
87
92
|
|
|
@@ -191,8 +196,17 @@ choose how to consume it:
|
|
|
191
196
|
// build step (Node)
|
|
192
197
|
await Quiver.build("./node_modules/@org/my-quiver", "./public/quivers/my-quiver");
|
|
193
198
|
// browser runtime
|
|
194
|
-
const quiver = await Quiver.
|
|
199
|
+
const quiver = await Quiver.fromBuiltUrl("/quivers/my-quiver/");
|
|
195
200
|
```
|
|
201
|
+
- **Node server-side runtime consumers** also run the build step, ship the
|
|
202
|
+
packed artifact in their deployment image, and load it from disk:
|
|
203
|
+
```ts
|
|
204
|
+
await Quiver.build("./node_modules/@org/my-quiver", "./static/quills/my-quiver");
|
|
205
|
+
// server runtime
|
|
206
|
+
const quiver = await Quiver.fromBuiltDir("./static/quills/my-quiver");
|
|
207
|
+
```
|
|
208
|
+
This keeps source quivers as devDependencies and avoids self-fetching
|
|
209
|
+
through the deployment's load balancer / CDN.
|
|
196
210
|
|
|
197
211
|
Rationale:
|
|
198
212
|
|
|
@@ -206,7 +220,7 @@ Rationale:
|
|
|
206
220
|
the default.** Authors who need to ship runtime-ready output directly
|
|
207
221
|
(e.g. their consumers cannot run a Node build step) may publish
|
|
208
222
|
`Quiver.build(...)` output to a CDN and instruct consumers to use
|
|
209
|
-
`Quiver.
|
|
223
|
+
`Quiver.fromBuiltUrl(<cdn-url>)`. Treated as the exception.
|
|
210
224
|
|
|
211
225
|
Validation responsibility shifts left: authors should run
|
|
212
226
|
`Quiver.fromDir` and `Quiver.build` in CI so `quiver_invalid` errors
|
|
@@ -222,17 +236,19 @@ V1 intentionally retains:
|
|
|
222
236
|
1. Font dehydration as a build-output property
|
|
223
237
|
2. Consumer validation tooling for source layouts (+ optional build-parity checks)
|
|
224
238
|
3. Manifest pointer resolution for build output
|
|
225
|
-
4. HTTP/HTTPS loading via `Quiver.
|
|
226
|
-
5.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
239
|
+
4. HTTP/HTTPS loading via `Quiver.fromBuiltUrl`
|
|
240
|
+
5. Filesystem loading of build output via `Quiver.fromBuiltDir` for Node
|
|
241
|
+
server-side runtimes
|
|
242
|
+
6. Source layout loading as first-class dev loop (`fromPackage` / `fromDir`)
|
|
243
|
+
7. Typed errors (`QuiverError`) with quiver/source context
|
|
244
|
+
8. Concurrency coalescing for in-flight loads
|
|
245
|
+
9. Preload/fail-fast helpers where they still add value
|
|
230
246
|
|
|
231
247
|
Removed from carryover assumptions:
|
|
232
248
|
|
|
233
249
|
- Any engine-registration cache fast path (`register`/`has`) because upstream removed the capability
|
|
234
|
-
- "Transport" as a user-facing concept (folded into `
|
|
235
|
-
|
|
250
|
+
- "Transport" as a user-facing concept (folded into `fromBuiltUrl` /
|
|
251
|
+
`fromBuiltDir` internals)
|
|
236
252
|
|
|
237
253
|
---
|
|
238
254
|
|
|
@@ -277,8 +293,10 @@ V1 runtime loading paths:
|
|
|
277
293
|
1. `Quiver.fromPackage(specifier)` — npm package resolution; loads source
|
|
278
294
|
(authoring/dev/Node runtime)
|
|
279
295
|
2. `Quiver.fromDir(path)` — local directory; loads source (Node)
|
|
280
|
-
3. `Quiver.
|
|
296
|
+
3. `Quiver.fromBuiltUrl(url)` — HTTP(S); loads build output (browser; also
|
|
281
297
|
works in Node)
|
|
298
|
+
4. `Quiver.fromBuiltDir(path)` — local directory; loads build output
|
|
299
|
+
(Node server-side runtime)
|
|
282
300
|
|
|
283
301
|
V1 build behavior:
|
|
284
302
|
|
|
@@ -361,7 +379,7 @@ Rehydration on load: the loader fetches the pointer → hashed manifest → requ
|
|
|
361
379
|
|
|
362
380
|
## API Surface (V1)
|
|
363
381
|
|
|
364
|
-
Single class,
|
|
382
|
+
Single class, four loaders + one builder. Each loader has one input
|
|
365
383
|
shape and one shape-of-thing-loaded; no auto-detection.
|
|
366
384
|
|
|
367
385
|
```ts
|
|
@@ -380,7 +398,13 @@ class Quiver {
|
|
|
380
398
|
// Browser-safe loader: load build output from an http(s):// or
|
|
381
399
|
// origin-relative URL. Throws `transport_error` on file:// inputs.
|
|
382
400
|
// (From `@quillmark/quiver` main.)
|
|
383
|
-
static
|
|
401
|
+
static fromBuiltUrl(url: string): Promise<Quiver>;
|
|
402
|
+
|
|
403
|
+
// Node-only loader: load build output from a local directory (the
|
|
404
|
+
// output of Quiver.build). No network. Use for server-side runtime
|
|
405
|
+
// when the packed artifact ships in the deployment image.
|
|
406
|
+
// (From `@quillmark/quiver/node`.)
|
|
407
|
+
static fromBuiltDir(dirPath: string): Promise<Quiver>;
|
|
384
408
|
|
|
385
409
|
// Node-only tooling: produce the runtime artifact from a source layout.
|
|
386
410
|
// (From `@quillmark/quiver/node`.)
|
|
@@ -429,12 +453,12 @@ const result = quill.render(doc, { format: "pdf" });
|
|
|
429
453
|
|
|
430
454
|
**Entrypoints:**
|
|
431
455
|
- `@quillmark/quiver` (main, browser-safe): `Quiver` class with only
|
|
432
|
-
`
|
|
456
|
+
`fromBuiltUrl` functional (Node-only loaders/builder throw
|
|
433
457
|
`transport_error` if reached in browser), `QuiverError`,
|
|
434
458
|
`QuillmarkLike`, `QuillLike`, shared types.
|
|
435
459
|
- `@quillmark/quiver/node`: adds `Quiver.fromPackage`, `Quiver.fromDir`,
|
|
436
|
-
`Quiver.build` behaviors. Single `Quiver` class —
|
|
437
|
-
fail fast outside Node.
|
|
460
|
+
`Quiver.fromBuiltDir`, `Quiver.build` behaviors. Single `Quiver` class —
|
|
461
|
+
Node-only factories fail fast outside Node.
|
|
438
462
|
- `@quillmark/quiver/testing` (Node-only): single export
|
|
439
463
|
`runQuiverTests(metaUrlOrDir, engine)` built on `node:test` (zero
|
|
440
464
|
external test-runner dependency). Optional convenience; users on other
|
|
@@ -466,7 +490,7 @@ const result = quill.render(doc, { format: "pdf" });
|
|
|
466
490
|
|
|
467
491
|
All V1 planner questions resolved; implementation plan can proceed against the spec above.
|
|
468
492
|
|
|
469
|
-
1. ~~Final `Quiver` interface shape and transport factoring style~~ → Single `Quiver` class,
|
|
493
|
+
1. ~~Final `Quiver` interface shape and transport factoring style~~ → Single `Quiver` class, four loaders (`fromPackage`, `fromDir`, `fromBuiltUrl`, `fromBuiltDir`) + one builder (`build`). Each loader names what it loads (source/built) and where it loads from (package/dir/url); no auto-detection.
|
|
470
494
|
2. ~~Final `Quiver.yaml` schema and unknown-field policy~~ → See §2: alphanumeric `name` and optional tooling-only `description`. Unknown fields are `quiver_invalid`.
|
|
471
495
|
3. ~~Canonical ref grammar and parser API contract~~ → Internal `parseQuillRef`, not exported. Selector syntax per §5. Throws `invalid_ref`.
|
|
472
496
|
4. ~~Exact warning policy for shadowed refs across quivers~~ → N/A in V1: no multi-quiver composition layer; each `Quiver` instance is independent (§4).
|
package/README.md
CHANGED
|
@@ -14,13 +14,16 @@ A Quiver has one authored shape: the **source layout** (`Quiver.yaml` at the
|
|
|
14
14
|
package root, quills under `quills/<name>/<x.y.z>/`). Authors publish it as
|
|
15
15
|
an npm package. Consumers decide how to consume it:
|
|
16
16
|
|
|
17
|
-
- **Node consumers** load the source layout directly with `Quiver.fromPackage
|
|
17
|
+
- **Node consumers** load the source layout directly with `Quiver.fromPackage`,
|
|
18
|
+
or load a packed (build-output) artifact from disk with
|
|
19
|
+
`Quiver.fromBuiltDir`.
|
|
18
20
|
- **Browser consumers** run `Quiver.build(...)` as a build step and serve the
|
|
19
|
-
output as static assets, loading it with `Quiver.
|
|
21
|
+
output as static assets, loading it with `Quiver.fromBuiltUrl`.
|
|
20
22
|
|
|
21
|
-
Each loader names exactly what it loads: `fromPackage
|
|
22
|
-
|
|
23
|
-
No auto-detection, no branching
|
|
23
|
+
Each loader names exactly what it loads. Source: `fromPackage(specifier)`,
|
|
24
|
+
`fromDir(path)`. Build output: `fromBuiltUrl(url)` (HTTP/HTTPS, browser-safe),
|
|
25
|
+
`fromBuiltDir(path)` (filesystem, Node-only). No auto-detection, no branching
|
|
26
|
+
on artifact shape.
|
|
24
27
|
|
|
25
28
|
This keeps the author flow to a single command (`npm publish` or `git tag`)
|
|
26
29
|
and puts the deployment-topology decision where it belongs: with the
|
|
@@ -91,22 +94,37 @@ await Quiver.build(
|
|
|
91
94
|
// browser runtime
|
|
92
95
|
import { Quiver } from "@quillmark/quiver";
|
|
93
96
|
|
|
94
|
-
const quiver = await Quiver.
|
|
97
|
+
const quiver = await Quiver.fromBuiltUrl("/quivers/my-quiver/");
|
|
95
98
|
const quill = await quiver.getQuill(doc.quillRef, { engine });
|
|
96
99
|
```
|
|
97
100
|
|
|
101
|
+
## Server-side runtime (Node, packed artifact on disk)
|
|
102
|
+
|
|
103
|
+
For server-side rendering where the packed artifact ships in the deployment
|
|
104
|
+
image, use `Quiver.fromBuiltDir` to read it from disk. This avoids the
|
|
105
|
+
self-fetch / load-balancer round-trip that `fromBuiltUrl` would force on a
|
|
106
|
+
self-hosted deployment, and lets the source quiver stay in
|
|
107
|
+
`devDependencies`:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { Quiver } from "@quillmark/quiver/node";
|
|
111
|
+
|
|
112
|
+
// Packed at build time, e.g. into ./static/quills/my-quiver
|
|
113
|
+
const quiver = await Quiver.fromBuiltDir("./static/quills/my-quiver");
|
|
114
|
+
```
|
|
115
|
+
|
|
98
116
|
## Advanced: pre-built distribution to a CDN
|
|
99
117
|
|
|
100
118
|
If you need to ship the runtime artifact directly (e.g. consumers cannot run
|
|
101
119
|
a Node build step), publish `Quiver.build` output to a CDN and have
|
|
102
|
-
consumers point `
|
|
120
|
+
consumers point `fromBuiltUrl` at the CDN URL:
|
|
103
121
|
|
|
104
122
|
```ts
|
|
105
123
|
import { Quiver } from "@quillmark/quiver/node";
|
|
106
124
|
|
|
107
125
|
await Quiver.build("./my-quiver", "./dist/my-quiver");
|
|
108
126
|
// upload ./dist/my-quiver to https://cdn.example.com/quivers/my-quiver/
|
|
109
|
-
const quiver = await Quiver.
|
|
127
|
+
const quiver = await Quiver.fromBuiltUrl("https://cdn.example.com/quivers/my-quiver/");
|
|
110
128
|
```
|
|
111
129
|
|
|
112
130
|
## Warm (prefetch all quill trees)
|
|
@@ -115,10 +133,13 @@ const quiver = await Quiver.fromBuilt("https://cdn.example.com/quivers/my-quiver
|
|
|
115
133
|
await quiver.warm();
|
|
116
134
|
```
|
|
117
135
|
|
|
118
|
-
`warm()` is
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
136
|
+
`warm()` is I/O-only: it loads every quill's tree (over the network for
|
|
137
|
+
`fromBuiltUrl`, off the filesystem for `fromPackage` / `fromDir` /
|
|
138
|
+
`fromBuiltDir`) and caches
|
|
139
|
+
them. It does not require an engine and does not materialize Quill
|
|
140
|
+
instances — that happens lazily on the first `getQuill` call, which is
|
|
141
|
+
microseconds. A subsequent `getQuill` reuses the cached tree, skipping
|
|
142
|
+
the load.
|
|
122
143
|
|
|
123
144
|
Once a tree has been turned into a Quill, the cached tree is dropped so
|
|
124
145
|
its bytes can be GC'd — the materialized Quill is the runtime artifact.
|
package/dist/bundle.js
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
import { zipSync, unzipSync } from "fflate";
|
|
5
5
|
/**
|
|
6
6
|
* Fixed epoch mtime for deterministic zip output.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* fflate reads mtime via local-time getters (getFullYear/getMonth/...) and rejects
|
|
9
|
+
* years before 1980. Date.UTC(1980, 0, 1) becomes 1979-12-31 in any TZ west of UTC,
|
|
10
|
+
* which both crashes the encoder and (where it doesn't crash) produces TZ-dependent
|
|
11
|
+
* bytes. Using the local-time constructor anchors the components to 1980-01-01
|
|
12
|
+
* 00:00:00 in *every* timezone, so the DOS timestamp written into the zip header
|
|
13
|
+
* is always identical.
|
|
8
14
|
*/
|
|
9
|
-
const ZIP_EPOCH = new Date(
|
|
15
|
+
const ZIP_EPOCH = new Date(1980, 0, 1, 0, 0, 0, 0);
|
|
10
16
|
/**
|
|
11
17
|
* Pack a flat file map into a deterministic zip.
|
|
12
18
|
* Keys are sorted before zipping so insertion order doesn't affect output.
|
package/dist/node.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Importing this module is the consumer's explicit declaration of intent:
|
|
5
5
|
* "I am running in Node and want the Node-only Quiver factories." It exposes
|
|
6
6
|
* the same `Quiver` class as the main entry, augmented with `fromDir`,
|
|
7
|
-
* `fromPackage`, and `build` static methods.
|
|
7
|
+
* `fromPackage`, `fromBuiltDir`, and `build` static methods.
|
|
8
8
|
*
|
|
9
9
|
* Side effect: at module evaluation time, the Node-only static methods are
|
|
10
10
|
* installed on the shared `Quiver` constructor. Any other module that already
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* runtime — but TypeScript will only expose them on the binding imported from
|
|
13
13
|
* here, so the import path remains the contract.
|
|
14
14
|
*
|
|
15
|
-
* Bundler note: importing this entry pulls in `./source-loader.js
|
|
16
|
-
* `./build.js`,
|
|
17
|
-
* bundles must never reach this
|
|
18
|
-
* no static or dynamic reference
|
|
15
|
+
* Bundler note: importing this entry pulls in `./source-loader.js`,
|
|
16
|
+
* `./build.js`, and `./transports/fs-built-transport.js`, all of which
|
|
17
|
+
* statically import `node:*` builtins. Browser bundles must never reach this
|
|
18
|
+
* module. The main entry (`./index.js`) makes no static or dynamic reference
|
|
19
|
+
* to it.
|
|
19
20
|
*/
|
|
20
21
|
import { Quiver as Base } from "./quiver.js";
|
|
21
22
|
import { type BuildOptions } from "./build.js";
|
|
@@ -40,6 +41,20 @@ type NodeQuiverStatics = {
|
|
|
40
41
|
* failure.
|
|
41
42
|
*/
|
|
42
43
|
fromDir(pathOrFileUrl: string): Promise<Base>;
|
|
44
|
+
/**
|
|
45
|
+
* Loads a packed (build-output) quiver from a local directory containing
|
|
46
|
+
* `Quiver.json` and the manifest/bundle/store files written by
|
|
47
|
+
* `Quiver.build`. Symmetric to `fromBuiltUrl(url)` but reads from disk
|
|
48
|
+
* instead of HTTP — no network required.
|
|
49
|
+
*
|
|
50
|
+
* Use this for server-side runtime when a packed artifact ships in the
|
|
51
|
+
* deployment image; consumers can keep source quivers as devDependencies
|
|
52
|
+
* and avoid self-fetching over their own load balancer.
|
|
53
|
+
*
|
|
54
|
+
* Throws `quiver_invalid` on format errors, `transport_error` on I/O
|
|
55
|
+
* failure.
|
|
56
|
+
*/
|
|
57
|
+
fromBuiltDir(dirPath: string): Promise<Base>;
|
|
43
58
|
/**
|
|
44
59
|
* Reads the Source Quiver at sourceDir, validates it, and writes the
|
|
45
60
|
* runtime build artifact to outDir.
|
package/dist/node.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Importing this module is the consumer's explicit declaration of intent:
|
|
5
5
|
* "I am running in Node and want the Node-only Quiver factories." It exposes
|
|
6
6
|
* the same `Quiver` class as the main entry, augmented with `fromDir`,
|
|
7
|
-
* `fromPackage`, and `build` static methods.
|
|
7
|
+
* `fromPackage`, `fromBuiltDir`, and `build` static methods.
|
|
8
8
|
*
|
|
9
9
|
* Side effect: at module evaluation time, the Node-only static methods are
|
|
10
10
|
* installed on the shared `Quiver` constructor. Any other module that already
|
|
@@ -12,15 +12,18 @@
|
|
|
12
12
|
* runtime — but TypeScript will only expose them on the binding imported from
|
|
13
13
|
* here, so the import path remains the contract.
|
|
14
14
|
*
|
|
15
|
-
* Bundler note: importing this entry pulls in `./source-loader.js
|
|
16
|
-
* `./build.js`,
|
|
17
|
-
* bundles must never reach this
|
|
18
|
-
* no static or dynamic reference
|
|
15
|
+
* Bundler note: importing this entry pulls in `./source-loader.js`,
|
|
16
|
+
* `./build.js`, and `./transports/fs-built-transport.js`, all of which
|
|
17
|
+
* statically import `node:*` builtins. Browser bundles must never reach this
|
|
18
|
+
* module. The main entry (`./index.js`) makes no static or dynamic reference
|
|
19
|
+
* to it.
|
|
19
20
|
*/
|
|
20
21
|
import { Quiver as Base } from "./quiver.js";
|
|
21
22
|
import { QuiverError } from "./errors.js";
|
|
22
23
|
import { scanSourceQuiver, SourceLoader } from "./source-loader.js";
|
|
23
24
|
import { buildQuiver } from "./build.js";
|
|
25
|
+
import { loadBuiltQuiver } from "./built-loader.js";
|
|
26
|
+
import { FsBuiltTransport } from "./transports/fs-built-transport.js";
|
|
24
27
|
import { createRequire } from "node:module";
|
|
25
28
|
import { dirname } from "node:path";
|
|
26
29
|
import { fileURLToPath } from "node:url";
|
|
@@ -35,6 +38,9 @@ Quiver.fromDir = async function fromDir(pathOrFileUrl) {
|
|
|
35
38
|
const { meta, catalog } = await scanSourceQuiver(dir);
|
|
36
39
|
return Base._fromLoader(meta.name, catalog, new SourceLoader(dir));
|
|
37
40
|
};
|
|
41
|
+
Quiver.fromBuiltDir = async function fromBuiltDir(dirPath) {
|
|
42
|
+
return loadBuiltQuiver(new FsBuiltTransport(dirPath));
|
|
43
|
+
};
|
|
38
44
|
Quiver.fromPackage = async function fromPackage(specifier) {
|
|
39
45
|
const req = createRequire(import.meta.url);
|
|
40
46
|
let yamlPath;
|
package/dist/quiver.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Polymorphism via composition: internally stores a pluggable loader
|
|
5
5
|
* (either source-backed or build-output-backed).
|
|
6
6
|
*
|
|
7
|
-
* This module is browser-safe: only `
|
|
8
|
-
* here. Node-only factories (`fromDir`, `fromPackage`, `
|
|
9
|
-
* on this class by `./node.js`, which is the
|
|
10
|
-
* the Node API surface.
|
|
7
|
+
* This module is browser-safe: only `fromBuiltUrl` and the instance API live
|
|
8
|
+
* here. Node-only factories (`fromDir`, `fromPackage`, `fromBuiltDir`,
|
|
9
|
+
* `build`) are installed on this class by `./node.js`, which is the
|
|
10
|
+
* consumer's explicit opt-in to the Node API surface.
|
|
11
11
|
*/
|
|
12
12
|
import type { QuillmarkLike, QuillLike } from "./engine-types.js";
|
|
13
13
|
/** @internal Internal loader strategy: source or build output. */
|
|
@@ -18,10 +18,10 @@ export declare class Quiver {
|
|
|
18
18
|
#private;
|
|
19
19
|
readonly name: string;
|
|
20
20
|
/**
|
|
21
|
-
* Private constructor — use static factory methods (`Quiver.
|
|
22
|
-
* the Node-only `Quiver.fromDir` / `Quiver.fromPackage`
|
|
23
|
-
* `@quillmark/quiver/node`). TS prevents
|
|
24
|
-
* compile time.
|
|
21
|
+
* Private constructor — use static factory methods (`Quiver.fromBuiltUrl`,
|
|
22
|
+
* or the Node-only `Quiver.fromDir` / `Quiver.fromPackage` /
|
|
23
|
+
* `Quiver.fromBuiltDir` installed by `@quillmark/quiver/node`). TS prevents
|
|
24
|
+
* external `new Quiver(...)` at compile time.
|
|
25
25
|
*/
|
|
26
26
|
private constructor();
|
|
27
27
|
/**
|
|
@@ -34,14 +34,14 @@ export declare class Quiver {
|
|
|
34
34
|
* Browser-safe factory. Loads build output from an HTTP/HTTPS URL.
|
|
35
35
|
*
|
|
36
36
|
* Origin-relative URLs (e.g. `/quivers/foo/`) are accepted in browser
|
|
37
|
-
* environments. `file://` URLs are rejected —
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* environments. `file://` URLs are rejected — to load build output from
|
|
38
|
+
* disk in Node, use `Quiver.fromBuiltDir(path)` from
|
|
39
|
+
* `@quillmark/quiver/node`.
|
|
40
40
|
*
|
|
41
41
|
* Throws `transport_error` on network/HTTP failure, `quiver_invalid`
|
|
42
42
|
* on format errors.
|
|
43
43
|
*/
|
|
44
|
-
static
|
|
44
|
+
static fromBuiltUrl(url: string): Promise<Quiver>;
|
|
45
45
|
/** Returns all known quill names, sorted lexicographically. */
|
|
46
46
|
quillNames(): string[];
|
|
47
47
|
/**
|
package/dist/quiver.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Polymorphism via composition: internally stores a pluggable loader
|
|
5
5
|
* (either source-backed or build-output-backed).
|
|
6
6
|
*
|
|
7
|
-
* This module is browser-safe: only `
|
|
8
|
-
* here. Node-only factories (`fromDir`, `fromPackage`, `
|
|
9
|
-
* on this class by `./node.js`, which is the
|
|
10
|
-
* the Node API surface.
|
|
7
|
+
* This module is browser-safe: only `fromBuiltUrl` and the instance API live
|
|
8
|
+
* here. Node-only factories (`fromDir`, `fromPackage`, `fromBuiltDir`,
|
|
9
|
+
* `build`) are installed on this class by `./node.js`, which is the
|
|
10
|
+
* consumer's explicit opt-in to the Node API surface.
|
|
11
11
|
*/
|
|
12
12
|
import { QuiverError } from "./errors.js";
|
|
13
13
|
import { parseQuillRef } from "./ref.js";
|
|
@@ -29,10 +29,10 @@ export class Quiver {
|
|
|
29
29
|
*/
|
|
30
30
|
#treeCache = new Map();
|
|
31
31
|
/**
|
|
32
|
-
* Private constructor — use static factory methods (`Quiver.
|
|
33
|
-
* the Node-only `Quiver.fromDir` / `Quiver.fromPackage`
|
|
34
|
-
* `@quillmark/quiver/node`). TS prevents
|
|
35
|
-
* compile time.
|
|
32
|
+
* Private constructor — use static factory methods (`Quiver.fromBuiltUrl`,
|
|
33
|
+
* or the Node-only `Quiver.fromDir` / `Quiver.fromPackage` /
|
|
34
|
+
* `Quiver.fromBuiltDir` installed by `@quillmark/quiver/node`). TS prevents
|
|
35
|
+
* external `new Quiver(...)` at compile time.
|
|
36
36
|
*/
|
|
37
37
|
constructor(name, catalog, loader) {
|
|
38
38
|
this.name = name;
|
|
@@ -51,16 +51,16 @@ export class Quiver {
|
|
|
51
51
|
* Browser-safe factory. Loads build output from an HTTP/HTTPS URL.
|
|
52
52
|
*
|
|
53
53
|
* Origin-relative URLs (e.g. `/quivers/foo/`) are accepted in browser
|
|
54
|
-
* environments. `file://` URLs are rejected —
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* environments. `file://` URLs are rejected — to load build output from
|
|
55
|
+
* disk in Node, use `Quiver.fromBuiltDir(path)` from
|
|
56
|
+
* `@quillmark/quiver/node`.
|
|
57
57
|
*
|
|
58
58
|
* Throws `transport_error` on network/HTTP failure, `quiver_invalid`
|
|
59
59
|
* on format errors.
|
|
60
60
|
*/
|
|
61
|
-
static async
|
|
61
|
+
static async fromBuiltUrl(url) {
|
|
62
62
|
if (url.startsWith("file://")) {
|
|
63
|
-
throw new QuiverError("transport_error", `Quiver.
|
|
63
|
+
throw new QuiverError("transport_error", `Quiver.fromBuiltUrl requires an http(s):// or origin-relative URL; got "${url}". For local build output, use Quiver.fromBuiltDir from @quillmark/quiver/node.`);
|
|
64
64
|
}
|
|
65
65
|
const { HttpTransport } = await import("./transports/http-transport.js");
|
|
66
66
|
const { loadBuiltQuiver } = await import("./built-loader.js");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FsBuiltTransport — Node-only built-quiver transport that reads packed
|
|
3
|
+
* artifacts from the local filesystem.
|
|
4
|
+
* Internal; not exported from index.ts.
|
|
5
|
+
*
|
|
6
|
+
* Static `node:*` imports — this module must never be reached from browser
|
|
7
|
+
* bundles. It is loaded lazily by `Quiver.fromBuiltDir` in `./node.js`.
|
|
8
|
+
*/
|
|
9
|
+
import type { BuiltTransport } from "../built-loader.js";
|
|
10
|
+
export declare class FsBuiltTransport implements BuiltTransport {
|
|
11
|
+
private readonly rootDir;
|
|
12
|
+
constructor(rootDir: string);
|
|
13
|
+
fetchBytes(relativePath: string): Promise<Uint8Array>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FsBuiltTransport — Node-only built-quiver transport that reads packed
|
|
3
|
+
* artifacts from the local filesystem.
|
|
4
|
+
* Internal; not exported from index.ts.
|
|
5
|
+
*
|
|
6
|
+
* Static `node:*` imports — this module must never be reached from browser
|
|
7
|
+
* bundles. It is loaded lazily by `Quiver.fromBuiltDir` in `./node.js`.
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from "node:fs/promises";
|
|
10
|
+
import { join, isAbsolute, normalize, sep } from "node:path";
|
|
11
|
+
import { QuiverError } from "../errors.js";
|
|
12
|
+
export class FsBuiltTransport {
|
|
13
|
+
rootDir;
|
|
14
|
+
constructor(rootDir) {
|
|
15
|
+
this.rootDir = rootDir;
|
|
16
|
+
}
|
|
17
|
+
async fetchBytes(relativePath) {
|
|
18
|
+
if (isAbsolute(relativePath)) {
|
|
19
|
+
throw new QuiverError("transport_error", `FsBuiltTransport: absolute paths are not allowed: "${relativePath}"`);
|
|
20
|
+
}
|
|
21
|
+
const normalized = normalize(relativePath);
|
|
22
|
+
if (normalized.startsWith("..") || normalized.split(sep).includes("..")) {
|
|
23
|
+
throw new QuiverError("transport_error", `FsBuiltTransport: path escapes root: "${relativePath}"`);
|
|
24
|
+
}
|
|
25
|
+
const filePath = join(this.rootDir, normalized);
|
|
26
|
+
try {
|
|
27
|
+
const buf = await readFile(filePath);
|
|
28
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw new QuiverError("transport_error", `Failed to read "${filePath}": ${err.message}`, { cause: err });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|