@docx-editor.dev/core 2.14.0 → 2.15.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/README.md +42 -0
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +6 -5
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +16 -10
- package/dist/binding.js +1 -1
- package/dist/chunk-24APKZAN.cjs +11 -0
- package/dist/chunk-2YH4MSHX.cjs +2 -0
- package/dist/chunk-5Y7AADI6.js +1 -0
- package/dist/chunk-AREFLNUP.js +11 -0
- package/dist/chunk-AS7YZNQE.cjs +2 -0
- package/dist/chunk-AVGCKH6A.cjs +20 -0
- package/dist/chunk-CDYVDQRI.cjs +5 -0
- package/dist/chunk-FGBADUSK.cjs +1 -0
- package/dist/chunk-HOEWFH5U.cjs +1 -0
- package/dist/chunk-KFELX7CN.js +2 -0
- package/dist/{chunk-OKEDGR65.js → chunk-KXPVOPR5.js} +1 -1
- package/dist/chunk-LGFKIF4M.cjs +1 -0
- package/dist/chunk-M52QXFKI.js +1 -0
- package/dist/chunk-MNUKSXRO.js +1 -0
- package/dist/chunk-PBOIGBDO.js +2 -0
- package/dist/chunk-PMHGONET.cjs +1 -0
- package/dist/chunk-PXKZUTHX.cjs +2 -0
- package/dist/chunk-Q4AB7E4O.cjs +1 -0
- package/dist/chunk-QJYH6AYD.js +1 -0
- package/dist/chunk-QRC37MWG.cjs +20 -0
- package/dist/chunk-RJSB6RJ7.js +20 -0
- package/dist/chunk-SB54HLFJ.js +20 -0
- package/dist/chunk-VP7SDFCM.js +1 -0
- package/dist/chunk-XCESLTJL.js +2 -0
- package/dist/{chunk-KIAP7PFQ.cjs → chunk-YL4Q5LZP.cjs} +1 -1
- package/dist/chunk-Z4527AXR.js +5 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +4 -3
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +4 -3
- package/dist/contracts/editor.d.ts +7 -7
- package/dist/contracts/interaction.d.ts +7 -7
- package/dist/contracts/modules.d.ts +8 -7
- package/dist/{custom-node-writes-DntmaAVW.d.ts → custom-node-writes-C9ArIlJh.d.ts} +2 -2
- package/dist/{editor-a6VvsfYU.d.ts → editor-sRxrFJd8.d.ts} +29 -21
- package/dist/editor.cjs +1 -1
- package/dist/editor.d.ts +27 -58
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -0
- package/dist/export.d.ts +337 -0
- package/dist/export.js +2 -0
- package/dist/font-resolver-BYEHQGTw.d.ts +251 -0
- package/dist/headless-document-view-DELC4E5v.d.ts +134 -0
- package/dist/hf-references-DTrHkktY.d.ts +70 -0
- package/dist/{index-C5ZnSRkF.d.ts → index-C3Gvq4jN.d.ts} +55 -246
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +18 -16
- package/dist/index.js +1 -1
- package/dist/{shaped-measurer-CFPnXFs9.d.cts → layout-shaping-DoGR5cf8.d.ts} +86 -12
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +1106 -729
- package/dist/layout.js +1 -1
- package/dist/{note-properties-CDFiNXcD.d.ts → note-properties-DSe8igrz.d.ts} +2 -2
- package/dist/{omml-equation-BY49UOIF.d.ts → omml-equation-BpRmfDAf.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +6 -6
- package/dist/output.js +1 -1
- package/dist/{protocol-gOY5GA8K.d.cts → protocol-DZzKxH5r.d.ts} +18 -12
- package/dist/{review-items-CCS1h93f.d.ts → review-items-DYRx187i.d.ts} +2 -2
- package/dist/{review-reads-BjZYeMd4.d.ts → review-reads-LbGUdNzn.d.ts} +22 -25
- package/dist/{revision-projection-BeXVrSSV.d.ts → revision-projection-DHRJH48u.d.ts} +1 -1
- package/dist/{semantic-cell-selection-BK91NCCG.d.ts → semantic-cell-selection-BXVWCBYm.d.ts} +4 -4
- package/dist/{semantic-interaction-BmQ7h2cq.d.ts → semantic-interaction-DZsDmPg5.d.ts} +1 -1
- package/dist/{semantic-paint-WJD2KeG1.d.ts → semantic-paint-f7SqN4oW.d.ts} +2 -2
- package/dist/{semantic-records-BpozY7-j.d.cts → semantic-records-EIdwId-a.d.ts} +301 -205
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +15 -65
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-D6HzlPR4.d.ts → tree-op-types-egdarvH_.d.ts} +7 -3
- package/dist/{tree-package-fragment-CWFjgH6a.d.ts → tree-package-fragment-DjkH4ESI.d.ts} +4 -70
- package/dist/{tree-session-contract-B2HfGt79.d.ts → tree-session-contract-CGOOgPjW.d.ts} +29 -23
- package/dist/{tree-store-APgWx6qn.d.ts → tree-store-DKJB0IcA.d.ts} +2 -2
- package/package.json +7 -2
- package/dist/automation.d.cts +0 -82
- package/dist/binding.d.cts +0 -153
- package/dist/chunk-2PIHW2QM.cjs +0 -1
- package/dist/chunk-2QTY5S6T.js +0 -1
- package/dist/chunk-4Z5MODAE.cjs +0 -2
- package/dist/chunk-5TKAPFZT.cjs +0 -2
- package/dist/chunk-DRQHIQ4R.cjs +0 -1
- package/dist/chunk-F2K6SDHA.cjs +0 -20
- package/dist/chunk-FBA57EUJ.js +0 -2
- package/dist/chunk-KTAQ7BRQ.js +0 -20
- package/dist/chunk-LBAHXZCU.cjs +0 -5
- package/dist/chunk-MCDUQYWP.js +0 -5
- package/dist/chunk-MQP26KCF.js +0 -1
- package/dist/chunk-NDJGSR6M.cjs +0 -19
- package/dist/chunk-NJNFJPGB.cjs +0 -11
- package/dist/chunk-O5M4CR4P.cjs +0 -2
- package/dist/chunk-UKUOZXUD.js +0 -19
- package/dist/chunk-VQ4R5LTU.js +0 -2
- package/dist/chunk-ZBEJHJN2.js +0 -11
- package/dist/chunk-ZVTW7RGD.js +0 -2
- package/dist/collaboration/replication.d.cts +0 -216
- package/dist/collaboration.d.cts +0 -176
- package/dist/contracts/document.d.cts +0 -273
- package/dist/contracts/editor.d.cts +0 -10
- package/dist/contracts/interaction.d.cts +0 -10
- package/dist/contracts/modules.d.cts +0 -130
- package/dist/contracts/types.d.cts +0 -562
- package/dist/custom-node-writes-C46r3_5O.d.cts +0 -310
- package/dist/document-properties-D6Ahr8D6.d.cts +0 -28
- package/dist/document-properties-D6Ahr8D6.d.ts +0 -28
- package/dist/editor-AJ06hyyg.d.cts +0 -1994
- package/dist/editor.d.cts +0 -393
- package/dist/failure-BnGjoXf0.d.cts +0 -64
- package/dist/index-Cbw4lkOt.d.cts +0 -3391
- package/dist/index.d.cts +0 -23
- package/dist/layout.d.cts +0 -2486
- package/dist/note-properties-Y6qYh2Hv.d.cts +0 -67
- package/dist/omml-equation-DB8d-jCq.d.cts +0 -84
- package/dist/output.d.cts +0 -74
- package/dist/protocol-BsmQgblT.d.ts +0 -1358
- package/dist/review-items-CaAkgi5s.d.cts +0 -360
- package/dist/review-reads-DEsV0OOW.d.cts +0 -163
- package/dist/revision-projection-DXbrfNGD.d.cts +0 -156
- package/dist/semantic-cell-selection-BMhku3B1.d.cts +0 -451
- package/dist/semantic-interaction-DUAnxbgf.d.cts +0 -160
- package/dist/semantic-paint-DufNL1Zr.d.cts +0 -247
- package/dist/semantic-records-92UnKeU_.d.ts +0 -2821
- package/dist/shaped-measurer-BWbindlI.d.ts +0 -168
- package/dist/store.d.cts +0 -2500
- package/dist/tree-op-types-BUulYD5y.d.cts +0 -3099
- package/dist/tree-package-fragment-Dhyw7oPm.d.cts +0 -732
- package/dist/tree-session-contract-BY9xd7s_.d.cts +0 -613
- package/dist/tree-store-DEEQ9wz_.d.cts +0 -416
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { F as FontSource, a as FontSourceSubstitution, b as FontFaceRequest, c as FontConfiguration } from './editor-sRxrFJd8.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A partial font configuration one origin contributes: sources, substitutions, or both.
|
|
5
|
+
* `loadDefaultFonts()` (the substitute package) and `loadFonts()` (the fetch helper) both
|
|
6
|
+
* return this shape, so every origin composes through `composeFontConfiguration` the
|
|
7
|
+
* same way.
|
|
8
|
+
*/
|
|
9
|
+
interface FontConfigurationFragment {
|
|
10
|
+
readonly sources?: readonly FontSource[];
|
|
11
|
+
readonly substitutions?: readonly FontSourceSubstitution[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The base of a composition: everything a `FontConfiguration` carries, all optional.
|
|
15
|
+
* Omitted fields take the documented defaults (`epoch` 0, `maxFontBytes` at the engine
|
|
16
|
+
* hard maximum, `defaultFont` Calibri at 11pt — Word's own default face and size).
|
|
17
|
+
*/
|
|
18
|
+
interface FontConfigurationBase extends FontConfigurationFragment {
|
|
19
|
+
/**
|
|
20
|
+
* Identity of this configuration's byte set. The engine uses it to tell one resolved
|
|
21
|
+
* font set from another; leave it unset and the editor supplies the load sequence.
|
|
22
|
+
*/
|
|
23
|
+
readonly epoch?: number;
|
|
24
|
+
/** Per-face byte ceiling. Defaults to the engine hard maximum; lower it to tighten intake. */
|
|
25
|
+
readonly maxFontBytes?: number;
|
|
26
|
+
/** The face used when a run names no font. Defaults to Word's own: Calibri at 11pt. */
|
|
27
|
+
readonly defaultFont?: FontConfiguration['defaultFont'];
|
|
28
|
+
/** BCP-47 tag passed to the shaper for language-sensitive shaping. */
|
|
29
|
+
readonly language?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What the document turned out to need, handed to an on-demand resolver.
|
|
33
|
+
*
|
|
34
|
+
* The families are the ones the file actually names — already name-validated and capped,
|
|
35
|
+
* so a resolver may treat them as a list to look up, never as URLs or paths to build.
|
|
36
|
+
*/
|
|
37
|
+
interface FontResolutionRequest {
|
|
38
|
+
/**
|
|
39
|
+
* Families needed by the document, deduped and capped at {@link MAX_RESOLVER_FAMILIES}.
|
|
40
|
+
* Order is deterministic but may express host priority; do not sort it before resolving.
|
|
41
|
+
*/
|
|
42
|
+
readonly families: readonly string[];
|
|
43
|
+
/** The face a run naming no font resolves to, so a resolver can cover it too. */
|
|
44
|
+
readonly defaultFamily: string;
|
|
45
|
+
/** Cancels document-scoped resolution; network-backed resolvers should pass it to fetch. */
|
|
46
|
+
readonly signal?: AbortSignal;
|
|
47
|
+
/**
|
|
48
|
+
* Faces an EARLIER origin in the same composition can already PAINT — either because it
|
|
49
|
+
* supplied the bytes, or because it mapped that face onto one it did supply.
|
|
50
|
+
*
|
|
51
|
+
* Absent, not empty, when there is nothing to report: the engine calling a resolver
|
|
52
|
+
* directly, and the first origin of a composition.
|
|
53
|
+
*
|
|
54
|
+
* FACES, not families, and only faces backed by bytes. Both narrowings are load-bearing.
|
|
55
|
+
* A family-grained list would let an origin holding only regular Arial suppress the bold
|
|
56
|
+
* and italic a later origin would have supplied, and a list built from substitutions
|
|
57
|
+
* alone would let an origin whose fetches all failed suppress the failover behind it,
|
|
58
|
+
* because both shipped resolvers emit their substitution map before fetching. Together
|
|
59
|
+
* they are what makes honouring this an OPTIMIZATION rather than a correctness
|
|
60
|
+
* requirement: skipping a reported face cannot lose one, so a resolver that ignores this
|
|
61
|
+
* list only spends bytes on a face first-wins composition would drop anyway.
|
|
62
|
+
*
|
|
63
|
+
* Match it case-insensitively. Word matches font names that way and both shipped
|
|
64
|
+
* resolvers do.
|
|
65
|
+
*/
|
|
66
|
+
readonly resolvedFaces?: readonly FontFaceRequest[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve fonts once the document's needs are known, instead of ahead of them.
|
|
70
|
+
*
|
|
71
|
+
* Called once per load, AFTER the file is parsed and mounted, with the families it
|
|
72
|
+
* declares; whatever it returns composes exactly like a statically supplied fragment.
|
|
73
|
+
* Returning nothing is a valid answer — it means "I cover none of this", and the
|
|
74
|
+
* document stays on the fixed measurer.
|
|
75
|
+
*
|
|
76
|
+
* A resolver that fetches makes opening a document perform network requests. That is a
|
|
77
|
+
* real change in posture and it must stay the APP's decision: the engine never supplies
|
|
78
|
+
* one, and the families here are file-derived, so a resolver must look them up in a set
|
|
79
|
+
* it shipped rather than interpolate them into a URL.
|
|
80
|
+
*/
|
|
81
|
+
type FontResolver = (request: FontResolutionRequest) => FontConfiguration | FontConfigurationFragment | undefined | Promise<FontConfiguration | FontConfigurationFragment | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Ceiling on the families one document can put in front of a resolver.
|
|
84
|
+
*
|
|
85
|
+
* A resolver typically turns each family into up to four faces, and the resource snapshot
|
|
86
|
+
* refuses more than `HARD_MAX_FONT_SOURCES` (256) sources — so 64 families is the point
|
|
87
|
+
* past which a document could no longer be served anyway. Capping here means a file
|
|
88
|
+
* declaring thousands of distinct `w:rFonts` cannot fan a resolver out across thousands
|
|
89
|
+
* of lookups (or fetches) before that limit is ever reached.
|
|
90
|
+
*/
|
|
91
|
+
declare const MAX_RESOLVER_FAMILIES = 64;
|
|
92
|
+
/** Word's document default when nothing else says otherwise: Calibri at 11pt. */
|
|
93
|
+
declare const WORD_DEFAULT_FONT: FontConfiguration['defaultFont'];
|
|
94
|
+
/**
|
|
95
|
+
* Merge a base and any number of fragments into one frozen `FontConfiguration`.
|
|
96
|
+
*
|
|
97
|
+
* A bare fragment IS a valid base, so the single-origin case is one argument:
|
|
98
|
+
* `composeFontConfiguration(await loadDefaultFonts())`. Pass extra fragments to layer
|
|
99
|
+
* origins, and set `epoch`/`maxFontBytes`/`defaultFont` on the base only when you need
|
|
100
|
+
* something other than the documented defaults.
|
|
101
|
+
*
|
|
102
|
+
* - Sources dedupe first-wins by (family, weight, style), in argument order — base
|
|
103
|
+
* before fragments, earlier fragments before later ones.
|
|
104
|
+
* - Substitutions dedupe first-wins by their `from` face, in the same order, and every
|
|
105
|
+
* substitution whose `from` face has a direct source anywhere in the composition is
|
|
106
|
+
* dropped: a real face always beats a stand-in.
|
|
107
|
+
* - The result is frozen (arrays included); the byte arrays themselves are the callers'
|
|
108
|
+
* and are not copied here — the resource snapshot takes its own defensive copy.
|
|
109
|
+
*/
|
|
110
|
+
declare function composeFontConfiguration(base: FontConfigurationBase, ...fragments: readonly FontConfigurationFragment[]): FontConfiguration;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The namespaced key carrying the type-level half of the mark, and the runtime property
|
|
114
|
+
* name that backs it.
|
|
115
|
+
*
|
|
116
|
+
* A plain string rather than a symbol on purpose: `@docx-editor.dev/fonts` has no runtime
|
|
117
|
+
* or type dependency on the engine, so it declares the same mark itself, and two
|
|
118
|
+
* `unique symbol`s in two packages would not unify. Two identical string keys do.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
declare const FONT_RESOLVER_MARK_KEY = "docx-editor.dev/font-resolver";
|
|
123
|
+
/**
|
|
124
|
+
* The runtime marker `defineFontResolver` sets and {@link isFontResolver} reads.
|
|
125
|
+
*
|
|
126
|
+
* Exported because a package mirroring the font contract structurally still has to mark
|
|
127
|
+
* the resolvers it builds. A package in that position sets
|
|
128
|
+
* `Symbol.for('docx-editor.dev/font-resolver')` itself; this constant is the same symbol,
|
|
129
|
+
* named, for everyone who can import it.
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
declare const FONT_RESOLVER_BRAND: unique symbol;
|
|
134
|
+
/**
|
|
135
|
+
* The type-level half of the mark: what {@link defineFontResolver} adds to a function's
|
|
136
|
+
* type so a `FontOrigin` list can REQUIRE it.
|
|
137
|
+
*
|
|
138
|
+
* Declared with a string key so `@docx-editor.dev/fonts` can declare an identical
|
|
139
|
+
* interface and have the two unify without importing anything from the engine. Set at
|
|
140
|
+
* runtime as well as in the type — non-enumerable, so it stays out of `Object.keys` and
|
|
141
|
+
* out of a host's own spread.
|
|
142
|
+
*
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
interface FontResolverMark {
|
|
146
|
+
/** Always `true`. Set non-enumerably by {@link defineFontResolver}. */
|
|
147
|
+
readonly 'docx-editor.dev/font-resolver': true;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A {@link FontResolver} that has been through {@link defineFontResolver}.
|
|
151
|
+
*
|
|
152
|
+
* This, not bare `FontResolver`, is what a `FontOrigin` list accepts. The mark is the only
|
|
153
|
+
* thing separating a resolver from a zero-argument loader, and getting that wrong loses
|
|
154
|
+
* every font silently, so the type asks for it up front.
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
type MarkedFontResolver<T extends FontResolver = FontResolver> = T & FontResolverMark;
|
|
159
|
+
/**
|
|
160
|
+
* Mark a function as an on-demand {@link FontResolver}.
|
|
161
|
+
*
|
|
162
|
+
* Wrap every resolver you put in a `fonts` list — `useFonts(...)`, `useDocxSource`'s
|
|
163
|
+
* `fonts` option, `composeFontOrigins`. The `fonts` PROP needs no marking, because a
|
|
164
|
+
* function there is always a resolver; a list also accepts the older zero-argument loader
|
|
165
|
+
* form (`{ fonts: defaultFonts }`), and this is what keeps the two apart.
|
|
166
|
+
*
|
|
167
|
+
* Returns the same function object, mutated, so the mark survives being passed around and
|
|
168
|
+
* a marked resolver stays `===` to itself. It does NOT survive `.bind()` or being wrapped:
|
|
169
|
+
* both make a new function object. Re-mark the result.
|
|
170
|
+
*
|
|
171
|
+
* ```ts
|
|
172
|
+
* const brandFonts = defineFontResolver(async ({ families }) => ({
|
|
173
|
+
* sources: await loadMine(families),
|
|
174
|
+
* }));
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* Throws a `TypeError` on a frozen or sealed function, which cannot take the mark. That is
|
|
178
|
+
* deliberate: returning it unmarked would compile — the return TYPE says marked — and then
|
|
179
|
+
* lose every font at runtime.
|
|
180
|
+
*
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
declare function defineFontResolver<T extends FontResolver>(resolve: T): MarkedFontResolver<T>;
|
|
184
|
+
/**
|
|
185
|
+
* Whether a value is a function marked by {@link defineFontResolver}.
|
|
186
|
+
*
|
|
187
|
+
* False for an unmarked function, which callers read as a zero-argument loader. Calling a
|
|
188
|
+
* resolver that way reads `request.defaultFamily` off `undefined` and throws, so the
|
|
189
|
+
* callers that make this choice say so rather than swallowing it — and the type-level mark
|
|
190
|
+
* on {@link MarkedFontResolver} is there to stop it reaching runtime at all.
|
|
191
|
+
*
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
declare function isFontResolver(value: unknown): value is MarkedFontResolver;
|
|
195
|
+
/**
|
|
196
|
+
* ONE font origin, in the one shape every origin takes: a finished configuration, a
|
|
197
|
+
* fragment, a promise for either, or a marked resolver that answers per document.
|
|
198
|
+
*
|
|
199
|
+
* The point of the union is that `packagedFonts()`, `googleFonts()`, `await defaultFonts()`
|
|
200
|
+
* and a hand-built `{ sources }` are all the same kind of thing, so a list of them needs no
|
|
201
|
+
* ordering rule beyond "first wins".
|
|
202
|
+
*
|
|
203
|
+
* The resolver arm is {@link MarkedFontResolver}, not bare `FontResolver`: a list may also
|
|
204
|
+
* hold a zero-argument loader, and only the mark separates the two.
|
|
205
|
+
*
|
|
206
|
+
* @public
|
|
207
|
+
*/
|
|
208
|
+
type FontOrigin = FontConfiguration | FontConfigurationFragment | MarkedFontResolver | Promise<FontConfiguration | FontConfigurationFragment | undefined> | undefined;
|
|
209
|
+
/** One font origin that could not contribute a valid fragment. @public */
|
|
210
|
+
interface FontOriginFailure {
|
|
211
|
+
/** Zero-based position in the first-wins origin list. */
|
|
212
|
+
readonly originIndex: number;
|
|
213
|
+
/** Resolver function name when one is safely available. */
|
|
214
|
+
readonly originName?: string;
|
|
215
|
+
readonly cause: unknown;
|
|
216
|
+
}
|
|
217
|
+
/** Diagnostics hook for ordered font-origin composition. @public */
|
|
218
|
+
interface ComposeFontOriginsOptions {
|
|
219
|
+
/** Fire-and-forget diagnostics; returned promises are observed but do not delay resolution. */
|
|
220
|
+
readonly onOriginFailure?: (failure: FontOriginFailure) => void;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Resolve a list of {@link FontOrigin}s against one document's needs and merge them,
|
|
224
|
+
* first-wins in list order.
|
|
225
|
+
*
|
|
226
|
+
* Origins resolve IN ORDER, one after another, and each is told which faces the ones
|
|
227
|
+
* before it can already paint ({@link FontResolutionRequest.resolvedFaces}). Sequential
|
|
228
|
+
* rather than a `Promise.all`, and that is a real cost — one extra origin's latency on the
|
|
229
|
+
* critical path — bought deliberately: composition is first-wins, so a later origin's copy
|
|
230
|
+
* of a face an earlier one supplied can never be used, and fetching it anyway spends the
|
|
231
|
+
* bytes twice and tells a font host which families the document uses for a result that
|
|
232
|
+
* gets thrown away. Order origins cheapest-first.
|
|
233
|
+
*
|
|
234
|
+
* A resolver that ignores `resolvedFaces` still composes correctly; it just spends more.
|
|
235
|
+
*
|
|
236
|
+
* ONE ORIGIN CANNOT SINK THE REST. An origin that throws, answers `null`, or answers
|
|
237
|
+
* something malformed is reported and skipped whole, and the origins around it still
|
|
238
|
+
* compose — an app that listed a flaky network origin behind a bundled one keeps the
|
|
239
|
+
* bundled faces. Skipped WHOLE: an answer is read completely before any of it is
|
|
240
|
+
* committed, so a half-ingested origin can never reach composition.
|
|
241
|
+
*
|
|
242
|
+
* The result carries NO `epoch`: it is a fragment for the engine to stamp with the load
|
|
243
|
+
* sequence. A fixed epoch from here would label every document's byte set as the same one.
|
|
244
|
+
* `undefined` means no origin contributed anything, which is a normal answer — the document
|
|
245
|
+
* stays on the fixed measurer.
|
|
246
|
+
*
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
declare function composeFontOrigins(origins: readonly FontOrigin[], request: FontResolutionRequest, options?: ComposeFontOriginsOptions): Promise<FontConfigurationFragment | undefined>;
|
|
250
|
+
|
|
251
|
+
export { type ComposeFontOriginsOptions as C, type FontOriginFailure as F, MAX_RESOLVER_FAMILIES as M, WORD_DEFAULT_FONT as W, type FontOrigin as a, FONT_RESOLVER_BRAND as b, FONT_RESOLVER_MARK_KEY as c, type FontConfigurationBase as d, type FontConfigurationFragment as e, type FontResolutionRequest as f, type FontResolver as g, type FontResolverMark as h, type MarkedFontResolver as i, composeFontConfiguration as j, composeFontOrigins as k, defineFontResolver as l, isFontResolver as m };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { a as HeaderFooterParts, b as HeaderFooterSectionResolution } from './hf-references-DTrHkktY.js';
|
|
2
|
+
import { b as OoxmlPackage, O as OoxmlPart, c as OoxmlElement, g as OoxmlPackageRejection } from './tree-op-types-egdarvH_.js';
|
|
3
|
+
|
|
4
|
+
/** The package with a hyperlink relationship guaranteed present, and that relationship's id. */
|
|
5
|
+
interface EnsuredHyperlinkRelationship {
|
|
6
|
+
readonly pkg: OoxmlPackage;
|
|
7
|
+
readonly relationshipId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The target this engine would write for `url`, or null when it would write none.
|
|
11
|
+
*
|
|
12
|
+
* The VALIDATION half of {@link ensureHyperlinkRelationship}, exported so a caller that must decide
|
|
13
|
+
* "would this be authored?" before it is allowed to change the package can ask without changing it.
|
|
14
|
+
* A relationship outlives a refusal — it lives beside the trees, outside the undo stack — so a
|
|
15
|
+
* caller planning a batch that may yet be refused has to ask this and mint later.
|
|
16
|
+
*
|
|
17
|
+
* Same rules, one implementation: `sanitizeHref`'s allowlist, a bound on the length, XML-writable
|
|
18
|
+
* text, and the absolute-URI gate the READ side applies. There is no legitimate reason for this
|
|
19
|
+
* engine to author a scheme it would refuse to open.
|
|
20
|
+
*/
|
|
21
|
+
declare function authorableHyperlinkTarget(url: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* The external hyperlink relationship for `url` on `ownerPart` (default: main document),
|
|
24
|
+
* reusing an existing one with the same target, or `null` when the URL is not something to
|
|
25
|
+
* write.
|
|
26
|
+
*
|
|
27
|
+
* REUSE IS BY EXACT TARGET, matching Word: linking twice to the same address produces one
|
|
28
|
+
* relationship. It is safe because a hyperlink relationship carries nothing but its target —
|
|
29
|
+
* two links sharing one are indistinguishable from two links with identical targets, and
|
|
30
|
+
* retargeting one always mints rather than rewriting (see the edit op).
|
|
31
|
+
*
|
|
32
|
+
* Ownership follows the story that holds the `w:hyperlink`: a header/footer or notes part
|
|
33
|
+
* mints into that part's `.rels`, never into `document.xml.rels`. Passing an owner the
|
|
34
|
+
* package does not declare fails closed (`null`) so a scoped insert cannot leave a stray
|
|
35
|
+
* body relationship behind.
|
|
36
|
+
*
|
|
37
|
+
* The URL is refused unless `sanitizeHref` admits it. Storing a `javascript:` target that a
|
|
38
|
+
* FILE authored is required — round-tripping never rewrites a document — but AUTHORING one
|
|
39
|
+
* here is not: there is no legitimate reason for this engine to write a scheme it would then
|
|
40
|
+
* refuse to open, and writing it would hand the next reader a live target this reader made.
|
|
41
|
+
*/
|
|
42
|
+
declare function ensureHyperlinkRelationship(pkg: OoxmlPackage, url: string, ownerPart?: string): EnsuredHyperlinkRelationship | null;
|
|
43
|
+
/**
|
|
44
|
+
* What a part's relationships answer for one `r:id`, over both maps.
|
|
45
|
+
*
|
|
46
|
+
* `relationships` holds the internal records and `externalTargets` the external ones, so a
|
|
47
|
+
* resolver reading only the first sees every hyperlink as dangling.
|
|
48
|
+
*/
|
|
49
|
+
declare function relationshipTargetIn(pkg: OoxmlPackage, ownerPart: string, relationshipId: string): {
|
|
50
|
+
readonly target: string;
|
|
51
|
+
readonly external: boolean;
|
|
52
|
+
readonly sinkSafe?: boolean;
|
|
53
|
+
} | null;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The document metadata Word's document-property fields render.
|
|
57
|
+
*
|
|
58
|
+
* Every member is optional: an absent part, an absent element, or an empty value all read as
|
|
59
|
+
* `undefined`, and a field over a missing property paints nothing. Keys are engine-internal
|
|
60
|
+
* names; the field → property mapping (`TITLE` → `title`, `AUTHOR` → `creator`, …) lives in
|
|
61
|
+
* `layout/field-doc-property.ts`.
|
|
62
|
+
*/
|
|
63
|
+
interface DocumentProperties {
|
|
64
|
+
/** `dc:title` — TITLE. */
|
|
65
|
+
readonly title?: string;
|
|
66
|
+
/** `dc:creator` — AUTHOR. */
|
|
67
|
+
readonly creator?: string;
|
|
68
|
+
/** `dc:subject` — SUBJECT. */
|
|
69
|
+
readonly subject?: string;
|
|
70
|
+
/** `cp:keywords` — KEYWORDS. */
|
|
71
|
+
readonly keywords?: string;
|
|
72
|
+
/** `cp:lastModifiedBy` — LASTSAVEDBY. */
|
|
73
|
+
readonly lastModifiedBy?: string;
|
|
74
|
+
/** `dc:description` — COMMENTS. */
|
|
75
|
+
readonly description?: string;
|
|
76
|
+
/** `Company` from `docProps/app.xml`. No field maps to it yet; carried for completeness. */
|
|
77
|
+
readonly company?: string;
|
|
78
|
+
/** `Manager` from `docProps/app.xml`. No field maps to it yet; carried for completeness. */
|
|
79
|
+
readonly manager?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Theme typefaces already validated for use by layout. @public */
|
|
83
|
+
interface HeadlessThemeFonts {
|
|
84
|
+
readonly major: string | null;
|
|
85
|
+
readonly minor: string | null;
|
|
86
|
+
/** East Asian heading face; optional for backwards-compatible custom views. */
|
|
87
|
+
readonly majorEastAsia?: string | null;
|
|
88
|
+
/** East Asian body face; optional for backwards-compatible custom views. */
|
|
89
|
+
readonly minorEastAsia?: string | null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The read capabilities shared by browser layout, server export, and future renderers.
|
|
93
|
+
*
|
|
94
|
+
* It deliberately exposes resolved package facts rather than a binding or editor session.
|
|
95
|
+
* An exporter can therefore consume the live document without importing ProseMirror or a DOM.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
interface HeadlessDocumentView {
|
|
99
|
+
part(): OoxmlPart;
|
|
100
|
+
currentPackage(): OoxmlPackage;
|
|
101
|
+
packageRevision(): number;
|
|
102
|
+
stylesRoot(): OoxmlElement | null;
|
|
103
|
+
numberingRoot(): OoxmlElement | null;
|
|
104
|
+
settingsRoot(): OoxmlElement | null;
|
|
105
|
+
documentThemeFonts(): HeadlessThemeFonts;
|
|
106
|
+
documentProperties(): DocumentProperties;
|
|
107
|
+
headerFooterPartsBySection(): readonly HeaderFooterParts[];
|
|
108
|
+
/**
|
|
109
|
+
* Occurrence-specific relationship metadata for header/footer stories.
|
|
110
|
+
*
|
|
111
|
+
* Optional for backwards-compatible host views; core derives it from `currentPackage()` when
|
|
112
|
+
* absent. Hosts with a working-tree overlay should expose their canonical resolution directly.
|
|
113
|
+
*/
|
|
114
|
+
headerFooterResolutionBySection?(): readonly HeaderFooterSectionResolution[];
|
|
115
|
+
relationshipTarget(relationshipId: string): ReturnType<typeof relationshipTargetIn>;
|
|
116
|
+
}
|
|
117
|
+
/** A bad package is data, not an exceptional control path. @public */
|
|
118
|
+
type HeadlessDocumentRejection = OoxmlPackageRejection | 'no-main-document-tree';
|
|
119
|
+
/** Result of opening untrusted DOCX bytes for neutral layout. @public */
|
|
120
|
+
type OpenHeadlessDocumentResult = {
|
|
121
|
+
readonly ok: true;
|
|
122
|
+
readonly view: HeadlessDocumentView;
|
|
123
|
+
} | {
|
|
124
|
+
readonly ok: false;
|
|
125
|
+
readonly reason: HeadlessDocumentRejection;
|
|
126
|
+
readonly detail?: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Open DOCX bytes through the bounded store reader and expose only neutral layout reads.
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
declare function openHeadlessDocument(bytes: Uint8Array): OpenHeadlessDocumentResult;
|
|
133
|
+
|
|
134
|
+
export { type DocumentProperties as D, type EnsuredHyperlinkRelationship as E, type HeadlessDocumentView as H, type OpenHeadlessDocumentResult as O, type HeadlessDocumentRejection as a, type HeadlessThemeFonts as b, authorableHyperlinkTarget as c, ensureHyperlinkRelationship as e, openHeadlessDocument as o, relationshipTargetIn as r };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { O as OoxmlPart, a as OoxmlNode, c as OoxmlElement, b as OoxmlPackage } from './tree-op-types-egdarvH_.js';
|
|
2
|
+
|
|
3
|
+
/** `w:headerReference w:type` vocabulary (ECMA-376 §17.10.5): default, first page, even pages. */
|
|
4
|
+
type HeaderFooterVariant = 'default' | 'first' | 'even';
|
|
5
|
+
/** Header vs footer region kind for chrome and lifecycle ops. */
|
|
6
|
+
type HeaderFooterKind = 'header' | 'footer';
|
|
7
|
+
/**
|
|
8
|
+
* A section's resolved header and footer parts, by variant.
|
|
9
|
+
*
|
|
10
|
+
* The `even` variant is only honoured when `w:evenAndOddHeaders` is set in settings.xml —
|
|
11
|
+
* without it Word ignores an authored even header, and so does this.
|
|
12
|
+
*/
|
|
13
|
+
interface HeaderFooterParts {
|
|
14
|
+
readonly headers: ReadonlyMap<HeaderFooterVariant, OoxmlPart>;
|
|
15
|
+
readonly footers: ReadonlyMap<HeaderFooterVariant, OoxmlPart>;
|
|
16
|
+
/** `w:evenAndOddHeaders` in settings.xml — without it the `even` variant is ignored. */
|
|
17
|
+
readonly evenAndOddHeaders: boolean;
|
|
18
|
+
/** Whether this section enables first-page header/footer furniture (`w:titlePg`). */
|
|
19
|
+
readonly titlePage: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One resolved furniture slot with enough metadata for "Same as previous" chrome.
|
|
23
|
+
*
|
|
24
|
+
* `inherited: true` means this section has no declared reference for the slot and the
|
|
25
|
+
* part comes from a predecessor. The first section never reports inherited — omitting a
|
|
26
|
+
* ref there is blank furniture, not inheritance from a later section.
|
|
27
|
+
*/
|
|
28
|
+
interface HeaderFooterSlotMeta {
|
|
29
|
+
readonly part: OoxmlPart;
|
|
30
|
+
readonly partName: string;
|
|
31
|
+
readonly rId: string;
|
|
32
|
+
readonly inherited: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Per-section resolution including declared-vs-inherited metadata. */
|
|
35
|
+
interface HeaderFooterSectionResolution {
|
|
36
|
+
readonly headers: ReadonlyMap<HeaderFooterVariant, HeaderFooterSlotMeta>;
|
|
37
|
+
readonly footers: ReadonlyMap<HeaderFooterVariant, HeaderFooterSlotMeta>;
|
|
38
|
+
readonly evenAndOddHeaders: boolean;
|
|
39
|
+
readonly titlePage: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `w:sectPr` nodes in section order, aligned with layout's `enumerateDocumentSections`.
|
|
43
|
+
*
|
|
44
|
+
* `null` means a section with no `w:sectPr` node (Word defaults, inherits HF from previous).
|
|
45
|
+
* Paragraph-level breaks first; the final entry covers remaining blocks (body-level or null).
|
|
46
|
+
*/
|
|
47
|
+
declare function collectSectionPropertyNodes(root: OoxmlNode): Array<OoxmlElement | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve header/footer parts for every section with declared-vs-inherited metadata.
|
|
50
|
+
*
|
|
51
|
+
* Index aligns with `enumerateDocumentSections` in the layout package. Existing merged
|
|
52
|
+
* maps stay available via {@link resolveHeaderFooterPartsBySection}.
|
|
53
|
+
*/
|
|
54
|
+
declare function resolveHeaderFooterResolutionBySection(pkg: OoxmlPackage): readonly HeaderFooterSectionResolution[];
|
|
55
|
+
/**
|
|
56
|
+
* Resolve header/footer parts for every section, applying OOXML inheritance.
|
|
57
|
+
*
|
|
58
|
+
* Index aligns with `enumerateDocumentSections` in the layout package.
|
|
59
|
+
*/
|
|
60
|
+
declare function resolveHeaderFooterPartsBySection(pkg: OoxmlPackage): readonly HeaderFooterParts[];
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the main-document header/footer references to their parts, gated by the
|
|
63
|
+
* settings the section actually declares.
|
|
64
|
+
*
|
|
65
|
+
* Returns the FINAL section's effective parts (after inheritance). Multi-section hosts
|
|
66
|
+
* should prefer `resolveHeaderFooterPartsBySection`.
|
|
67
|
+
*/
|
|
68
|
+
declare function resolveHeaderFooterParts(pkg: OoxmlPackage): HeaderFooterParts;
|
|
69
|
+
|
|
70
|
+
export { type HeaderFooterVariant as H, type HeaderFooterParts as a, type HeaderFooterSectionResolution as b, type HeaderFooterKind as c, type HeaderFooterSlotMeta as d, collectSectionPropertyNodes as e, resolveHeaderFooterPartsBySection as f, resolveHeaderFooterResolutionBySection as g, resolveHeaderFooterParts as r };
|