@quillmark/wasm 0.112.0 → 0.114.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 +1612 -0
- package/README.md +91 -66
- package/core/wasm.d.ts +153 -183
- package/core/wasm.js +283 -391
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +6 -11
- package/package.json +2 -2
- package/{backends/pdfform → render}/wasm.d.ts +204 -265
- package/{backends/pdfform → render}/wasm.js +364 -450
- package/{backends/typst → render}/wasm_bg.wasm +0 -0
- package/{backends/typst → render}/wasm_bg.wasm.d.ts +8 -15
- package/runtime/runtime.d.ts +88 -179
- package/runtime/runtime.js +144 -585
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +0 -107
- package/backends/typst/wasm.d.ts +0 -1511
- package/backends/typst/wasm.js +0 -3008
|
Binary file
|
|
@@ -22,18 +22,15 @@ export const document_cards: (a: number, b: number) => void;
|
|
|
22
22
|
export const document_clone: (a: number) => number;
|
|
23
23
|
export const document_currentStorageVersion: (a: number) => void;
|
|
24
24
|
export const document_equals: (a: number, b: number) => number;
|
|
25
|
-
export const document_formatDiagnostic: (a: number, b: number) => void;
|
|
26
25
|
export const document_formatRules: (a: number) => void;
|
|
27
|
-
export const document_fromJson: (a: number, b: number, c: number) => void;
|
|
28
26
|
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
27
|
+
export const document_fromStored: (a: number, b: number, c: number) => void;
|
|
29
28
|
export const document_getExt: (a: number, b: number, c: number) => void;
|
|
30
|
-
export const document_getExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
31
29
|
export const document_getStored: (a: number, b: number, c: number) => void;
|
|
32
30
|
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
33
31
|
export const document_isFill: (a: number, b: number, c: number) => void;
|
|
34
|
-
export const
|
|
32
|
+
export const document_loadStored: (a: number, b: number, c: number, d: number) => void;
|
|
35
33
|
export const document_main: (a: number, b: number) => void;
|
|
36
|
-
export const document_makeCard: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
37
34
|
export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
|
|
38
35
|
export const document_new: (a: number, b: number, c: number) => void;
|
|
39
36
|
export const document_overwrite: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -42,61 +39,57 @@ export const document_quillRef: (a: number, b: number) => void;
|
|
|
42
39
|
export const document_quillRefHint: (a: number) => void;
|
|
43
40
|
export const document_removeCard: (a: number, b: number, c: number) => void;
|
|
44
41
|
export const document_removeExt: (a: number, b: number, c: number) => void;
|
|
45
|
-
export const document_removeExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
46
42
|
export const document_removeField: (a: number, b: number, c: number) => void;
|
|
47
43
|
export const document_removeSeedOverlay: (a: number, b: number, c: number, d: number) => void;
|
|
48
44
|
export const document_revise: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
49
45
|
export const document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
|
|
50
|
-
export const document_setCardKind: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
51
46
|
export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
|
|
52
47
|
export const document_storageVersionOf: (a: number, b: number, c: number) => void;
|
|
53
48
|
export const document_storeExt: (a: number, b: number, c: number, d: number) => void;
|
|
54
|
-
export const document_storeExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
55
49
|
export const document_storeField: (a: number, b: number, c: number, d: number) => void;
|
|
56
50
|
export const document_storeFields: (a: number, b: number, c: number, d: number) => void;
|
|
57
51
|
export const document_storeFill: (a: number, b: number, c: number, d: number) => void;
|
|
58
52
|
export const document_storeSeedOverlay: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
59
|
-
export const document_toJson: (a: number, b: number) => void;
|
|
60
53
|
export const document_toMarkdown: (a: number, b: number) => void;
|
|
61
|
-
export const
|
|
54
|
+
export const document_toStored: (a: number, b: number) => void;
|
|
62
55
|
export const document_warnings: (a: number, b: number) => void;
|
|
63
56
|
export const exportMarkdown: (a: number, b: number) => void;
|
|
57
|
+
export const formatDiagnostic: (a: number, b: number) => void;
|
|
64
58
|
export const formatDocPath: (a: number, b: number) => void;
|
|
65
59
|
export const importMarkdown: (a: number, b: number, c: number) => void;
|
|
66
60
|
export const livesession_backendId: (a: number, b: number) => void;
|
|
67
61
|
export const livesession_fieldAt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
68
62
|
export const livesession_fieldBoxes: (a: number, b: number, c: number, d: number) => void;
|
|
69
|
-
export const livesession_locate: (a: number, b: number, c: number, d: number) =>
|
|
63
|
+
export const livesession_locate: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
70
64
|
export const livesession_pageCount: (a: number) => number;
|
|
71
65
|
export const livesession_pageSize: (a: number, b: number, c: number) => void;
|
|
72
66
|
export const livesession_paint: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
73
|
-
export const livesession_positionAt: (a: number, b: number, c: number, d: number, e: number) =>
|
|
67
|
+
export const livesession_positionAt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
74
68
|
export const livesession_regions: (a: number, b: number) => void;
|
|
75
69
|
export const livesession_render: (a: number, b: number, c: number) => void;
|
|
76
|
-
export const livesession_supportsCanvas: (a: number) => number;
|
|
77
70
|
export const livesession_update: (a: number, b: number, c: number) => void;
|
|
78
71
|
export const livesession_warnings: (a: number, b: number) => void;
|
|
79
72
|
export const mapMarks: (a: number, b: number, c: number) => void;
|
|
80
73
|
export const mapPos: (a: number, b: number, c: number, d: number) => void;
|
|
81
74
|
export const parseDocPath: (a: number, b: number, c: number) => void;
|
|
75
|
+
export const quill__resolve: (a: number, b: number, c: number) => void;
|
|
82
76
|
export const quill_backendId: (a: number, b: number) => void;
|
|
83
77
|
export const quill_blueprint: (a: number, b: number) => void;
|
|
84
78
|
export const quill_conform: (a: number, b: number, c: number) => void;
|
|
85
79
|
export const quill_fromTree: (a: number, b: number) => void;
|
|
86
80
|
export const quill_metadata: (a: number, b: number) => void;
|
|
87
81
|
export const quill_parse: (a: number, b: number, c: number, d: number) => void;
|
|
88
|
-
export const quill_resolve: (a: number, b: number, c: number) => void;
|
|
89
82
|
export const quill_schema: (a: number, b: number) => void;
|
|
90
83
|
export const quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
91
84
|
export const quill_seedDocument: (a: number) => number;
|
|
92
85
|
export const quill_seedMain: (a: number, b: number) => void;
|
|
93
86
|
export const quill_toTree: (a: number) => number;
|
|
94
87
|
export const quill_validate: (a: number, b: number, c: number) => void;
|
|
88
|
+
export const quill_warnings: (a: number, b: number) => void;
|
|
95
89
|
export const quillmark_new: () => number;
|
|
96
90
|
export const quillmark_open: (a: number, b: number, c: number, d: number) => void;
|
|
97
91
|
export const quillmark_render: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
98
92
|
export const quillmark_supportedFormats: (a: number, b: number, c: number) => void;
|
|
99
|
-
export const quillmark_supportsCanvas: (a: number, b: number) => number;
|
|
100
93
|
export const rebase: (a: number, b: number, c: number, d: number) => void;
|
|
101
94
|
export const start: () => void;
|
|
102
95
|
export const __wbindgen_export: (a: number, b: number) => number;
|
package/runtime/runtime.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// The render-side types are defined HERE as the backend-neutral render contract,
|
|
4
|
-
// not sourced from any one private backend build; `runtime.types.test-d.ts`
|
|
5
|
-
// asserts they stay mutually assignable with the Typst backend's generated
|
|
6
|
-
// declarations.
|
|
1
|
+
// The canonical consumer API, and the package's sole export: `@quillmark/wasm`
|
|
2
|
+
// resolves here.
|
|
7
3
|
//
|
|
8
4
|
// The `Quill`/`Document` `init` resolves to ARE the core build's classes, never
|
|
9
5
|
// wrappers. Two copies of this package are two WASM linear memories and two
|
|
@@ -26,7 +22,8 @@ import type {
|
|
|
26
22
|
mapPos,
|
|
27
23
|
mapMarks,
|
|
28
24
|
parseDocPath,
|
|
29
|
-
formatDocPath
|
|
25
|
+
formatDocPath,
|
|
26
|
+
formatDiagnostic
|
|
30
27
|
} from '../core/wasm.js';
|
|
31
28
|
|
|
32
29
|
/**
|
|
@@ -46,6 +43,7 @@ export interface CoreSurface {
|
|
|
46
43
|
mapMarks: typeof mapMarks;
|
|
47
44
|
parseDocPath: typeof parseDocPath;
|
|
48
45
|
formatDocPath: typeof formatDocPath;
|
|
46
|
+
formatDiagnostic: typeof formatDiagnostic;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
/**
|
|
@@ -110,29 +108,24 @@ export type {
|
|
|
110
108
|
QuillFieldUi,
|
|
111
109
|
QuillCardUi,
|
|
112
110
|
QuillGroupUi,
|
|
111
|
+
QuillMatrixGroup,
|
|
113
112
|
QuillMetadata
|
|
114
113
|
} from '../core/wasm.js';
|
|
115
114
|
|
|
116
115
|
// Content edit vocabulary: the op-grained content model `Document`'s methods
|
|
117
116
|
// speak (`applyChange(addr, bundle)`, `overwrite(addr, rt)`, `revise(…) => Delta`).
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
// must name all of them; they are its correctness core, not edge types.
|
|
124
|
-
// `ContentLineKind` is the shared half of `ContentLine` and `setKind`, so lifting
|
|
125
|
-
// a line's kind whole (destructure off `containers`/`continues`, spread the rest
|
|
126
|
-
// into the op) is the version-proof spelling of building a `setKind`. Naming it
|
|
127
|
-
// is what makes that spelling type-check without a cast. The alternative, an
|
|
128
|
-
// arm-by-arm switch, means guessing at the open arm's shape and re-editing on
|
|
129
|
-
// every arm added.
|
|
117
|
+
// `ContentLineKind` is the shared half of `ContentLine` and `setKind`, and
|
|
118
|
+
// `ContentMarkKind` of `ContentMark` and a mark op's `add` / `remove`: lifting a
|
|
119
|
+
// read value's kind whole — destructure off the envelope, spread the rest into
|
|
120
|
+
// the op — is the version-proof spelling of the op, and naming the type is what
|
|
121
|
+
// makes that spelling type-check without a cast.
|
|
130
122
|
export type {
|
|
131
123
|
Content,
|
|
132
124
|
ContentLine,
|
|
133
125
|
ContentLineKind,
|
|
134
126
|
ContentContainer,
|
|
135
127
|
ContentMark,
|
|
128
|
+
ContentMarkKind,
|
|
136
129
|
ContentIsland,
|
|
137
130
|
TableProps,
|
|
138
131
|
ImageProps,
|
|
@@ -150,13 +143,9 @@ export type {
|
|
|
150
143
|
DocPathSeg
|
|
151
144
|
} from '../core/wasm.js';
|
|
152
145
|
|
|
153
|
-
// The
|
|
154
|
-
// + source rung per declared field
|
|
155
|
-
// never a row in `fields`)
|
|
156
|
-
// `quill.schema`.
|
|
157
|
-
// Declared in the core build's generated `.d.ts` via a
|
|
158
|
-
// `typescript_custom_section`; re-exported here so the single public entry
|
|
159
|
-
// point names them.
|
|
146
|
+
// The schema-bound whole-document read on `quill.reader(doc)`: the resolved
|
|
147
|
+
// view (`reader.resolve()`, value + source rung per declared field, the body a
|
|
148
|
+
// `body` sibling on its card and never a row in `fields`).
|
|
160
149
|
export type {
|
|
161
150
|
FieldSource,
|
|
162
151
|
ResolvedField,
|
|
@@ -165,8 +154,6 @@ export type {
|
|
|
165
154
|
Resolved
|
|
166
155
|
} from '../core/wasm.js';
|
|
167
156
|
|
|
168
|
-
// ── Error contract ──────────────────────────────────────────────────────────
|
|
169
|
-
|
|
170
157
|
/**
|
|
171
158
|
* The error every fallible method in this package throws: parse
|
|
172
159
|
* (`Document.fromMarkdown`), document mutation, validation
|
|
@@ -193,97 +180,12 @@ export interface QuillmarkError extends Error {
|
|
|
193
180
|
*/
|
|
194
181
|
export declare function isQuillmarkError(e: unknown): e is QuillmarkError;
|
|
195
182
|
|
|
196
|
-
|
|
197
|
-
// `ContentContainer.container` are open sets: each union has a residual
|
|
198
|
-
// `{ …: string; … }` arm, so a bare discriminant check never narrows the payload
|
|
199
|
-
// (TS keeps the residual arm live, since a `string` can equal the literal).
|
|
200
|
-
// These guards are the checked narrowing path for the pinned arms; only the
|
|
201
|
-
// payload-carrying arms get one, since the rest narrow to nothing.
|
|
202
|
-
|
|
203
|
-
import type {
|
|
204
|
-
ContentIsland,
|
|
205
|
-
TableProps,
|
|
206
|
-
ImageProps,
|
|
207
|
-
ContentMark,
|
|
208
|
-
ContentLine,
|
|
209
|
-
ContentContainer
|
|
210
|
-
} from '../core/wasm.js';
|
|
183
|
+
import type { ContentContainer } from '../core/wasm.js';
|
|
211
184
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/** Narrow a {@link ContentIsland} to the pinned `image` arm (`props: ImageProps`). */
|
|
218
|
-
export declare function isImageIsland(
|
|
219
|
-
island: ContentIsland
|
|
220
|
-
): island is ContentIsland & { type: 'image'; props: ImageProps };
|
|
221
|
-
|
|
222
|
-
/** Narrow a {@link ContentMark} to the `link` arm (carries `attrs.url`). */
|
|
223
|
-
export declare function isLinkMark(
|
|
224
|
-
mark: ContentMark
|
|
225
|
-
): mark is ContentMark & { type: 'link'; attrs: { url: string } };
|
|
226
|
-
|
|
227
|
-
/** Narrow a {@link ContentMark} to the `anchor` arm (carries `attrs.id`). */
|
|
228
|
-
export declare function isAnchorMark(
|
|
229
|
-
mark: ContentMark
|
|
230
|
-
): mark is ContentMark & { type: 'anchor'; attrs: { id: string } };
|
|
231
|
-
|
|
232
|
-
/** Narrow a {@link ContentLine} to the `heading` arm (carries `attrs.level`). */
|
|
233
|
-
export declare function isHeadingLine(
|
|
234
|
-
line: ContentLine
|
|
235
|
-
): line is ContentLine & { kind: 'heading'; attrs: { level: number } };
|
|
236
|
-
|
|
237
|
-
/** Narrow a {@link ContentLine} to the `code` arm (carries `attrs.lang`). */
|
|
238
|
-
export declare function isCodeLine(
|
|
239
|
-
line: ContentLine
|
|
240
|
-
): line is ContentLine & { kind: 'code'; attrs?: { lang?: string } };
|
|
241
|
-
|
|
242
|
-
/** Narrow a {@link ContentContainer} to the `list_item` arm (carries its shape). */
|
|
243
|
-
export declare function isListItemContainer(
|
|
244
|
-
container: ContentContainer
|
|
245
|
-
): container is ContentContainer & {
|
|
246
|
-
container: 'list_item';
|
|
247
|
-
attrs: { ordered: boolean; start: number; ordinal: number };
|
|
248
|
-
instance: number;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
// The guards above answer "is this arm X". These four answer "is this a value
|
|
252
|
-
// this build knows?", the question a read-modify-write consumer must ask: an
|
|
253
|
-
// edit restates every line's kind and containers, so a construct the consumer
|
|
254
|
-
// cannot hold is gone on write-back unless carried inertly, and enumerating the
|
|
255
|
-
// built-in names by hand re-couples to a closed set.
|
|
256
|
-
//
|
|
257
|
-
// They classify unknown TAGS, not unknown payloads on known tags: a future
|
|
258
|
-
// `kind: "footnote"` carrying an `attrs.ref` loses `ref` at any consumer that
|
|
259
|
-
// predates it, with or without these. The spelling needs no classifying: a
|
|
260
|
-
// payload rides `attrs` whether or not this build knows the name.
|
|
261
|
-
|
|
262
|
-
/** True when this build does not know `line.kind`: the open arm, carrying opaque `attrs`. */
|
|
263
|
-
export declare function isUnknownLine(
|
|
264
|
-
line: ContentLine
|
|
265
|
-
): line is ContentLine & { kind: string; attrs: unknown };
|
|
266
|
-
|
|
267
|
-
/** True when this build does not know `container.container`. See {@link isUnknownLine}. */
|
|
268
|
-
export declare function isUnknownContainer(
|
|
269
|
-
container: ContentContainer
|
|
270
|
-
): container is ContentContainer & { container: string; attrs: unknown };
|
|
271
|
-
|
|
272
|
-
/** True when this build does not know `mark.type`. See {@link isUnknownLine}. */
|
|
273
|
-
export declare function isUnknownMark(
|
|
274
|
-
mark: ContentMark
|
|
275
|
-
): mark is ContentMark & { type: string; attrs: unknown };
|
|
276
|
-
|
|
277
|
-
/** True when this build does not know `island.type` (its payload rides `props`, not `attrs`). */
|
|
278
|
-
export declare function isUnknownIsland(
|
|
279
|
-
island: ContentIsland
|
|
280
|
-
): island is ContentIsland & { type: string; props: unknown };
|
|
281
|
-
|
|
282
|
-
// `ContentContainer.instance` is required, so a checker reports an omission; it
|
|
283
|
-
// cannot report a `0` stamped on every run, which is the same write. Adjacent
|
|
284
|
-
// runs of one shape sharing a value arrive welded, and nothing reports that
|
|
285
|
-
// either: the flat `containers` form cannot tell it from one container spanning
|
|
286
|
-
// two paragraphs. This carries the rule a codec would otherwise re-derive.
|
|
185
|
+
// `ContentIsland.type`, `ContentMark.type`, `ContentLine.kind`,
|
|
186
|
+
// `ContentContainer.container` and an island's `loss` are closed sets, so a
|
|
187
|
+
// bare discriminant check narrows the payload on its own:
|
|
188
|
+
// `line.kind === 'heading'` reaches `line.attrs.level`, with no guard to call.
|
|
287
189
|
|
|
288
190
|
/**
|
|
289
191
|
* Stamp `instance` across one parent's blocks at one depth, in document order,
|
|
@@ -296,8 +198,9 @@ export declare function isUnknownIsland(
|
|
|
296
198
|
* `instance` held.
|
|
297
199
|
*
|
|
298
200
|
* The `instance` it stamps is canonical, so a document reads back the value it
|
|
299
|
-
* was written
|
|
300
|
-
*
|
|
201
|
+
* was written — a `0` as an absent key, which decodes to the same value.
|
|
202
|
+
* `ordinal` stays the caller's, and a write is renumbered to a gapless index
|
|
203
|
+
* within its run.
|
|
301
204
|
*
|
|
302
205
|
* Which fields decide a weld is coarser than equality for a list: CommonMark
|
|
303
206
|
* reads only a list's first number, so `1. a` beside `3. b` welds despite the
|
|
@@ -316,8 +219,8 @@ export declare function assignInstances(
|
|
|
316
219
|
|
|
317
220
|
// The backend-neutral render contract, defined here rather than re-exported from
|
|
318
221
|
// one private backend because no single backend owns the canonical API's types.
|
|
319
|
-
//
|
|
320
|
-
// them from diverging from the generated `pkg/
|
|
222
|
+
// The render build must satisfy these shapes; `runtime.types.test-d.ts` keeps
|
|
223
|
+
// them from diverging from the generated `pkg/render/wasm.d.ts`.
|
|
321
224
|
|
|
322
225
|
import type { Quill, Document, Card } from '../core/wasm.js';
|
|
323
226
|
import type { Diagnostic } from '../core/wasm.js';
|
|
@@ -332,9 +235,14 @@ export interface Artifact {
|
|
|
332
235
|
/** Options for one render. */
|
|
333
236
|
export interface RenderOptions {
|
|
334
237
|
format?: OutputFormat;
|
|
238
|
+
/**
|
|
239
|
+
* Pixels per inch for raster formats (PNG); ignored by PDF and SVG.
|
|
240
|
+
* Defaults to 144. Must be finite, above 0, and small enough to keep every
|
|
241
|
+
* rendered page under 268435456 pixels — anything else throws
|
|
242
|
+
* `backend::invalid_raster_scale`.
|
|
243
|
+
*/
|
|
335
244
|
ppi?: number;
|
|
336
245
|
pages?: number[];
|
|
337
|
-
producer?: string;
|
|
338
246
|
/**
|
|
339
247
|
* Populate {@link RenderResult.regions} with schema-field geometry, for
|
|
340
248
|
* consumers without a live session. Defaults to `false`.
|
|
@@ -379,26 +287,17 @@ export interface ContentHit {
|
|
|
379
287
|
* direction use {@link LiveSession.fieldAt}, which resolves a point on *any*
|
|
380
288
|
* placement, not just the first one surfaced here.
|
|
381
289
|
*
|
|
382
|
-
* COORDINATE TRANSFORM. `rect` is in PDF points with a **bottom-left** origin
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* percentages of the page, so they track the displayed size across DPI and pane
|
|
386
|
-
* resize for free; only the Y axis flips:
|
|
387
|
-
*
|
|
388
|
-
* ```js
|
|
389
|
-
* const [x0, y0, x1, y1] = region.rect; // PDF pt, bottom-left origin
|
|
390
|
-
* const left = (x0 / pageWidthPt) * 100; // % of page (from PageSize.widthPt)
|
|
391
|
-
* const top = (1 - y1 / pageHeightPt) * 100; // %: flip Y (from PageSize.heightPt)
|
|
392
|
-
* const width = ((x1 - x0) / pageWidthPt) * 100;
|
|
393
|
-
* const height = ((y1 - y0) / pageHeightPt) * 100;
|
|
394
|
-
* ```
|
|
395
|
-
*
|
|
396
|
-
* For painting **into a raster** at `renderScale` (= `layoutScale × densityScale`),
|
|
397
|
-
* use the device-pixel form instead:
|
|
290
|
+
* COORDINATE TRANSFORM. `rect` is in PDF points with a **bottom-left** origin
|
|
291
|
+
* where a canvas or CSS overlay is top-left, so only the Y axis flips, off `y1`
|
|
292
|
+
* — the rect's *upper* edge — and never off `y0`:
|
|
398
293
|
*
|
|
399
294
|
* ```js
|
|
400
|
-
* const
|
|
401
|
-
*
|
|
295
|
+
* const [x0, y0, x1, y1] = region.rect;
|
|
296
|
+
* // Into a raster painted at renderScale (= layoutScale × densityScale):
|
|
297
|
+
* const left = x0 * renderScale, top = (pageHeightPt - y1) * renderScale;
|
|
298
|
+
* // Or, for an HTML overlay on a width:100% canvas, as % of the page, which
|
|
299
|
+
* // tracks the displayed size across DPI and pane resize with no scale to thread:
|
|
300
|
+
* const leftPct = (x0 / pageWidthPt) * 100, topPct = (1 - y1 / pageHeightPt) * 100;
|
|
402
301
|
* ```
|
|
403
302
|
*/
|
|
404
303
|
export interface FieldRegion {
|
|
@@ -429,7 +328,6 @@ export interface RenderResult {
|
|
|
429
328
|
artifacts: Artifact[];
|
|
430
329
|
warnings: Diagnostic[];
|
|
431
330
|
outputFormat: OutputFormat;
|
|
432
|
-
renderTimeMs: number;
|
|
433
331
|
/**
|
|
434
332
|
* Schema-field geometry, populated only when {@link RenderOptions.regions}
|
|
435
333
|
* asked for it. Page indices are document-space even under a `pages` subset.
|
|
@@ -448,7 +346,13 @@ export interface PageSize {
|
|
|
448
346
|
|
|
449
347
|
/** Inputs to `paint`. */
|
|
450
348
|
export interface PaintOptions {
|
|
349
|
+
/** How big the page is on screen, in CSS px per point. Default 1. */
|
|
451
350
|
layoutScale?: number;
|
|
351
|
+
/**
|
|
352
|
+
* How sharp it is: `window.devicePixelRatio`, in-app zoom and
|
|
353
|
+
* `visualViewport.scale` folded into one number. Default 1, because the
|
|
354
|
+
* painter cannot see any of them (SSR, tests, off-screen).
|
|
355
|
+
*/
|
|
452
356
|
densityScale?: number;
|
|
453
357
|
}
|
|
454
358
|
|
|
@@ -482,25 +386,24 @@ export interface ChangeSet {
|
|
|
482
386
|
|
|
483
387
|
/**
|
|
484
388
|
* A backend registry entry. `load` is the lazy thunk returning the
|
|
485
|
-
* dynamically-imported backend build module; `formats
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
389
|
+
* dynamically-imported backend build module; `formats` is the required static
|
|
390
|
+
* capability manifest, which is what makes `Engine.supportedFormats` free: it
|
|
391
|
+
* answers from it without loading a backend binary or cloning a quill. A
|
|
392
|
+
* malformed descriptor throws at `new Engine(...)`.
|
|
489
393
|
*/
|
|
490
394
|
export interface BackendDescriptor {
|
|
491
395
|
load: () => Promise<unknown>;
|
|
492
396
|
formats: OutputFormat[];
|
|
493
|
-
canvas: boolean;
|
|
494
397
|
}
|
|
495
398
|
|
|
496
399
|
export interface EngineOptions {
|
|
497
400
|
/**
|
|
498
401
|
* Extra or overriding backend descriptors, merged over the built-ins. Keys are
|
|
499
402
|
* backend ids (as declared by `Quill.yaml`'s `backend:` and reported by
|
|
500
|
-
* `Quill.backendId`). Each value is a `BackendDescriptor`: `formats
|
|
501
|
-
*
|
|
403
|
+
* `Quill.backendId`). Each value is a `BackendDescriptor`: `formats` is
|
|
404
|
+
* required, so the format probe is ALWAYS free (no binary load, no quill
|
|
502
405
|
* clone). Malformed entries throw at construction. The default registry maps
|
|
503
|
-
* `"typst"` to the bundled
|
|
406
|
+
* `"typst"` and `"acroform"` to the bundled render build.
|
|
504
407
|
*/
|
|
505
408
|
backends?: Record<string, BackendDescriptor>;
|
|
506
409
|
}
|
|
@@ -510,6 +413,10 @@ export interface EngineOptions {
|
|
|
510
413
|
* `quill.backendId`, lazily loads that backend build, clones the quill and
|
|
511
414
|
* document into the backend's WASM memory on demand, renders, and frees the
|
|
512
415
|
* clones. The cross-memory crossing is invisible to callers.
|
|
416
|
+
*
|
|
417
|
+
* A `quill.backendId` outside the registry rejects with
|
|
418
|
+
* `engine::backend_not_found`, the capability probes included. The diagnostic's
|
|
419
|
+
* `hint` names the registered ids.
|
|
513
420
|
*/
|
|
514
421
|
export declare class Engine {
|
|
515
422
|
constructor(options?: EngineOptions);
|
|
@@ -518,6 +425,12 @@ export declare class Engine {
|
|
|
518
425
|
* Render `doc` against `quill` in one shot. Both handles are read
|
|
519
426
|
* synchronously before the first await, so the caller may `free()` them as
|
|
520
427
|
* soon as this call returns.
|
|
428
|
+
*
|
|
429
|
+
* This is the surface that merges the two warning halves:
|
|
430
|
+
* {@link RenderResult.warnings} carries `doc.warnings` (parse, `conform::*`,
|
|
431
|
+
* `plate::unsupported_construct`) ahead of the compile's own. A
|
|
432
|
+
* {@link LiveSession} outlives the document it opened from, so
|
|
433
|
+
* {@link LiveSession.render} carries the compile half alone.
|
|
521
434
|
*/
|
|
522
435
|
render(quill: Quill, doc: Document, options?: RenderOptions): Promise<RenderResult>;
|
|
523
436
|
|
|
@@ -535,17 +448,6 @@ export declare class Engine {
|
|
|
535
448
|
* backend binary or cloning the quill. Async for API stability.
|
|
536
449
|
*/
|
|
537
450
|
supportedFormats(quill: Quill): Promise<OutputFormat[]>;
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Whether `quill`'s backend can paint sessions to a canvas: a pre-session
|
|
541
|
-
* estimate, not a fact about any particular compile, answered from the
|
|
542
|
-
* descriptor's `canvas` manifest like `supportedFormats`. A specific compile
|
|
543
|
-
* can still refuse to paint (a 0-page document, say), so this can answer
|
|
544
|
-
* `true` while the resulting {@link LiveSession.supportsCanvas} answers
|
|
545
|
-
* `false`. Gate mounting a canvas UI on this, and the `paint` call itself on
|
|
546
|
-
* the session's getter.
|
|
547
|
-
*/
|
|
548
|
-
supportsCanvas(quill: Quill): Promise<boolean>;
|
|
549
451
|
}
|
|
550
452
|
|
|
551
453
|
/**
|
|
@@ -553,23 +455,19 @@ export declare class Engine {
|
|
|
553
455
|
*
|
|
554
456
|
* CANVAS PAINT IS COMPLETE: {@link LiveSession.paint} writes a whole page
|
|
555
457
|
* raster, every piece of page content already visible in the painted pixels,
|
|
556
|
-
* with no compositing required by the caller —
|
|
557
|
-
*
|
|
458
|
+
* with no compositing required by the caller — acroform bakes each bound field
|
|
459
|
+
* value into the widget's appearance stream to satisfy this. {@link LiveSession.regions}
|
|
558
460
|
* carries schema-field geometry for overlays drawn on top; it is never needed to
|
|
559
461
|
* complete the picture.
|
|
462
|
+
*
|
|
463
|
+
* A compile with no pages throws from {@link LiveSession.pageSize} and
|
|
464
|
+
* {@link LiveSession.paint}, naming the page index and the `pageCount` that
|
|
465
|
+
* excludes it. Every backend paints, so that is the only refusal either owes.
|
|
560
466
|
*/
|
|
561
467
|
export declare class LiveSession {
|
|
562
468
|
private constructor();
|
|
563
469
|
readonly pageCount: number;
|
|
564
470
|
readonly backendId: string;
|
|
565
|
-
/**
|
|
566
|
-
* `true` iff `paint`/`pageSize` will succeed for THIS compile: the
|
|
567
|
-
* authoritative answer, which can be `false` even where
|
|
568
|
-
* {@link Engine.supportsCanvas} answered `true` for the same `quill` (a
|
|
569
|
-
* canvas-capable backend compiled to a 0-page document has nothing to paint).
|
|
570
|
-
* Re-check it after `open()` rather than relying on the engine hint.
|
|
571
|
-
*/
|
|
572
|
-
readonly supportsCanvas: boolean;
|
|
573
471
|
readonly warnings: Diagnostic[];
|
|
574
472
|
/**
|
|
575
473
|
* Recompile the session against `doc`: the edit verb of a live preview.
|
|
@@ -659,8 +557,6 @@ export declare class LiveSession {
|
|
|
659
557
|
free(): void;
|
|
660
558
|
}
|
|
661
559
|
|
|
662
|
-
// ── Typed writer: the schema-bound front door ───────────────────────────────
|
|
663
|
-
|
|
664
560
|
// `quill.writer(doc)` is patched onto the re-exported `Quill` prototype (the
|
|
665
561
|
// class is re-exported verbatim, so the method is declared by merging into the
|
|
666
562
|
// core module's `Quill` rather than redeclaring the class).
|
|
@@ -673,13 +569,14 @@ declare module '../core/wasm.js' {
|
|
|
673
569
|
*/
|
|
674
570
|
writer(doc: Document): DocumentWriter;
|
|
675
571
|
/**
|
|
676
|
-
* Bind this quill's schema to `doc` for
|
|
572
|
+
* Bind this quill's schema to `doc` for schema-bound reads: the read twin of
|
|
677
573
|
* {@link Quill.writer}, mirroring core's `quill.reader(&doc)`. Each field is
|
|
678
|
-
* read
|
|
679
|
-
*
|
|
680
|
-
* throws rather than reading back `undefined
|
|
681
|
-
*
|
|
682
|
-
*
|
|
574
|
+
* read in the values form (every content leaf as its codec's text, every
|
|
575
|
+
* other value as stored) with schema authority, so a name the schema does
|
|
576
|
+
* not declare throws rather than reading back `undefined`; the render
|
|
577
|
+
* view reads through `resolve()`. Holds both handles by reference and
|
|
578
|
+
* owns neither (nothing
|
|
579
|
+
* to `free()`); ephemeral by convention: bind, read, discard.
|
|
683
580
|
*/
|
|
684
581
|
reader(doc: Document): DocumentReader;
|
|
685
582
|
}
|
|
@@ -824,6 +721,10 @@ export declare class DocumentReader {
|
|
|
824
721
|
* schema's `items` / `properties` / `variants`, so the element's storage
|
|
825
722
|
* form is not the caller's business. The empty path is {@link getContent}.
|
|
826
723
|
*
|
|
724
|
+
* The `Content` is a write input, so this is the read a round-trip takes:
|
|
725
|
+
* an anchor and an island `id` have no markdown projection, and survive an
|
|
726
|
+
* edit only by riding this read back through `writer.set` of the field.
|
|
727
|
+
*
|
|
827
728
|
* `undefined` for an absent field and for a path that names nothing in the
|
|
828
729
|
* stored value: a repeater's row index goes stale between derive and read,
|
|
829
730
|
* so absence there is a read, not a fault. Throws `UnknownField` for an
|
|
@@ -834,6 +735,14 @@ export declare class DocumentReader {
|
|
|
834
735
|
getContentAt(addr: Addr | string, path: PathStep[]): Content | undefined;
|
|
835
736
|
/** The main body's markdown: the quill-free body read. Equals `get({})`. */
|
|
836
737
|
bodyMarkdown(): string;
|
|
738
|
+
/**
|
|
739
|
+
* The resolved-value view: for every declared field, the value the render
|
|
740
|
+
* projection would use and the rung it came from (`authored` / `default` /
|
|
741
|
+
* `blank`). The one read that blank-fills and coerces; {@link get} reports
|
|
742
|
+
* what the document carries. Value and provenance only; completeness stays
|
|
743
|
+
* `quill.validate`'s.
|
|
744
|
+
*/
|
|
745
|
+
resolve(): Resolved;
|
|
837
746
|
/**
|
|
838
747
|
* A {@link CardReader} for the composable card at `index`. Index validity is
|
|
839
748
|
* checked lazily at read time, so an out-of-range index does not throw here.
|