@vscode/markdown-editor 0.0.2-0 → 0.0.2-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 (96) hide show
  1. package/dist/_observables/assert.d.ts +2 -0
  2. package/dist/_observables/deps.d.ts +28 -0
  3. package/dist/_observables/disposables.d.ts +19 -0
  4. package/dist/_observables/equals.d.ts +32 -0
  5. package/dist/_observables/index.d.ts +2 -0
  6. package/dist/_observables/observableInternal/base.d.ts +172 -0
  7. package/dist/_observables/observableInternal/changeTracker.d.ts +44 -0
  8. package/dist/_observables/observableInternal/commonFacade/cancellation.d.ts +24 -0
  9. package/dist/_observables/observableInternal/commonFacade/deps.d.ts +24 -0
  10. package/dist/_observables/observableInternal/debugLocation.d.ts +21 -0
  11. package/dist/_observables/observableInternal/debugName.d.ts +33 -0
  12. package/dist/_observables/observableInternal/experimental/deferUnobserve.d.ts +16 -0
  13. package/dist/_observables/observableInternal/experimental/reducer.d.ts +37 -0
  14. package/dist/_observables/observableInternal/experimental/utils.d.ts +15 -0
  15. package/dist/_observables/observableInternal/index.d.ts +25 -0
  16. package/dist/_observables/observableInternal/logging/consoleObservableLogger.d.ts +40 -0
  17. package/dist/_observables/observableInternal/logging/debugGetDependencyGraph.d.ts +4 -0
  18. package/dist/_observables/observableInternal/logging/debugger/debuggerRpc.d.ts +4 -0
  19. package/dist/_observables/observableInternal/logging/debugger/devToolsLogger.d.ts +43 -0
  20. package/dist/_observables/observableInternal/logging/debugger/rpc.d.ts +41 -0
  21. package/dist/_observables/observableInternal/logging/debugger/utils.d.ts +13 -0
  22. package/dist/_observables/observableInternal/logging/logging.d.ts +30 -0
  23. package/dist/_observables/observableInternal/map.d.ts +18 -0
  24. package/dist/_observables/observableInternal/observables/baseObservable.d.ts +58 -0
  25. package/dist/_observables/observableInternal/observables/constObservable.d.ts +5 -0
  26. package/dist/_observables/observableInternal/observables/derived.d.ts +46 -0
  27. package/dist/_observables/observableInternal/observables/derivedImpl.d.ts +83 -0
  28. package/dist/_observables/observableInternal/observables/lazyObservableValue.d.ts +27 -0
  29. package/dist/_observables/observableInternal/observables/observableFromEvent.d.ts +37 -0
  30. package/dist/_observables/observableInternal/observables/observableSignal.d.ts +11 -0
  31. package/dist/_observables/observableInternal/observables/observableSignalFromEvent.d.ts +5 -0
  32. package/dist/_observables/observableInternal/observables/observableValue.d.ts +37 -0
  33. package/dist/_observables/observableInternal/observables/observableValueOpts.d.ts +8 -0
  34. package/dist/_observables/observableInternal/reactions/autorun.d.ts +56 -0
  35. package/dist/_observables/observableInternal/reactions/autorunImpl.d.ts +53 -0
  36. package/dist/_observables/observableInternal/set.d.ts +17 -0
  37. package/dist/_observables/observableInternal/transaction.d.ts +27 -0
  38. package/dist/_observables/observableInternal/utils/promise.d.ts +75 -0
  39. package/dist/_observables/observableInternal/utils/runOnChange.d.ts +7 -0
  40. package/dist/_observables/observableInternal/utils/utils.d.ts +43 -0
  41. package/dist/_observables/observableInternal/utils/utilsCancellation.d.ts +10 -0
  42. package/dist/_observables/observableInternal/utils/valueWithChangeEvent.d.ts +10 -0
  43. package/dist/_observables/utils.d.ts +15 -0
  44. package/dist/index.d.ts +1769 -6
  45. package/dist/observables.d.ts +4 -1
  46. package/package.json +1 -1
  47. package/dist/commands/cursorCommands.d.ts +0 -13
  48. package/dist/commands/editCommands.d.ts +0 -14
  49. package/dist/commands/index.d.ts +0 -4
  50. package/dist/commands/selectionCommands.d.ts +0 -6
  51. package/dist/commands/types.d.ts +0 -26
  52. package/dist/core/geometry.d.ts +0 -37
  53. package/dist/core/index.d.ts +0 -8
  54. package/dist/core/lengthEdit.d.ts +0 -38
  55. package/dist/core/offsetRange.d.ts +0 -26
  56. package/dist/core/selection.d.ts +0 -13
  57. package/dist/core/sourceOffset.d.ts +0 -1
  58. package/dist/core/stringEdit.d.ts +0 -27
  59. package/dist/core/stringValue.d.ts +0 -8
  60. package/dist/core/wordUtils.d.ts +0 -6
  61. package/dist/highlighter/defaultMonacoSyntaxHighlighter.d.ts +0 -20
  62. package/dist/highlighter/index.d.ts +0 -3
  63. package/dist/highlighter/monacoSyntaxHighlighter.d.ts +0 -38
  64. package/dist/highlighter/syntaxHighlighter.d.ts +0 -67
  65. package/dist/model/cursorNavigation.d.ts +0 -7
  66. package/dist/model/editorModel.d.ts +0 -54
  67. package/dist/model/index.d.ts +0 -4
  68. package/dist/model/measuredLayoutModel.d.ts +0 -50
  69. package/dist/parser/_micromarkAdapter.d.ts +0 -7
  70. package/dist/parser/ast.d.ts +0 -274
  71. package/dist/parser/index.d.ts +0 -4
  72. package/dist/parser/parse.d.ts +0 -2
  73. package/dist/parser/parser.d.ts +0 -14
  74. package/dist/parser/reconcile.d.ts +0 -33
  75. package/dist/parser/test/getAnnotatedSource.d.ts +0 -2
  76. package/dist/parser/test/snapshot.d.ts +0 -9
  77. package/dist/parser/visualizeAst.d.ts +0 -33
  78. package/dist/test/random.d.ts +0 -16
  79. package/dist/view/content/blockView.d.ts +0 -179
  80. package/dist/view/content/documentView.d.ts +0 -41
  81. package/dist/view/content/dom.d.ts +0 -16
  82. package/dist/view/content/katexEditableIdentifiers.d.ts +0 -36
  83. package/dist/view/content/viewNode.d.ts +0 -93
  84. package/dist/view/editorController.d.ts +0 -34
  85. package/dist/view/editorView.d.ts +0 -100
  86. package/dist/view/fixture/astViewerView.d.ts +0 -27
  87. package/dist/view/fixture/cyclingTsHighlighter.d.ts +0 -17
  88. package/dist/view/fixture/debugColors.d.ts +0 -26
  89. package/dist/view/fixture/monacoDebugPanel.d.ts +0 -7
  90. package/dist/view/index.d.ts +0 -9
  91. package/dist/view/measuredLayoutDebugView.d.ts +0 -70
  92. package/dist/view/parts/cursorView.d.ts +0 -29
  93. package/dist/view/parts/selectionView.d.ts +0 -57
  94. package/dist/view/viewData.d.ts +0 -251
  95. package/dist/view/visualLineMap.d.ts +0 -157
  96. package/dist/view/visualizeViewTree.d.ts +0 -5
@@ -1,251 +0,0 @@
1
- import { OffsetRange } from '../core/offsetRange.js';
2
- import { GlueAstNode, BlockAstNode, CodeBlockAstNode, DocumentAstNode, EmphasisAstNode, HeadingAstNode, ImageAstNode, InlineCodeAstNode, InlineMathAstNode, LinkAstNode, ListAstNode, ListItemAstNode, MarkerAstNode, MathBlockAstNode, ParagraphAstNode, StrikethroughAstNode, StrongAstNode, TableAstNode, TableCellAstNode, TableRowAstNode, TextAstNode, ThematicBreakAstNode, BlockQuoteAstNode } from '../parser/ast.js';
3
- /**
4
- * The view-data root. Mirrors {@link DocumentAstNode}: {@link blocks} holds only
5
- * its top-level blocks (each wrapped with where it starts and whether it is
6
- * active), while {@link children} additionally interleaves the rendered
7
- * document-level glue (the blank lines between blocks) in source order.
8
- */
9
- export declare class DocumentViewData {
10
- readonly ast: DocumentAstNode;
11
- readonly blocks: readonly DocumentBlockViewData[];
12
- /**
13
- * Blocks and inter-block glue interleaved in source order — the actual
14
- * mount sequence. {@link blocks} is the block-only projection used for
15
- * measurement and selection.
16
- */
17
- readonly children: readonly DocumentChildViewData[];
18
- readonly kind = "document";
19
- constructor(ast: DocumentAstNode, blocks: readonly DocumentBlockViewData[],
20
- /**
21
- * Blocks and inter-block glue interleaved in source order — the actual
22
- * mount sequence. {@link blocks} is the block-only projection used for
23
- * measurement and selection.
24
- */
25
- children: readonly DocumentChildViewData[]);
26
- }
27
- /** A top-level block plus the document-level state the renderer applies to it. */
28
- export interface DocumentBlockViewData {
29
- readonly ast: BlockAstNode;
30
- readonly absoluteStart: number;
31
- /** Whether the selection reaches this block (drives `md-block-active`). */
32
- readonly isActive: boolean;
33
- readonly view: BlockViewData;
34
- }
35
- /** A mounted document child: a block or a run of inter-block glue. */
36
- export interface DocumentChildViewData {
37
- readonly absoluteStart: number;
38
- /** For a block: selection reaches it. For glue: a neighbouring block is active. */
39
- readonly isActive: boolean;
40
- readonly view: BlockViewData | GlueViewData;
41
- readonly kind: 'block' | 'glue';
42
- }
43
- export type BlockViewData = HeadingViewData | ParagraphViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData;
44
- export declare class HeadingViewData {
45
- readonly ast: HeadingAstNode;
46
- readonly content: readonly AnyViewData[];
47
- readonly kind = "heading";
48
- constructor(ast: HeadingAstNode, content: readonly AnyViewData[]);
49
- }
50
- export declare class ParagraphViewData {
51
- readonly ast: ParagraphAstNode;
52
- readonly content: readonly AnyViewData[];
53
- readonly kind = "paragraph";
54
- constructor(ast: ParagraphAstNode, content: readonly AnyViewData[]);
55
- }
56
- export declare class CodeBlockViewData {
57
- readonly ast: CodeBlockAstNode;
58
- /** Active: render the fenced source; inactive: the (custom/highlighted) block. */
59
- readonly showMarkup: boolean;
60
- readonly content: readonly AnyViewData[];
61
- readonly kind = "codeBlock";
62
- constructor(ast: CodeBlockAstNode,
63
- /** Active: render the fenced source; inactive: the (custom/highlighted) block. */
64
- showMarkup: boolean, content: readonly AnyViewData[]);
65
- }
66
- export declare class MathBlockViewData {
67
- readonly ast: MathBlockAstNode;
68
- /** Active: render the source; inactive: the KaTeX output. */
69
- readonly showMarkup: boolean;
70
- readonly content: readonly AnyViewData[];
71
- readonly kind = "mathBlock";
72
- constructor(ast: MathBlockAstNode,
73
- /** Active: render the source; inactive: the KaTeX output. */
74
- showMarkup: boolean, content: readonly AnyViewData[]);
75
- }
76
- export declare class BlockQuoteViewData {
77
- readonly ast: BlockQuoteAstNode;
78
- readonly content: readonly AnyViewData[];
79
- readonly kind = "blockQuote";
80
- constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[]);
81
- }
82
- export declare class ListViewData {
83
- readonly ast: ListAstNode;
84
- readonly content: readonly AnyViewData[];
85
- readonly kind = "list";
86
- constructor(ast: ListAstNode, content: readonly AnyViewData[]);
87
- }
88
- export declare class TableViewData {
89
- readonly ast: TableAstNode;
90
- readonly content: readonly AnyViewData[];
91
- readonly kind = "table";
92
- constructor(ast: TableAstNode, content: readonly AnyViewData[]);
93
- }
94
- export type InlineViewData = TextViewData | StrongViewData | EmphasisViewData | StrikethroughViewData | InlineCodeViewData | InlineMathViewData | LinkViewData | ImageViewData;
95
- export declare class StrongViewData {
96
- readonly ast: StrongAstNode;
97
- readonly content: readonly AnyViewData[];
98
- readonly kind = "strong";
99
- constructor(ast: StrongAstNode, content: readonly AnyViewData[]);
100
- }
101
- export declare class EmphasisViewData {
102
- readonly ast: EmphasisAstNode;
103
- readonly content: readonly AnyViewData[];
104
- readonly kind = "emphasis";
105
- constructor(ast: EmphasisAstNode, content: readonly AnyViewData[]);
106
- }
107
- export declare class StrikethroughViewData {
108
- readonly ast: StrikethroughAstNode;
109
- readonly content: readonly AnyViewData[];
110
- readonly kind = "strikethrough";
111
- constructor(ast: StrikethroughAstNode, content: readonly AnyViewData[]);
112
- }
113
- export declare class InlineCodeViewData {
114
- readonly ast: InlineCodeAstNode;
115
- readonly content: readonly AnyViewData[];
116
- readonly kind = "inlineCode";
117
- constructor(ast: InlineCodeAstNode, content: readonly AnyViewData[]);
118
- }
119
- export declare class InlineMathViewData {
120
- readonly ast: InlineMathAstNode;
121
- /** Active: render the `$…$` source; inactive: the KaTeX output. */
122
- readonly showMarkup: boolean;
123
- readonly content: readonly AnyViewData[];
124
- readonly kind = "inlineMath";
125
- constructor(ast: InlineMathAstNode,
126
- /** Active: render the `$…$` source; inactive: the KaTeX output. */
127
- showMarkup: boolean, content: readonly AnyViewData[]);
128
- }
129
- export declare class LinkViewData {
130
- readonly ast: LinkAstNode;
131
- readonly content: readonly AnyViewData[];
132
- readonly kind = "link";
133
- constructor(ast: LinkAstNode, content: readonly AnyViewData[]);
134
- }
135
- export declare class ImageViewData {
136
- readonly ast: ImageAstNode;
137
- /** Active: render the `![alt](url)` source; inactive: the `<img>`. */
138
- readonly showMarkup: boolean;
139
- readonly content: readonly AnyViewData[];
140
- readonly kind = "image";
141
- constructor(ast: ImageAstNode,
142
- /** Active: render the `![alt](url)` source; inactive: the `<img>`. */
143
- showMarkup: boolean, content: readonly AnyViewData[]);
144
- }
145
- export declare class ListItemViewData {
146
- readonly ast: ListItemAstNode;
147
- /** Whether the selection reaches this item (reveals its markers). */
148
- readonly isActive: boolean;
149
- readonly content: readonly AnyViewData[];
150
- /** 1-based list nesting depth, used to size the indentation gutter. */
151
- readonly level: number;
152
- readonly kind = "listItem";
153
- constructor(ast: ListItemAstNode,
154
- /** Whether the selection reaches this item (reveals its markers). */
155
- isActive: boolean, content: readonly AnyViewData[],
156
- /** 1-based list nesting depth, used to size the indentation gutter. */
157
- level: number);
158
- }
159
- export declare class TableRowViewData {
160
- readonly ast: TableRowAstNode;
161
- readonly isDelimiter: boolean;
162
- readonly content: readonly AnyViewData[];
163
- readonly kind = "tableRow";
164
- constructor(ast: TableRowAstNode, isDelimiter: boolean, content: readonly AnyViewData[]);
165
- }
166
- export declare class TableCellViewData {
167
- readonly ast: TableCellAstNode;
168
- /** Whether the selection reaches this cell (reveals its inline markers). */
169
- readonly isActive: boolean;
170
- /** Whether the owning table is active (reveals the structural pipes). */
171
- readonly showTableGlue: boolean;
172
- readonly content: readonly AnyViewData[];
173
- readonly kind = "tableCell";
174
- constructor(ast: TableCellAstNode,
175
- /** Whether the selection reaches this cell (reveals its inline markers). */
176
- isActive: boolean,
177
- /** Whether the owning table is active (reveals the structural pipes). */
178
- showTableGlue: boolean, content: readonly AnyViewData[]);
179
- }
180
- export declare class TextViewData {
181
- readonly ast: TextAstNode;
182
- readonly showWhitespace: boolean;
183
- readonly leftWordBoundary: boolean;
184
- readonly rightWordBoundary: boolean;
185
- readonly kind = "text";
186
- /**
187
- * Whether non-obvious whitespace in this text is revealed (block is active).
188
- * `leftWordBoundary`/`rightWordBoundary` say whether the inline sibling on
189
- * that side ends/starts with visible word content (e.g. inline code, a link,
190
- * emphasis); a single space touching such a sibling is obvious and stays
191
- * undecorated, just like a space between two words within this leaf.
192
- */
193
- constructor(ast: TextAstNode, showWhitespace: boolean, leftWordBoundary?: boolean, rightWordBoundary?: boolean);
194
- }
195
- export declare class ThematicBreakViewData {
196
- readonly ast: ThematicBreakAstNode;
197
- /** Active: reveal the source markup (`---`) instead of the rendered rule. */
198
- readonly showMarkup: boolean;
199
- /** Marker (and any absorbed trailing glue), rendered only when active. */
200
- readonly content: readonly AnyViewData[];
201
- readonly kind = "thematicBreak";
202
- constructor(ast: ThematicBreakAstNode,
203
- /** Active: reveal the source markup (`---`) instead of the rendered rule. */
204
- showMarkup: boolean,
205
- /** Marker (and any absorbed trailing glue), rendered only when active. */
206
- content: readonly AnyViewData[]);
207
- }
208
- export declare class MarkerViewData {
209
- readonly ast: MarkerAstNode;
210
- readonly visible: boolean;
211
- readonly kind = "marker";
212
- constructor(ast: MarkerAstNode, visible: boolean);
213
- }
214
- export declare class GlueViewData {
215
- readonly ast: GlueAstNode;
216
- readonly visible: boolean;
217
- /**
218
- * Whether a source newline in this glue gets a visible `↵`. True only in
219
- * inline flow, where the newline collapses to a space and the `↵` reveals
220
- * the line ending hiding there; between block-level siblings (list items,
221
- * block children) the break is already visible, so no `↵` is drawn.
222
- */
223
- readonly decorateNewline: boolean;
224
- readonly kind = "glue";
225
- constructor(ast: GlueAstNode, visible: boolean,
226
- /**
227
- * Whether a source newline in this glue gets a visible `↵`. True only in
228
- * inline flow, where the newline collapses to a space and the `↵` reveals
229
- * the line ending hiding there; between block-level siblings (list items,
230
- * block children) the break is already visible, so no `↵` is drawn.
231
- */
232
- decorateNewline: boolean);
233
- }
234
- export type AnyViewData = DocumentViewData | BlockViewData | InlineViewData | ListItemViewData | TableRowViewData | TableCellViewData | MarkerViewData | GlueViewData;
235
- /**
236
- * Map the parsed document + active/selection state to its view-data tree.
237
- *
238
- * Top-level blocks are mirrored into {@link DocumentViewData.blocks}. A block's
239
- * trailing blank lines are attributed by the parser to the block itself (a
240
- * `blockGap`/`blockBreak` glue at the end of its content), so they are built as
241
- * part of the block and revealed only when that block is active — no neighbour
242
- * scan. The only such glue that survives at the document level is one with no
243
- * host block (a leading gap before the first block); it is mirrored into
244
- * {@link DocumentViewData.children} and revealed when its nearest block is
245
- * active.
246
- * An inactive block's view-data is a pure function of its AST, so when `previous`
247
- * holds a view-data for the same block object (the parser preserves identity for
248
- * unchanged subtrees) that was *also* inactive, the whole subtree is reused by
249
- * identity — the common case for a selection move, making it O(active blocks).
250
- */
251
- export declare function buildDocumentViewData(doc: DocumentAstNode, activeBlocks: ReadonlySet<BlockAstNode>, selectionRange: OffsetRange | undefined, previous: DocumentViewData | undefined): DocumentViewData;
@@ -1,157 +0,0 @@
1
- import { OffsetRange } from '../core/offsetRange.js';
2
- import { Point2D, Rect2D } from '../core/geometry.js';
3
- import { SourceOffset } from '../core/sourceOffset.js';
4
- import { ViewNode } from './content/viewNode.js';
5
- /**
6
- * Geometry of the rendered document, as a map from source offsets to 2D
7
- * positions and back.
8
- *
9
- * Structure (top to bottom):
10
- *
11
- * VisualLineMap = ordered list of VisualLines
12
- * VisualLine = a horizontal band [rect.top, rect.bottom) split
13
- * into one or more VisualRuns
14
- * VisualRun = a contiguous source range painted at a rectangle
15
- * on the line
16
- *
17
- * Invariants:
18
- * - `lines[i].rect.bottom <= lines[i+1].rect.top + ε`
19
- * - For any offset `o` covered by some run on line `L`:
20
- * `xAtOffset(o)` is inside that run's horizontal range
21
- * `xAtOffset(o)` is inside `L.rect.left..L.rect.right`
22
- *
23
- * The "map" goes both ways:
24
- * - SourceOffset → (line, x) via {@link lineIndexOfOffset} + {@link xAtOffset}
25
- * - Point2D → SourceOffset via {@link offsetAtPoint}
26
- *
27
- * Both directions are total but not bijective: many offsets at a line
28
- * boundary map to the same `x`, and large areas of the document
29
- * (padding, gaps) map onto the nearest offset on the nearest line.
30
- *
31
- * Rendering a caret rect from these primitives is a consumer concern:
32
- *
33
- * const i = map.lineIndexOfOffset(o);
34
- * const caretRect = map.lineRect(i).withZeroWidthAt(map.xAtOffset(o));
35
- */
36
- export declare class VisualLineMap {
37
- readonly lines: readonly VisualLine[];
38
- static readonly EMPTY: VisualLineMap;
39
- static measure(blockViews: readonly {
40
- readonly absoluteStart: number;
41
- readonly viewNode: ViewNode;
42
- }[]): VisualLineMap;
43
- constructor(lines: readonly VisualLine[]);
44
- get lineCount(): number;
45
- get isEmpty(): boolean;
46
- lineRect(lineIndex: number): Rect2D;
47
- /**
48
- * Line whose runs cover the offset, or the nearest line by source
49
- * distance if no run covers it.
50
- *
51
- * An offset that is only a run's *trailing* boundary (`offset ===
52
- * endExclusive`) — most notably the source offset just past a
53
- * line-breaking `\n`, which a zero-width run reports as its end on the line
54
- * it terminates — belongs to the START of the NEXT line instead. Preferring
55
- * the line that actually *starts* the offset makes the caret advance past a
56
- * newline to the next line rather than collapsing onto the previous line's
57
- * end (which would render two distinct offsets at the same caret position).
58
- * The first such trailing-boundary line is remembered as a fallback for the
59
- * document's very last offset, where no later line starts it.
60
- */
61
- lineIndexOfOffset(offset: SourceOffset): number;
62
- /**
63
- * x of the caret position before `offset`, on the line returned by
64
- * {@link lineIndexOfOffset}. Returns `0` when the map is empty.
65
- */
66
- xAtOffset(offset: SourceOffset): number;
67
- /**
68
- * Line whose vertical band contains `y`, clamped to the first/last
69
- * line when `y` is outside the document.
70
- */
71
- lineIndexAtY(y: number): number;
72
- /**
73
- * Snap a 2D point to the nearest source offset. Uses `y` to pick a
74
- * line, then `x` to pick an offset within it. Up/down navigation
75
- * uses {@link offsetInLineAtX} directly to preserve desired column.
76
- */
77
- offsetAtPoint(point: Point2D): SourceOffset;
78
- /** Snap `x` to the nearest offset on a specific line. */
79
- offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
80
- }
81
- /**
82
- * One visual line of rendered text: a horizontal band
83
- * (`rect.top`..`rect.bottom`) split into one or more {@link VisualRun}s
84
- * arranged left-to-right.
85
- */
86
- export declare class VisualLine {
87
- readonly rect: Rect2D;
88
- readonly runs: readonly VisualRun[];
89
- constructor(rect: Rect2D, runs: readonly VisualRun[]);
90
- containsOffset(offset: SourceOffset): boolean;
91
- /**
92
- * How `offset` relates to this line's runs:
93
- * - `'covers'`: a run starts at or strictly contains the offset
94
- * (`start <= offset < endExclusive`) — the caret belongs on this line.
95
- * - `'end'`: the offset is only some run's trailing boundary
96
- * (`offset === endExclusive`) with no run covering it — a line-break
97
- * boundary the caret should leave for the next line.
98
- * - `'none'`: no run touches the offset.
99
- */
100
- offsetMembership(offset: SourceOffset): 'covers' | 'end' | 'none';
101
- /**
102
- * Min `|offset - r|` over offsets `r` in any of this line's runs. Used
103
- * to pick the nearest line when no run actually covers the offset.
104
- */
105
- sourceDistanceTo(offset: SourceOffset): number;
106
- /**
107
- * x of the caret position before `offset` on this line. When `offset`
108
- * is past all runs (trailing whitespace / blank line), returns the
109
- * right edge of the last run; when before all runs, returns the left
110
- * edge of the first run.
111
- */
112
- xAtOffset(offset: SourceOffset): number;
113
- /**
114
- * Snap `x` to the nearest offset on this line. If `x` falls inside a
115
- * run, the offset is interpolated by character fraction; otherwise it
116
- * snaps to the closer edge of the nearest run.
117
- */
118
- offsetAtX(x: number): SourceOffset;
119
- }
120
- /**
121
- * The DOM source of a {@link VisualRun}. When set, `xAtOffset` and
122
- * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`
123
- * instead of linear interpolation across the run's rect. This matters for
124
- * proportional fonts where character widths differ a lot (e.g. `m` vs `i`)
125
- * and a caret placed by interpolation lands several pixels inside the
126
- * wrong character.
127
- *
128
- * Hand-built runs (tests) omit this; their `xAtOffset` falls back to
129
- * linear interpolation.
130
- */
131
- export interface VisualRunSource {
132
- readonly textNode: Text;
133
- /** Offset within `textNode.data` corresponding to `sourceRange.start`. */
134
- readonly textNodeStart: number;
135
- }
136
- /**
137
- * One contiguous run of text painted on a single visual line.
138
- *
139
- * When constructed with a {@link VisualRunSource}, `xAtOffset` returns the
140
- * pixel-exact x of the caret before character `offset` by measuring the
141
- * prefix `[textNodeStart, textNodeStart + (offset - sourceStart))` with a
142
- * DOM `Range`. Without a source it falls back to linear interpolation
143
- * across `rect.width`.
144
- */
145
- export declare class VisualRun {
146
- readonly sourceRange: OffsetRange;
147
- readonly rect: Rect2D;
148
- readonly source?: VisualRunSource | undefined;
149
- constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined);
150
- get sourceStart(): SourceOffset;
151
- get sourceEndExclusive(): SourceOffset;
152
- get sourceLength(): number;
153
- containsOffset(offset: SourceOffset): boolean;
154
- sourceDistanceTo(offset: SourceOffset): number;
155
- xAtOffset(offset: SourceOffset): number;
156
- offsetAtX(x: number): SourceOffset;
157
- }
@@ -1,5 +0,0 @@
1
- import { AstVisualization } from '../parser/visualizeAst.js';
2
- import { DocumentViewData } from './viewData.js';
3
- import { DocumentViewNode } from './content/documentView.js';
4
- export declare function visualizeViewData(root: DocumentViewData, source: string): AstVisualization;
5
- export declare function visualizeViewNode(root: DocumentViewNode, source: string): AstVisualization;