@docx-editor.dev/core 2.13.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.cts +3 -3
- package/dist/automation.d.ts +3 -3
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +4 -4
- package/dist/binding.d.ts +4 -4
- package/dist/binding.js +1 -1
- package/dist/{chunk-PFSJVAWJ.cjs → chunk-2PIHW2QM.cjs} +1 -1
- package/dist/chunk-2QTY5S6T.js +1 -0
- package/dist/chunk-4Z5MODAE.cjs +2 -0
- package/dist/{chunk-WANKXD34.cjs → chunk-5TKAPFZT.cjs} +1 -1
- package/dist/chunk-DRQHIQ4R.cjs +1 -0
- package/dist/chunk-F2K6SDHA.cjs +20 -0
- package/dist/chunk-FBA57EUJ.js +2 -0
- package/dist/{chunk-67S7OHE6.cjs → chunk-KIAP7PFQ.cjs} +1 -1
- package/dist/chunk-KTAQ7BRQ.js +20 -0
- package/dist/chunk-LBAHXZCU.cjs +5 -0
- package/dist/chunk-MCDUQYWP.js +5 -0
- package/dist/chunk-MQP26KCF.js +1 -0
- package/dist/chunk-NDJGSR6M.cjs +19 -0
- package/dist/chunk-NJNFJPGB.cjs +11 -0
- package/dist/chunk-O5M4CR4P.cjs +2 -0
- package/dist/{chunk-HWWHGREA.js → chunk-OKEDGR65.js} +1 -1
- package/dist/chunk-UKUOZXUD.js +19 -0
- package/dist/chunk-VQ4R5LTU.js +2 -0
- package/dist/chunk-ZBEJHJN2.js +11 -0
- package/dist/{chunk-PRIBU3UH.js → chunk-ZVTW7RGD.js} +1 -1
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.cts +1 -1
- package/dist/collaboration/replication.d.ts +1 -1
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.cts +1 -1
- package/dist/collaboration.d.ts +1 -1
- package/dist/contracts/editor.d.cts +4 -4
- package/dist/contracts/editor.d.ts +4 -4
- package/dist/contracts/interaction.d.cts +4 -4
- package/dist/contracts/interaction.d.ts +4 -4
- package/dist/contracts/modules.d.cts +2 -2
- package/dist/contracts/modules.d.ts +2 -2
- package/dist/{editor-DLrTueVe.d.cts → editor-AJ06hyyg.d.cts} +26 -2
- package/dist/{editor-KiB6JNvk.d.ts → editor-a6VvsfYU.d.ts} +26 -2
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.cts +15 -15
- package/dist/editor.d.ts +15 -15
- package/dist/editor.js +1 -1
- package/dist/{index-D4Pxdo_p.d.ts → index-C5ZnSRkF.d.ts} +49 -15
- package/dist/{index-D_PA2Xv6.d.cts → index-Cbw4lkOt.d.cts} +49 -15
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +36 -86
- package/dist/layout.d.ts +36 -86
- package/dist/layout.js +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +4 -4
- package/dist/output.d.ts +4 -4
- package/dist/output.js +1 -1
- package/dist/{protocol-DjgYKCAy.d.ts → protocol-BsmQgblT.d.ts} +1 -1
- package/dist/{protocol-C8L58j66.d.cts → protocol-gOY5GA8K.d.cts} +1 -1
- package/dist/{review-reads-DcGYCH0w.d.ts → review-reads-BjZYeMd4.d.ts} +6 -19
- package/dist/{review-reads-BrTDmoYH.d.cts → review-reads-DEsV0OOW.d.cts} +6 -19
- package/dist/{revision-projection-BmLtLPxH.d.ts → revision-projection-BeXVrSSV.d.ts} +23 -2
- package/dist/{revision-projection-Dknlar93.d.cts → revision-projection-DXbrfNGD.d.cts} +23 -2
- package/dist/{semantic-cell-selection-BZ50i-Fu.d.ts → semantic-cell-selection-BK91NCCG.d.ts} +15 -6
- package/dist/{semantic-cell-selection-COnfaOZO.d.cts → semantic-cell-selection-BMhku3B1.d.cts} +15 -6
- package/dist/{semantic-interaction-BDJ4TBjm.d.ts → semantic-interaction-BmQ7h2cq.d.ts} +1 -1
- package/dist/{semantic-interaction-Bq3ixB0I.d.cts → semantic-interaction-DUAnxbgf.d.cts} +1 -1
- package/dist/{semantic-paint-C5SMTO8Y.d.cts → semantic-paint-DufNL1Zr.d.cts} +1 -1
- package/dist/{semantic-paint-DuhhY5-R.d.ts → semantic-paint-WJD2KeG1.d.ts} +1 -1
- package/dist/{semantic-records-BI1jpft7.d.ts → semantic-records-92UnKeU_.d.ts} +546 -5
- package/dist/{semantic-records-Btw3Ao4v.d.cts → semantic-records-BpozY7-j.d.cts} +546 -5
- package/dist/shaped-measurer-BWbindlI.d.ts +168 -0
- package/dist/shaped-measurer-CFPnXFs9.d.cts +168 -0
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +14 -7
- package/dist/store.d.ts +14 -7
- package/dist/store.js +1 -1
- package/dist/{tree-package-fragment-B1supBtE.d.ts → tree-package-fragment-CWFjgH6a.d.ts} +1 -9
- package/dist/{tree-package-fragment-ByN5yzll.d.cts → tree-package-fragment-Dhyw7oPm.d.cts} +1 -9
- package/dist/{tree-session-contract-BasiwZgZ.d.ts → tree-session-contract-B2HfGt79.d.ts} +6 -2
- package/dist/{tree-session-contract-DbeBenMR.d.cts → tree-session-contract-BY9xd7s_.d.cts} +6 -2
- package/package.json +2 -2
- package/dist/chunk-3AT4RUQ3.cjs +0 -19
- package/dist/chunk-4NAQLFXA.cjs +0 -2
- package/dist/chunk-BHAUFJO6.js +0 -20
- package/dist/chunk-F7U4OLMS.cjs +0 -2
- package/dist/chunk-FNMXRLGW.cjs +0 -5
- package/dist/chunk-I36WS6XX.cjs +0 -20
- package/dist/chunk-IOTL2GGW.js +0 -1
- package/dist/chunk-OF2QZCTN.js +0 -19
- package/dist/chunk-RO3HFCML.js +0 -5
- package/dist/chunk-SFOUCTKA.js +0 -2
- package/dist/chunk-VBEKERLJ.js +0 -2
- package/dist/chunk-XETEMUIP.cjs +0 -11
- package/dist/chunk-YMW34EBA.js +0 -11
- package/dist/shaped-measurer-CqdYa0fa.d.cts +0 -619
- package/dist/shaped-measurer-qnBJziPx.d.ts +0 -619
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
import { R as ResolvedRunStyle, T as TextMeasurer } from './semantic-records-Btw3Ao4v.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A face, as something asks for it: family plus the two axes this engine admits.
|
|
5
|
-
*
|
|
6
|
-
* Only static weights and slants. Variable-font axes are deliberately outside this vocabulary —
|
|
7
|
-
* the shaper refuses variation axes, and a variable file admitted here would render bold at
|
|
8
|
-
* regular weight.
|
|
9
|
-
*/
|
|
10
|
-
interface FontRequest {
|
|
11
|
-
readonly family: string;
|
|
12
|
-
readonly weight: number;
|
|
13
|
-
readonly style: 'normal' | 'italic';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A request that was answered by a DIFFERENT face than the one asked for.
|
|
17
|
-
*
|
|
18
|
-
* Recorded rather than silently applied, because a substitution changes measurement: it is part
|
|
19
|
-
* of the shaping fingerprint, so a cached run shaped against a substitute is never reused for the
|
|
20
|
-
* real face.
|
|
21
|
-
*/
|
|
22
|
-
interface FontSubstitution {
|
|
23
|
-
readonly requested: FontRequest;
|
|
24
|
-
readonly resolved: FontRequest;
|
|
25
|
-
readonly lineMetrics?: {
|
|
26
|
-
readonly heightEm: number;
|
|
27
|
-
readonly baselineEm: number;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
declare const RESOLVED_FONT_BRAND: unique symbol;
|
|
31
|
-
/**
|
|
32
|
-
* A face that passed admission: the bytes are present, within limits, hash-verified, and parse as
|
|
33
|
-
* a font.
|
|
34
|
-
*
|
|
35
|
-
* Branded, so a `ResolvedFont` cannot be constructed by an object literal. Holding one is proof
|
|
36
|
-
* the checks ran — which is what lets shaping skip re-validating on every call.
|
|
37
|
-
*/
|
|
38
|
-
interface ResolvedFont {
|
|
39
|
-
readonly [RESOLVED_FONT_BRAND]: true;
|
|
40
|
-
readonly id: string;
|
|
41
|
-
readonly identity: string;
|
|
42
|
-
readonly request: FontRequest;
|
|
43
|
-
readonly family: string;
|
|
44
|
-
/** Owned byte length, available without creating a defensive byte copy. */
|
|
45
|
-
readonly byteLength: number;
|
|
46
|
-
readonly bytes: Uint8Array;
|
|
47
|
-
readonly hash: string;
|
|
48
|
-
readonly faceIndex: number;
|
|
49
|
-
readonly substitution: FontSubstitution | null;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Largest single face this engine will ever admit, whatever a caller configures.
|
|
53
|
-
*
|
|
54
|
-
* A CEILING, not a default: a host may set a smaller `maxFontBytes`, but nothing can raise it
|
|
55
|
-
* past this. Font bytes come from files, and an unbounded face is a memory-exhaustion vector.
|
|
56
|
-
*/
|
|
57
|
-
declare const HARD_MAX_FONT_BYTES: number;
|
|
58
|
-
/** Most faces one snapshot may hold, whatever a caller configures. */
|
|
59
|
-
declare const HARD_MAX_FONT_SOURCES = 256;
|
|
60
|
-
/** Most bytes all admitted faces may total, whatever a caller configures. */
|
|
61
|
-
declare const HARD_MAX_AGGREGATE_FONT_BYTES: number;
|
|
62
|
-
/**
|
|
63
|
-
* Why a face was not admitted.
|
|
64
|
-
*
|
|
65
|
-
* `forbidden` and `hashMismatch` are adversarial signals rather than ordinary failures: the first
|
|
66
|
-
* is a face the host declared off-limits, the second is bytes that are not what their source
|
|
67
|
-
* claimed.
|
|
68
|
-
*/
|
|
69
|
-
type FontResolutionErrorCode = 'missing' | 'forbidden' | 'overLimit' | 'malformed' | 'hashMismatch';
|
|
70
|
-
/**
|
|
71
|
-
* A face that could not be admitted, carrying whatever evidence the refusal produced.
|
|
72
|
-
*
|
|
73
|
-
* RETURNED rather than thrown by `FontResourceSnapshot.resolve`, because a missing face is an
|
|
74
|
-
* ordinary condition — layout falls back and carries on. It extends `Error` so a caller that
|
|
75
|
-
* would rather throw can.
|
|
76
|
-
*/
|
|
77
|
-
declare class FontResolutionError extends Error {
|
|
78
|
-
readonly name = "FontResolutionError";
|
|
79
|
-
readonly request: FontRequest;
|
|
80
|
-
readonly code: FontResolutionErrorCode;
|
|
81
|
-
readonly limit?: number;
|
|
82
|
-
readonly actual?: number;
|
|
83
|
-
readonly diagnostic?: string;
|
|
84
|
-
readonly expectedHash?: string;
|
|
85
|
-
readonly actualHash?: string;
|
|
86
|
-
constructor(code: FontResolutionErrorCode, request: FontRequest, details?: {
|
|
87
|
-
readonly limit?: number;
|
|
88
|
-
readonly actual?: number;
|
|
89
|
-
readonly diagnostic?: string;
|
|
90
|
-
readonly expectedHash?: string;
|
|
91
|
-
readonly actualHash?: string;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* One face offered to a snapshot, before admission.
|
|
96
|
-
*
|
|
97
|
-
* `hash` is checked against the bytes, so a source cannot claim a face it did not supply. Setting
|
|
98
|
-
* `availability` to `forbidden` declares a face that exists but must not be used, which resolves
|
|
99
|
-
* as a typed refusal rather than as "missing".
|
|
100
|
-
*/
|
|
101
|
-
interface FontResourceDefinition {
|
|
102
|
-
readonly request: FontRequest;
|
|
103
|
-
readonly id: string;
|
|
104
|
-
readonly bytes: Uint8Array;
|
|
105
|
-
readonly hash: string;
|
|
106
|
-
readonly faceIndex: number;
|
|
107
|
-
readonly availability?: 'available' | 'forbidden';
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* A host-declared redirect: requests for `from` resolve to `to`.
|
|
111
|
-
*
|
|
112
|
-
* How a metric-compatible substitute is wired in — a document naming Calibri resolves to Carlito
|
|
113
|
-
* without the document being rewritten.
|
|
114
|
-
*/
|
|
115
|
-
interface DeclaredFontSubstitution {
|
|
116
|
-
readonly from: FontRequest;
|
|
117
|
-
readonly to: FontRequest;
|
|
118
|
-
readonly lineMetrics?: {
|
|
119
|
-
readonly heightEm: number;
|
|
120
|
-
readonly baselineEm: number;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/** Whether bytes parse as a usable font, with a diagnostic when they do not. */
|
|
124
|
-
type FontValidationResult = {
|
|
125
|
-
readonly valid: true;
|
|
126
|
-
} | {
|
|
127
|
-
readonly valid: false;
|
|
128
|
-
readonly diagnostic: string;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* The injected check that bytes really are a font.
|
|
132
|
-
*
|
|
133
|
-
* Injected because it is the shaper that knows — HarfBuzz can open a face and read its tables,
|
|
134
|
-
* and this layer must not duplicate that judgement. Every byte reaching it is file input.
|
|
135
|
-
*/
|
|
136
|
-
type FontByteValidator = (bytes: Uint8Array, faceIndex: number) => FontValidationResult;
|
|
137
|
-
/**
|
|
138
|
-
* An immutable set of admitted faces, and the only way to reach one.
|
|
139
|
-
*
|
|
140
|
-
* `epoch` identifies the snapshot: fonts change by REPLACING it, never by mutation, so a layout
|
|
141
|
-
* pass holds one snapshot for its whole run and cannot observe a face appearing or vanishing
|
|
142
|
-
* midway.
|
|
143
|
-
*/
|
|
144
|
-
interface FontResourceSnapshot {
|
|
145
|
-
readonly epoch: number;
|
|
146
|
-
/** The admitted face, or a typed refusal. Never throws. */
|
|
147
|
-
resolve(request: FontRequest): ResolvedFont | FontResolutionError;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* How a snapshot is built: which faces, under what limits, validated how.
|
|
151
|
-
*
|
|
152
|
-
* `maxFontBytes` is clamped to {@link HARD_MAX_FONT_BYTES} — a caller may tighten the budget but
|
|
153
|
-
* never widen it past the engine's own ceiling.
|
|
154
|
-
*/
|
|
155
|
-
interface FontResourceSnapshotOptions {
|
|
156
|
-
readonly epoch: number;
|
|
157
|
-
readonly maxFontBytes: number;
|
|
158
|
-
readonly resources: readonly FontResourceDefinition[];
|
|
159
|
-
readonly substitutions?: readonly DeclaredFontSubstitution[];
|
|
160
|
-
readonly validateFont: FontByteValidator;
|
|
161
|
-
readonly instrumentation?: FontResourceInstrumentation;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Optional counters for the operations font admission is expected to do RARELY.
|
|
165
|
-
*
|
|
166
|
-
* Exists so tests can assert the absence of work: hashing and byte-copying a 64 MB face on every
|
|
167
|
-
* resolve would not be visible in output, only in a stalled document, so the checks assert these
|
|
168
|
-
* fire once rather than per call.
|
|
169
|
-
*/
|
|
170
|
-
interface FontResourceInstrumentation {
|
|
171
|
-
readonly onOwnedByteCopy?: () => void;
|
|
172
|
-
readonly onHash?: () => void;
|
|
173
|
-
readonly onTableScan?: () => void;
|
|
174
|
-
readonly onAdmission?: () => void;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* The canonical string identifying one face request.
|
|
178
|
-
*
|
|
179
|
-
* Case- and whitespace-normalized, so `"Times New Roman"` and `"times new roman"` are one key —
|
|
180
|
-
* a document may name a family either way and both must reach the same face.
|
|
181
|
-
*/
|
|
182
|
-
declare const fontRequestKey: (request: FontRequest) => string;
|
|
183
|
-
/** Bounded minimum sfnt/TTC check; Task 4 supplies full parser-backed validation. */
|
|
184
|
-
declare const boundedStructuralFontValidator: FontByteValidator;
|
|
185
|
-
/**
|
|
186
|
-
* Admit a set of faces and return the immutable snapshot layout resolves against.
|
|
187
|
-
*
|
|
188
|
-
* Admission is the trust boundary for font bytes: counts and sizes are checked against the hard
|
|
189
|
-
* ceilings, each face's hash is re-derived and compared, and the bytes are handed to the injected
|
|
190
|
-
* validator. A face failing any of these is recorded as a typed refusal rather than dropped, so
|
|
191
|
-
* `resolve` can explain itself instead of answering "missing".
|
|
192
|
-
*/
|
|
193
|
-
declare const createFontResourceSnapshot: (options: FontResourceSnapshotOptions) => FontResourceSnapshot;
|
|
194
|
-
|
|
195
|
-
declare const FIXED_POINT: unique symbol;
|
|
196
|
-
/** Fixed-point coordinates are safe integers in units declared by ShapingEnvironment.fixedPointScale. */
|
|
197
|
-
type FixedPoint = number & {
|
|
198
|
-
readonly [FIXED_POINT]: true;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Brand a safe integer as a {@link FixedPoint} coordinate.
|
|
202
|
-
*
|
|
203
|
-
* Fixed point rather than float throughout shaping so that two runs shaped identically compare
|
|
204
|
-
* EQUAL — float accumulation would make the same text measure differently depending on how it was
|
|
205
|
-
* split, and pagination is decided on those measurements.
|
|
206
|
-
*
|
|
207
|
-
* @throws RangeError when the value is not a safe integer.
|
|
208
|
-
*/
|
|
209
|
-
declare const fixedPoint: (value: number) => FixedPoint;
|
|
210
|
-
/** Which way a run reads. The parity projection of its bidi embedding level. */
|
|
211
|
-
type TextDirection = 'ltr' | 'rtl';
|
|
212
|
-
/** How fixed-point conversion breaks ties. Part of the shaping fingerprint. */
|
|
213
|
-
type FixedPointRoundingMode = 'halfAwayFromZero' | 'halfToEven' | 'towardZero';
|
|
214
|
-
/** Which Unicode normalization is applied before shaping, if any. */
|
|
215
|
-
type NormalizationPolicy = 'none' | 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
|
|
216
|
-
/**
|
|
217
|
-
* The shaping library and its exact version.
|
|
218
|
-
*
|
|
219
|
-
* Versioned because a library upgrade can change glyph positioning, and a cached measurement
|
|
220
|
-
* taken under the old one must not be reused under the new one.
|
|
221
|
-
*/
|
|
222
|
-
interface VersionedShapingLibrary {
|
|
223
|
-
readonly name: string;
|
|
224
|
-
readonly version: string;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Everything that determines how text shapes — the complete input to a
|
|
228
|
-
* {@link ShapingEnvironment}.
|
|
229
|
-
*
|
|
230
|
-
* Exhaustive on purpose. Any field that could change a glyph's position belongs here, because the
|
|
231
|
-
* environment's fingerprint is what decides whether a cached shaped run may be reused.
|
|
232
|
-
*/
|
|
233
|
-
interface ShapingEnvironmentInput {
|
|
234
|
-
readonly font: ResolvedFont;
|
|
235
|
-
readonly variationAxes: Readonly<Record<string, number>>;
|
|
236
|
-
readonly shapingLibrary: VersionedShapingLibrary;
|
|
237
|
-
readonly unicodeDataVersion: string;
|
|
238
|
-
readonly normalization: NormalizationPolicy;
|
|
239
|
-
readonly script: string;
|
|
240
|
-
readonly language: string;
|
|
241
|
-
readonly direction: TextDirection;
|
|
242
|
-
readonly features: Readonly<Record<string, number>>;
|
|
243
|
-
readonly fallbackOrder: readonly ResolvedFont[];
|
|
244
|
-
readonly fixedPointScale: number;
|
|
245
|
-
readonly roundingMode: FixedPointRoundingMode;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* A validated {@link ShapingEnvironmentInput} — build one with `createShapingEnvironment`.
|
|
249
|
-
*
|
|
250
|
-
* Structurally identical to its input, but the nominal distinction is the point: holding one
|
|
251
|
-
* means the tags, axes and fonts inside it have already been checked.
|
|
252
|
-
*/
|
|
253
|
-
interface ShapingEnvironment extends ShapingEnvironmentInput {
|
|
254
|
-
}
|
|
255
|
-
/** One shaping call: the text, its size, its bidi level, and the environment to shape it in. */
|
|
256
|
-
interface ShapeInput {
|
|
257
|
-
readonly text: string;
|
|
258
|
-
readonly fontSizeHalfPoints: number;
|
|
259
|
-
/** Exact UAX #9 embedding/isolate level; direction is its parity projection. */
|
|
260
|
-
readonly bidiLevel: number;
|
|
261
|
-
readonly environment: ShapingEnvironment;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* One positioned glyph.
|
|
265
|
-
*
|
|
266
|
-
* `id` is a glyph index in its FACE, not a character — a ligature is one glyph spanning several
|
|
267
|
-
* characters, and a single character may produce several glyphs. Use `cluster` to get back to
|
|
268
|
-
* text.
|
|
269
|
-
*/
|
|
270
|
-
interface ShapedGlyph {
|
|
271
|
-
readonly id: number;
|
|
272
|
-
/** UTF-16 text offset identifying the cluster that produced this glyph. */
|
|
273
|
-
readonly cluster: number;
|
|
274
|
-
/** Pen origin before this glyph's shaping offsets, in fixed-point run coordinates. */
|
|
275
|
-
readonly originX: FixedPoint;
|
|
276
|
-
readonly originY: FixedPoint;
|
|
277
|
-
readonly advanceX: FixedPoint;
|
|
278
|
-
readonly advanceY: FixedPoint;
|
|
279
|
-
readonly offsetX: FixedPoint;
|
|
280
|
-
readonly offsetY: FixedPoint;
|
|
281
|
-
/** Exact monochrome outline returned by the admitted HarfBuzz face. */
|
|
282
|
-
readonly outline: GlyphOutline;
|
|
283
|
-
}
|
|
284
|
-
/** A glyph's outline as SVG path data, in font design units. */
|
|
285
|
-
interface GlyphOutline {
|
|
286
|
-
readonly path: string;
|
|
287
|
-
/** Design units per em — divide by this to scale the path to a point size. */
|
|
288
|
-
readonly unitsPerEm: number;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* One cluster: the smallest indivisible text-to-glyph correspondence.
|
|
292
|
-
*
|
|
293
|
-
* The unit the CARET moves by. A cluster may be several characters (a ligature) or several glyphs
|
|
294
|
-
* (a decomposed mark), so neither a character index nor a glyph index is a valid caret position —
|
|
295
|
-
* `caretEdges` is, and it includes both endpoints.
|
|
296
|
-
*/
|
|
297
|
-
interface ShapedCluster {
|
|
298
|
-
/** Half-open logical UTF-16 range in ShapedRun.text. */
|
|
299
|
-
readonly textStart: number;
|
|
300
|
-
readonly textEnd: number;
|
|
301
|
-
/** Half-open visual glyph range in ShapedRun.glyphs. */
|
|
302
|
-
readonly glyphStart: number;
|
|
303
|
-
readonly glyphEnd: number;
|
|
304
|
-
readonly advance: FixedPoint;
|
|
305
|
-
/** Fixed-point edges from this cluster's visual origin, including both endpoints. */
|
|
306
|
-
readonly caretEdges: readonly FixedPoint[];
|
|
307
|
-
/** Index into ShapedRun.fontSpans, preserving the exact fallback choice. */
|
|
308
|
-
readonly fontSpan: number;
|
|
309
|
-
}
|
|
310
|
-
/** A run's vertical metrics, from the face that shaped it. Drives line height and baseline. */
|
|
311
|
-
interface ShapedVerticalMetrics {
|
|
312
|
-
readonly ascent: FixedPoint;
|
|
313
|
-
readonly descent: FixedPoint;
|
|
314
|
-
readonly lineGap: FixedPoint;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* A stretch of glyphs that came from ONE face.
|
|
318
|
-
*
|
|
319
|
-
* A run whose text needed fallback has several of these. Recording the exact face per span is
|
|
320
|
-
* what lets a re-shape reproduce the same result rather than re-running fallback selection and
|
|
321
|
-
* possibly choosing differently.
|
|
322
|
-
*/
|
|
323
|
-
interface ShapedFontSpan {
|
|
324
|
-
readonly glyphStart: number;
|
|
325
|
-
readonly glyphEnd: number;
|
|
326
|
-
readonly font: ResolvedFont;
|
|
327
|
-
/** null denotes the primary font; otherwise this is the environment fallback-order index. */
|
|
328
|
-
readonly fallbackIndex: number | null;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* One shaped run: text turned into positioned glyphs, with everything needed to measure it, paint
|
|
332
|
-
* it, and put a caret in it.
|
|
333
|
-
*
|
|
334
|
-
* The engine's measurement unit. Layout never measures characters — it measures these.
|
|
335
|
-
*/
|
|
336
|
-
interface ShapedRun {
|
|
337
|
-
readonly text: string;
|
|
338
|
-
readonly direction: TextDirection;
|
|
339
|
-
readonly bidiLevel: number;
|
|
340
|
-
readonly glyphs: readonly ShapedGlyph[];
|
|
341
|
-
readonly clusters: readonly ShapedCluster[];
|
|
342
|
-
readonly fontSpans: readonly ShapedFontSpan[];
|
|
343
|
-
readonly metrics: ShapedVerticalMetrics;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* A {@link ShapedRun} reduced to the fields two shaping results must agree on to be considered
|
|
347
|
-
* identical.
|
|
348
|
-
*
|
|
349
|
-
* Fonts appear as {@link FontFingerprintInputs} rather than whole `ResolvedFont` objects, so the
|
|
350
|
-
* comparison is over VALUES and does not depend on object identity — which is what makes it work
|
|
351
|
-
* across a reload or a worker boundary.
|
|
352
|
-
*/
|
|
353
|
-
interface ShapedRunComparatorInputs {
|
|
354
|
-
readonly text: string;
|
|
355
|
-
readonly direction: TextDirection;
|
|
356
|
-
readonly script: string;
|
|
357
|
-
readonly language: string;
|
|
358
|
-
readonly bidiLevel: number;
|
|
359
|
-
readonly glyphs: readonly ShapedGlyph[];
|
|
360
|
-
readonly clusters: readonly ShapedCluster[];
|
|
361
|
-
readonly fontSpans: readonly {
|
|
362
|
-
readonly glyphStart: number;
|
|
363
|
-
readonly glyphEnd: number;
|
|
364
|
-
readonly fallbackIndex: number | null;
|
|
365
|
-
readonly font: FontFingerprintInputs;
|
|
366
|
-
}[];
|
|
367
|
-
readonly metrics: ShapedVerticalMetrics;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* The one thing layout needs from a shaping backend.
|
|
371
|
-
*
|
|
372
|
-
* Injected rather than imported, which is what keeps layout DOM-free and testable: a fixed-metric
|
|
373
|
-
* shaper measures deterministically in a test, HarfBuzz measures for real in a browser, and
|
|
374
|
-
* layout cannot tell the difference.
|
|
375
|
-
*/
|
|
376
|
-
interface TextShaper {
|
|
377
|
-
shape(input: ShapeInput): ShapedRun;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* A font reduced to the values that identify it for fingerprinting.
|
|
381
|
-
*
|
|
382
|
-
* Includes the content `hash` and `faceIndex`, so two faces with the same family name but
|
|
383
|
-
* different bytes fingerprint differently — which is what stops a cached measurement being reused
|
|
384
|
-
* against a substituted face.
|
|
385
|
-
*/
|
|
386
|
-
interface FontFingerprintInputs {
|
|
387
|
-
readonly identity: string;
|
|
388
|
-
readonly id: string;
|
|
389
|
-
readonly family: string;
|
|
390
|
-
readonly request: FontRequest;
|
|
391
|
-
readonly hash: string;
|
|
392
|
-
readonly faceIndex: number;
|
|
393
|
-
readonly byteLength: number;
|
|
394
|
-
readonly substitution: FontSubstitution | null;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* A {@link ShapingEnvironment} reduced to comparable values.
|
|
398
|
-
*
|
|
399
|
-
* Records and axis maps become SORTED entry arrays, because two environments differing only in
|
|
400
|
-
* key insertion order must fingerprint the same — otherwise a cache would miss on a difference
|
|
401
|
-
* that changes no glyph.
|
|
402
|
-
*/
|
|
403
|
-
interface ShapingEnvironmentFingerprintInputs {
|
|
404
|
-
readonly font: FontFingerprintInputs;
|
|
405
|
-
readonly variationAxes: readonly (readonly [string, number])[];
|
|
406
|
-
readonly shapingLibrary: VersionedShapingLibrary;
|
|
407
|
-
readonly unicodeDataVersion: string;
|
|
408
|
-
readonly normalization: NormalizationPolicy;
|
|
409
|
-
readonly script: string;
|
|
410
|
-
readonly language: string;
|
|
411
|
-
readonly direction: TextDirection;
|
|
412
|
-
readonly features: readonly (readonly [string, number])[];
|
|
413
|
-
readonly fallbackOrder: readonly FontFingerprintInputs[];
|
|
414
|
-
readonly fixedPointScale: number;
|
|
415
|
-
readonly roundingMode: FixedPointRoundingMode;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Validate and freeze a shaping environment.
|
|
419
|
-
*
|
|
420
|
-
* Checks every field that could silently corrupt a measurement: OpenType tags must be four ASCII
|
|
421
|
-
* bytes, script and language must be non-blank and control-character free, fonts must already be
|
|
422
|
-
* validated. Throws rather than coercing — a bad tag that shapes anyway produces a document that
|
|
423
|
-
* measures wrong everywhere and looks fine.
|
|
424
|
-
*
|
|
425
|
-
* @throws TypeError on a malformed tag, name, or axis value.
|
|
426
|
-
*/
|
|
427
|
-
declare const createShapingEnvironment: (input: ShapingEnvironmentInput) => ShapingEnvironment;
|
|
428
|
-
/**
|
|
429
|
-
* Reduce an environment to its comparable form, with records sorted so key order cannot affect
|
|
430
|
-
* the result.
|
|
431
|
-
*/
|
|
432
|
-
declare const shapingEnvironmentFingerprintInputs: (input: ShapingEnvironmentInput) => ShapingEnvironmentFingerprintInputs;
|
|
433
|
-
/** Canonical serialization of every shaping variable, including byte hash and provenance. */
|
|
434
|
-
declare const shapingEnvironmentFingerprint: (environment: ShapingEnvironmentInput) => string;
|
|
435
|
-
/**
|
|
436
|
-
* Validate and freeze a shaped run against the environment that produced it.
|
|
437
|
-
*
|
|
438
|
-
* Checks the internal consistency a shaper must satisfy: direction matches the environment,
|
|
439
|
-
* cluster ranges tile the text without gaps or overlap, glyph ranges stay in bounds, font spans
|
|
440
|
-
* cover every glyph, and caret edges are monotonic. A shaper that violates any of these produces
|
|
441
|
-
* a caret that lands in the wrong place, which is far harder to diagnose downstream than here.
|
|
442
|
-
*
|
|
443
|
-
* @throws TypeError when the run and environment disagree, or the run is internally inconsistent.
|
|
444
|
-
*/
|
|
445
|
-
declare const createShapedRun: (input: ShapedRun, environmentInput: ShapingEnvironmentInput) => ShapedRun;
|
|
446
|
-
/**
|
|
447
|
-
* Reduce a shaped run to its comparable form, validating it on the way through.
|
|
448
|
-
*
|
|
449
|
-
* What the D9 determinism oracles compare: two shaping runs of the same text in the same
|
|
450
|
-
* environment must produce byte-identical structures here.
|
|
451
|
-
*/
|
|
452
|
-
declare const shapedRunComparatorInputs: (input: ShapedRun, environment: ShapingEnvironmentInput) => ShapedRunComparatorInputs;
|
|
453
|
-
|
|
454
|
-
/** Immutable per-operation environment. Configuration, extension, shaping, and producer changes are
|
|
455
|
-
* coarse gates; resource changes are compared through CacheProvenance.resourceDependencies. */
|
|
456
|
-
interface OperationSnapshot {
|
|
457
|
-
readonly resourceEpoch: number;
|
|
458
|
-
readonly configEpoch: number;
|
|
459
|
-
readonly extensionFingerprint: string;
|
|
460
|
-
readonly shapingHash: string;
|
|
461
|
-
readonly producerVersion: number;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* One resource a cached entry consumed, and the fingerprint it had at the time.
|
|
465
|
-
*
|
|
466
|
-
* Per-dependency rather than one global epoch, so updating one font does not evict entries that
|
|
467
|
-
* consumed a different, unchanged font.
|
|
468
|
-
*/
|
|
469
|
-
interface ResourceDependencyProvenance {
|
|
470
|
-
readonly key: string;
|
|
471
|
-
readonly fingerprint: string;
|
|
472
|
-
}
|
|
473
|
-
/** Everything recorded with a cache entry: the model revision (provenance only) + the fingerprints
|
|
474
|
-
* and snapshot that DO gate reuse. */
|
|
475
|
-
interface CacheProvenance extends OperationSnapshot {
|
|
476
|
-
/** Model revision the entry was computed at — provenance, NOT compared for reuse. */
|
|
477
|
-
readonly revision: number;
|
|
478
|
-
/** Fingerprint of the transitive dependency closure (see DependencyGraph.fingerprint). */
|
|
479
|
-
readonly dependencyFingerprint: string;
|
|
480
|
-
/** Fingerprint of the unit's own direct inputs (its content). */
|
|
481
|
-
readonly inputFingerprint: string;
|
|
482
|
-
/** Exact operation resources this entry consumed, sorted by key. */
|
|
483
|
-
readonly resourceDependencies: readonly ResourceDependencyProvenance[];
|
|
484
|
-
}
|
|
485
|
-
/** Why a lookup missed — for cache-instrumentation assertions. */
|
|
486
|
-
type CacheMiss = {
|
|
487
|
-
readonly hit: false;
|
|
488
|
-
readonly reason: 'absent';
|
|
489
|
-
} | {
|
|
490
|
-
readonly hit: false;
|
|
491
|
-
readonly reason: 'dependency-changed';
|
|
492
|
-
} | {
|
|
493
|
-
readonly hit: false;
|
|
494
|
-
readonly reason: 'input-changed';
|
|
495
|
-
} | {
|
|
496
|
-
readonly hit: false;
|
|
497
|
-
readonly reason: 'resource-changed';
|
|
498
|
-
readonly resourceKey: string;
|
|
499
|
-
} | {
|
|
500
|
-
readonly hit: false;
|
|
501
|
-
readonly reason: 'epoch-changed';
|
|
502
|
-
readonly epoch: keyof OperationSnapshot;
|
|
503
|
-
};
|
|
504
|
-
/**
|
|
505
|
-
* A cache probe: the value and its provenance on a hit, or the reason it missed.
|
|
506
|
-
*
|
|
507
|
-
* Misses are typed rather than merely absent, so a caller can tell a cold entry from one
|
|
508
|
-
* invalidated by a dependency change.
|
|
509
|
-
*/
|
|
510
|
-
type CacheLookup<V> = {
|
|
511
|
-
readonly hit: true;
|
|
512
|
-
readonly value: V;
|
|
513
|
-
readonly provenance: CacheProvenance;
|
|
514
|
-
} | CacheMiss;
|
|
515
|
-
/** Which field of an {@link OperationSnapshot} changed. */
|
|
516
|
-
type OperationSnapshotField = keyof OperationSnapshot;
|
|
517
|
-
/**
|
|
518
|
-
* Whether the environment is still the one an in-flight operation started under.
|
|
519
|
-
*
|
|
520
|
-
* `restart` names the fields that moved. A long layout pass whose fonts or configuration change
|
|
521
|
-
* midway must restart rather than finish against a mixture of both.
|
|
522
|
-
*/
|
|
523
|
-
type OperationSnapshotGuard = {
|
|
524
|
-
readonly status: 'current';
|
|
525
|
-
} | {
|
|
526
|
-
readonly status: 'restart';
|
|
527
|
-
readonly changed: readonly OperationSnapshotField[];
|
|
528
|
-
};
|
|
529
|
-
/** Capture, validate, and freeze the environment used throughout one derived operation. */
|
|
530
|
-
declare const captureOperationSnapshot: (source: OperationSnapshot) => OperationSnapshot;
|
|
531
|
-
/**
|
|
532
|
-
* Compare the current environment against the one an operation captured, naming what changed.
|
|
533
|
-
*/
|
|
534
|
-
declare const guardOperationSnapshot: (captured: OperationSnapshot, current: OperationSnapshot) => OperationSnapshotGuard;
|
|
535
|
-
/**
|
|
536
|
-
* The layout measurement cache, keyed by fingerprint rather than by revision.
|
|
537
|
-
*
|
|
538
|
-
* An entry may be reused ACROSS revisions: the model revision is recorded as PROVENANCE, not as
|
|
539
|
-
* an equality condition. Reuse is proven only when the transitive dependency fingerprint, the
|
|
540
|
-
* unit's own input fingerprint, and every non-model environment input all match — which is what
|
|
541
|
-
* lets an edit in one paragraph leave the rest of a long document measured.
|
|
542
|
-
*/
|
|
543
|
-
declare class ResolvedCache<V> {
|
|
544
|
-
private readonly entries;
|
|
545
|
-
/** Look up `key` against the CURRENT fingerprints + snapshot (revision excluded from the match).
|
|
546
|
-
* A hit proves the entry is unaffected; a miss names the reason (absent/dependency/input/epoch). */
|
|
547
|
-
get(key: string, want: Omit<CacheProvenance, 'revision'>): CacheLookup<V>;
|
|
548
|
-
/** Store a freshly computed entry with full provenance. */
|
|
549
|
-
set(key: string, value: V, provenance: CacheProvenance): void;
|
|
550
|
-
/** Drop entries produced against a stale operation epoch — restart affected work on an epoch
|
|
551
|
-
* change (8.3). Returns the number evicted. */
|
|
552
|
-
evictEpoch(current: OperationSnapshot): number;
|
|
553
|
-
/** Evict only entries whose consumed resource fingerprint changed at the new resource epoch. */
|
|
554
|
-
evictResources(current: OperationSnapshot, resourceFingerprints: ReadonlyMap<string, string>): number;
|
|
555
|
-
get size(): number;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* A fully resolved shaping bundle: fonts, shaper, and the environment they were admitted
|
|
560
|
-
* under. Produced by the editor lane's font configuration (`createLayoutShaping`) and
|
|
561
|
-
* consumed to build shaped measurers. Lived in the legacy `metrics.ts` until the legacy
|
|
562
|
-
* layout lane was deleted; the type is the surviving contract between the two lanes.
|
|
563
|
-
*/
|
|
564
|
-
interface LayoutShapingOptions {
|
|
565
|
-
readonly fonts: FontResourceSnapshot;
|
|
566
|
-
readonly shaper: TextShaper;
|
|
567
|
-
readonly defaultFont: {
|
|
568
|
-
readonly family: string;
|
|
569
|
-
readonly sizeHalfPoints: number;
|
|
570
|
-
};
|
|
571
|
-
readonly environment: {
|
|
572
|
-
readonly variationAxes: Readonly<Record<string, number>>;
|
|
573
|
-
readonly shapingLibrary: VersionedShapingLibrary;
|
|
574
|
-
readonly unicodeDataVersion: string;
|
|
575
|
-
readonly normalization: NormalizationPolicy;
|
|
576
|
-
readonly language: string;
|
|
577
|
-
readonly features: Readonly<Record<string, number>>;
|
|
578
|
-
readonly fixedPointScale: number;
|
|
579
|
-
readonly roundingMode: FixedPointRoundingMode;
|
|
580
|
-
};
|
|
581
|
-
readonly ligatureCaretPolicy: 'cluster-edges-only';
|
|
582
|
-
readonly operation: OperationSnapshot;
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* How the shaped measurer resolves fonts and bounds its work.
|
|
586
|
-
*
|
|
587
|
-
* Font resolution is the HOST's: returning null means "not available" and measurement falls back
|
|
588
|
-
* rather than throwing, because a document naming a font nobody has must still lay out.
|
|
589
|
-
*/
|
|
590
|
-
interface ShapedMeasurerOptions {
|
|
591
|
-
readonly shaper: TextShaper;
|
|
592
|
-
/**
|
|
593
|
-
* The font a run should be measured with.
|
|
594
|
-
*
|
|
595
|
-
* Returning null means "not available", and measurement falls back rather than throwing:
|
|
596
|
-
* a document naming a font nobody has must still lay out. Resolution is the host's,
|
|
597
|
-
* because which bytes stand in for `Calibri` is a packaging decision, not a layout one.
|
|
598
|
-
*/
|
|
599
|
-
readonly resolveFont: (style: ResolvedRunStyle) => ResolvedFont | null;
|
|
600
|
-
/** Used when no font resolves. */
|
|
601
|
-
readonly fallback: TextMeasurer;
|
|
602
|
-
readonly shapingLibrary: VersionedShapingLibrary;
|
|
603
|
-
readonly unicodeDataVersion: string;
|
|
604
|
-
/** Fixed-point units per point in the shaper's output. */
|
|
605
|
-
readonly fixedPointScale?: number;
|
|
606
|
-
/** ISO 15924 script and BCP 47 language for shaping. Latin/English by default. */
|
|
607
|
-
readonly script?: string;
|
|
608
|
-
readonly language?: string;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* A {@link TextMeasurer} that measures through the shaper rather than through a canvas.
|
|
612
|
-
*
|
|
613
|
-
* The accurate path: advances come from the same shaping run that will position the glyphs, so
|
|
614
|
-
* measurement and paint cannot disagree. Falls back per-run when a font is unavailable rather than
|
|
615
|
-
* throwing, because a document naming a font nobody has must still lay out.
|
|
616
|
-
*/
|
|
617
|
-
declare function createShapedMeasurer(options: ShapedMeasurerOptions): TextMeasurer;
|
|
618
|
-
|
|
619
|
-
export { shapingEnvironmentFingerprint as $, type ShapedRunComparatorInputs as A, type ShapedVerticalMetrics as B, type CacheLookup as C, type DeclaredFontSubstitution as D, type ShapingEnvironment as E, type FontByteValidator as F, type GlyphOutline as G, HARD_MAX_AGGREGATE_FONT_BYTES as H, type ShapingEnvironmentFingerprintInputs as I, type ShapingEnvironmentInput as J, boundedStructuralFontValidator as K, type LayoutShapingOptions as L, captureOperationSnapshot as M, type NormalizationPolicy as N, type OperationSnapshot as O, createFontResourceSnapshot as P, createShapedMeasurer as Q, ResolvedCache as R, type ShapedRun as S, type TextShaper as T, createShapedRun as U, type VersionedShapingLibrary as V, createShapingEnvironment as W, fixedPoint as X, fontRequestKey as Y, guardOperationSnapshot as Z, shapedRunComparatorInputs as _, type FixedPointRoundingMode as a, shapingEnvironmentFingerprintInputs as a0, type FixedPoint as b, type TextDirection as c, type CacheMiss as d, type CacheProvenance as e, type FontFingerprintInputs as f, type FontRequest as g, FontResolutionError as h, type FontResolutionErrorCode as i, type FontResourceDefinition as j, type FontResourceInstrumentation as k, type FontResourceSnapshot as l, type FontResourceSnapshotOptions as m, type FontSubstitution as n, type FontValidationResult as o, HARD_MAX_FONT_BYTES as p, HARD_MAX_FONT_SOURCES as q, type OperationSnapshotField as r, type OperationSnapshotGuard as s, type ResolvedFont as t, type ResourceDependencyProvenance as u, type ShapeInput as v, type ShapedCluster as w, type ShapedFontSpan as x, type ShapedGlyph as y, type ShapedMeasurerOptions as z };
|