@bastani/atomic-tui 0.9.90-alpha.1 → 0.10.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-command-names.d.ts +1 -1
- package/dist/builtin-command-names.d.ts.map +1 -1
- package/dist/builtin-command-names.js +0 -2
- package/dist/builtin-command-names.js.map +1 -1
- package/dist/clickable-hints.d.ts.map +1 -1
- package/dist/clickable-hints.js +75 -19
- package/dist/clickable-hints.js.map +1 -1
- package/dist/components/editor.d.ts +39 -0
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +110 -0
- package/dist/components/editor.js.map +1 -1
- package/dist/components/scroll-view.d.ts +17 -0
- package/dist/components/scroll-view.d.ts.map +1 -1
- package/dist/components/scroll-view.js +40 -0
- package/dist/components/scroll-view.js.map +1 -1
- package/dist/components/windowed-container.d.ts +87 -0
- package/dist/components/windowed-container.d.ts.map +1 -1
- package/dist/components/windowed-container.js +212 -3
- package/dist/components/windowed-container.js.map +1 -1
- package/dist/editor-component.d.ts +9 -0
- package/dist/editor-component.d.ts.map +1 -1
- package/dist/editor-component.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kill-ring.d.ts +2 -0
- package/dist/kill-ring.d.ts.map +1 -1
- package/dist/kill-ring.js +6 -0
- package/dist/kill-ring.js.map +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +6 -1
- package/dist/layout.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +45 -1
- package/dist/tui-alt-screen.d.ts.map +1 -1
- package/dist/tui-alt-screen.js +550 -48
- package/dist/tui-alt-screen.js.map +1 -1
- package/dist/tui-main-screen.d.ts +27 -1
- package/dist/tui-main-screen.d.ts.map +1 -1
- package/dist/tui-main-screen.js +216 -15
- package/dist/tui-main-screen.js.map +1 -1
- package/dist/tui.d.ts +56 -4
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +58 -7
- package/dist/tui.js.map +1 -1
- package/dist/undo-stack.d.ts +2 -0
- package/dist/undo-stack.d.ts.map +1 -1
- package/dist/undo-stack.js +6 -0
- package/dist/undo-stack.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import { Container } from "../tui.js";
|
|
2
|
+
const archivePositions = new WeakMap();
|
|
3
|
+
const historyAnchors = new WeakMap();
|
|
2
4
|
const SLICE_BUDGET_MS = 8;
|
|
3
5
|
const SLICE_CHILDREN = 48;
|
|
4
6
|
const SWEEP_INTERVAL_MS = 1_000;
|
|
5
7
|
const MAX_WINDOW_PASSES = 4;
|
|
8
|
+
function weakRowPosition(owner, leaf, within) {
|
|
9
|
+
return () => {
|
|
10
|
+
const component = leaf.deref();
|
|
11
|
+
const span = component && owner.deref()?.windowRowSpan(component);
|
|
12
|
+
return span && span.bottom > span.top ? span.top + Math.min(within, span.bottom - span.top - 1) : undefined;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Order of two saved leaves, ignoring the row within them. */
|
|
16
|
+
function compareLeaves(a, b) {
|
|
17
|
+
return a.seq - b.seq || a.block - b.block || a.part - b.part;
|
|
18
|
+
}
|
|
6
19
|
const entries = new WeakMap();
|
|
7
20
|
let staleChanges = 0;
|
|
8
21
|
function yieldThen(run) {
|
|
9
22
|
setImmediate(run).unref();
|
|
10
23
|
}
|
|
11
24
|
export class WindowedContainer extends Container {
|
|
25
|
+
/** Identify the leaf of a mutable saved transcript. A selection can then keep just its selected characters
|
|
26
|
+
* across eviction or an external rewrite, without keeping the component or its page. */
|
|
27
|
+
static markHistoryComponent(component, source, seq, block, part, provisional = false) {
|
|
28
|
+
archivePositions.set(component, { source, seq, block, part, ...(provisional ? { provisional: true } : {}) });
|
|
29
|
+
}
|
|
30
|
+
/** Mark the row that stands for a source's saved history. Its mounted saved rows follow it; a copy can draw the
|
|
31
|
+
* rest of a selection from `history`. Holding the anchor's source does not keep the anchor alive. */
|
|
32
|
+
static markHistoryAnchor(component, source, history) {
|
|
33
|
+
historyAnchors.set(component, { source, history });
|
|
34
|
+
const owner = entries.get(component)?.owner;
|
|
35
|
+
(owner?.windowHost ?? owner)?.anchors.push(new WeakRef(component));
|
|
36
|
+
}
|
|
37
|
+
/** History anchors this window has laid out. */
|
|
38
|
+
anchors = [];
|
|
12
39
|
/** The container that last laid this one out among its own rows, when this one is nested in it. */
|
|
13
40
|
windowHost;
|
|
14
41
|
/** The windowed container this one is a child of, in that layout. */
|
|
@@ -16,6 +43,9 @@ export class WindowedContainer extends Container {
|
|
|
16
43
|
/** The host's laid-out entries this container's children occupied, `[first, end)`. */
|
|
17
44
|
windowSpan = { first: 0, end: 0 };
|
|
18
45
|
laidOut = [];
|
|
46
|
+
observed = false;
|
|
47
|
+
/** Observe only children whose rows are actually returned to the viewport, never an offscreen measurement. */
|
|
48
|
+
onVisibleChild;
|
|
19
49
|
offsets = [0];
|
|
20
50
|
staleOffsetsFrom = Number.POSITIVE_INFINITY;
|
|
21
51
|
width = 0;
|
|
@@ -38,6 +68,14 @@ export class WindowedContainer extends Container {
|
|
|
38
68
|
windowChildren() {
|
|
39
69
|
return this.children;
|
|
40
70
|
}
|
|
71
|
+
/** The last window layout's span for a leaf, measured in the root document's rows; no render or tree walk. */
|
|
72
|
+
windowRowSpan(component) {
|
|
73
|
+
const entry = entries.get(component);
|
|
74
|
+
const root = this.windowHost ?? this;
|
|
75
|
+
if (!entry || root.laidOut[entry.index] !== entry)
|
|
76
|
+
return undefined;
|
|
77
|
+
return { top: root.offsets[entry.index], bottom: root.offsets[entry.index + 1] };
|
|
78
|
+
}
|
|
41
79
|
invalidate() {
|
|
42
80
|
for (const child of this.windowChildren()) {
|
|
43
81
|
const entry = entries.get(child);
|
|
@@ -52,7 +90,10 @@ export class WindowedContainer extends Container {
|
|
|
52
90
|
const width = Math.max(1, Math.floor(request.width));
|
|
53
91
|
const height = Math.max(0, Math.floor(request.height));
|
|
54
92
|
this.requestRender = request.requestRender;
|
|
55
|
-
|
|
93
|
+
// A scroll moves from the rows the reader saw, wherever rows added or removed above have put them since.
|
|
94
|
+
const anchor = !request.exact && (request.top === this.lastTop || request.moved !== undefined)
|
|
95
|
+
? this.scrollAnchor(this.lastTop, height)
|
|
96
|
+
: undefined;
|
|
56
97
|
if (width !== this.width) {
|
|
57
98
|
this.width = width;
|
|
58
99
|
for (const entry of this.laidOut)
|
|
@@ -72,7 +113,111 @@ export class WindowedContainer extends Container {
|
|
|
72
113
|
this.scheduleSweep();
|
|
73
114
|
this.lastTop = top;
|
|
74
115
|
const length = this.rowCount();
|
|
75
|
-
return {
|
|
116
|
+
return {
|
|
117
|
+
top,
|
|
118
|
+
length,
|
|
119
|
+
at: this.observed ? (index) => this.visibleRowAt(index) : (index) => this.rowAt(index),
|
|
120
|
+
trackRow: (index) => {
|
|
121
|
+
if (index < 0 || index >= length)
|
|
122
|
+
return undefined;
|
|
123
|
+
const anchor = this.locateAnchor(index);
|
|
124
|
+
if (!anchor)
|
|
125
|
+
return undefined;
|
|
126
|
+
return weakRowPosition(new WeakRef(this), new WeakRef(anchor.entry.component), anchor.within);
|
|
127
|
+
},
|
|
128
|
+
historyRow: (index) => {
|
|
129
|
+
if (index < 0 || index >= length)
|
|
130
|
+
return undefined;
|
|
131
|
+
const anchor = this.locateAnchor(index);
|
|
132
|
+
const position = anchor && archivePositions.get(anchor.entry.component);
|
|
133
|
+
return position && anchor ? { ...position, line: anchor.within } : undefined;
|
|
134
|
+
},
|
|
135
|
+
historyEdges: (index) => {
|
|
136
|
+
const run = index >= 0 && index < length ? this.historyRunAt(index) : undefined;
|
|
137
|
+
if (!run)
|
|
138
|
+
return undefined;
|
|
139
|
+
const owner = new WeakRef(this);
|
|
140
|
+
const edge = (index, within) => weakRowPosition(owner, new WeakRef(this.laidOut[index].component), within);
|
|
141
|
+
return {
|
|
142
|
+
source: run.source,
|
|
143
|
+
...(run.first > 0 ? { above: edge(run.first - 1, Number.MAX_SAFE_INTEGER) } : {}),
|
|
144
|
+
...(run.last + 1 < this.laidOut.length ? { below: edge(run.last + 1, 0) } : {}),
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
historyAnchor: () => {
|
|
148
|
+
const at = this.anchorIndex();
|
|
149
|
+
if (at === undefined)
|
|
150
|
+
return undefined;
|
|
151
|
+
const anchor = this.laidOut[at];
|
|
152
|
+
const { source, history } = historyAnchors.get(anchor.component);
|
|
153
|
+
let below = at + 1;
|
|
154
|
+
while (below < this.laidOut.length &&
|
|
155
|
+
(this.laidOut[below].height === 0 ||
|
|
156
|
+
archivePositions.get(this.laidOut[below].component)?.source === source))
|
|
157
|
+
below++;
|
|
158
|
+
const owner = new WeakRef(this);
|
|
159
|
+
const edge = (index, within) => weakRowPosition(owner, new WeakRef(this.laidOut[index].component), within);
|
|
160
|
+
let next = at + 1;
|
|
161
|
+
while (next < below && this.laidOut[next].height === 0)
|
|
162
|
+
next++;
|
|
163
|
+
const first = next < below ? archivePositions.get(this.laidOut[next].component) : undefined;
|
|
164
|
+
const width = this.width;
|
|
165
|
+
return {
|
|
166
|
+
source,
|
|
167
|
+
edges: {
|
|
168
|
+
source,
|
|
169
|
+
above: edge(at, Number.MAX_SAFE_INTEGER),
|
|
170
|
+
...(below < this.laidOut.length ? { below: edge(below, 0) } : {}),
|
|
171
|
+
},
|
|
172
|
+
...(first ? { first } : {}),
|
|
173
|
+
last: history.last,
|
|
174
|
+
read: (from, to) => history.read(from, to, width),
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
visitHistoryRun: (index, from, to, visit) => {
|
|
178
|
+
const run = index >= 0 && index < length ? this.historyRunAt(index) : undefined;
|
|
179
|
+
if (!run)
|
|
180
|
+
return;
|
|
181
|
+
let moved = false;
|
|
182
|
+
for (let i = run.first; i <= run.last; i++) {
|
|
183
|
+
const entry = this.laidOut[i];
|
|
184
|
+
const position = archivePositions.get(entry.component);
|
|
185
|
+
if (position?.source !== run.source)
|
|
186
|
+
continue;
|
|
187
|
+
if (from && compareLeaves(position, from) < 0)
|
|
188
|
+
continue;
|
|
189
|
+
if (to && compareLeaves(position, to) > 0)
|
|
190
|
+
continue;
|
|
191
|
+
if (!entry.current || entry.width !== this.width)
|
|
192
|
+
moved = this.renderEntry(entry, this.width) || moved;
|
|
193
|
+
for (let line = 0; line < entry.lines.length; line++)
|
|
194
|
+
visit(entry.lines[line], { ...position, line });
|
|
195
|
+
// A provisional leaf that draws nothing now (its card is drawn at the other end of the pair) is still
|
|
196
|
+
// provisional: a copy draws its entry as the whole transcript does.
|
|
197
|
+
if (position.provisional && entry.lines.length === 0)
|
|
198
|
+
visit("", { ...position, line: 0 });
|
|
199
|
+
}
|
|
200
|
+
if (moved)
|
|
201
|
+
this.requestRender?.();
|
|
202
|
+
},
|
|
203
|
+
visitVolatileRows: (first, last, visit) => {
|
|
204
|
+
if (!length || first >= length || last < 0)
|
|
205
|
+
return;
|
|
206
|
+
for (let i = this.indexAt(Math.max(0, first)); i < this.laidOut.length; i++) {
|
|
207
|
+
const entry = this.laidOut[i], start = this.offsets[i];
|
|
208
|
+
if (start > last)
|
|
209
|
+
break;
|
|
210
|
+
if (!entry.current)
|
|
211
|
+
continue;
|
|
212
|
+
const history = archivePositions.get(entry.component);
|
|
213
|
+
if (!history && entry.component.selectionTextMayChangeOnReplay !== true)
|
|
214
|
+
continue;
|
|
215
|
+
entry.selectionRenderer ??= Symbol();
|
|
216
|
+
for (let row = Math.max(first, start); row <= last && row < start + entry.lines.length; row++)
|
|
217
|
+
visit(row, entry.lines[row - start], entry.selectionRenderer, history && { ...history, line: row - start });
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
};
|
|
76
221
|
}
|
|
77
222
|
settleRows() {
|
|
78
223
|
if (this.width === 0)
|
|
@@ -149,6 +294,15 @@ export class WindowedContainer extends Container {
|
|
|
149
294
|
rowCount() {
|
|
150
295
|
return this.offsets[this.laidOut.length] ?? 0;
|
|
151
296
|
}
|
|
297
|
+
visibleRowAt(row) {
|
|
298
|
+
const line = this.rowAt(row);
|
|
299
|
+
if (line !== undefined) {
|
|
300
|
+
const entry = this.laidOut[this.lastRowIndex];
|
|
301
|
+
if (entry)
|
|
302
|
+
entry.owner?.onVisibleChild?.(entry.component);
|
|
303
|
+
}
|
|
304
|
+
return line;
|
|
305
|
+
}
|
|
152
306
|
rowAt(row) {
|
|
153
307
|
if (row < 0 || row >= this.rowCount())
|
|
154
308
|
return undefined;
|
|
@@ -173,6 +327,34 @@ export class WindowedContainer extends Container {
|
|
|
173
327
|
}
|
|
174
328
|
return Math.max(0, low);
|
|
175
329
|
}
|
|
330
|
+
/** The laid-out index of the first history anchor still in this window. */
|
|
331
|
+
anchorIndex() {
|
|
332
|
+
for (let i = 0; i < this.anchors.length; i++) {
|
|
333
|
+
const component = this.anchors[i].deref();
|
|
334
|
+
const entry = component && entries.get(component);
|
|
335
|
+
if (entry && this.laidOut[entry.index] === entry)
|
|
336
|
+
return entry.index;
|
|
337
|
+
if (!component)
|
|
338
|
+
this.anchors.splice(i--, 1);
|
|
339
|
+
}
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
/** The laid-out entries of the saved run around `row`: one source, possibly with empty rows between. */
|
|
343
|
+
historyRunAt(row) {
|
|
344
|
+
if (this.laidOut.length === 0)
|
|
345
|
+
return undefined;
|
|
346
|
+
const at = this.indexAt(row);
|
|
347
|
+
const source = archivePositions.get(this.laidOut[at].component)?.source;
|
|
348
|
+
if (!source)
|
|
349
|
+
return undefined;
|
|
350
|
+
const inRun = (entry) => entry.height === 0 || archivePositions.get(entry.component)?.source === source;
|
|
351
|
+
let first = at, last = at;
|
|
352
|
+
while (first > 0 && inRun(this.laidOut[first - 1]))
|
|
353
|
+
first--;
|
|
354
|
+
while (last + 1 < this.laidOut.length && inRun(this.laidOut[last + 1]))
|
|
355
|
+
last++;
|
|
356
|
+
return { source, first, last };
|
|
357
|
+
}
|
|
176
358
|
locateAnchor(top) {
|
|
177
359
|
if (this.laidOut.length === 0)
|
|
178
360
|
return undefined;
|
|
@@ -180,13 +362,35 @@ export class WindowedContainer extends Container {
|
|
|
180
362
|
const entry = this.laidOut[index];
|
|
181
363
|
return entry ? { entry, within: Math.max(0, top - (this.offsets[index] ?? 0)) } : undefined;
|
|
182
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* The row that keeps the reader's place when rows change before the next frame: the row at `top`, or, while a
|
|
367
|
+
* history anchor is on screen, the first row after it. Saved pages are mounted right after that anchor, so the rows
|
|
368
|
+
* the reader saw below it keep their place, not the rows above it.
|
|
369
|
+
*/
|
|
370
|
+
scrollAnchor(top, height) {
|
|
371
|
+
const at = this.locateAnchor(top);
|
|
372
|
+
if (!at)
|
|
373
|
+
return undefined;
|
|
374
|
+
for (let index = this.indexAt(Math.max(0, top)); index < this.laidOut.length; index++) {
|
|
375
|
+
if ((this.offsets[index] ?? 0) >= top + height)
|
|
376
|
+
break;
|
|
377
|
+
if (!historyAnchors.has(this.laidOut[index].component))
|
|
378
|
+
continue;
|
|
379
|
+
const next = this.laidOut[index + 1];
|
|
380
|
+
return next ? { entry: next, within: top - (this.offsets[index + 1] ?? 0) } : at;
|
|
381
|
+
}
|
|
382
|
+
return at;
|
|
383
|
+
}
|
|
183
384
|
topFor(request, anchor, height) {
|
|
184
385
|
const maxTop = Math.max(0, this.rowCount() - height);
|
|
185
386
|
if (request.followEnd)
|
|
186
387
|
return maxTop;
|
|
187
388
|
let top = Math.floor(request.top);
|
|
188
389
|
if (anchor && this.laidOut[anchor.entry.index] === anchor.entry) {
|
|
189
|
-
top =
|
|
390
|
+
top =
|
|
391
|
+
(this.offsets[anchor.entry.index] ?? 0) +
|
|
392
|
+
Math.min(anchor.within, Math.max(0, anchor.entry.height - 1)) +
|
|
393
|
+
(request.moved ?? 0);
|
|
190
394
|
}
|
|
191
395
|
return Math.max(0, Math.min(maxTop, top));
|
|
192
396
|
}
|
|
@@ -195,7 +399,10 @@ export class WindowedContainer extends Container {
|
|
|
195
399
|
let index = 0;
|
|
196
400
|
let rebuilt;
|
|
197
401
|
const position = () => rebuilt?.length ?? index;
|
|
402
|
+
this.observed = false;
|
|
198
403
|
const visit = (container) => {
|
|
404
|
+
if (container.onVisibleChild)
|
|
405
|
+
this.observed = true;
|
|
199
406
|
for (const child of container.windowChildren()) {
|
|
200
407
|
if (child instanceof WindowedContainer) {
|
|
201
408
|
child.windowHost = this;
|
|
@@ -250,6 +457,8 @@ export class WindowedContainer extends Container {
|
|
|
250
457
|
};
|
|
251
458
|
entries.set(component, entry);
|
|
252
459
|
staleChanges++;
|
|
460
|
+
if (historyAnchors.has(component))
|
|
461
|
+
this.anchors.push(new WeakRef(component));
|
|
253
462
|
}
|
|
254
463
|
else if (entry.width !== this.width) {
|
|
255
464
|
entry.current = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windowed-container.js","sourceRoot":"","sources":["../../src/components/windowed-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,WAAW,CAAC;AAmBtD,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAc5B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAoB,CAAC;AAChD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,SAAS,SAAS,CAAC,GAAe;IACjC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C,mGAAmG;IAC3F,UAAU,CAAgC;IAClD,qEAAqE;IAC7D,YAAY,CAAgC;IACpD,sFAAsF;IAC9E,UAAU,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IAClC,OAAO,GAAY,EAAE,CAAC;IACtB,O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,MAAM,EAAE,CAAC;YACvD,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YACnC,OAAO;QACR,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI;YAAE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC1D,CAAC;CACD","sourcesContent":["import { type Component, Container } from \"../tui.ts\";\n\nexport interface WindowRows {\n\treadonly length: number;\n\tat(index: number): string | undefined;\n}\n\nexport interface WindowRequest {\n\treadonly width: number;\n\treadonly top: number;\n\treadonly height: number;\n\treadonly followEnd: boolean;\n\treadonly requestRender: () => void;\n}\n\nexport interface WindowLayout extends WindowRows {\n\treadonly top: number;\n}\n\nconst SLICE_BUDGET_MS = 8;\nconst SLICE_CHILDREN = 48;\nconst SWEEP_INTERVAL_MS = 1_000;\nconst MAX_WINDOW_PASSES = 4;\n\ninterface Entry {\n\treadonly component: Component;\n\t/** The windowed container whose children include `component`. */\n\towner: WindowedContainer | undefined;\n\tlines: readonly string[];\n\twidth: number;\n\tcurrent: boolean;\n\theight: number;\n\tindex: number;\n\trenderedIn: number;\n}\n\nconst entries = new WeakMap<Component, Entry>();\nlet staleChanges = 0;\n\nfunction yieldThen(run: () => void): void {\n\tsetImmediate(run).unref();\n}\n\nexport class WindowedContainer extends Container {\n\t/** The container that last laid this one out among its own rows, when this one is nested in it. */\n\tprivate windowHost: WindowedContainer | undefined;\n\t/** The windowed container this one is a child of, in that layout. */\n\tprivate windowParent: WindowedContainer | undefined;\n\t/** The host's laid-out entries this container's children occupied, `[first, end)`. */\n\tprivate windowSpan = { first: 0, end: 0 };\n\tprivate laidOut: Entry[] = [];\n\tprivate offsets: number[] = [0];\n\tprivate staleOffsetsFrom = Number.POSITIVE_INFINITY;\n\tprivate width = 0;\n\tprivate layouts = 0;\n\tprivate windowStart = 0;\n\tprivate windowEnd = 0;\n\tprivate measuredRows = 0;\n\tprivate measuredChildren = 0;\n\tprivate lastRowIndex = 0;\n\tprivate lastTop = 0;\n\tprivate requestRender: (() => void) | undefined;\n\tprivate sweep: { stale: number; up: number; down: number; full: boolean } | undefined;\n\tprivate sweepScheduled = false;\n\tprivate lastFullSweepAt = Number.NEGATIVE_INFINITY;\n\tprivate sweptStale = -1;\n\n\t/** Content width of the window that laid out these children, including a containing window's layout. */\n\tprotected get windowLayoutWidth(): number | undefined {\n\t\treturn this.windowHost?.width || this.width || undefined;\n\t}\n\n\tprotected windowChildren(): readonly Component[] {\n\t\treturn this.children;\n\t}\n\n\toverride invalidate(): void {\n\t\tfor (const child of this.windowChildren()) {\n\t\t\tconst entry = entries.get(child);\n\t\t\tif (entry?.current) {\n\t\t\t\tentry.current = false;\n\t\t\t\tstaleChanges++;\n\t\t\t}\n\t\t}\n\t\tsuper.invalidate();\n\t}\n\n\tlayoutWindow(request: WindowRequest): WindowLayout {\n\t\tconst width = Math.max(1, Math.floor(request.width));\n\t\tconst height = Math.max(0, Math.floor(request.height));\n\t\tthis.requestRender = request.requestRender;\n\t\tconst anchor = request.top === this.lastTop ? this.locateAnchor(request.top) : undefined;\n\t\tif (width !== this.width) {\n\t\t\tthis.width = width;\n\t\t\tfor (const entry of this.laidOut) entry.current = false;\n\t\t\tstaleChanges++;\n\t\t}\n\t\tthis.syncEntries();\n\t\tthis.updateOffsets();\n\t\tconst layout = ++this.layouts;\n\t\tlet top = this.topFor(request, anchor, height);\n\t\tfor (let pass = 0; pass < MAX_WINDOW_PASSES; pass++) {\n\t\t\tif (!this.renderRows(top - height, top + 2 * height, width, layout)) break;\n\t\t\tthis.updateOffsets();\n\t\t\ttop = this.topFor(request, anchor, height);\n\t\t}\n\t\tthis.scheduleSweep();\n\t\tthis.lastTop = top;\n\t\tconst length = this.rowCount();\n\t\treturn { top, length, at: (index) => this.rowAt(index) };\n\t}\n\n\tsettleRows(): void {\n\t\tif (this.width === 0) return;\n\t\tfor (const entry of this.laidOut) this.renderEntry(entry, this.width);\n\t}\n\n\tasync renderInSlices(width: number): Promise<string[]> {\n\t\tconst safeWidth = Math.max(1, Math.floor(width));\n\t\tif (safeWidth !== this.width) {\n\t\t\tthis.width = safeWidth;\n\t\t\tfor (const entry of this.laidOut) entry.current = false;\n\t\t}\n\t\tthis.syncEntries();\n\t\tthis.updateOffsets();\n\t\tlet deadline = performance.now() + SLICE_BUDGET_MS;\n\t\tfor (let index = 0; index < this.laidOut.length; index++) {\n\t\t\tif (performance.now() >= deadline) {\n\t\t\t\tawait new Promise<void>((resolve) => setImmediate(resolve));\n\t\t\t\tdeadline = performance.now() + SLICE_BUDGET_MS;\n\t\t\t}\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (entry) this.renderEntry(entry, safeWidth);\n\t\t}\n\t\tconst lines: string[] = [];\n\t\tfor (const entry of this.laidOut) for (const line of entry.lines) lines.push(line);\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The child drawn at `row` as the last layout drew it: an entry, or a nested windowed container with the rows its\n\t * children took. A nested container answers from the layout of the container that laid it out, so its own mouse\n\t * handler sees the rows that were painted. Without a layout at `width`, the children are rendered to measure them.\n\t */\n\toverride childAtRow(width: number, row: number): { component: Component; row: number; height: number } | undefined {\n\t\tconst window = this.windowAt(width);\n\t\tif (!window) return super.childAtRow(width, row);\n\t\tconst { host, first, end } = window;\n\t\tconst base = host.offsets[first] ?? 0;\n\t\tconst absolute = base + row;\n\t\tif (row < 0 || absolute >= (host.offsets[end] ?? base)) return undefined;\n\t\tconst index = host.indexAt(absolute);\n\t\tconst entry = host.laidOut[index];\n\t\tif (!entry || index < first || index >= end) return undefined;\n\t\tlet child: Component = entry.component;\n\t\tlet span = { first: index, end: index + 1 };\n\t\tfor (let owner = entry.owner; owner !== this; owner = owner.windowParent) {\n\t\t\tif (!owner) return undefined;\n\t\t\tchild = owner;\n\t\t\tspan = owner.windowSpan;\n\t\t}\n\t\tconst start = host.offsets[span.first] ?? 0;\n\t\tconst stop = host.offsets[span.end] ?? start;\n\t\tif (absolute < start || absolute >= stop) return undefined;\n\t\treturn { component: child, row: absolute - start, height: stop - start };\n\t}\n\n\tprivate windowAt(width: number): { host: WindowedContainer; first: number; end: number } | undefined {\n\t\tif (this.width === width && this.laidOut.length > 0) return { host: this, first: 0, end: this.laidOut.length };\n\t\tconst host = this.windowHost;\n\t\tif (!host || host.width !== width || host.laidOut.length === 0) return undefined;\n\t\tconst { first, end } = this.windowSpan;\n\t\treturn end > first && end <= host.laidOut.length ? { host, first, end } : undefined;\n\t}\n\n\tprivate rowCount(): number {\n\t\treturn this.offsets[this.laidOut.length] ?? 0;\n\t}\n\n\tprivate rowAt(row: number): string | undefined {\n\t\tif (row < 0 || row >= this.rowCount()) return undefined;\n\t\tlet index = this.lastRowIndex;\n\t\tif (!((this.offsets[index] ?? 0) <= row && row < (this.offsets[index + 1] ?? 0))) index = this.indexAt(row);\n\t\tthis.lastRowIndex = index;\n\t\tconst entry = this.laidOut[index];\n\t\tif (!entry?.current) return \"\";\n\t\treturn entry.lines[row - (this.offsets[index] ?? 0)] ?? \"\";\n\t}\n\n\tprivate indexAt(row: number): number {\n\t\tlet low = 0;\n\t\tlet high = this.laidOut.length - 1;\n\t\twhile (low < high) {\n\t\t\tconst middle = (low + high + 1) >> 1;\n\t\t\tif ((this.offsets[middle] ?? 0) <= row) low = middle;\n\t\t\telse high = middle - 1;\n\t\t}\n\t\treturn Math.max(0, low);\n\t}\n\n\tprivate locateAnchor(top: number): { entry: Entry; within: number } | undefined {\n\t\tif (this.laidOut.length === 0) return undefined;\n\t\tconst index = this.indexAt(Math.max(0, top));\n\t\tconst entry = this.laidOut[index];\n\t\treturn entry ? { entry, within: Math.max(0, top - (this.offsets[index] ?? 0)) } : undefined;\n\t}\n\n\tprivate topFor(\n\t\trequest: WindowRequest,\n\t\tanchor: { entry: Entry; within: number } | undefined,\n\t\theight: number,\n\t): number {\n\t\tconst maxTop = Math.max(0, this.rowCount() - height);\n\t\tif (request.followEnd) return maxTop;\n\t\tlet top = Math.floor(request.top);\n\t\tif (anchor && this.laidOut[anchor.entry.index] === anchor.entry) {\n\t\t\ttop = (this.offsets[anchor.entry.index] ?? 0) + Math.min(anchor.within, Math.max(0, anchor.entry.height - 1));\n\t\t}\n\t\treturn Math.max(0, Math.min(maxTop, top));\n\t}\n\n\tprivate syncEntries(): void {\n\t\tconst laidOut = this.laidOut;\n\t\tlet index = 0;\n\t\tlet rebuilt: Entry[] | undefined;\n\t\tconst position = (): number => rebuilt?.length ?? index;\n\t\tconst visit = (container: WindowedContainer): void => {\n\t\t\tfor (const child of container.windowChildren()) {\n\t\t\t\tif (child instanceof WindowedContainer) {\n\t\t\t\t\tchild.windowHost = this;\n\t\t\t\t\tchild.windowParent = container;\n\t\t\t\t\tconst first = position();\n\t\t\t\t\tvisit(child);\n\t\t\t\t\tchild.windowSpan = { first, end: position() };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (rebuilt === undefined) {\n\t\t\t\t\tconst kept = laidOut[index];\n\t\t\t\t\tif (kept?.component === child) {\n\t\t\t\t\t\tkept.owner = container;\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\trebuilt = laidOut.slice(0, index);\n\t\t\t\t}\n\t\t\t\tconst entry = this.entryFor(child);\n\t\t\t\tentry.owner = container;\n\t\t\t\trebuilt.push(entry);\n\t\t\t}\n\t\t};\n\t\tvisit(this);\n\t\tif (rebuilt === undefined) {\n\t\t\tif (index === laidOut.length) return;\n\t\t\trebuilt = laidOut.slice(0, index);\n\t\t}\n\t\tfor (let position = index; position < rebuilt.length; position++) {\n\t\t\tconst entry = rebuilt[position];\n\t\t\tif (entry) entry.index = position;\n\t\t}\n\t\tthis.laidOut = rebuilt;\n\t\tthis.staleOffsetsFrom = Math.min(this.staleOffsetsFrom, index);\n\t\tthis.lastRowIndex = 0;\n\t}\n\n\tprivate entryFor(component: Component): Entry {\n\t\tlet entry = entries.get(component);\n\t\tif (!entry) {\n\t\t\tconst estimate =\n\t\t\t\tthis.measuredChildren > 0 ? Math.max(1, Math.round(this.measuredRows / this.measuredChildren)) : 1;\n\t\t\tentry = {\n\t\t\t\tcomponent,\n\t\t\t\towner: undefined,\n\t\t\t\tlines: [],\n\t\t\t\twidth: 0,\n\t\t\t\tcurrent: false,\n\t\t\t\theight: estimate,\n\t\t\t\tindex: 0,\n\t\t\t\trenderedIn: 0,\n\t\t\t};\n\t\t\tentries.set(component, entry);\n\t\t\tstaleChanges++;\n\t\t} else if (entry.width !== this.width) {\n\t\t\tentry.current = false;\n\t\t}\n\t\treturn entry;\n\t}\n\n\tprivate updateOffsets(): void {\n\t\tconst from = this.staleOffsetsFrom;\n\t\tif (from === Number.POSITIVE_INFINITY) return;\n\t\tconst { laidOut, offsets } = this;\n\t\toffsets.length = laidOut.length + 1;\n\t\tlet row = from === 0 ? 0 : (offsets[from] ?? 0);\n\t\tfor (let index = from; index < laidOut.length; index++) {\n\t\t\toffsets[index] = row;\n\t\t\trow += laidOut[index]?.height ?? 0;\n\t\t}\n\t\toffsets[laidOut.length] = row;\n\t\tthis.staleOffsetsFrom = Number.POSITIVE_INFINITY;\n\t}\n\n\tprivate renderRows(start: number, end: number, width: number, layout: number): boolean {\n\t\tif (this.laidOut.length === 0) return false;\n\t\tlet changed = false;\n\t\tlet first = this.indexAt(Math.max(0, start));\n\t\twhile (first > 0 && this.offsets[first - 1] === this.offsets[first]) first--;\n\t\tlet index = first;\n\t\tfor (; index < this.laidOut.length && (this.offsets[index] ?? 0) < Math.max(end, 1); index++) {\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (!entry || entry.renderedIn === layout) continue;\n\t\t\tentry.renderedIn = layout;\n\t\t\tif (this.renderEntry(entry, width)) changed = true;\n\t\t}\n\t\tthis.windowStart = first;\n\t\tthis.windowEnd = index;\n\t\treturn changed;\n\t}\n\n\tprivate renderEntry(entry: Entry, width: number): boolean {\n\t\tconst lines = entry.component.render(width);\n\t\tif (entry.width === 0) {\n\t\t\tthis.measuredRows += lines.length;\n\t\t\tthis.measuredChildren++;\n\t\t}\n\t\tentry.lines = lines;\n\t\tentry.width = width;\n\t\tentry.current = true;\n\t\tif (entry.height === lines.length) return false;\n\t\tentry.height = lines.length;\n\t\tif (this.laidOut[entry.index] === entry) this.staleOffsetsFrom = Math.min(this.staleOffsetsFrom, entry.index);\n\t\treturn true;\n\t}\n\n\tprivate scheduleSweep(): void {\n\t\tif (this.sweepScheduled) return;\n\t\tthis.sweepScheduled = true;\n\t\tconst run = () => this.sweepSlice();\n\t\tif (this.sweptStale !== staleChanges) yieldThen(run);\n\t\telse setTimeout(run, Math.max(0, this.lastFullSweepAt + SWEEP_INTERVAL_MS - performance.now())).unref();\n\t}\n\n\tprivate sweepSlice(): void {\n\t\tif (this.width === 0) {\n\t\t\tthis.sweepScheduled = false;\n\t\t\treturn;\n\t\t}\n\t\tlet sweep = this.sweep;\n\t\tif (!sweep || sweep.stale !== staleChanges) {\n\t\t\tconst full = sweep?.full ?? this.sweptStale === staleChanges;\n\t\t\tsweep = { stale: staleChanges, up: this.windowStart - 1, down: this.windowEnd, full };\n\t\t\tthis.sweep = sweep;\n\t\t}\n\t\tconst deadline = performance.now() + SLICE_BUDGET_MS;\n\t\tlet rendered = 0;\n\t\tlet moved = false;\n\t\twhile (rendered < SLICE_CHILDREN && performance.now() < deadline) {\n\t\t\tlet index: number;\n\t\t\tif (sweep.up >= 0) index = sweep.up--;\n\t\t\telse if (sweep.down < this.laidOut.length) index = sweep.down++;\n\t\t\telse break;\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (!entry || (entry.current && !sweep.full)) continue;\n\t\t\trendered++;\n\t\t\tif (this.renderEntry(entry, this.width)) moved = true;\n\t\t}\n\t\tif (moved) this.requestRender?.();\n\t\tif (sweep.up >= 0 || sweep.down < this.laidOut.length) {\n\t\t\tyieldThen(() => this.sweepSlice());\n\t\t\treturn;\n\t\t}\n\t\tthis.sweep = undefined;\n\t\tthis.sweepScheduled = false;\n\t\tthis.sweptStale = sweep.stale;\n\t\tif (sweep.full) this.lastFullSweepAt = performance.now();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"windowed-container.js","sourceRoot":"","sources":["../../src/components/windowed-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,WAAW,CAAC;AAYtD,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA+C,CAAC;AA+BpF,MAAM,cAAc,GAAG,IAAI,OAAO,EAA2E,CAAC;AAsD9G,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAgB5B,SAAS,eAAe,CACvB,KAAiC,EACjC,IAAwB,EACxB,MAAc;IAEd,OAAO,GAAG,EAAE;QACX,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,SAAS,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAClE,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7G,CAAC,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,SAAS,aAAa,CAAC,CAAc,EAAE,CAAc;IACpD,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,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;YAClC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,SAAS;YACvD,QAAQ,EAAE,CAAC;YACX,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC;gBAAE,KAAK,GAAG,IAAI,CAAC;QACvD,CAAC;QACD,IAAI,KAAK;YAAE,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACvD,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YACnC,OAAO;QACR,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI;YAAE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC1D,CAAC;CACD","sourcesContent":["import { type Component, Container } from \"../tui.ts\";\n\nexport interface HistoryRowPosition {\n\treadonly source: symbol;\n\treadonly seq: number;\n\treadonly block: number;\n\treadonly part: number;\n\treadonly line: number;\n\t/** The row stands in for a card whose call and result are drawn on different pages: what it shows depends on which\n\t * pages are mounted, so a selection never captures it and a copy draws its entry as the whole transcript does. */\n\treadonly provisional?: true;\n}\nconst archivePositions = new WeakMap<Component, Omit<HistoryRowPosition, \"line\">>();\n\n/** A saved leaf: a rendered part of a saved entry, without the row within it. */\nexport type HistoryLeaf = Omit<HistoryRowPosition, \"line\">;\n\n/** The rows of one saved leaf that is not mounted, drawn on request. */\nexport interface HistoryRowsBlock {\n\treadonly position: HistoryLeaf;\n\treadonly lines: readonly string[];\n}\n\n/** Saved rows that are no longer, or never were, mounted below a history anchor. */\nexport interface HistorySource {\n\t/** The last sequence number of the saved rows. */\n\treadonly last: number;\n\t/** Draw, without mounting, the saved leaves of entries `from` through `to` at `width`, in document order. */\n\tread(from: number, to: number, width: number): Promise<readonly HistoryRowsBlock[]>;\n}\n\n/** The row that stands for a source's saved history: its mounted saved rows follow it, and everything else of the\n * source can be drawn on request. */\nexport interface HistoryAnchorView {\n\treadonly source: symbol;\n\treadonly edges: HistoryRunEdges;\n\t/** The first saved leaf mounted right below the anchor, if any. */\n\treadonly first?: HistoryLeaf;\n\treadonly last: number;\n\t/** Draw saved rows at the width of this layout. */\n\tread(from: number, to: number): Promise<readonly HistoryRowsBlock[]>;\n}\n\nconst historyAnchors = new WeakMap<Component, { readonly source: symbol; readonly history: HistorySource }>();\n\n/** The rows just outside a run of saved rows from one source, which stay in place when the run is released. */\nexport interface HistoryRunEdges {\n\treadonly source: symbol;\n\t/** The last row above the run, if any. */\n\treadonly above?: () => number | undefined;\n\t/** The first row below the run, if any. */\n\treadonly below?: () => number | undefined;\n}\n\nexport interface WindowRows {\n\treadonly length: number;\n\tat(index: number): string | undefined;\n\t/** A weak position within a painted leaf; resolving it never draws or requests history. */\n\ttrackRow?(index: number): (() => number | undefined) | undefined;\n\thistoryRow?(index: number): HistoryRowPosition | undefined;\n\t/** Weak positions of the rows around the saved run that holds `index`; no render, read or retained leaf. */\n\thistoryEdges?(index: number): HistoryRunEdges | undefined;\n\t/** The mounted history anchor of this document, if any. */\n\thistoryAnchor?(): HistoryAnchorView | undefined;\n\t/** Visit the rows of the mounted saved entries around `index` from `from` through `to`, in order, drawing an entry\n\t * not yet drawn at this width as the background sweep would. A provisional leaf that draws no row is visited once,\n\t * with an empty line. Never requests an unmounted page. */\n\tvisitHistoryRun?(\n\t\tindex: number,\n\t\tfrom: HistoryLeaf | undefined,\n\t\tto: HistoryLeaf | undefined,\n\t\tvisit: (line: string, position: HistoryRowPosition) => void,\n\t): void;\n\t/** Visit already rendered, non-replayable rows of an active selection, without requesting historical content. */\n\tvisitVolatileRows?(\n\t\tfirst: number,\n\t\tlast: number,\n\t\tvisit: (row: number, line: string, renderer: symbol, history?: HistoryRowPosition) => void,\n\t): void;\n}\n\nexport interface WindowRequest {\n\treadonly width: number;\n\treadonly top: number;\n\t/** Rows the reader scrolled by since the last layout, when `top` is the last top moved by them. */\n\treadonly moved?: number;\n\t/** Show the row at `top` itself, whatever changed above it since the last layout. */\n\treadonly exact?: boolean;\n\treadonly height: number;\n\treadonly followEnd: boolean;\n\treadonly requestRender: () => void;\n}\n\nexport interface WindowLayout extends WindowRows {\n\treadonly top: number;\n}\n\nconst SLICE_BUDGET_MS = 8;\nconst SLICE_CHILDREN = 48;\nconst SWEEP_INTERVAL_MS = 1_000;\nconst MAX_WINDOW_PASSES = 4;\n\ninterface Entry {\n\treadonly component: Component;\n\t/** Opaque identity for selections. Holding it does not keep this entry or its component alive. */\n\tselectionRenderer?: symbol;\n\t/** The windowed container whose children include `component`. */\n\towner: WindowedContainer | undefined;\n\tlines: readonly string[];\n\twidth: number;\n\tcurrent: boolean;\n\theight: number;\n\tindex: number;\n\trenderedIn: number;\n}\n\nfunction weakRowPosition(\n\towner: WeakRef<WindowedContainer>,\n\tleaf: WeakRef<Component>,\n\twithin: number,\n): () => number | undefined {\n\treturn () => {\n\t\tconst component = leaf.deref();\n\t\tconst span = component && owner.deref()?.windowRowSpan(component);\n\t\treturn span && span.bottom > span.top ? span.top + Math.min(within, span.bottom - span.top - 1) : undefined;\n\t};\n}\n\n/** Order of two saved leaves, ignoring the row within them. */\nfunction compareLeaves(a: HistoryLeaf, b: HistoryLeaf): number {\n\treturn a.seq - b.seq || a.block - b.block || a.part - b.part;\n}\n\nconst entries = new WeakMap<Component, Entry>();\nlet staleChanges = 0;\n\nfunction yieldThen(run: () => void): void {\n\tsetImmediate(run).unref();\n}\n\nexport class WindowedContainer extends Container {\n\t/** Identify the leaf of a mutable saved transcript. A selection can then keep just its selected characters\n\t * across eviction or an external rewrite, without keeping the component or its page. */\n\tstatic markHistoryComponent(\n\t\tcomponent: Component,\n\t\tsource: symbol,\n\t\tseq: number,\n\t\tblock: number,\n\t\tpart: number,\n\t\tprovisional = false,\n\t): void {\n\t\tarchivePositions.set(component, { source, seq, block, part, ...(provisional ? { provisional: true } : {}) });\n\t}\n\t/** Mark the row that stands for a source's saved history. Its mounted saved rows follow it; a copy can draw the\n\t * rest of a selection from `history`. Holding the anchor's source does not keep the anchor alive. */\n\tstatic markHistoryAnchor(component: Component, source: symbol, history: HistorySource): void {\n\t\thistoryAnchors.set(component, { source, history });\n\t\tconst owner = entries.get(component)?.owner;\n\t\t(owner?.windowHost ?? owner)?.anchors.push(new WeakRef(component));\n\t}\n\t/** History anchors this window has laid out. */\n\tprivate anchors: WeakRef<Component>[] = [];\n\t/** The container that last laid this one out among its own rows, when this one is nested in it. */\n\tprivate windowHost: WindowedContainer | undefined;\n\t/** The windowed container this one is a child of, in that layout. */\n\tprivate windowParent: WindowedContainer | undefined;\n\t/** The host's laid-out entries this container's children occupied, `[first, end)`. */\n\tprivate windowSpan = { first: 0, end: 0 };\n\tprivate laidOut: Entry[] = [];\n\tprivate observed = false;\n\t/** Observe only children whose rows are actually returned to the viewport, never an offscreen measurement. */\n\tonVisibleChild?: (child: Component) => void;\n\tprivate offsets: number[] = [0];\n\tprivate staleOffsetsFrom = Number.POSITIVE_INFINITY;\n\tprivate width = 0;\n\tprivate layouts = 0;\n\tprivate windowStart = 0;\n\tprivate windowEnd = 0;\n\tprivate measuredRows = 0;\n\tprivate measuredChildren = 0;\n\tprivate lastRowIndex = 0;\n\tprivate lastTop = 0;\n\tprivate requestRender: (() => void) | undefined;\n\tprivate sweep: { stale: number; up: number; down: number; full: boolean } | undefined;\n\tprivate sweepScheduled = false;\n\tprivate lastFullSweepAt = Number.NEGATIVE_INFINITY;\n\tprivate sweptStale = -1;\n\n\t/** Content width of the window that laid out these children, including a containing window's layout. */\n\tprotected get windowLayoutWidth(): number | undefined {\n\t\treturn this.windowHost?.width || this.width || undefined;\n\t}\n\n\tprotected windowChildren(): readonly Component[] {\n\t\treturn this.children;\n\t}\n\n\t/** The last window layout's span for a leaf, measured in the root document's rows; no render or tree walk. */\n\twindowRowSpan(component: Component): { readonly top: number; readonly bottom: number } | undefined {\n\t\tconst entry = entries.get(component);\n\t\tconst root = this.windowHost ?? this;\n\t\tif (!entry || root.laidOut[entry.index] !== entry) return undefined;\n\t\treturn { top: root.offsets[entry.index]!, bottom: root.offsets[entry.index + 1]! };\n\t}\n\n\toverride invalidate(): void {\n\t\tfor (const child of this.windowChildren()) {\n\t\t\tconst entry = entries.get(child);\n\t\t\tif (entry?.current) {\n\t\t\t\tentry.current = false;\n\t\t\t\tstaleChanges++;\n\t\t\t}\n\t\t}\n\t\tsuper.invalidate();\n\t}\n\n\tlayoutWindow(request: WindowRequest): WindowLayout {\n\t\tconst width = Math.max(1, Math.floor(request.width));\n\t\tconst height = Math.max(0, Math.floor(request.height));\n\t\tthis.requestRender = request.requestRender;\n\t\t// A scroll moves from the rows the reader saw, wherever rows added or removed above have put them since.\n\t\tconst anchor =\n\t\t\t!request.exact && (request.top === this.lastTop || request.moved !== undefined)\n\t\t\t\t? this.scrollAnchor(this.lastTop, height)\n\t\t\t\t: undefined;\n\t\tif (width !== this.width) {\n\t\t\tthis.width = width;\n\t\t\tfor (const entry of this.laidOut) entry.current = false;\n\t\t\tstaleChanges++;\n\t\t}\n\t\tthis.syncEntries();\n\t\tthis.updateOffsets();\n\t\tconst layout = ++this.layouts;\n\t\tlet top = this.topFor(request, anchor, height);\n\t\tfor (let pass = 0; pass < MAX_WINDOW_PASSES; pass++) {\n\t\t\tif (!this.renderRows(top - height, top + 2 * height, width, layout)) break;\n\t\t\tthis.updateOffsets();\n\t\t\ttop = this.topFor(request, anchor, height);\n\t\t}\n\t\tthis.scheduleSweep();\n\t\tthis.lastTop = top;\n\t\tconst length = this.rowCount();\n\t\treturn {\n\t\t\ttop,\n\t\t\tlength,\n\t\t\tat: this.observed ? (index) => this.visibleRowAt(index) : (index) => this.rowAt(index),\n\t\t\ttrackRow: (index) => {\n\t\t\t\tif (index < 0 || index >= length) return undefined;\n\t\t\t\tconst anchor = this.locateAnchor(index);\n\t\t\t\tif (!anchor) return undefined;\n\t\t\t\treturn weakRowPosition(new WeakRef(this), new WeakRef(anchor.entry.component), anchor.within);\n\t\t\t},\n\t\t\thistoryRow: (index) => {\n\t\t\t\tif (index < 0 || index >= length) return undefined;\n\t\t\t\tconst anchor = this.locateAnchor(index);\n\t\t\t\tconst position = anchor && archivePositions.get(anchor.entry.component);\n\t\t\t\treturn position && anchor ? { ...position, line: anchor.within } : undefined;\n\t\t\t},\n\t\t\thistoryEdges: (index) => {\n\t\t\t\tconst run = index >= 0 && index < length ? this.historyRunAt(index) : undefined;\n\t\t\t\tif (!run) return undefined;\n\t\t\t\tconst owner = new WeakRef(this);\n\t\t\t\tconst edge = (index: number, within: number) =>\n\t\t\t\t\tweakRowPosition(owner, new WeakRef(this.laidOut[index]!.component), within);\n\t\t\t\treturn {\n\t\t\t\t\tsource: run.source,\n\t\t\t\t\t...(run.first > 0 ? { above: edge(run.first - 1, Number.MAX_SAFE_INTEGER) } : {}),\n\t\t\t\t\t...(run.last + 1 < this.laidOut.length ? { below: edge(run.last + 1, 0) } : {}),\n\t\t\t\t};\n\t\t\t},\n\t\t\thistoryAnchor: () => {\n\t\t\t\tconst at = this.anchorIndex();\n\t\t\t\tif (at === undefined) return undefined;\n\t\t\t\tconst anchor = this.laidOut[at]!;\n\t\t\t\tconst { source, history } = historyAnchors.get(anchor.component)!;\n\t\t\t\tlet below = at + 1;\n\t\t\t\twhile (\n\t\t\t\t\tbelow < this.laidOut.length &&\n\t\t\t\t\t(this.laidOut[below]!.height === 0 ||\n\t\t\t\t\t\tarchivePositions.get(this.laidOut[below]!.component)?.source === source)\n\t\t\t\t)\n\t\t\t\t\tbelow++;\n\t\t\t\tconst owner = new WeakRef(this);\n\t\t\t\tconst edge = (index: number, within: number) =>\n\t\t\t\t\tweakRowPosition(owner, new WeakRef(this.laidOut[index]!.component), within);\n\t\t\t\tlet next = at + 1;\n\t\t\t\twhile (next < below && this.laidOut[next]!.height === 0) next++;\n\t\t\t\tconst first = next < below ? archivePositions.get(this.laidOut[next]!.component) : undefined;\n\t\t\t\tconst width = this.width;\n\t\t\t\treturn {\n\t\t\t\t\tsource,\n\t\t\t\t\tedges: {\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tabove: edge(at, Number.MAX_SAFE_INTEGER),\n\t\t\t\t\t\t...(below < this.laidOut.length ? { below: edge(below, 0) } : {}),\n\t\t\t\t\t},\n\t\t\t\t\t...(first ? { first } : {}),\n\t\t\t\t\tlast: history.last,\n\t\t\t\t\tread: (from, to) => history.read(from, to, width),\n\t\t\t\t};\n\t\t\t},\n\t\t\tvisitHistoryRun: (index, from, to, visit) => {\n\t\t\t\tconst run = index >= 0 && index < length ? this.historyRunAt(index) : undefined;\n\t\t\t\tif (!run) return;\n\t\t\t\tlet moved = false;\n\t\t\t\tfor (let i = run.first; i <= run.last; i++) {\n\t\t\t\t\tconst entry = this.laidOut[i]!;\n\t\t\t\t\tconst position = archivePositions.get(entry.component);\n\t\t\t\t\tif (position?.source !== run.source) continue;\n\t\t\t\t\tif (from && compareLeaves(position, from) < 0) continue;\n\t\t\t\t\tif (to && compareLeaves(position, to) > 0) continue;\n\t\t\t\t\tif (!entry.current || entry.width !== this.width) moved = this.renderEntry(entry, this.width) || moved;\n\t\t\t\t\tfor (let line = 0; line < entry.lines.length; line++) visit(entry.lines[line]!, { ...position, line });\n\t\t\t\t\t// A provisional leaf that draws nothing now (its card is drawn at the other end of the pair) is still\n\t\t\t\t\t// provisional: a copy draws its entry as the whole transcript does.\n\t\t\t\t\tif (position.provisional && entry.lines.length === 0) visit(\"\", { ...position, line: 0 });\n\t\t\t\t}\n\t\t\t\tif (moved) this.requestRender?.();\n\t\t\t},\n\t\t\tvisitVolatileRows: (first, last, visit) => {\n\t\t\t\tif (!length || first >= length || last < 0) return;\n\t\t\t\tfor (let i = this.indexAt(Math.max(0, first)); i < this.laidOut.length; i++) {\n\t\t\t\t\tconst entry = this.laidOut[i]!,\n\t\t\t\t\t\tstart = this.offsets[i]!;\n\t\t\t\t\tif (start > last) break;\n\t\t\t\t\tif (!entry.current) continue;\n\t\t\t\t\tconst history = archivePositions.get(entry.component);\n\t\t\t\t\tif (!history && entry.component.selectionTextMayChangeOnReplay !== true) continue;\n\t\t\t\t\tentry.selectionRenderer ??= Symbol();\n\t\t\t\t\tfor (let row = Math.max(first, start); row <= last && row < start + entry.lines.length; row++)\n\t\t\t\t\t\tvisit(\n\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\tentry.lines[row - start]!,\n\t\t\t\t\t\t\tentry.selectionRenderer,\n\t\t\t\t\t\t\thistory && { ...history, line: row - start },\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tsettleRows(): void {\n\t\tif (this.width === 0) return;\n\t\tfor (const entry of this.laidOut) this.renderEntry(entry, this.width);\n\t}\n\n\tasync renderInSlices(width: number): Promise<string[]> {\n\t\tconst safeWidth = Math.max(1, Math.floor(width));\n\t\tif (safeWidth !== this.width) {\n\t\t\tthis.width = safeWidth;\n\t\t\tfor (const entry of this.laidOut) entry.current = false;\n\t\t}\n\t\tthis.syncEntries();\n\t\tthis.updateOffsets();\n\t\tlet deadline = performance.now() + SLICE_BUDGET_MS;\n\t\tfor (let index = 0; index < this.laidOut.length; index++) {\n\t\t\tif (performance.now() >= deadline) {\n\t\t\t\tawait new Promise<void>((resolve) => setImmediate(resolve));\n\t\t\t\tdeadline = performance.now() + SLICE_BUDGET_MS;\n\t\t\t}\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (entry) this.renderEntry(entry, safeWidth);\n\t\t}\n\t\tconst lines: string[] = [];\n\t\tfor (const entry of this.laidOut) for (const line of entry.lines) lines.push(line);\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The child drawn at `row` as the last layout drew it: an entry, or a nested windowed container with the rows its\n\t * children took. A nested container answers from the layout of the container that laid it out, so its own mouse\n\t * handler sees the rows that were painted. Without a layout at `width`, the children are rendered to measure them.\n\t */\n\toverride childAtRow(width: number, row: number): { component: Component; row: number; height: number } | undefined {\n\t\tconst window = this.windowAt(width);\n\t\tif (!window) return super.childAtRow(width, row);\n\t\tconst { host, first, end } = window;\n\t\tconst base = host.offsets[first] ?? 0;\n\t\tconst absolute = base + row;\n\t\tif (row < 0 || absolute >= (host.offsets[end] ?? base)) return undefined;\n\t\tconst index = host.indexAt(absolute);\n\t\tconst entry = host.laidOut[index];\n\t\tif (!entry || index < first || index >= end) return undefined;\n\t\tlet child: Component = entry.component;\n\t\tlet span = { first: index, end: index + 1 };\n\t\tfor (let owner = entry.owner; owner !== this; owner = owner.windowParent) {\n\t\t\tif (!owner) return undefined;\n\t\t\tchild = owner;\n\t\t\tspan = owner.windowSpan;\n\t\t}\n\t\tconst start = host.offsets[span.first] ?? 0;\n\t\tconst stop = host.offsets[span.end] ?? start;\n\t\tif (absolute < start || absolute >= stop) return undefined;\n\t\treturn { component: child, row: absolute - start, height: stop - start };\n\t}\n\n\tprivate windowAt(width: number): { host: WindowedContainer; first: number; end: number } | undefined {\n\t\tif (this.width === width && this.laidOut.length > 0) return { host: this, first: 0, end: this.laidOut.length };\n\t\tconst host = this.windowHost;\n\t\tif (!host || host.width !== width || host.laidOut.length === 0) return undefined;\n\t\tconst { first, end } = this.windowSpan;\n\t\treturn end > first && end <= host.laidOut.length ? { host, first, end } : undefined;\n\t}\n\n\tprivate rowCount(): number {\n\t\treturn this.offsets[this.laidOut.length] ?? 0;\n\t}\n\n\tprivate visibleRowAt(row: number): string | undefined {\n\t\tconst line = this.rowAt(row);\n\t\tif (line !== undefined) {\n\t\t\tconst entry = this.laidOut[this.lastRowIndex];\n\t\t\tif (entry) entry.owner?.onVisibleChild?.(entry.component);\n\t\t}\n\t\treturn line;\n\t}\n\n\tprivate rowAt(row: number): string | undefined {\n\t\tif (row < 0 || row >= this.rowCount()) return undefined;\n\t\tlet index = this.lastRowIndex;\n\t\tif (!((this.offsets[index] ?? 0) <= row && row < (this.offsets[index + 1] ?? 0))) index = this.indexAt(row);\n\t\tthis.lastRowIndex = index;\n\t\tconst entry = this.laidOut[index];\n\t\tif (!entry?.current) return \"\";\n\t\treturn entry.lines[row - (this.offsets[index] ?? 0)] ?? \"\";\n\t}\n\n\tprivate indexAt(row: number): number {\n\t\tlet low = 0;\n\t\tlet high = this.laidOut.length - 1;\n\t\twhile (low < high) {\n\t\t\tconst middle = (low + high + 1) >> 1;\n\t\t\tif ((this.offsets[middle] ?? 0) <= row) low = middle;\n\t\t\telse high = middle - 1;\n\t\t}\n\t\treturn Math.max(0, low);\n\t}\n\n\t/** The laid-out index of the first history anchor still in this window. */\n\tprivate anchorIndex(): number | undefined {\n\t\tfor (let i = 0; i < this.anchors.length; i++) {\n\t\t\tconst component = this.anchors[i]!.deref();\n\t\t\tconst entry = component && entries.get(component);\n\t\t\tif (entry && this.laidOut[entry.index] === entry) return entry.index;\n\t\t\tif (!component) this.anchors.splice(i--, 1);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** The laid-out entries of the saved run around `row`: one source, possibly with empty rows between. */\n\tprivate historyRunAt(row: number): { source: symbol; first: number; last: number } | undefined {\n\t\tif (this.laidOut.length === 0) return undefined;\n\t\tconst at = this.indexAt(row);\n\t\tconst source = archivePositions.get(this.laidOut[at]!.component)?.source;\n\t\tif (!source) return undefined;\n\t\tconst inRun = (entry: Entry) => entry.height === 0 || archivePositions.get(entry.component)?.source === source;\n\t\tlet first = at,\n\t\t\tlast = at;\n\t\twhile (first > 0 && inRun(this.laidOut[first - 1]!)) first--;\n\t\twhile (last + 1 < this.laidOut.length && inRun(this.laidOut[last + 1]!)) last++;\n\t\treturn { source, first, last };\n\t}\n\n\tprivate locateAnchor(top: number): { entry: Entry; within: number } | undefined {\n\t\tif (this.laidOut.length === 0) return undefined;\n\t\tconst index = this.indexAt(Math.max(0, top));\n\t\tconst entry = this.laidOut[index];\n\t\treturn entry ? { entry, within: Math.max(0, top - (this.offsets[index] ?? 0)) } : undefined;\n\t}\n\n\t/**\n\t * The row that keeps the reader's place when rows change before the next frame: the row at `top`, or, while a\n\t * history anchor is on screen, the first row after it. Saved pages are mounted right after that anchor, so the rows\n\t * the reader saw below it keep their place, not the rows above it.\n\t */\n\tprivate scrollAnchor(top: number, height: number): { entry: Entry; within: number } | undefined {\n\t\tconst at = this.locateAnchor(top);\n\t\tif (!at) return undefined;\n\t\tfor (let index = this.indexAt(Math.max(0, top)); index < this.laidOut.length; index++) {\n\t\t\tif ((this.offsets[index] ?? 0) >= top + height) break;\n\t\t\tif (!historyAnchors.has(this.laidOut[index]!.component)) continue;\n\t\t\tconst next = this.laidOut[index + 1];\n\t\t\treturn next ? { entry: next, within: top - (this.offsets[index + 1] ?? 0) } : at;\n\t\t}\n\t\treturn at;\n\t}\n\n\tprivate topFor(\n\t\trequest: WindowRequest,\n\t\tanchor: { entry: Entry; within: number } | undefined,\n\t\theight: number,\n\t): number {\n\t\tconst maxTop = Math.max(0, this.rowCount() - height);\n\t\tif (request.followEnd) return maxTop;\n\t\tlet top = Math.floor(request.top);\n\t\tif (anchor && this.laidOut[anchor.entry.index] === anchor.entry) {\n\t\t\ttop =\n\t\t\t\t(this.offsets[anchor.entry.index] ?? 0) +\n\t\t\t\tMath.min(anchor.within, Math.max(0, anchor.entry.height - 1)) +\n\t\t\t\t(request.moved ?? 0);\n\t\t}\n\t\treturn Math.max(0, Math.min(maxTop, top));\n\t}\n\n\tprivate syncEntries(): void {\n\t\tconst laidOut = this.laidOut;\n\t\tlet index = 0;\n\t\tlet rebuilt: Entry[] | undefined;\n\t\tconst position = (): number => rebuilt?.length ?? index;\n\t\tthis.observed = false;\n\t\tconst visit = (container: WindowedContainer): void => {\n\t\t\tif (container.onVisibleChild) this.observed = true;\n\t\t\tfor (const child of container.windowChildren()) {\n\t\t\t\tif (child instanceof WindowedContainer) {\n\t\t\t\t\tchild.windowHost = this;\n\t\t\t\t\tchild.windowParent = container;\n\t\t\t\t\tconst first = position();\n\t\t\t\t\tvisit(child);\n\t\t\t\t\tchild.windowSpan = { first, end: position() };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (rebuilt === undefined) {\n\t\t\t\t\tconst kept = laidOut[index];\n\t\t\t\t\tif (kept?.component === child) {\n\t\t\t\t\t\tkept.owner = container;\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\trebuilt = laidOut.slice(0, index);\n\t\t\t\t}\n\t\t\t\tconst entry = this.entryFor(child);\n\t\t\t\tentry.owner = container;\n\t\t\t\trebuilt.push(entry);\n\t\t\t}\n\t\t};\n\t\tvisit(this);\n\t\tif (rebuilt === undefined) {\n\t\t\tif (index === laidOut.length) return;\n\t\t\trebuilt = laidOut.slice(0, index);\n\t\t}\n\t\tfor (let position = index; position < rebuilt.length; position++) {\n\t\t\tconst entry = rebuilt[position];\n\t\t\tif (entry) entry.index = position;\n\t\t}\n\t\tthis.laidOut = rebuilt;\n\t\tthis.staleOffsetsFrom = Math.min(this.staleOffsetsFrom, index);\n\t\tthis.lastRowIndex = 0;\n\t}\n\n\tprivate entryFor(component: Component): Entry {\n\t\tlet entry = entries.get(component);\n\t\tif (!entry) {\n\t\t\tconst estimate =\n\t\t\t\tthis.measuredChildren > 0 ? Math.max(1, Math.round(this.measuredRows / this.measuredChildren)) : 1;\n\t\t\tentry = {\n\t\t\t\tcomponent,\n\t\t\t\towner: undefined,\n\t\t\t\tlines: [],\n\t\t\t\twidth: 0,\n\t\t\t\tcurrent: false,\n\t\t\t\theight: estimate,\n\t\t\t\tindex: 0,\n\t\t\t\trenderedIn: 0,\n\t\t\t};\n\t\t\tentries.set(component, entry);\n\t\t\tstaleChanges++;\n\t\t\tif (historyAnchors.has(component)) this.anchors.push(new WeakRef(component));\n\t\t} else if (entry.width !== this.width) {\n\t\t\tentry.current = false;\n\t\t}\n\t\treturn entry;\n\t}\n\n\tprivate updateOffsets(): void {\n\t\tconst from = this.staleOffsetsFrom;\n\t\tif (from === Number.POSITIVE_INFINITY) return;\n\t\tconst { laidOut, offsets } = this;\n\t\toffsets.length = laidOut.length + 1;\n\t\tlet row = from === 0 ? 0 : (offsets[from] ?? 0);\n\t\tfor (let index = from; index < laidOut.length; index++) {\n\t\t\toffsets[index] = row;\n\t\t\trow += laidOut[index]?.height ?? 0;\n\t\t}\n\t\toffsets[laidOut.length] = row;\n\t\tthis.staleOffsetsFrom = Number.POSITIVE_INFINITY;\n\t}\n\n\tprivate renderRows(start: number, end: number, width: number, layout: number): boolean {\n\t\tif (this.laidOut.length === 0) return false;\n\t\tlet changed = false;\n\t\tlet first = this.indexAt(Math.max(0, start));\n\t\twhile (first > 0 && this.offsets[first - 1] === this.offsets[first]) first--;\n\t\tlet index = first;\n\t\tfor (; index < this.laidOut.length && (this.offsets[index] ?? 0) < Math.max(end, 1); index++) {\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (!entry || entry.renderedIn === layout) continue;\n\t\t\tentry.renderedIn = layout;\n\t\t\tif (this.renderEntry(entry, width)) changed = true;\n\t\t}\n\t\tthis.windowStart = first;\n\t\tthis.windowEnd = index;\n\t\treturn changed;\n\t}\n\n\tprivate renderEntry(entry: Entry, width: number): boolean {\n\t\tconst lines = entry.component.render(width);\n\t\tif (entry.width === 0) {\n\t\t\tthis.measuredRows += lines.length;\n\t\t\tthis.measuredChildren++;\n\t\t}\n\t\tentry.lines = lines;\n\t\tentry.width = width;\n\t\tentry.current = true;\n\t\tif (entry.height === lines.length) return false;\n\t\tentry.height = lines.length;\n\t\tif (this.laidOut[entry.index] === entry) this.staleOffsetsFrom = Math.min(this.staleOffsetsFrom, entry.index);\n\t\treturn true;\n\t}\n\n\tprivate scheduleSweep(): void {\n\t\tif (this.sweepScheduled) return;\n\t\tthis.sweepScheduled = true;\n\t\tconst run = () => this.sweepSlice();\n\t\tif (this.sweptStale !== staleChanges) yieldThen(run);\n\t\telse setTimeout(run, Math.max(0, this.lastFullSweepAt + SWEEP_INTERVAL_MS - performance.now())).unref();\n\t}\n\n\tprivate sweepSlice(): void {\n\t\tif (this.width === 0) {\n\t\t\tthis.sweepScheduled = false;\n\t\t\treturn;\n\t\t}\n\t\tlet sweep = this.sweep;\n\t\tif (!sweep || sweep.stale !== staleChanges) {\n\t\t\tconst full = sweep?.full ?? this.sweptStale === staleChanges;\n\t\t\tsweep = { stale: staleChanges, up: this.windowStart - 1, down: this.windowEnd, full };\n\t\t\tthis.sweep = sweep;\n\t\t}\n\t\tconst deadline = performance.now() + SLICE_BUDGET_MS;\n\t\tlet rendered = 0;\n\t\tlet moved = false;\n\t\twhile (rendered < SLICE_CHILDREN && performance.now() < deadline) {\n\t\t\tlet index: number;\n\t\t\tif (sweep.up >= 0) index = sweep.up--;\n\t\t\telse if (sweep.down < this.laidOut.length) index = sweep.down++;\n\t\t\telse break;\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (!entry || (entry.current && !sweep.full)) continue;\n\t\t\trendered++;\n\t\t\tif (this.renderEntry(entry, this.width)) moved = true;\n\t\t}\n\t\tif (moved) this.requestRender?.();\n\t\tif (sweep.up >= 0 || sweep.down < this.laidOut.length) {\n\t\t\tyieldThen(() => this.sweepSlice());\n\t\t\treturn;\n\t\t}\n\t\tthis.sweep = undefined;\n\t\tthis.sweepScheduled = false;\n\t\tthis.sweptStale = sweep.stale;\n\t\tif (sweep.full) this.lastFullSweepAt = performance.now();\n\t}\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AutocompleteProvider } from "./autocomplete.ts";
|
|
2
|
+
import type { EditorDraft } from "./components/editor.ts";
|
|
2
3
|
import type { Component } from "./tui.ts";
|
|
3
4
|
/**
|
|
4
5
|
* Interface for custom editor components.
|
|
@@ -21,6 +22,10 @@ export interface EditorComponent extends Component {
|
|
|
21
22
|
/** Add text to history for up/down navigation */
|
|
22
23
|
addToHistory?(text: string): void;
|
|
23
24
|
getHistory?(): readonly string[];
|
|
25
|
+
/** Replace the up/down history, newest first as `getHistory` returns it, without changing the text */
|
|
26
|
+
setHistory?(newestFirst: readonly string[]): void;
|
|
27
|
+
/** Add entries older than the whole history behind it, newest first, without ending history browsing */
|
|
28
|
+
appendOlderHistory?(newestFirst: readonly string[]): void;
|
|
24
29
|
/** Insert text at current cursor position */
|
|
25
30
|
insertTextAtCursor?(text: string): void;
|
|
26
31
|
/**
|
|
@@ -28,6 +33,10 @@ export interface EditorComponent extends Component {
|
|
|
28
33
|
* Falls back to getText() if not implemented.
|
|
29
34
|
*/
|
|
30
35
|
getExpandedText?(): string;
|
|
36
|
+
/** The prompt's whole state (text, cursor, pastes, undo, Up-history browsing), detached from later editing. */
|
|
37
|
+
snapshotDraft?(): EditorDraft;
|
|
38
|
+
/** Put back a prompt state {@link snapshotDraft} took. */
|
|
39
|
+
restoreDraft?(draft: EditorDraft): void;
|
|
31
40
|
/** Set the autocomplete provider */
|
|
32
41
|
setAutocompleteProvider?(provider: AutocompleteProvider): void;
|
|
33
42
|
/** Border color function */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-component.d.ts","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAKjD,mCAAmC;IACnC,OAAO,IAAI,MAAM,CAAC;IAElB,2BAA2B;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,qEAAqE;IACrE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAMhC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,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AC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;OAGG;IACH,eAAe,CAAC,IAAI,MAAM,CAAC;IAE3B,+GAA+G;IAC/G,aAAa,CAAC,IAAI,WAAW,CAAC;IAE9B,0DAA0D;IAC1D,YAAY,CAAC,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAMxC,oCAAoC;IACpC,uBAAuB,CAAC,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAM/D,4BAA4B;IAC5B,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtC,6BAA6B;IAC7B,WAAW,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC,qDAAqD;IACrD,yBAAyB,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-component.js","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"","sourcesContent":["import type { AutocompleteProvider } from \"./autocomplete.ts\";\nimport type { Component } from \"./tui.ts\";\n\n/**\n * Interface for custom editor components.\n *\n * This allows extensions to provide their own editor implementation\n * (e.g., vim mode, emacs mode, custom keybindings) while maintaining\n * compatibility with the core application.\n */\nexport interface EditorComponent extends Component {\n\t// =========================================================================\n\t// Core text access (required)\n\t// =========================================================================\n\n\t/** Get the current text content */\n\tgetText(): string;\n\n\t/** Set the text content */\n\tsetText(text: string): void;\n\n\t/** Handle raw terminal input (key presses, paste sequences, etc.) */\n\thandleInput(data: string): void;\n\n\t// =========================================================================\n\t// Callbacks (required)\n\t// =========================================================================\n\n\t/** Called when user submits (e.g., Enter key) */\n\tonSubmit?: (text: string) => void;\n\n\t/** Called when text changes */\n\tonChange?: (text: string) => void;\n\n\t// =========================================================================\n\t// History support (optional)\n\t// =========================================================================\n\n\t/** Add text to history for up/down navigation */\n\taddToHistory?(text: string): void;\n\n\tgetHistory?(): readonly string[];\n\n\t// =========================================================================\n\t// Advanced text manipulation (optional)\n\t// =========================================================================\n\n\t/** Insert text at current cursor position */\n\tinsertTextAtCursor?(text: string): void;\n\n\t/**\n\t * Get text with any markers expanded (e.g., paste markers).\n\t * Falls back to getText() if not implemented.\n\t */\n\tgetExpandedText?(): string;\n\n\t// =========================================================================\n\t// Autocomplete support (optional)\n\t// =========================================================================\n\n\t/** Set the autocomplete provider */\n\tsetAutocompleteProvider?(provider: AutocompleteProvider): void;\n\n\t// =========================================================================\n\t// Appearance (optional)\n\t// =========================================================================\n\n\t/** Border color function */\n\tborderColor?: (str: string) => string;\n\n\t/** Set horizontal padding */\n\tsetPaddingX?(padding: number): void;\n\n\t/** Set max visible items in autocomplete dropdown */\n\tsetAutocompleteMaxVisible?(maxVisible: number): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"editor-component.js","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"","sourcesContent":["import type { AutocompleteProvider } from \"./autocomplete.ts\";\nimport type { EditorDraft } from \"./components/editor.ts\";\nimport type { Component } from \"./tui.ts\";\n\n/**\n * Interface for custom editor components.\n *\n * This allows extensions to provide their own editor implementation\n * (e.g., vim mode, emacs mode, custom keybindings) while maintaining\n * compatibility with the core application.\n */\nexport interface EditorComponent extends Component {\n\t// =========================================================================\n\t// Core text access (required)\n\t// =========================================================================\n\n\t/** Get the current text content */\n\tgetText(): string;\n\n\t/** Set the text content */\n\tsetText(text: string): void;\n\n\t/** Handle raw terminal input (key presses, paste sequences, etc.) */\n\thandleInput(data: string): void;\n\n\t// =========================================================================\n\t// Callbacks (required)\n\t// =========================================================================\n\n\t/** Called when user submits (e.g., Enter key) */\n\tonSubmit?: (text: string) => void;\n\n\t/** Called when text changes */\n\tonChange?: (text: string) => void;\n\n\t// =========================================================================\n\t// History support (optional)\n\t// =========================================================================\n\n\t/** Add text to history for up/down navigation */\n\taddToHistory?(text: string): void;\n\n\tgetHistory?(): readonly string[];\n\n\t/** Replace the up/down history, newest first as `getHistory` returns it, without changing the text */\n\tsetHistory?(newestFirst: readonly string[]): void;\n\n\t/** Add entries older than the whole history behind it, newest first, without ending history browsing */\n\tappendOlderHistory?(newestFirst: readonly string[]): void;\n\n\t// =========================================================================\n\t// Advanced text manipulation (optional)\n\t// =========================================================================\n\n\t/** Insert text at current cursor position */\n\tinsertTextAtCursor?(text: string): void;\n\n\t/**\n\t * Get text with any markers expanded (e.g., paste markers).\n\t * Falls back to getText() if not implemented.\n\t */\n\tgetExpandedText?(): string;\n\n\t/** The prompt's whole state (text, cursor, pastes, undo, Up-history browsing), detached from later editing. */\n\tsnapshotDraft?(): EditorDraft;\n\n\t/** Put back a prompt state {@link snapshotDraft} took. */\n\trestoreDraft?(draft: EditorDraft): void;\n\n\t// =========================================================================\n\t// Autocomplete support (optional)\n\t// =========================================================================\n\n\t/** Set the autocomplete provider */\n\tsetAutocompleteProvider?(provider: AutocompleteProvider): void;\n\n\t// =========================================================================\n\t// Appearance (optional)\n\t// =========================================================================\n\n\t/** Border color function */\n\tborderColor?: (str: string) => string;\n\n\t/** Set horizontal padding */\n\tsetPaddingX?(padding: number): void;\n\n\t/** Set max visible items in autocomplete dropdown */\n\tsetAutocompleteMaxVisible?(maxVisible: number): void;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { bindBundledHintCommands, clickableHint, clickableHintText, clickableKey
|
|
|
4
4
|
export { backgroundAnsi, type Color, type ColorMixSpace, colorToHex, colorToOkhsl, colorToOklch, colorToRgb, foregroundAnsi, type IndexedColor, indexedColor, mixColors, type OkhslChannels, type OklchChannels, type OklchColorValue, okhslColor, oklchColor, parseColor, type RgbColorValue, rgbColor, styleText, styleTextWithAnsi, type TerminalColorMode, type TextAttributes, type TextStyle, } from "./colors.ts";
|
|
5
5
|
export { Box } from "./components/box.ts";
|
|
6
6
|
export { CancellableLoader } from "./components/cancellable-loader.ts";
|
|
7
|
-
export { Editor, type EditorAutocompleteHintEntry, type EditorOptions, type EditorTheme, } from "./components/editor.ts";
|
|
7
|
+
export { Editor, type EditorAutocompleteHintEntry, type EditorDraft, type EditorOptions, type EditorTheme, editorDraftText, emptyEditorDraft, } from "./components/editor.ts";
|
|
8
8
|
export { HStack } from "./components/h-stack.ts";
|
|
9
9
|
export { Image, type ImageOptions, type ImageTheme, type ImageTranscoder, setImageTranscoder, } from "./components/image.ts";
|
|
10
10
|
export { Input } from "./components/input.ts";
|
|
@@ -18,7 +18,7 @@ export { Spacer } from "./components/spacer.ts";
|
|
|
18
18
|
export { Text } from "./components/text.ts";
|
|
19
19
|
export { TruncatedText } from "./components/truncated-text.ts";
|
|
20
20
|
export { type StackChild, type StackEntry, type StackEntryOptions, type StackOptions, VStack, } from "./components/v-stack.ts";
|
|
21
|
-
export { WindowedContainer, type WindowLayout, type WindowRequest, type WindowRows, } from "./components/windowed-container.ts";
|
|
21
|
+
export { type HistoryLeaf, type HistoryRowsBlock, type HistorySource, WindowedContainer, type WindowLayout, type WindowRequest, type WindowRows, } from "./components/windowed-container.ts";
|
|
22
22
|
export type { EditorComponent } from "./editor-component.ts";
|
|
23
23
|
export { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from "./fuzzy.ts";
|
|
24
24
|
export { getKeybindings, getSelectPageIndex, type Keybinding, type KeybindingConflict, type KeybindingDefinition, type KeybindingDefinitions, type Keybindings, type KeybindingsConfig, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,KAAK,YAAY,GAC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a,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,WAAW,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,uBAAuB,EACvB,YAAY,EACZ,KAAK,mBAAmB,EACxB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { backgroundAnsi, colorToHex, colorToOkhsl, colorToOklch, colorToRgb, for
|
|
|
9
9
|
// Components
|
|
10
10
|
export { Box } from "./components/box.js";
|
|
11
11
|
export { CancellableLoader } from "./components/cancellable-loader.js";
|
|
12
|
-
export { Editor, } from "./components/editor.js";
|
|
12
|
+
export { Editor, editorDraftText, emptyEditorDraft, } from "./components/editor.js";
|
|
13
13
|
export { HStack } from "./components/h-stack.js";
|
|
14
14
|
export { Image, setImageTranscoder, } from "./components/image.js";
|
|
15
15
|
export { Input } from "./components/input.js";
|