rapier-markdown-kit 1.2.45 → 1.2.46

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.
Files changed (41) hide show
  1. package/LICENSE +12 -5
  2. package/README.md +131 -10
  3. package/dist/agent/vendor/BROWSER-ENTITIES.json +36 -0
  4. package/dist/agent/vendor/MARKDOWN-RUNTIME.json +136 -0
  5. package/dist/agent/vendor/MARKDOWNIT.json +582 -0
  6. package/dist/agent/vendor/NOTICE.txt +60 -0
  7. package/dist/agent/vendor/markdown-licenses/entities-LICENSE.txt +11 -0
  8. package/dist/agent/vendor/markdown-licenses/linkify-it-LICENSE.txt +22 -0
  9. package/dist/agent/vendor/markdown-licenses/markdown-it-LICENSE.txt +22 -0
  10. package/dist/agent/vendor/markdown-licenses/mdurl-LICENSE.txt +45 -0
  11. package/dist/agent/vendor/markdown-licenses/punycode.js-LICENSE-MIT.txt +20 -0
  12. package/dist/agent/vendor/markdown-licenses/uc.micro-LICENSE.txt +20 -0
  13. package/dist/agent/vendor/markdown-plugins.json +46 -0
  14. package/dist/agent/vendor/markdown-plugins.mjs +27 -0
  15. package/dist/agent/vendor/markdown-runtime.mjs +13 -0
  16. package/dist/kit/assets.d.mts +106 -0
  17. package/dist/kit/index.d.mts +151 -0
  18. package/dist/kit/layout.d.mts +61 -0
  19. package/dist/kit/ledger/carried.d.mts +12 -6
  20. package/dist/kit/ledger/carried.mjs +1 -1
  21. package/dist/kit/ledger/format.mjs +5 -3
  22. package/dist/kit/ledger/text-merge.mjs +33 -0
  23. package/dist/kit/ledger/transport.mjs +61 -2
  24. package/dist/kit/ledger.d.mts +137 -31
  25. package/dist/kit/markdown-it.d.mts +2 -2
  26. package/dist/kit/marks.d.mts +241 -0
  27. package/dist/kit/marks.mjs +39 -1
  28. package/dist/kit/model.d.mts +191 -0
  29. package/dist/kit/render-entry.d.mts +654 -0
  30. package/dist/kit/render.mjs +8 -7
  31. package/dist/kit/typography.d.mts +42 -0
  32. package/dist/kit/will.d.mts +26 -3
  33. package/dist/math/delimiters.mjs +38 -0
  34. package/dist/math/markdown-rules.mjs +103 -0
  35. package/dist/spec/document-fonts.mjs +2 -10
  36. package/dist/spec/md-assets.mjs +1 -0
  37. package/dist/spec/md-comments.mjs +384 -0
  38. package/dist/spec/md-marks.mjs +9 -0
  39. package/dist/spec/md-parser-config.mjs +463 -0
  40. package/dist/spec/md-parser-runtime.mjs +23 -0
  41. package/package.json +30 -8
@@ -0,0 +1,241 @@
1
+ // SPDX-License-Identifier: MIT
2
+ export {};
3
+ export interface MarkdownReference {href: string; title: string}
4
+ /** Plugins may add their own entries; known references retain their concrete shape. */
5
+ export interface MarkdownEnvironment {
6
+ references?: Record<string, MarkdownReference>;
7
+ [name: string | symbol]: unknown;
8
+ }
9
+ export interface MarkdownToken {
10
+ type: string;
11
+ tag: string;
12
+ nesting: -1 | 0 | 1;
13
+ attrs: [string, string | number][] | null;
14
+ map: [number, number] | null;
15
+ level: number;
16
+ children: MarkdownToken[] | null;
17
+ content: string;
18
+ markup: string;
19
+ info: string;
20
+ meta: Record<string, unknown> | null;
21
+ block: boolean;
22
+ hidden: boolean;
23
+ attrIndex(name: string): number;
24
+ attrPush(attr: [string, string | number]): void;
25
+ attrSet(name: string, value: string | number): void;
26
+ attrGet(name: string): string | number | null;
27
+ attrJoin(name: string, value: string | number): void;
28
+ }
29
+ export interface MarkdownOptions {
30
+ html?: boolean; xhtmlOut?: boolean; breaks?: boolean; langPrefix?: string;
31
+ linkify?: boolean; typographer?: boolean; quotes?: string | string[]; maxNesting?: number;
32
+ highlight?: ((source: string, language: string, attrs: string) => string) | null;
33
+ }
34
+ export interface MarkdownCoreState {
35
+ src: string;
36
+ env: MarkdownEnvironment;
37
+ tokens: MarkdownToken[];
38
+ inlineMode: boolean;
39
+ md: MarkdownParser;
40
+ }
41
+ export interface MarkdownInlineState {
42
+ src: string; env: MarkdownEnvironment; md: MarkdownParser; tokens: MarkdownToken[];
43
+ pos: number; posMax: number; level: number; pending: string; pendingLevel: number;
44
+ push(type: string, tag: string, nesting: -1 | 0 | 1): MarkdownToken;
45
+ pushPending(): MarkdownToken;
46
+ }
47
+ export interface MarkdownBlockState {
48
+ src: string; env: MarkdownEnvironment; md: MarkdownParser; tokens: MarkdownToken[];
49
+ bMarks: number[]; eMarks: number[]; tShift: number[]; sCount: number[]; bsCount: number[];
50
+ blkIndent: number; line: number; lineMax: number; tight: boolean; listIndent: number;
51
+ parentType: string; level: number;
52
+ push(type: string, tag: string, nesting: -1 | 0 | 1): MarkdownToken;
53
+ getLines(begin: number, end: number, indent: number, keepLastLF: boolean): string;
54
+ isEmpty(line: number): boolean;
55
+ }
56
+ // A parser may enrich these states. Rules receive the concrete state of their parser.
57
+ export type MarkdownCoreRule = {run(state: MarkdownCoreState): void}['run'];
58
+ export type MarkdownInlineRule = {run(state: MarkdownInlineState, silent: boolean): boolean}['run'];
59
+ export type MarkdownBlockRule = {run(state: MarkdownBlockState, start: number, end: number, silent: boolean): boolean}['run'];
60
+ export interface MarkdownRuler<Rule> {
61
+ /** Present on markdown-it at runtime; omitted by some upstream declaration versions. */
62
+ __rules__?: {name: string; fn: Rule; enabled: boolean; alt: string[]}[];
63
+ at(name: string, rule: Rule, options?: {alt: string[]}): void;
64
+ before(before: string, name: string, rule: Rule, options?: {alt: string[]}): void;
65
+ after(after: string, name: string, rule: Rule, options?: {alt: string[]}): void;
66
+ push(name: string, rule: Rule, options?: {alt: string[]}): void;
67
+ getRules(chain: string): Rule[];
68
+ }
69
+ export type MarkdownRenderRule = {render(tokens: MarkdownToken[], index: number, options: MarkdownOptions,
70
+ env: MarkdownEnvironment, renderer: MarkdownRenderer): string}['render'];
71
+ export interface MarkdownRenderer {
72
+ rules: Record<string, MarkdownRenderRule | undefined>;
73
+ rapierTransformHtml?(html: string): string;
74
+ renderToken(tokens: MarkdownToken[], index: number, options: MarkdownOptions): string;
75
+ renderInline(tokens: MarkdownToken[], options: MarkdownOptions, env: MarkdownEnvironment): string;
76
+ renderInlineAsText(tokens: MarkdownToken[], options: MarkdownOptions, env: MarkdownEnvironment): string;
77
+ render(tokens: MarkdownToken[], options: MarkdownOptions, env: MarkdownEnvironment): string;
78
+ }
79
+ /** The markdown-it instance hooks used by the portable kit. No parser package is required for these types. */
80
+ export interface MarkdownParser {
81
+ core: {ruler: MarkdownRuler<MarkdownCoreRule>};
82
+ inline: {
83
+ ruler: MarkdownRuler<MarkdownInlineRule>;
84
+ parse(source: string, parser: MarkdownParser, env: MarkdownEnvironment, tokens: MarkdownToken[]): void;
85
+ };
86
+ block: {ruler: MarkdownRuler<MarkdownBlockRule>};
87
+ renderer: MarkdownRenderer;
88
+ options: MarkdownOptions;
89
+ helpers: {
90
+ parseLinkDestination(source: string, start: number, end: number): {ok: boolean; pos: number; str: string};
91
+ parseLinkLabel(state: MarkdownInlineState, start: number, disableNested?: boolean): number;
92
+ };
93
+ utils: {unescapeAll(source: string): string; escapeHtml(source: string): string; normalizeReference(source: string): string};
94
+ validateLink(url: string): boolean;
95
+ normalizeLink(url: string): string;
96
+ parse(source: string, env: MarkdownEnvironment): MarkdownToken[];
97
+ parseInline(source: string, env: MarkdownEnvironment): MarkdownToken[];
98
+ render(source: string, env?: MarkdownEnvironment): string;
99
+ renderInline(source: string, env?: MarkdownEnvironment): string;
100
+ }
101
+ /** Direct parser-internal consumers require markdown-it's runtime state constructor and rule records. */
102
+ export interface MarkdownParserInternals extends MarkdownParser {
103
+ core: {ruler: MarkdownRuler<MarkdownCoreRule> & {__rules__: {name: string; fn: MarkdownCoreRule; enabled: boolean; alt: string[]}[]}};
104
+ inline: MarkdownParser['inline'] & {
105
+ State: new (source: string, parser: MarkdownParser, env: MarkdownEnvironment, tokens: MarkdownToken[]) => MarkdownInlineState;
106
+ ruler: MarkdownRuler<MarkdownInlineRule> & {__rules__: {name: string; fn: MarkdownInlineRule; enabled: boolean; alt: string[]}[]};
107
+ };
108
+ block: {ruler: MarkdownRuler<MarkdownBlockRule> & {__rules__: {name: string; fn: MarkdownBlockRule; enabled: boolean; alt: string[]}[]}};
109
+ }
110
+
111
+ export const TEXT_COLOR_NAMES: Readonly<{
112
+ green: '#1c7547'; red: '#b32034'; blue: '#175dc4'; gold: '#865818'; purple: '#7924d7';
113
+ }>;
114
+ export const PAGE_BREAK_MARKER: '<!--md-break:v1 page-->';
115
+ export interface FontStack {readonly stack: string; readonly css: string; readonly word: string}
116
+ export const FONT_STACKS: Readonly<Record<'sans' | 'serif' | 'mono' | 'system' | 'hand', FontStack>>;
117
+ export interface TypographyFamily {readonly name: string; readonly css: string; readonly custom: boolean}
118
+ export interface TypographySize {
119
+ readonly css: string;
120
+ readonly unit: 'pt' | 'px';
121
+ readonly value: number;
122
+ readonly points: number;
123
+ readonly halfPoints: number;
124
+ }
125
+ export interface TypographyStyle {
126
+ readonly size?: string;
127
+ readonly color?: string;
128
+ readonly family?: TypographyFamily;
129
+ }
130
+ export interface TypographyInput {size?: string; color?: string; family?: string | TypographyFamily}
131
+ export interface TypographyChanges {size?: string | null; color?: string | null; family?: string | TypographyFamily | null}
132
+ export interface NormalizedTypographyChanges {
133
+ readonly size?: string | null;
134
+ readonly color?: string | null;
135
+ readonly family?: TypographyFamily | null;
136
+ }
137
+ export interface TypographySourceRange {start: number; innerStart: number; innerEnd: number; end: number; style: TypographyStyle}
138
+ export interface TypographyRuns {text: string; paint: TypographyStyle[]; leaves: {start: number; end: number; blocked: boolean}[]}
139
+ export interface TypographyGrammar {
140
+ normalizeFontFamily(value: unknown): string | null;
141
+ fontFamilyCss(value: unknown): string;
142
+ FONT_STACKS: Readonly<Record<string, FontStack>>;
143
+ }
144
+ export interface InlineTypography {
145
+ size(value: unknown): TypographySize | null;
146
+ color(value: unknown): string | null;
147
+ family(value: unknown): TypographyFamily | null;
148
+ familyCss(value: unknown): TypographyFamily | null;
149
+ normalize(value: TypographyInput, removals?: false): TypographyStyle;
150
+ normalize(value: TypographyChanges, removals: true): NormalizedTypographyChanges;
151
+ normalize(value: TypographyInput, removals: boolean): TypographyStyle;
152
+ parseStyle(value: unknown, editable?: false): TypographyStyle;
153
+ parseStyle(value: unknown, editable: boolean): TypographyStyle | null;
154
+ style(value: TypographyInput): string;
155
+ open(value: TypographyInput): string;
156
+ wrap(value: TypographyInput, content: string): string;
157
+ parseOpen(source: string, decode?: (source: string) => string, editable?: boolean): TypographyStyle | null;
158
+ nodeStyle(node: Pick<Element, 'getAttribute'> | null | undefined): TypographyStyle;
159
+ runs(root: Node): TypographyRuns;
160
+ install<P extends MarkdownParser>(parser: P): P;
161
+ }
162
+ export function normalizeFontFamily(value: unknown): string | null;
163
+ export function fontFamilyCss(value: unknown): string;
164
+ export function formatFontRun(family: string, content: string): string;
165
+ export function formatColorRun(hex: string, content: string): string;
166
+ /** This factory configures inline source typography, not DOM paragraph refinement. */
167
+ export function createTypography(grammar: TypographyGrammar): Readonly<InlineTypography>;
168
+ export const typography: Readonly<InlineTypography>;
169
+ export function typographySourceRanges(source: string, parser: MarkdownParser): TypographySourceRange[];
170
+
171
+ export type InkKind = 'under' | 'strike' | 'ring' | 'bracket' | 'free' | 'arrow' | 'end';
172
+ export const INK_KINDS: readonly ['under', 'strike', 'ring', 'bracket', 'free', 'arrow', 'end'];
173
+ export const INK_CLOSE: '<!--/ink-->';
174
+ export const INK_PATH_MAX: 160;
175
+ export const INK_INT_MAX: 999999;
176
+ export const INK_OPEN_PATTERN: string;
177
+ export type InkPoint = readonly [number, number];
178
+ interface InkStroke {
179
+ hex?: string | null;
180
+ width?: number | null;
181
+ box?: InkPoint | null;
182
+ at?: InkPoint | null;
183
+ }
184
+ export type InkInput =
185
+ | (InkStroke & {kind: 'under' | 'strike'; id?: never; path?: readonly InkPoint[] | null})
186
+ | (InkStroke & {kind: 'ring' | 'bracket' | 'free'; id?: never; path: readonly [InkPoint, ...InkPoint[]]})
187
+ | (InkStroke & {kind: 'arrow'; id: number; path?: readonly InkPoint[] | null})
188
+ | {kind: 'end'; id: number; hex?: null; width?: null; box?: null; at?: null; path?: readonly [] | null};
189
+ interface ParsedInkStroke {
190
+ readonly hex: string | null;
191
+ readonly width?: number;
192
+ readonly box: [number, number] | null;
193
+ readonly at: [number, number] | null;
194
+ }
195
+ export type ParsedInk =
196
+ | (ParsedInkStroke & {readonly kind: 'under' | 'strike'; readonly id?: never; readonly path: [number, number][]})
197
+ | (ParsedInkStroke & {readonly kind: 'ring' | 'bracket' | 'free'; readonly id?: never; readonly path: [[number, number], ...[number, number][]]})
198
+ | (ParsedInkStroke & {readonly kind: 'arrow'; readonly id: number; readonly path: [number, number][]})
199
+ | {readonly kind: 'end'; readonly id: number; readonly hex: null; readonly width?: never;
200
+ readonly box: null; readonly at: null; readonly path: []};
201
+ export function readInkMatch(match: RegExpMatchArray): Readonly<ParsedInk> | null;
202
+ export function parseInkOpen(comment: string): Readonly<ParsedInk> | null;
203
+ export function parseInkBody(body: string): Readonly<ParsedInk> | null;
204
+ export function formatInkOpen(mark: InkInput): string;
205
+ export function formatInkRun(mark: InkInput, content: string): string;
206
+ export function matchInkOpen(text: string): {mark: Readonly<ParsedInk>; length: number} | null;
207
+ export function inkOpenBody(opener: string): string | null;
208
+ export function formatInkOpenFromBody(body: string): string | null;
209
+ export function isInkClose(comment: unknown): boolean;
210
+ export interface InkSourceView {
211
+ readonly length: number;
212
+ contains(value: string): boolean;
213
+ readSlice(start: number, end: number): string;
214
+ }
215
+ export interface InkEdit {pos: number; removed: string; inserted: string}
216
+ export function mayRetireInk(source: InkSourceView, rows: readonly InkEdit[]): boolean;
217
+ export type InkMarker =
218
+ | {start: number; end: number; mark: Readonly<ParsedInk>; close: false}
219
+ | {start: number; end: number; mark: null; close: true; arrowId?: number};
220
+ export interface InkRun {start: number; end: number; innerStart: number; innerEnd: number; mark: Readonly<ParsedInk>}
221
+ export interface InkSpanPairs {runs: InkRun[]; strays: InkMarker[]}
222
+ export interface InkArrow {
223
+ id: number;
224
+ tail: Omit<InkRun, 'mark'> & {mark: Extract<ParsedInk, {kind: 'arrow'}>};
225
+ head: Omit<InkRun, 'mark'> & {mark: Extract<ParsedInk, {kind: 'end'}>};
226
+ }
227
+ export interface InkPairs extends InkSpanPairs {arrows: InkArrow[]}
228
+ export function scanInkMarkers(source: string): InkMarker[];
229
+ export function pairInkMarkers(source: string, markers?: readonly InkMarker[] | null): InkPairs;
230
+ export function pairInkSpans(source: string, markers?: readonly InkMarker[] | null): InkSpanPairs;
231
+ export function pairMarkers(source: string, kind: 'ink', markers?: readonly InkMarker[] | null): InkPairs;
232
+ export function quotedWillSpan(source: string, spans: readonly (readonly [number, number])[]): {
233
+ start: number; end: number; where: 'fence' | 'raw-pre' | 'raw-div' | 'raw-table' | 'raw-html' | 'frontmatter';
234
+ } | null;
235
+ export function sliceInkArrows(source: string, start?: number, end?: number, markers?: readonly InkMarker[] | null): string;
236
+ export function prepareInkPaste(source: string, existing?: string, markers?: readonly InkMarker[] | null): string;
237
+ export function stripInkMarkers(text: string): string;
238
+ export function hasInkMarker(text: string): boolean;
239
+ export function formatPageBreak(): typeof PAGE_BREAK_MARKER;
240
+ export function isPageBreakLine(text: unknown): boolean;
241
+ export function isPageBreakBlock(text: unknown): boolean;
@@ -1,2 +1,40 @@
1
1
  // SPDX-License-Identifier: MIT
2
- export * from '../spec/md-marks.mjs';
2
+ export {
3
+ FONT_STACKS,
4
+ INK_CLOSE,
5
+ INK_INT_MAX,
6
+ INK_KINDS,
7
+ INK_OPEN_PATTERN,
8
+ INK_PATH_MAX,
9
+ PAGE_BREAK_MARKER,
10
+ TEXT_COLOR_NAMES,
11
+ createTypography,
12
+ fontFamilyCss,
13
+ formatColorRun,
14
+ formatFontRun,
15
+ formatInkOpen,
16
+ formatInkOpenFromBody,
17
+ formatInkRun,
18
+ formatPageBreak,
19
+ hasInkMarker,
20
+ inkOpenBody,
21
+ isInkClose,
22
+ isPageBreakBlock,
23
+ isPageBreakLine,
24
+ matchInkOpen,
25
+ mayRetireInk,
26
+ normalizeFontFamily,
27
+ pairInkMarkers,
28
+ pairInkSpans,
29
+ pairMarkers,
30
+ parseInkBody,
31
+ parseInkOpen,
32
+ prepareInkPaste,
33
+ quotedWillSpan,
34
+ readInkMatch,
35
+ scanInkMarkers,
36
+ sliceInkArrows,
37
+ stripInkMarkers,
38
+ typography,
39
+ typographySourceRanges
40
+ } from '../spec/md-marks.mjs';
@@ -0,0 +1,191 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import type {Layout} from './layout.mjs';
3
+ export {};
4
+
5
+ export interface RichTextItem {
6
+ text: string;
7
+ font: string;
8
+ letterSpacing?: number;
9
+ extraWidth?: number;
10
+ break?: 'normal' | 'never';
11
+ hyphenate?: boolean;
12
+ width?: never;
13
+ }
14
+ export interface RichBoxItem {width: number; text?: never}
15
+ export type RichItem = RichTextItem | RichBoxItem;
16
+ export interface PreparationOptions {
17
+ whiteSpace?: 'normal' | 'pre-wrap';
18
+ wordBreak?: 'normal' | 'keep-all';
19
+ language?: string;
20
+ policy?: 'wrap' | 'paragraph';
21
+ hanging?: boolean;
22
+ paragraphBreaks?: readonly number[] | null;
23
+ }
24
+ declare const preparedInline: unique symbol;
25
+ declare const preparedParagraph: unique symbol;
26
+ /** Opaque measured source. Retain the handle rather than cloning or serializing it. */
27
+ export interface PreparedRichParagraph {readonly [preparedInline]: true}
28
+ /** Paragraph-fit geometry is distinct from the inline engine's handle. */
29
+ export interface ParagraphGeometry {readonly [preparedParagraph]: true}
30
+ export type PreparedHandle = PreparedRichParagraph | ParagraphGeometry;
31
+ type WrapPreparation = PreparationOptions & {policy?: 'wrap'};
32
+ type ParagraphPreparation = PreparationOptions & {policy: 'paragraph'};
33
+ /** Cancellation with return() publishes no handle or plan. */
34
+ export interface PreparationWork<T> extends IterableIterator<void, T | null | undefined, void> {
35
+ return(value?: T | null): IteratorReturnResult<T | null | undefined>;
36
+ }
37
+ export type PreparationSteps = PreparationWork<PreparedHandle>;
38
+ export interface FitWidthRequest {segment: number; word: number; from: number; to: number}
39
+ export type ReadKnownWidth = (request: FitWidthRequest) => number | undefined;
40
+ export type FitWork<P> = Generator<FitWidthRequest | null, P | null, number | undefined>;
41
+ export type FrozenFitPlan<P extends {lines: object[]}> = Readonly<Omit<P, 'lines'>> & {
42
+ readonly lines: readonly Readonly<P['lines'][number]>[];
43
+ };
44
+ export interface PreparationScope {
45
+ prepare(owner: object, items: readonly RichItem[], options: ParagraphPreparation): ParagraphGeometry | null;
46
+ prepare(owner: object, items: readonly RichItem[], options?: WrapPreparation): PreparedRichParagraph | null;
47
+ prepare(owner: object, items: readonly RichItem[], options: PreparationOptions): PreparedHandle | null;
48
+ prepareSteps(owner: object, items: readonly RichItem[], options: ParagraphPreparation): PreparationWork<ParagraphGeometry>;
49
+ prepareSteps(owner: object, items: readonly RichItem[], options?: WrapPreparation): PreparationWork<PreparedRichParagraph>;
50
+ prepareSteps(owner: object, items: readonly RichItem[], options: PreparationOptions): PreparationSteps;
51
+ fit<P extends {lines: object[]}>(owner: object, handle: ParagraphGeometry,
52
+ createWork: (readKnown: ReadKnownWidth) => FitWork<P>): FrozenFitPlan<P> | null;
53
+ fitSteps<P extends {lines: object[]}>(owner: object, handle: ParagraphGeometry,
54
+ createWork: (readKnown: ReadKnownWidth) => FitWork<P>): PreparationWork<FrozenFitPlan<P>>;
55
+ current(handle: PreparedHandle | null | undefined): boolean;
56
+ invalidateFonts(): number;
57
+ forget(owner: object): void;
58
+ retire(options?: {documentChanged?: boolean}): void;
59
+ }
60
+ export function createPreparationScope(document?: Document | null): PreparationScope;
61
+ export function prepareRichParagraph(items: readonly RichItem[], options: ParagraphPreparation): ParagraphGeometry | null;
62
+ export function prepareRichParagraph(items: readonly RichItem[], options?: WrapPreparation): PreparedRichParagraph | null;
63
+ export function prepareRichParagraph(items: readonly RichItem[], options: PreparationOptions): PreparedHandle | null;
64
+ export function captureFontAuthority(document?: Document | null): number;
65
+ export function invalidateRichMetrics(document?: Document | null): number;
66
+ /** Unsupported properties are accepted as input and return false, without changing the source. */
67
+ export interface RichStyle {
68
+ writingMode?: string; direction?: string; unicodeBidi?: string; textTransform?: string;
69
+ fontKerning?: string; fontOpticalSizing?: string; fontStretch?: string; fontSizeAdjust?: string;
70
+ textRendering?: string; verticalAlign?: string; whiteSpace?: string; wordBreak?: string;
71
+ hyphens?: string; lineBreak?: string; hangingPunctuation?: string; tabSize?: string;
72
+ textWrapStyle?: string; fontFeatureSettings?: string; fontVariationSettings?: string;
73
+ fontVariant?: string; fontVariantLigatures?: string; fontVariantCaps?: string;
74
+ fontVariantNumeric?: string; fontVariantEastAsian?: string; fontVariantPosition?: string;
75
+ fontVariantAlternates?: string; fontSynthesis?: string; fontSynthesisWeight?: string;
76
+ fontSynthesisStyle?: string; fontSynthesisSmallCaps?: string; letterSpacing?: string; wordSpacing?: string;
77
+ }
78
+ export function supportsRichStyle(style: RichStyle | null | undefined, contentLanguage?: string): boolean;
79
+
80
+ declare const richCursor: unique symbol;
81
+ declare const fragmentCursor: unique symbol;
82
+ export interface RichInlineCursor {readonly [richCursor]: true}
83
+ export interface RichFragmentCursor {readonly [fragmentCursor]: true}
84
+ export interface RichInlineFragmentRange {
85
+ itemIndex: number;
86
+ gapBefore: number;
87
+ gapItemIndex: number;
88
+ occupiedWidth: number;
89
+ start: RichFragmentCursor;
90
+ end: RichFragmentCursor;
91
+ }
92
+ export interface RichInlineLineRange {
93
+ fragments: RichInlineFragmentRange[];
94
+ width: number;
95
+ end: RichInlineCursor;
96
+ }
97
+ export interface FlowFragment {
98
+ itemIndex: number;
99
+ sourceStart: number;
100
+ sourceEnd: number;
101
+ gapBefore: number;
102
+ gapItemIndex: number;
103
+ occupiedWidth: number;
104
+ }
105
+ export interface MaterializedFragment extends FlowFragment {
106
+ text: string;
107
+ }
108
+ export interface MaterializedLine {
109
+ fragments: MaterializedFragment[];
110
+ width: number;
111
+ end: RichInlineCursor;
112
+ }
113
+ export function layoutNextRichInlineLineRange(prepared: PreparedRichParagraph, maxWidth: number,
114
+ start?: RichInlineCursor): RichInlineLineRange | null;
115
+ export function materializeRichInlineLineRange(prepared: PreparedRichParagraph, line: RichInlineLineRange): MaterializedLine;
116
+ export interface MappedFragment {text: string; offsets: number[]; start: number; end: number}
117
+ export type MappableFragment = {sourceStart: number; sourceEnd: number} & (
118
+ {text: string; derive?: false} | {derive: true; glyph?: string}
119
+ );
120
+ export function mapFragment(run: string | {raw: string; break?: 'normal' | 'never'}, fragment: MappableFragment,
121
+ options?: {whiteSpace?: 'normal' | 'pre-wrap'}): MappedFragment | null;
122
+
123
+ export interface LineMetrics {line: number; cap: number; capTop: number}
124
+ export interface FontMeasurementAuthority {
125
+ captureFontAuthority(document: Document): number;
126
+ fontReady(document: Document, font: string, text: string): boolean;
127
+ }
128
+ export function createLineMeasurer(authority?: FontMeasurementAuthority | null): (element: Element | null | undefined) => LineMetrics | null;
129
+ export function lineMetrics(element: Element | null | undefined): LineMetrics | null;
130
+ export function linesHeight(lines: number, metrics: Pick<LineMetrics, 'line' | 'cap'> | null | undefined): number | null;
131
+ export interface PictureBox {x: number; width: number; height: number}
132
+ export interface Rect extends PictureBox {y: number}
133
+ export function linesSlices<T extends Rect>(slices: readonly T[], layout: Layout | null | undefined,
134
+ metrics: LineMetrics | null | undefined, y: number, height: number): T[] | readonly T[];
135
+ export function linesTop(layout: Layout | null | undefined, metrics: LineMetrics | null | undefined): number;
136
+ export function imageBox(columnWidth: number, naturalWidth: number, naturalHeight: number, layout?: Layout,
137
+ defaultWidth?: number, metrics?: LineMetrics | null): PictureBox | null;
138
+ export interface ReservedRaster {
139
+ fit: PictureBox;
140
+ reserved: PictureBox;
141
+ visualDeltaX: number;
142
+ visualDeltaY: number;
143
+ }
144
+ export function rasterReserved(columnWidth: number, unrotated: PictureBox | null, rad: number): ReservedRaster | null;
145
+ export type ProfileSpan = readonly [number, number];
146
+ export interface SpanProfile {
147
+ spanAt(t: number): ProfileSpan | null;
148
+ runsAt?(t: number): readonly ProfileSpan[] | null;
149
+ }
150
+ export type ShapeProfile = SpanProfile | {runsAt(t: number): readonly ProfileSpan[] | null; spanAt?(t: number): ProfileSpan | null};
151
+ export interface RunProfile extends SpanProfile {runsAt(t: number): readonly ProfileSpan[]}
152
+ export function alphaProfile(image: HTMLImageElement): RunProfile | null;
153
+ export function polygonProfile(corners: readonly ProfileSpan[]): SpanProfile;
154
+ export function rotatedBoundsRad(width: number, height: number, rad: number): {width: number; height: number};
155
+ export function rasterTiltProfile(width: number, height: number, rad: number): SpanProfile;
156
+ export function rotatedRasterAlpha(baseAlpha: RunProfile | null, width: number, height: number, rad: number): RunProfile | null;
157
+ export function bandsProfile(bands: readonly (readonly ProfileSpan[])[]): RunProfile | null;
158
+ export function serializeProfile(profile: ShapeProfile | null | undefined, count?: number): string;
159
+ export function parseProfile(text: string): RunProfile | null;
160
+ export function frameScale(element: Element | null | undefined): number;
161
+ export function pictureSlices(profile: ShapeProfile | null, x: number, y: number, width: number, height: number, scale?: number): Rect[];
162
+ export function besideSlices<T extends Rect>(slices: readonly T[], columnLeft: number, columnRight: number,
163
+ pictureLeft: number, pictureWidth: number): readonly T[];
164
+ export interface BandSlot {x: number; width: number}
165
+ export interface FlowSlot extends BandSlot {y: number; block?: number; channel?: number}
166
+ export type SlotsForBand = (width: number, obstacles: readonly Rect[], top: number, height: number, minWidth?: number) => BandSlot[] | null;
167
+ export const slotsForBand: SlotsForBand;
168
+ export interface SlotSequenceResult {slots: FlowSlot[]; end: number; multiple: boolean}
169
+ export type SlotSequence = (width: number, top: number, obstacles: readonly Rect[], lineHeight: number,
170
+ minWidth: number, slotsForBand: SlotsForBand, direction?: 'ltr' | 'rtl', order?: 'columns' | 'rows') => SlotSequenceResult | null;
171
+ export const slotSequence: SlotSequence;
172
+ export function columnsFilled(slots: readonly FlowSlot[], placed: readonly FlowSlot[]): boolean;
173
+ export type FlowLine<F extends FlowFragment = MaterializedFragment> = FlowSlot & {fragments: F[]} &
174
+ (F extends MaterializedFragment ? {end: RichInlineCursor} : {wordSpacing: number});
175
+ export interface FlowPlan<F extends FlowFragment = MaterializedFragment> {lines: FlowLine<F>[]; height: number}
176
+ export function flowLines(flow: PreparedRichParagraph, width: number, top: number, obstacles: readonly Rect[],
177
+ lineHeight: number, minWidth: number, direction?: 'ltr' | 'rtl', balance?: number,
178
+ align?: 'start' | 'end' | 'left' | 'right' | 'center' | 'justify'): FlowPlan | null;
179
+ export interface WrapShape {boxWidth: number; boxHeight: number; startY: number; points: [number, number][]}
180
+ export function wrapShape(side: 'left' | 'right', obstacles: readonly Rect[], width: number, top: number): WrapShape | null;
181
+ export function boxClearance(obstacles: readonly Rect[], width: number, top: number, height: number,
182
+ floor: number): {left: number; right: number; fits: boolean} | null;
183
+ export interface EdgeLine {block: Element; top: number; bottom: number; start: number; content: number}
184
+ export function edgeLines(root: Element, skip?: (text: Text) => boolean): EdgeLine[];
185
+ export interface EdgeMarks {
186
+ markers: {item: Element; shift: number}[];
187
+ bars: {quote: Element; runs: {shift: number; top: number; bottom: number}[]}[];
188
+ steps: Element[];
189
+ }
190
+ export function edgeMarks(root: Element, before: readonly EdgeLine[], skip?: (text: Text) => boolean): EdgeMarks;
191
+ export function imageOnly(paragraph: Node, image: Node): boolean;