@linloir/limr 1.0.0 → 1.0.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.
Files changed (64) hide show
  1. package/README.en.md +36 -8
  2. package/README.md +36 -8
  3. package/benchmarks/results/layout.json +2593 -0
  4. package/benchmarks/results/markstream-code.json +1823 -0
  5. package/benchmarks/results/markstream-reading-repeat.json +1152 -0
  6. package/benchmarks/results/markstream.json +12486 -0
  7. package/benchmarks/results/streaming-browser.json +77 -0
  8. package/benchmarks/results/streaming.json +357 -0
  9. package/dist/base.css +83 -3
  10. package/dist/{chunk-TTISGBST.js → chunk-BG5QUQFR.js} +327 -72
  11. package/dist/chunk-BG5QUQFR.js.map +1 -0
  12. package/dist/chunk-BVHHOVMT.js +179 -0
  13. package/dist/chunk-BVHHOVMT.js.map +1 -0
  14. package/dist/chunk-FJZCQY2S.js +155 -0
  15. package/dist/chunk-FJZCQY2S.js.map +1 -0
  16. package/dist/chunk-FSI5OTBW.js +1 -0
  17. package/dist/{chunk-N77VD2YR.js → chunk-GU2RPESF.js} +145 -83
  18. package/dist/chunk-GU2RPESF.js.map +1 -0
  19. package/dist/{chunk-3ILUZKDB.js → chunk-SUAAUGAX.js} +1280 -501
  20. package/dist/chunk-SUAAUGAX.js.map +1 -0
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/index.js +13 -5
  23. package/dist/extensions/index.d.ts +30 -5
  24. package/dist/extensions/index.js +15 -3
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +27 -8
  27. package/dist/{engine-43u8B4yt.d.ts → knuth-plass-C8mgFm7W.d.ts} +67 -1
  28. package/dist/knuth-plass-layout-CHQCWKB5.js +449 -0
  29. package/dist/knuth-plass-layout-CHQCWKB5.js.map +1 -0
  30. package/dist/react/index.d.ts +5 -4
  31. package/dist/react/index.js +5 -3
  32. package/dist/styles.css +83 -3
  33. package/dist/{translations-DHnYMg4h.d.ts → translations-BXzSwLBJ.d.ts} +39 -2
  34. package/docs/en/README.md +8 -6
  35. package/docs/en/annotations.md +3 -1
  36. package/docs/en/api.md +9 -1
  37. package/docs/en/architecture.md +11 -3
  38. package/docs/en/extensions.md +53 -4
  39. package/docs/en/getting-started.md +2 -0
  40. package/docs/en/integration.md +26 -2
  41. package/docs/en/modules.md +9 -5
  42. package/docs/en/performance.md +42 -2
  43. package/docs/en/styles.md +21 -2
  44. package/docs/en/syntax.md +118 -15
  45. package/docs/zh-CN/README.md +8 -6
  46. package/docs/zh-CN/annotations.md +3 -1
  47. package/docs/zh-CN/api.md +9 -1
  48. package/docs/zh-CN/architecture.md +11 -3
  49. package/docs/zh-CN/extensions.md +55 -4
  50. package/docs/zh-CN/getting-started.md +2 -0
  51. package/docs/zh-CN/integration.md +26 -2
  52. package/docs/zh-CN/modules.md +9 -5
  53. package/docs/zh-CN/performance.md +42 -2
  54. package/docs/zh-CN/styles.md +21 -2
  55. package/docs/zh-CN/syntax.md +120 -15
  56. package/package.json +9 -1
  57. package/skills/limr-plugin-development/references/contract.md +9 -3
  58. package/skills/limr-use/references/integration.md +11 -3
  59. package/skills/limr-use/references/syntax.md +8 -5
  60. package/dist/chunk-3ILUZKDB.js.map +0 -1
  61. package/dist/chunk-N77VD2YR.js.map +0 -1
  62. package/dist/chunk-TTISGBST.js.map +0 -1
  63. package/dist/chunk-V2OG4Y3F.js +0 -1
  64. /package/dist/{chunk-V2OG4Y3F.js.map → chunk-FSI5OTBW.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { k as SourceRange, f as DocumentSnapshot, h as SelectionSnapshot, b as AnnotationOccurrence, g as HighlightData, A as Annotation, a as AnnotationAnchor, M as MarkdownNode } from '../engine-43u8B4yt.js';
2
- export { B as Block, D as Diagnostic, c as DocumentEngine, d as DocumentMetrics, e as DocumentOptions, H as Heading, P as ParseContext, R as Rect, S as SelectionResult, i as SourcePoint, j as SourcePosition, l as SyntaxExtension, m as createDocument, r as replaceExtension } from '../engine-43u8B4yt.js';
1
+ import { m as SourceRange, f as DocumentSnapshot, j as SelectionSnapshot, b as AnnotationOccurrence, g as HighlightData, A as Annotation, a as AnnotationAnchor, M as MarkdownNode } from '../knuth-plass-C8mgFm7W.js';
2
+ export { B as Block, D as Diagnostic, c as DocumentEngine, d as DocumentMetrics, e as DocumentOptions, H as Heading, K as KnuthPlassOptions, L as LineBreak, h as LineItem, P as ParagraphLayout, i as ParseContext, R as Rect, S as SelectionResult, k as SourcePoint, l as SourcePosition, n as SyntaxExtension, o as createDocument, p as knuthPlass, q as prepareKnuthPlass, r as replaceExtension, t as texBadness } from '../knuth-plass-C8mgFm7W.js';
3
3
  import 'micromark-util-types';
4
4
  import 'mdast-util-from-markdown';
5
5
 
@@ -3,17 +3,22 @@ import {
3
3
  annotationReferenceRange,
4
4
  createDocument,
5
5
  defaultHighlight,
6
- intersects,
7
6
  mapText,
8
- rangeOf,
9
7
  replaceExtension,
10
8
  resolveAnnotationAnchors,
11
- safeUrl,
12
9
  sameRange,
13
- selectionFromRange,
10
+ selectionFromRange
11
+ } from "../chunk-BG5QUQFR.js";
12
+ import {
13
+ intersects,
14
+ knuthPlass,
15
+ prepareKnuthPlass,
16
+ rangeOf,
17
+ safeUrl,
18
+ texBadness,
14
19
  textContent,
15
20
  walk
16
- } from "../chunk-TTISGBST.js";
21
+ } from "../chunk-FJZCQY2S.js";
17
22
  import {
18
23
  LruCache,
19
24
  ResourceCache
@@ -26,13 +31,16 @@ export {
26
31
  createDocument,
27
32
  defaultHighlight,
28
33
  intersects,
34
+ knuthPlass,
29
35
  mapText,
36
+ prepareKnuthPlass,
30
37
  rangeOf,
31
38
  replaceExtension,
32
39
  resolveAnnotationAnchors,
33
40
  safeUrl,
34
41
  sameRange,
35
42
  selectionFromRange,
43
+ texBadness,
36
44
  textContent,
37
45
  walk
38
46
  };
@@ -1,8 +1,8 @@
1
- import { N as NodeRenderer, f as AnnotationType, R as RendererExtension, i as MarkdownProps, S as SelectionAction } from '../translations-DHnYMg4h.js';
2
- export { n as TranslationMode, o as TranslationsOptions, t as translations } from '../translations-DHnYMg4h.js';
1
+ import { N as NodeRenderer, R as RendererExtension, f as AnnotationType, i as MarkdownProps, S as SelectionAction } from '../translations-BXzSwLBJ.js';
2
+ export { p as TranslationMode, q as TranslationsOptions, t as translations } from '../translations-BXzSwLBJ.js';
3
3
  import { KatexOptions } from 'katex';
4
4
  import * as react from 'react';
5
- import '../engine-43u8B4yt.js';
5
+ import '../knuth-plass-C8mgFm7W.js';
6
6
  import 'micromark-util-types';
7
7
  import 'mdast-util-from-markdown';
8
8
 
@@ -12,9 +12,10 @@ interface BlockExtensionOptions {
12
12
  tags?: readonly string[];
13
13
  directives?: readonly string[];
14
14
  selection?: 'content' | 'atomic';
15
+ streaming?: RendererExtension['streaming'];
15
16
  }
16
17
  /** A tag/directive adapter with original source positions and streaming recovery. */
17
- declare function defineBlock({ name, component, tags, directives, selection }: BlockExtensionOptions): RendererExtension;
18
+ declare function defineBlock({ name, component, tags, directives, selection, streaming }: BlockExtensionOptions): RendererExtension;
18
19
  declare function defineAnnotation<T>(type: AnnotationType<T>): RendererExtension;
19
20
  declare function defineExtension(extension: RendererExtension): RendererExtension;
20
21
 
@@ -28,6 +29,30 @@ interface MathOptions {
28
29
  }
29
30
  declare function math(options?: MathOptions): RendererExtension;
30
31
 
32
+ /** Lazy, atomic diagrams. An unclosed streaming fence never reaches Mermaid. */
33
+ declare function mermaid(): RendererExtension;
34
+
35
+ declare function calloutType(value: string): string;
36
+ /** Obsidian blockquotes and LiMR ::callout share the same renderer and AST. */
37
+ declare function callout(options?: {
38
+ component?: NodeRenderer;
39
+ }): RendererExtension;
40
+
41
+ interface InlineHighlightOptions {
42
+ color?: string;
43
+ component?: NodeRenderer;
44
+ }
45
+ /** Markdown-authored highlights share the normal paint/hover/copy machinery,
46
+ * while their source remains the authority for editing. */
47
+ declare function inlineHighlights(options?: InlineHighlightOptions): RendererExtension;
48
+
49
+ interface FootnoteData {
50
+ body: string;
51
+ }
52
+ /** GFM definitions keep their AST identity for incremental parsing, but their
53
+ * references use the same marker/sidebar/overlay contract as other modules. */
54
+ declare function footnotes(options?: Partial<AnnotationType<FootnoteData>>): RendererExtension;
55
+
31
56
  interface CodeHighlightOptions {
32
57
  languages?: readonly string[];
33
58
  lightTheme?: string;
@@ -127,4 +152,4 @@ declare function highlightPalette(options?: HighlightOptions): SelectionAction;
127
152
  declare function highlightSelection(): SelectionAction;
128
153
  declare function deleteAnnotations(): SelectionAction;
129
154
 
130
- export { AnnotationMarkdown, type BlockExtensionOptions, type CitationData, type CodeHighlightOptions, type FiguresOptions, type HighlightOptions, type MathOptions, type VideoOptions, citation, codeHighlight, copyText, defineAnnotation, defineBlock, defineExtension, definition, deleteAnnotations, extras, figures, gfm, highlightColors, highlightPalette, highlightSelection, math, preloadMath, question, standard, video };
155
+ export { AnnotationMarkdown, type BlockExtensionOptions, type CitationData, type CodeHighlightOptions, type FiguresOptions, type FootnoteData, type HighlightOptions, type InlineHighlightOptions, type MathOptions, type VideoOptions, callout, calloutType, citation, codeHighlight, copyText, defineAnnotation, defineBlock, defineExtension, definition, deleteAnnotations, extras, figures, footnotes, gfm, highlightColors, highlightPalette, highlightSelection, inlineHighlights, math, mermaid, preloadMath, question, standard, video };
@@ -1,6 +1,8 @@
1
- import "../chunk-V2OG4Y3F.js";
1
+ import "../chunk-FSI5OTBW.js";
2
2
  import {
3
3
  AnnotationMarkdown,
4
+ callout,
5
+ calloutType,
4
6
  citation,
5
7
  codeHighlight,
6
8
  copyText,
@@ -11,21 +13,28 @@ import {
11
13
  deleteAnnotations,
12
14
  extras,
13
15
  figures,
16
+ footnotes,
14
17
  gfm,
15
18
  highlightColors,
16
19
  highlightPalette,
17
20
  highlightSelection,
21
+ inlineHighlights,
18
22
  math,
23
+ mermaid,
19
24
  preloadMath,
20
25
  question,
21
26
  standard,
22
27
  translations,
23
28
  video
24
- } from "../chunk-3ILUZKDB.js";
25
- import "../chunk-TTISGBST.js";
29
+ } from "../chunk-SUAAUGAX.js";
30
+ import "../chunk-BG5QUQFR.js";
31
+ import "../chunk-BVHHOVMT.js";
32
+ import "../chunk-FJZCQY2S.js";
26
33
  import "../chunk-6N6TFHEN.js";
27
34
  export {
28
35
  AnnotationMarkdown,
36
+ callout,
37
+ calloutType,
29
38
  citation,
30
39
  codeHighlight,
31
40
  copyText,
@@ -36,11 +45,14 @@ export {
36
45
  deleteAnnotations,
37
46
  extras,
38
47
  figures,
48
+ footnotes,
39
49
  gfm,
40
50
  highlightColors,
41
51
  highlightPalette,
42
52
  highlightSelection,
53
+ inlineHighlights,
43
54
  math,
55
+ mermaid,
44
56
  preloadMath,
45
57
  question,
46
58
  standard,
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { A as Annotation, a as AnnotationAnchor, b as AnnotationOccurrence, B as Block, D as Diagnostic, c as DocumentEngine, d as DocumentMetrics, e as DocumentOptions, f as DocumentSnapshot, H as Heading, g as HighlightData, M as MarkdownNode, P as ParseContext, R as Rect, S as SelectionResult, h as SelectionSnapshot, i as SourcePoint, j as SourcePosition, k as SourceRange, l as SyntaxExtension, m as createDocument, r as replaceExtension } from './engine-43u8B4yt.js';
1
+ export { A as Annotation, a as AnnotationAnchor, b as AnnotationOccurrence, B as Block, D as Diagnostic, c as DocumentEngine, d as DocumentMetrics, e as DocumentOptions, f as DocumentSnapshot, H as Heading, g as HighlightData, K as KnuthPlassOptions, L as LineBreak, h as LineItem, M as MarkdownNode, P as ParagraphLayout, i as ParseContext, R as Rect, S as SelectionResult, j as SelectionSnapshot, k as SourcePoint, l as SourcePosition, m as SourceRange, n as SyntaxExtension, o as createDocument, p as knuthPlass, q as prepareKnuthPlass, r as replaceExtension, t as texBadness } from './knuth-plass-C8mgFm7W.js';
2
2
  export { LruCache, ResourceCache, TextMapping, annotationReferenceRange, defaultHighlight, intersects, mapText, rangeOf, resolveAnnotationAnchors, safeUrl, sameRange, selectionFromRange, textContent, walk } from './core/index.js';
3
- export { A as ActionContext, a as AnnotationContentProps, b as AnnotationExpansion, c as AnnotationOverlayCardProps, d as AnnotationPresentation, e as AnnotationSidebarPreviewProps, f as AnnotationType, D as DocumentCommands, g as DocumentProvider, h as DocumentProviderProps, L as LiMRLocale, M as Markdown, i as MarkdownProps, N as NodeRenderer, j as NodeRendererProps, R as RendererExtension, k as RendererParameters, S as SelectionAction, l as StyledProps, T as TextToken, m as ToolbarActionContext, n as TranslationMode, o as TranslationsOptions, V as ViewConfiguration, t as translations, u as useAnchor, p as useAnnotation, q as useAnnotationState, r as useAnnotations, s as useDocument, v as useDocumentSelector, w as useLiMR, x as useLocale, y as useRendererParameter, z as useSelection } from './translations-DHnYMg4h.js';
3
+ export { A as ActionContext, a as AnnotationContentProps, b as AnnotationExpansion, c as AnnotationOverlayCardProps, d as AnnotationPresentation, e as AnnotationSidebarPreviewProps, f as AnnotationType, D as DocumentCommands, g as DocumentProvider, h as DocumentProviderProps, L as LiMRLocale, M as Markdown, i as MarkdownProps, N as NodeRenderer, j as NodeRendererProps, R as RendererExtension, k as RendererOverride, l as RendererParameters, S as SelectionAction, m as StreamEffect, n as StyledProps, T as TextToken, o as ToolbarActionContext, p as TranslationMode, q as TranslationsOptions, r as TypographyMode, V as ViewConfiguration, t as translations, u as useAnchor, s as useAnnotation, v as useAnnotationState, w as useAnnotations, x as useDocument, y as useDocumentSelector, z as useLiMR, B as useLocale, C as useRendererParameter, E as useSelection } from './translations-BXzSwLBJ.js';
4
4
  export { AnnotationCard, AnnotationCardProps, AnnotationContent, AnnotationGroup, AnnotationOverlay, AnnotationOverlayProps, AnnotationSidebar, AnnotationSidebarProps, InlineMarker, InlineMarkerProps, Reader, ReaderProps, SelectionToolbar, SelectionToolbarProps, SidebarItem, SidebarPositioner, TableOfContents, TableOfContentsProps, ToolIcon, ToolIconName, alignSidebar, chinese, english } from './react/index.js';
5
- export { AnnotationMarkdown, BlockExtensionOptions, CitationData, CodeHighlightOptions, FiguresOptions, HighlightOptions, MathOptions, VideoOptions, citation, codeHighlight, copyText, defineAnnotation, defineBlock, defineExtension, definition, deleteAnnotations, extras, figures, gfm, highlightColors, highlightPalette, highlightSelection, math, preloadMath, question, standard, video } from './extensions/index.js';
5
+ export { AnnotationMarkdown, BlockExtensionOptions, CitationData, CodeHighlightOptions, FiguresOptions, FootnoteData, HighlightOptions, InlineHighlightOptions, MathOptions, VideoOptions, callout, calloutType, citation, codeHighlight, copyText, defineAnnotation, defineBlock, defineExtension, definition, deleteAnnotations, extras, figures, footnotes, gfm, highlightColors, highlightPalette, highlightSelection, inlineHighlights, math, mermaid, preloadMath, question, standard, video } from './extensions/index.js';
6
6
  import 'micromark-util-types';
7
7
  import 'mdast-util-from-markdown';
8
8
  import 'react';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-V2OG4Y3F.js";
1
+ import "./chunk-FSI5OTBW.js";
2
2
  import {
3
3
  AnnotationContent,
4
4
  AnnotationGroup,
@@ -8,7 +8,7 @@ import {
8
8
  SelectionToolbar,
9
9
  TableOfContents,
10
10
  alignSidebar
11
- } from "./chunk-N77VD2YR.js";
11
+ } from "./chunk-GU2RPESF.js";
12
12
  import {
13
13
  AnnotationCard,
14
14
  AnnotationMarkdown,
@@ -16,6 +16,8 @@ import {
16
16
  InlineMarker,
17
17
  Markdown,
18
18
  ToolIcon,
19
+ callout,
20
+ calloutType,
19
21
  chinese,
20
22
  citation,
21
23
  codeHighlight,
@@ -28,11 +30,14 @@ import {
28
30
  english,
29
31
  extras,
30
32
  figures,
33
+ footnotes,
31
34
  gfm,
32
35
  highlightColors,
33
36
  highlightPalette,
34
37
  highlightSelection,
38
+ inlineHighlights,
35
39
  math,
40
+ mermaid,
36
41
  preloadMath,
37
42
  question,
38
43
  standard,
@@ -48,23 +53,29 @@ import {
48
53
  useRendererParameter,
49
54
  useSelection,
50
55
  video
51
- } from "./chunk-3ILUZKDB.js";
56
+ } from "./chunk-SUAAUGAX.js";
52
57
  import {
53
58
  DocumentEngine,
54
59
  annotationReferenceRange,
55
60
  createDocument,
56
61
  defaultHighlight,
57
- intersects,
58
62
  mapText,
59
- rangeOf,
60
63
  replaceExtension,
61
64
  resolveAnnotationAnchors,
62
- safeUrl,
63
65
  sameRange,
64
- selectionFromRange,
66
+ selectionFromRange
67
+ } from "./chunk-BG5QUQFR.js";
68
+ import "./chunk-BVHHOVMT.js";
69
+ import {
70
+ intersects,
71
+ knuthPlass,
72
+ prepareKnuthPlass,
73
+ rangeOf,
74
+ safeUrl,
75
+ texBadness,
65
76
  textContent,
66
77
  walk
67
- } from "./chunk-TTISGBST.js";
78
+ } from "./chunk-FJZCQY2S.js";
68
79
  import {
69
80
  LruCache,
70
81
  ResourceCache
@@ -88,6 +99,8 @@ export {
88
99
  ToolIcon,
89
100
  alignSidebar,
90
101
  annotationReferenceRange,
102
+ callout,
103
+ calloutType,
91
104
  chinese,
92
105
  citation,
93
106
  codeHighlight,
@@ -102,14 +115,19 @@ export {
102
115
  english,
103
116
  extras,
104
117
  figures,
118
+ footnotes,
105
119
  gfm,
106
120
  highlightColors,
107
121
  highlightPalette,
108
122
  highlightSelection,
123
+ inlineHighlights,
109
124
  intersects,
125
+ knuthPlass,
110
126
  mapText,
111
127
  math,
128
+ mermaid,
112
129
  preloadMath,
130
+ prepareKnuthPlass,
113
131
  question,
114
132
  rangeOf,
115
133
  replaceExtension,
@@ -118,6 +136,7 @@ export {
118
136
  sameRange,
119
137
  selectionFromRange,
120
138
  standard,
139
+ texBadness,
121
140
  textContent,
122
141
  translations,
123
142
  useAnchor,
@@ -27,6 +27,8 @@ interface MarkdownNode {
27
27
  attributeNodes?: Record<string, MarkdownNode>;
28
28
  inline?: boolean;
29
29
  selection?: 'content' | 'atomic';
30
+ /** The opening syntax is known but its closing delimiter has not arrived. */
31
+ incomplete?: boolean;
30
32
  [key: string]: unknown;
31
33
  }
32
34
  interface ParseContext {
@@ -41,6 +43,8 @@ interface SyntaxExtension {
41
43
  mdast?: readonly Extension$1[];
42
44
  tags?: readonly string[];
43
45
  directives?: readonly string[];
46
+ /** Directive bodies are literal source (for example code or LaTeX). */
47
+ literal?: boolean;
44
48
  selection?: 'content' | 'atomic';
45
49
  transform?: (root: MarkdownNode, context: ParseContext) => void;
46
50
  display?: 'block' | 'inline' | 'auto';
@@ -74,12 +78,16 @@ interface AnnotationOccurrence extends AnnotationAnchor {
74
78
  id: string;
75
79
  annotationIds: readonly string[];
76
80
  embedded?: boolean;
81
+ /** Optional referenced text range, distinct from the marker's source range. */
82
+ referenceRange?: SourceRange;
77
83
  }
78
84
  /** Data for the built-in `highlight` annotation type. */
79
85
  interface HighlightData {
80
86
  color?: string;
81
87
  style?: 'background' | 'underline' | 'dotted' | 'wavy';
82
88
  hidden?: boolean;
89
+ /** Authored in Markdown: the default toolbar offers copying without editing. */
90
+ readOnly?: boolean;
83
91
  }
84
92
  interface Block {
85
93
  id: string;
@@ -126,6 +134,8 @@ interface SelectionResult {
126
134
  interface SelectionSnapshot {
127
135
  documentId: string;
128
136
  revision: number;
137
+ /** Readable selected text; the browser adapter substitutes complete original
138
+ * source (including delimiters) for selected atomic content once settled. */
129
139
  text: string;
130
140
  quality: 'exact' | 'atomic' | 'unmapped';
131
141
  raw: SelectionResult;
@@ -156,6 +166,9 @@ declare class DocumentEngine {
156
166
  private listeners;
157
167
  private definitionSignature;
158
168
  private recoveryOffset;
169
+ private lines;
170
+ private facts;
171
+ private relevant;
159
172
  constructor(source?: string, options?: DocumentOptions);
160
173
  getSnapshot: () => DocumentSnapshot;
161
174
  subscribe: (listener: () => void) => (() => void);
@@ -169,4 +182,57 @@ declare class DocumentEngine {
169
182
  declare function createDocument(source?: string, options?: DocumentOptions): DocumentEngine;
170
183
  declare function replaceExtension<T extends SyntaxExtension>(extensions: readonly T[], replacement: T): T[];
171
184
 
172
- export { type Annotation as A, type Block as B, type Diagnostic as D, type Heading as H, type MarkdownNode as M, type ParseContext as P, type Rect as R, type SelectionResult as S, type AnnotationAnchor as a, type AnnotationOccurrence as b, DocumentEngine as c, type DocumentMetrics as d, type DocumentOptions as e, type DocumentSnapshot as f, type HighlightData as g, type SelectionSnapshot as h, type SourcePoint as i, type SourcePosition as j, type SourceRange as k, type SyntaxExtension as l, createDocument as m, replaceExtension as r };
185
+ /** TeX82's paragraph model (tex.web, sections 815–873): boxes, glue,
186
+ * discretionary penalties, four fitness classes and a minimum-demerit path.
187
+ * Widths are converted to scaled units for TeX's integer badness calculation. */
188
+ type LineItem = {
189
+ type: 'box';
190
+ width: number;
191
+ } | {
192
+ type: 'glue';
193
+ width: number;
194
+ stretch: number;
195
+ shrink: number;
196
+ infinite?: boolean;
197
+ } | {
198
+ type: 'penalty';
199
+ width: number;
200
+ penalty: number;
201
+ flagged?: boolean;
202
+ automatic?: boolean;
203
+ };
204
+ interface KnuthPlassOptions {
205
+ pretolerance?: number;
206
+ tolerance?: number;
207
+ linePenalty?: number;
208
+ hyphenPenalty?: number;
209
+ adjacentDemerits?: number;
210
+ doubleHyphenDemerits?: number;
211
+ finalHyphenDemerits?: number;
212
+ /** Extra stretch in CSS pixels in the emergency pass, as in TeX. */
213
+ emergencyStretch?: number;
214
+ looseness?: number;
215
+ /** Default: Knuth–Liang en-US patterns. Return pieces that join to the word. */
216
+ hyphenate?: false | ((word: string) => readonly string[]);
217
+ }
218
+ interface LineBreak {
219
+ index: number;
220
+ start: number;
221
+ ratio: number;
222
+ fitness: number;
223
+ }
224
+ interface ParagraphLayout {
225
+ lines: LineBreak[];
226
+ demerits: number;
227
+ pass: 'pretolerance' | 'tolerance' | 'emergency' | 'final';
228
+ }
229
+ /** The integer approximation used by TeX, including its saturation at 10000. */
230
+ declare function texBadness(amount: number, available: number): number;
231
+ /** Prefix sums and safe active-node pruning remove repeated line scans. With
232
+ * constant line lengths and zero looseness, equal fitness is an exact shared
233
+ * state: future cost is independent of line count. No beam or word limit. */
234
+ declare function knuthPlass(items: readonly LineItem[], lengths: number | readonly number[], options?: KnuthPlassOptions): ParagraphLayout;
235
+ /** Retains width/stretch prefix sums across responsive layouts of the same text. */
236
+ declare function prepareKnuthPlass(items: readonly LineItem[]): (lengths: number | readonly number[], options?: KnuthPlassOptions) => ParagraphLayout;
237
+
238
+ export { type Annotation as A, type Block as B, type Diagnostic as D, type Heading as H, type KnuthPlassOptions as K, type LineBreak as L, type MarkdownNode as M, type ParagraphLayout as P, type Rect as R, type SelectionResult as S, type AnnotationAnchor as a, type AnnotationOccurrence as b, DocumentEngine as c, type DocumentMetrics as d, type DocumentOptions as e, type DocumentSnapshot as f, type HighlightData as g, type LineItem as h, type ParseContext as i, type SelectionSnapshot as j, type SourcePoint as k, type SourcePosition as l, type SourceRange as m, type SyntaxExtension as n, createDocument as o, knuthPlass as p, prepareKnuthPlass as q, replaceExtension as r, texBadness as t };