@gravionlabs/helix-code 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,604 @@
1
+ import { EditorState, Extension, StateField } from "@codemirror/state";
2
+ import * as i0 from "@angular/core";
3
+ import { InjectionToken } from "@angular/core";
4
+ import { LanguageDescription, LanguageSupport } from "@codemirror/language";
5
+ import { ControlValueAccessor } from "@angular/forms";
6
+ import { FormValueControl } from "@angular/forms/signals";
7
+ import { EditorView } from "@codemirror/view";
8
+ /**
9
+ * The editor theme of Helix: surfaces, text, cursor, selection, active line, gutters, panels and
10
+ * tooltips, all on `var(--h-*)` values, so the editor follows the light and dark theme and a
11
+ * primary colour that changes at runtime without a rebuild. Font family and size come from
12
+ * `--hx-code-font-family` and `--hx-code-font-size`, with defaults.
13
+ *
14
+ * It needs no import from helix-ui: dark mode is the `.app-dark` class, through CSS only.
15
+ * Pair it with `hxCodeHighlight()` for the syntax colours.
16
+ */
17
+ export declare function hxCodeTheme(): Extension;
18
+ /** The syntax roles of Helix code, each one a CSS variable `--hx-code-<role>`. */
19
+ type HxCodeRole = 'keyword' | 'string' | 'number' | 'comment' | 'function' | 'type' | 'property' | 'operator' | 'meta' | 'invalid' | 'link' | 'heading';
20
+ /** The default colour of a role in the light and the dark theme. */
21
+ interface HxCodeColor {
22
+ readonly light: string;
23
+ readonly dark: string;
24
+ }
25
+ /**
26
+ * The defaults of `--hx-code-*`. Every colour reaches at least 4.5:1 against the editor background
27
+ * (`--h-content-background`: `#ffffff` light, `#1b1b1f` dark); the token test checks it.
28
+ */
29
+ export declare const HX_CODE_PALETTE: Readonly<Record<HxCodeRole, HxCodeColor>>;
30
+ /**
31
+ * The syntax highlighting of Helix code: a `HighlightStyle` on lezer tags whose colours are the CSS
32
+ * variables `--hx-code-<role>` (see {@link HX_CODE_PALETTE}), with defaults for the light and the
33
+ * dark (`.app-dark`) theme set inside the extension; there is no stylesheet to import.
34
+ * A theme switch needs no rebuild of the editor.
35
+ */
36
+ export declare function hxCodeHighlight(): Extension;
37
+ /**
38
+ * The languages an `hx-code-editor` knows. Defaults to `@codemirror/language-data`; provide a
39
+ * shorter list to leave out grammars. Only the editor reads it and passes it to the functions.
40
+ */
41
+ export declare const HX_CODE_LANGUAGES: InjectionToken<readonly LanguageDescription[]>;
42
+ /** The `LanguageDescription` for a file name or path, or `null` when none matches. */
43
+ export declare function hxLanguageFor(path: string, languages?: readonly LanguageDescription[]): LanguageDescription | null;
44
+ /**
45
+ * Loads the `LanguageSupport` for a file name; the grammar is a lazy chunk.
46
+ * Resolves to `null` when no language matches or the load fails; it never throws.
47
+ */
48
+ export declare function hxLoadLanguage(path: string, languages?: readonly LanguageDescription[]): Promise<LanguageSupport | null>;
49
+ /**
50
+ * A CodeMirror editor in an Angular template: text in and out, the language chosen by file path,
51
+ * the Helix theme and highlighting by default, and `extensions` for the app's own features.
52
+ * A real form control for template-driven, reactive and signal forms.
53
+ *
54
+ * ```html
55
+ * <hx-code-editor aria-label="Source" path="app.ts" [(value)]="text" />
56
+ * <hx-code-editor aria-label="Config" path="a.json" [formControl]="control" />
57
+ * ```
58
+ *
59
+ * `valueChange` fires on user edits only. Every other input reconfigures the running view; the
60
+ * view is created once and destroyed with the component. Give the editor an accessible name with
61
+ * `aria-label` or `aria-labelledby` on the host.
62
+ */
63
+ export declare class HxCodeEditor implements ControlValueAccessor, FormValueControl<string> {
64
+ #private;
65
+ readonly value: import("@angular/core").ModelSignal<string>;
66
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
67
+ readonly invalid: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
68
+ readonly touch: import("@angular/core").OutputEmitterRef<void>;
69
+ /** A file name or path; it selects the language. Empty: plain text. */
70
+ readonly path: import("@angular/core").InputSignal<string>;
71
+ readonly readOnly: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
72
+ readonly lineNumbers: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
73
+ readonly lineWrapping: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
74
+ /** Extra CodeMirror extensions of the app (completion, search, linting, …). */
75
+ readonly extensions: import("@angular/core").InputSignal<readonly Extension[]>;
76
+ readonly ariaLabel: import("@angular/core").InputSignal<string | null>;
77
+ readonly ariaLabelledby: import("@angular/core").InputSignal<string | null>;
78
+ /** The `EditorView`, or `null` before the first render. */
79
+ readonly view: import("@angular/core").Signal<EditorView | null>;
80
+ private readonly container;
81
+ protected readonly isDisabled: () => boolean;
82
+ constructor();
83
+ /** Moves the keyboard focus into the editor. */
84
+ focus(): void;
85
+ protected onFocusOut(): void;
86
+ writeValue(value: string | null): void;
87
+ registerOnChange(fn: (value: string) => void): void;
88
+ registerOnTouched(fn: () => void): void;
89
+ setDisabledState(disabled: boolean): void;
90
+ static ɵfac: i0.ɵɵFactoryDeclaration<HxCodeEditor, never>;
91
+ static ɵcmp: i0.ɵɵComponentDeclaration<HxCodeEditor, "hx-code-editor", never, {
92
+ "value": {
93
+ "alias": "value";
94
+ "required": false;
95
+ "isSignal": true;
96
+ };
97
+ "disabled": {
98
+ "alias": "disabled";
99
+ "required": false;
100
+ "isSignal": true;
101
+ };
102
+ "invalid": {
103
+ "alias": "invalid";
104
+ "required": false;
105
+ "isSignal": true;
106
+ };
107
+ "path": {
108
+ "alias": "path";
109
+ "required": false;
110
+ "isSignal": true;
111
+ };
112
+ "readOnly": {
113
+ "alias": "readOnly";
114
+ "required": false;
115
+ "isSignal": true;
116
+ };
117
+ "lineNumbers": {
118
+ "alias": "lineNumbers";
119
+ "required": false;
120
+ "isSignal": true;
121
+ };
122
+ "lineWrapping": {
123
+ "alias": "lineWrapping";
124
+ "required": false;
125
+ "isSignal": true;
126
+ };
127
+ "extensions": {
128
+ "alias": "extensions";
129
+ "required": false;
130
+ "isSignal": true;
131
+ };
132
+ "ariaLabel": {
133
+ "alias": "aria-label";
134
+ "required": false;
135
+ "isSignal": true;
136
+ };
137
+ "ariaLabelledby": {
138
+ "alias": "aria-labelledby";
139
+ "required": false;
140
+ "isSignal": true;
141
+ };
142
+ }, {
143
+ "value": "valueChange";
144
+ "touch": "touch";
145
+ }, never, never, true, never>;
146
+ }
147
+ /** A comment on lines of one side of a diff. Lines are 1-based. */
148
+ interface HxDiffComment {
149
+ readonly id: string;
150
+ readonly side: 'original' | 'modified';
151
+ readonly startLine: number;
152
+ readonly endLine: number;
153
+ readonly text: string;
154
+ readonly author?: string;
155
+ /** ISO 8601, as GitHub `created_at`. */
156
+ readonly time?: string;
157
+ }
158
+ /**
159
+ * CodeMirror command: opens the comment draft box on the line of the cursor, so the box is
160
+ * reachable by keyboard; focus moves into its textarea and back to the editor when it closes.
161
+ * It does nothing (returns `false`) in an editor without comments enabled. Bind it to a key:
162
+ * `keymap.of([{ key: 'Mod-Alt-m', run: openCommentDraft }])`.
163
+ */
164
+ export declare function openCommentDraft(view: EditorView): boolean;
165
+ /** A review finding on lines of one side of a diff. Lines are 1-based. */
166
+ interface HxDiffFinding {
167
+ readonly id: string;
168
+ readonly side: 'original' | 'modified';
169
+ readonly startLine: number;
170
+ readonly endLine: number;
171
+ readonly severity: 'blocking' | 'note';
172
+ readonly title: string;
173
+ readonly detail?: string;
174
+ }
175
+ /** One comment of a thread. `time` is ISO 8601, as GitHub `created_at`. */
176
+ interface HxDiffThreadComment {
177
+ readonly id: string;
178
+ readonly author: string;
179
+ readonly time: string;
180
+ readonly text: string;
181
+ }
182
+ /** A review thread on lines of one side of a diff: the first comment, its replies, resolved state. */
183
+ interface HxDiffThread {
184
+ readonly id: string;
185
+ readonly side: 'original' | 'modified';
186
+ readonly startLine: number;
187
+ readonly endLine: number;
188
+ readonly resolved: boolean;
189
+ readonly comments: readonly HxDiffThreadComment[];
190
+ }
191
+ /** How the two versions are laid out. `auto`: split when the host is wide enough, else unified. */
192
+ type HxDiffLayout = 'auto' | 'split' | 'unified';
193
+ /** The text a line number refers to. */
194
+ type HxDiffSide = 'original' | 'modified';
195
+ /** The collapsing of unchanged regions: `margin` lines stay visible, at least `minSize` collapse. */
196
+ interface HxDiffCollapse {
197
+ readonly margin?: number;
198
+ readonly minSize?: number;
199
+ }
200
+ /** A comment the reviewer wrote: the lines on `side` and the text of those lines as `quote`. */
201
+ interface HxDiffCommentAdded {
202
+ readonly side: HxDiffSide;
203
+ readonly startLine: number;
204
+ readonly endLine: number;
205
+ readonly text: string;
206
+ readonly quote: string;
207
+ }
208
+ /** A reply was written in a thread. */
209
+ interface HxDiffReplyAdded {
210
+ readonly threadId: string;
211
+ readonly text: string;
212
+ }
213
+ /** The resolve button of a thread was used. */
214
+ interface HxDiffResolvedChange {
215
+ readonly threadId: string;
216
+ readonly resolved: boolean;
217
+ }
218
+ /** The action of a finding box was used: the finding and the text of its lines on its side. */
219
+ interface HxDiffFindingAction {
220
+ readonly id: string;
221
+ readonly quote: string;
222
+ }
223
+ /** The decision on one change in review mode. */
224
+ type HxChangeDecision = 'accept' | 'reject';
225
+ /** A change was decided: its position in the initial list of changes and the decision. */
226
+ interface HxDiffChangeDecided {
227
+ readonly index: number;
228
+ readonly decision: HxChangeDecision;
229
+ }
230
+ /**
231
+ * Shows two versions of a text, side by side or unified, read-only: syntax highlighting, marked
232
+ * changed words, a change gutter with `+` and `-`, and collapsed unchanged regions.
233
+ *
234
+ * ```html
235
+ * <hx-diff-view aria-label="Changes" path="app.ts" [original]="before" [modified]="after" />
236
+ * ```
237
+ *
238
+ * With `commentable`, a click on a line number opens a comment box (Shift-click extends the range)
239
+ * and `commentAdded` reports the saved text; `comments` are shown below their last line.
240
+ *
241
+ * `findings` are shown as boxes below their last line, the lines marked in the gutter; with
242
+ * `findingActionLabel` each box has a button and `findingAction` reports `{id, quote}`.
243
+ *
244
+ * `threads` (`HxDiffThread`) are boxes below their last line, after findings and before comments:
245
+ * the comments in order, a reply field (`replyAdded`) and a resolve button (`resolvedChange`); a
246
+ * resolved thread is one line until clicked. `renderComment` turns text into HTML (Markdown); its
247
+ * result is sanitized with Angular `DomSanitizer` before it is inserted.
248
+ *
249
+ * With `reviewable` (unified layout only, ignored with `layout="split"`) each change has an accept
250
+ * and a reject button; `changeDecided` reports `{index, decision}` (`index` is the position in the
251
+ * initial list of changes and stays stable), `result()` is the text after the decisions so far
252
+ * (undecided changes stay as in `modified`), `pendingChanges()` counts the undecided changes, and
253
+ * `acceptAll()` / `rejectAll()` decide the rest. A decided change leaves `changeCount()`.
254
+ *
255
+ * The view is rebuilt when a text, `layout`, `path`, `reviewable` or `collapseUnchanged` changes; a theme switch
256
+ * needs no rebuild (colors are CSS variables `--hx-diff-added-*`, `--hx-diff-removed-*`).
257
+ */
258
+ export declare class HxDiffView {
259
+ #private;
260
+ /** The old version. Empty: a new file. */
261
+ readonly original: import("@angular/core").InputSignal<string>;
262
+ /** The new version. Empty: a deleted file. */
263
+ readonly modified: import("@angular/core").InputSignal<string>;
264
+ /** A file name or path; it selects the language. Empty: plain text. */
265
+ readonly path: import("@angular/core").InputSignal<string>;
266
+ /** `split` (default), `unified`, or `auto`: split from `splitMinWidth` of the host, else unified. */
267
+ readonly layout: import("@angular/core").InputSignal<HxDiffLayout>;
268
+ /** With `layout="auto"`: the host width in px from which the split layout is used. */
269
+ readonly splitMinWidth: import("@angular/core").InputSignal<number>;
270
+ /** `true` (default): margin 3, minimum 4. `false`: show everything. Or set both numbers. */
271
+ readonly collapseUnchanged: import("@angular/core").InputSignal<boolean | HxDiffCollapse>;
272
+ /** The comments to show, below their last line. Changing them does not rebuild the view. */
273
+ readonly comments: import("@angular/core").InputSignal<readonly HxDiffComment[]>;
274
+ /** `true`: a click on a line number opens a comment box. Default off. */
275
+ readonly commentable: import("@angular/core").InputSignal<boolean>;
276
+ /** The review findings to show, below their last line. Changing them does not rebuild the view. */
277
+ readonly findings: import("@angular/core").InputSignal<readonly HxDiffFinding[]>;
278
+ /** The label of the button on each finding box. Empty (default): no button. */
279
+ readonly findingActionLabel: import("@angular/core").InputSignal<string>;
280
+ /** The button of a finding box was pressed. */
281
+ readonly findingAction: import("@angular/core").OutputEmitterRef<HxDiffFindingAction>;
282
+ /** The review threads to show, below their last line. Changing them does not rebuild the view. */
283
+ readonly threads: import("@angular/core").InputSignal<readonly HxDiffThread[]>;
284
+ /** Optional: text of a comment to HTML (e.g. Markdown). The result is sanitized. Default plain text. */
285
+ readonly renderComment: import("@angular/core").InputSignal<((text: string) => string) | null>;
286
+ /** A reply was written in a thread; the app stores it and passes the thread back. */
287
+ readonly replyAdded: import("@angular/core").OutputEmitterRef<HxDiffReplyAdded>;
288
+ /** The resolve button of a thread was used. */
289
+ readonly resolvedChange: import("@angular/core").OutputEmitterRef<HxDiffResolvedChange>;
290
+ /** A comment was written; the app stores it and passes it back through `comments`. */
291
+ readonly commentAdded: import("@angular/core").OutputEmitterRef<HxDiffCommentAdded>;
292
+ /** `true`: each change has an accept and a reject button. Unified layout only. Default off. */
293
+ readonly reviewable: import("@angular/core").InputSignal<boolean>;
294
+ /** A change was accepted or rejected. */
295
+ readonly changeDecided: import("@angular/core").OutputEmitterRef<HxDiffChangeDecided>;
296
+ readonly ariaLabel: import("@angular/core").InputSignal<string | null>;
297
+ readonly ariaLabelledby: import("@angular/core").InputSignal<string | null>;
298
+ /** The number of changes (chunks) of the diff. */
299
+ readonly changeCount: import("@angular/core").Signal<number>;
300
+ /** The 1-based number of the change at the cursor; 0 when no change is selected yet. */
301
+ readonly currentChange: import("@angular/core").Signal<number>;
302
+ /** The text after the decisions so far; undecided changes show as in `modified`. */
303
+ readonly result: import("@angular/core").Signal<string>;
304
+ /** The number of changes without a decision. */
305
+ readonly pendingChanges: import("@angular/core").Signal<number>;
306
+ /** The layout in use: `auto` resolved by the host width. `null` while `auto` is not measured. */
307
+ readonly effectiveLayout: import("@angular/core").Signal<"split" | "unified" | null>;
308
+ private readonly container;
309
+ constructor();
310
+ /** Accepts every undecided change: the modified text is kept. */
311
+ acceptAll(): void;
312
+ /** Rejects every undecided change: the original lines are restored. */
313
+ rejectAll(): void;
314
+ /** Moves to the next change; after the last one it wraps to the first. */
315
+ next(): void;
316
+ /** Moves to the previous change; before the first one it wraps to the last. */
317
+ previous(): void;
318
+ /**
319
+ * Scrolls to a 1-based line of the original or the modified text and expands a collapsed region
320
+ * around it. A line outside the text is clamped.
321
+ */
322
+ revealLine(line: number, side?: HxDiffSide): void;
323
+ static ɵfac: i0.ɵɵFactoryDeclaration<HxDiffView, never>;
324
+ static ɵcmp: i0.ɵɵComponentDeclaration<HxDiffView, "hx-diff-view", never, {
325
+ "original": {
326
+ "alias": "original";
327
+ "required": true;
328
+ "isSignal": true;
329
+ };
330
+ "modified": {
331
+ "alias": "modified";
332
+ "required": true;
333
+ "isSignal": true;
334
+ };
335
+ "path": {
336
+ "alias": "path";
337
+ "required": false;
338
+ "isSignal": true;
339
+ };
340
+ "layout": {
341
+ "alias": "layout";
342
+ "required": false;
343
+ "isSignal": true;
344
+ };
345
+ "splitMinWidth": {
346
+ "alias": "splitMinWidth";
347
+ "required": false;
348
+ "isSignal": true;
349
+ };
350
+ "collapseUnchanged": {
351
+ "alias": "collapseUnchanged";
352
+ "required": false;
353
+ "isSignal": true;
354
+ };
355
+ "comments": {
356
+ "alias": "comments";
357
+ "required": false;
358
+ "isSignal": true;
359
+ };
360
+ "commentable": {
361
+ "alias": "commentable";
362
+ "required": false;
363
+ "isSignal": true;
364
+ };
365
+ "findings": {
366
+ "alias": "findings";
367
+ "required": false;
368
+ "isSignal": true;
369
+ };
370
+ "findingActionLabel": {
371
+ "alias": "findingActionLabel";
372
+ "required": false;
373
+ "isSignal": true;
374
+ };
375
+ "threads": {
376
+ "alias": "threads";
377
+ "required": false;
378
+ "isSignal": true;
379
+ };
380
+ "renderComment": {
381
+ "alias": "renderComment";
382
+ "required": false;
383
+ "isSignal": true;
384
+ };
385
+ "reviewable": {
386
+ "alias": "reviewable";
387
+ "required": false;
388
+ "isSignal": true;
389
+ };
390
+ "ariaLabel": {
391
+ "alias": "aria-label";
392
+ "required": false;
393
+ "isSignal": true;
394
+ };
395
+ "ariaLabelledby": {
396
+ "alias": "aria-labelledby";
397
+ "required": false;
398
+ "isSignal": true;
399
+ };
400
+ }, {
401
+ "findingAction": "findingAction";
402
+ "replyAdded": "replyAdded";
403
+ "resolvedChange": "resolvedChange";
404
+ "commentAdded": "commentAdded";
405
+ "changeDecided": "changeDecided";
406
+ }, never, never, true, never>;
407
+ }
408
+ /** The roles of the diff colors: `--hx-diff-added-*` and `--hx-diff-removed-*`. */
409
+ type HxDiffKind = 'added' | 'removed';
410
+ /** `background` tints a changed line, `mark` a changed word, `sign` the gutter sign. */
411
+ type HxDiffPart = 'background' | 'mark' | 'sign';
412
+ /** The defaults of `--hx-diff-*` in the light and the dark theme. */
413
+ export declare const HX_DIFF_PALETTE: Readonly<Record<HxDiffKind, Readonly<Record<HxDiffPart, {
414
+ light: string;
415
+ dark: string;
416
+ }>>>>;
417
+ /**
418
+ * The Helix colors of the diff view. Added and removed lines, changed words and the gutter signs
419
+ * (`+`, `-`) take their colors from `--hx-diff-added-*` and `--hx-diff-removed-*`; the defaults for
420
+ * `.app-dark` are set here, so a theme switch needs no rebuild.
421
+ */
422
+ export declare function hxDiffTheme(): Extension;
423
+ /** A piece of a changed line; `changed` pieces are the words that differ from the paired line. */
424
+ interface HxSegment {
425
+ text: string;
426
+ changed: boolean;
427
+ }
428
+ interface HxDiffRow {
429
+ kind: 'same' | 'add' | 'del';
430
+ /** The line without its line break. */
431
+ text: string;
432
+ /** Word-level pieces of a line that has a partner on the other side; absent otherwise. */
433
+ segments?: HxSegment[];
434
+ }
435
+ /** Word-level difference of two lines: the pieces of each side, marking what the other lacks. */
436
+ export declare function hxWordDiff(oldLine: string, newLine: string): {
437
+ old: HxSegment[];
438
+ new: HxSegment[];
439
+ };
440
+ /**
441
+ * Line-based diff of two texts (longest common subsequence over lines, after the common head and
442
+ * tail are trimmed). Where a run of removed lines is followed by a run of added lines, the lines
443
+ * are paired in order and get word-level `segments`; surplus lines get none.
444
+ *
445
+ * CRLF is read as LF, and a final line break does not add a line, so `'x\n'` and `'x'` give no
446
+ * rows. If the differing middle has more than 4,000,000 cells (n*m), it falls back to
447
+ * "all deleted, then all added" instead of building the table.
448
+ */
449
+ export declare function hxDiffLines(oldText: string, newText: string): HxDiffRow[];
450
+ /** Number of added and removed lines. */
451
+ export declare function hxDiffStat(rows: readonly HxDiffRow[]): {
452
+ added: number;
453
+ removed: number;
454
+ };
455
+ /** A run of lines both versions share, or a hunk where they differ. */
456
+ type HxMergePart = {
457
+ kind: 'same';
458
+ lines: string[];
459
+ } | {
460
+ kind: 'hunk';
461
+ index: number;
462
+ mine: string[];
463
+ theirs: string[];
464
+ };
465
+ /** Which side of a hunk goes into the merged note. */
466
+ type HxMergeChoice = 'mine' | 'theirs' | 'both';
467
+ /** Splits the difference of two texts into shared runs and hunks (`mine` is `a`, `theirs` is `b`). */
468
+ export declare function hxMergeParts(a: string, b: string): HxMergePart[];
469
+ /** The merged text; a hunk without a choice takes `'mine'`. It ends with a line break when `endsWithBreak` is true and it has lines. */
470
+ export declare function hxMergeText(parts: readonly HxMergePart[], choices: Readonly<Record<number, HxMergeChoice>>, endsWithBreak: boolean): string;
471
+ /** A line range of a conflict, 0-based, both ends inclusive and both marker lines. */
472
+ interface HxConflictRange {
473
+ from: number;
474
+ to: number;
475
+ }
476
+ /**
477
+ * A Git conflict in a text. Line numbers are 0-based.
478
+ *
479
+ * Each range runs from the line of its own marker to the line of the next marker, so the content
480
+ * of a side is the lines strictly between `from` and `to`:
481
+ *
482
+ * - `ours`: `<<<<<<<` to `|||||||` (diff3 style) or to `=======`
483
+ * - `base` (diff3 style only): `|||||||` to `=======`
484
+ * - `theirs`: `=======` to `>>>>>>>`
485
+ *
486
+ * `start` is the `<<<<<<<` line, `end` the `>>>>>>>` line. The labels are the text after the markers.
487
+ */
488
+ interface HxConflict {
489
+ start: number;
490
+ end: number;
491
+ ours: HxConflictRange;
492
+ base?: HxConflictRange;
493
+ theirs: HxConflictRange;
494
+ oursLabel: string;
495
+ baseLabel?: string;
496
+ theirsLabel: string;
497
+ }
498
+ /**
499
+ * Finds the conflicts of `text`. Malformed markers (no end, a start inside a conflict, markers in
500
+ * the wrong order) are left as plain text; this never throws.
501
+ */
502
+ export declare function hxParseConflicts(text: string): HxConflict[];
503
+ type HxConflictChoice = 'ours' | 'theirs' | 'both';
504
+ /** The conflicts of the document; they follow every edit. */
505
+ export declare const hxConflictField: StateField<readonly HxConflict[]>;
506
+ /** The number of conflicts left in the document; 0 without the extension. */
507
+ export declare function hxConflictCount(state: EditorState): number;
508
+ /** Moves the cursor to the next conflict after the cursor line; wraps around. */
509
+ export declare const hxNextConflict: (view: EditorView) => boolean;
510
+ /** Moves the cursor to the previous conflict before the cursor line; wraps around. */
511
+ export declare const hxPreviousConflict: (view: EditorView) => boolean;
512
+ /**
513
+ * Shows Git conflict markers as blocks: the ours, base and theirs lines colored, the marker lines
514
+ * dimmed, and a row above each conflict with Accept ours, Accept theirs and Accept both. An
515
+ * action is one undoable change. There is no key map: bind {@link hxNextConflict} and
516
+ * {@link hxPreviousConflict} in the app.
517
+ *
518
+ * Colors: `--hx-code-conflict-ours-bg`, `--hx-code-conflict-theirs-bg` and
519
+ * `--hx-code-conflict-marker-opacity`, with defaults for the light and the dark theme.
520
+ */
521
+ export declare function hxConflictMarkers(): Extension;
522
+ /**
523
+ * Merges two versions of a text: shared lines are shown once, each differing part offers mine, theirs or both,
524
+ * and the result can be edited before it is taken. It renders no dialog; the app places it.
525
+ */
526
+ export declare class HxConflictMerge {
527
+ #private;
528
+ protected readonly id: string;
529
+ /** My version of the text. */
530
+ readonly mine: import("@angular/core").InputSignal<string>;
531
+ /** Their version of the text. */
532
+ readonly theirs: import("@angular/core").InputSignal<string>;
533
+ readonly mineLabel: import("@angular/core").InputSignal<string>;
534
+ readonly theirsLabel: import("@angular/core").InputSignal<string>;
535
+ /** The final text on confirm. */
536
+ readonly merged: import("@angular/core").OutputEmitterRef<string>;
537
+ /** Cancel was pressed. */
538
+ readonly cancelled: import("@angular/core").OutputEmitterRef<void>;
539
+ protected readonly parts: import("@angular/core").Signal<import("@gravionlabs/helix-code").HxMergePart[]>;
540
+ protected readonly hunks: import("@angular/core").Signal<{
541
+ kind: "hunk";
542
+ index: number;
543
+ mine: string[];
544
+ theirs: string[];
545
+ }[]>;
546
+ /** Choices the user made; a change of `mine` or `theirs` resets them. */
547
+ protected readonly choices: import("@angular/core").WritableSignal<Record<number, HxMergeChoice>>;
548
+ /** The hand-edited result, or `null` while the result follows the choices. */
549
+ protected readonly edit: import("@angular/core").WritableSignal<string | null>;
550
+ /** A choice waiting for the answer to the overwrite prompt. */
551
+ protected readonly pending: import("@angular/core").WritableSignal<{
552
+ index: number;
553
+ choice: HxMergeChoice;
554
+ } | null>;
555
+ protected readonly choiceOptions: readonly {
556
+ value: HxMergeChoice;
557
+ label: "mine" | "theirs" | "both";
558
+ }[];
559
+ /** The merged text for the current choices; a part without a choice takes mine. */
560
+ readonly result: import("@angular/core").Signal<string>;
561
+ /** The number of differing parts the user has not chosen yet. */
562
+ readonly unresolved: import("@angular/core").Signal<number>;
563
+ /** The text in the result field: the hand edit, else the merged text. */
564
+ protected readonly text: import("@angular/core").Signal<string>;
565
+ protected choiceOf(index: number): HxMergeChoice;
566
+ protected choose(index: number, choice: HxMergeChoice): void;
567
+ protected overwrite(): void;
568
+ protected keepEdit(): void;
569
+ protected onEdit(event: Event): void;
570
+ protected confirm(): void;
571
+ protected lines(lines: readonly string[]): string;
572
+ private apply;
573
+ /** Native radios check themselves before the click handler runs; put the check back on the current choice. */
574
+ private restoreRadios;
575
+ static ɵfac: i0.ɵɵFactoryDeclaration<HxConflictMerge, never>;
576
+ static ɵcmp: i0.ɵɵComponentDeclaration<HxConflictMerge, "hx-conflict-merge", never, {
577
+ "mine": {
578
+ "alias": "mine";
579
+ "required": true;
580
+ "isSignal": true;
581
+ };
582
+ "theirs": {
583
+ "alias": "theirs";
584
+ "required": true;
585
+ "isSignal": true;
586
+ };
587
+ "mineLabel": {
588
+ "alias": "mineLabel";
589
+ "required": false;
590
+ "isSignal": true;
591
+ };
592
+ "theirsLabel": {
593
+ "alias": "theirsLabel";
594
+ "required": false;
595
+ "isSignal": true;
596
+ };
597
+ }, {
598
+ "merged": "merged";
599
+ "cancelled": "cancelled";
600
+ }, never, never, true, never>;
601
+ }
602
+ /** Version of `@gravionlabs/helix-code`; a placeholder until the editor components land. */
603
+ export declare const HELIX_CODE_VERSION = "0.1.0";
604
+ export type { HxChangeDecision, HxCodeColor, HxCodeRole, HxConflict, HxConflictChoice, HxConflictRange, HxDiffChangeDecided, HxDiffCollapse, HxDiffComment, HxDiffCommentAdded, HxDiffFinding, HxDiffFindingAction, HxDiffLayout, HxDiffReplyAdded, HxDiffResolvedChange, HxDiffRow, HxDiffSide, HxDiffThread, HxDiffThreadComment, HxMergeChoice, HxMergePart, HxSegment };