@react-x11/components 0.2.1 → 0.3.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.
- package/dist/internal/heights.d.ts +26 -1
- package/dist/internal/heights.d.ts.map +1 -1
- package/dist/internal/heights.js +57 -6
- package/dist/internal/heights.js.map +1 -1
- package/dist/internal/scroll.d.ts +11 -0
- package/dist/internal/scroll.d.ts.map +1 -1
- package/dist/internal/scroll.js +43 -3
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/timers.d.ts +8 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/internal/timers.js +10 -0
- package/dist/internal/timers.js.map +1 -1
- package/dist/internal/window.d.ts +161 -0
- package/dist/internal/window.d.ts.map +1 -0
- package/dist/internal/window.js +417 -0
- package/dist/internal/window.js.map +1 -0
- package/dist/table/index.d.ts +73 -2
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +405 -161
- package/dist/table/index.js.map +1 -1
- package/dist/tree/index.d.ts +65 -5
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +446 -189
- package/dist/tree/index.js.map +1 -1
- package/package.json +1 -1
- package/src/internal/heights.ts +57 -6
- package/src/internal/scroll.ts +59 -3
- package/src/internal/timers.ts +13 -0
- package/src/internal/window.ts +570 -0
- package/src/table/index.ts +599 -178
- package/src/tree/index.ts +687 -260
|
@@ -24,8 +24,14 @@ export declare class RowHeights {
|
|
|
24
24
|
private rows;
|
|
25
25
|
/** Fenwick tree over the heights, 1-based. */
|
|
26
26
|
private tree;
|
|
27
|
-
/** What an unmeasured row is assumed to be
|
|
27
|
+
/** What an unmeasured row is assumed to be, effectively: the caller's
|
|
28
|
+
* `base`, until `adapt` has seen enough real rows to know better. */
|
|
28
29
|
private estimate;
|
|
30
|
+
/** The estimate the caller declared. A caller changing it is a caller
|
|
31
|
+
* changing their mind, and it wins back over adaptation. */
|
|
32
|
+
private base;
|
|
33
|
+
/** Running sum of the measured map's values, so `adapt` is O(1). */
|
|
34
|
+
private sum;
|
|
29
35
|
/** Largest power of two <= n, for the O(log n) descent in `indexAt`. */
|
|
30
36
|
private power;
|
|
31
37
|
/** Set when a measurement could not be applied in place, so the next
|
|
@@ -42,6 +48,8 @@ export declare class RowHeights {
|
|
|
42
48
|
* arrive, when a sort flips, when a filter runs, all O(n) events already.
|
|
43
49
|
*/
|
|
44
50
|
sync(rows: readonly Keyed[], estimate: number): void;
|
|
51
|
+
/** Rebuild the tree from the measured map and the current estimate. */
|
|
52
|
+
private rebuild;
|
|
45
53
|
/**
|
|
46
54
|
* Record what a row actually laid out at. Returns whether this changed
|
|
47
55
|
* anything — which is what tells the component whether to re-render, and
|
|
@@ -73,6 +81,23 @@ export declare class RowHeights {
|
|
|
73
81
|
hasMeasurements(): boolean;
|
|
74
82
|
/** How many of the current rows have a real measurement. */
|
|
75
83
|
measuredCount(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Let the estimate learn from the rows that have been measured.
|
|
86
|
+
*
|
|
87
|
+
* The fixed guess is why a measured list converges slowly: every row not
|
|
88
|
+
* yet seen is assumed `estimate`, the scrollbar believes the sum, and each
|
|
89
|
+
* newly measured row moves everything. Once enough rows have real numbers,
|
|
90
|
+
* their mean is a far better guess for the rest — one O(n) rebuild brings
|
|
91
|
+
* every unmeasured offset close to where measuring will find it, so the
|
|
92
|
+
* corrections that follow are small.
|
|
93
|
+
*
|
|
94
|
+
* Returns whether anything changed. **Every offset of every unmeasured row
|
|
95
|
+
* moves when it does** — the caller owns keeping what is on screen still,
|
|
96
|
+
* the same anchor arithmetic a measurement pass does. Deliberately not
|
|
97
|
+
* called from `measure`: the caller decides when a wholesale move is safe
|
|
98
|
+
* to make, which is while nothing is scrolling.
|
|
99
|
+
*/
|
|
100
|
+
adapt(): boolean;
|
|
76
101
|
/**
|
|
77
102
|
* Forget every measurement, keeping the row list.
|
|
78
103
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heights.d.ts","sourceRoot":"","sources":["../../src/internal/heights.ts"],"names":[],"mappings":"AA0CA;;sBAEsB;AACtB,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC;;qEAEqE;AACrE,UAAU,KAAK;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAU;IACrB,oDAAoD;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,iDAAiD;IACjD,OAAO,CAAC,IAAI,CAAwB;IACpC,8CAA8C;IAC9C,OAAO,CAAC,IAAI,CAAiB;IAC7B
|
|
1
|
+
{"version":3,"file":"heights.d.ts","sourceRoot":"","sources":["../../src/internal/heights.ts"],"names":[],"mappings":"AA0CA;;sBAEsB;AACtB,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC;;qEAEqE;AACrE,UAAU,KAAK;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAU;IACrB,oDAAoD;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,iDAAiD;IACjD,OAAO,CAAC,IAAI,CAAwB;IACpC,8CAA8C;IAC9C,OAAO,CAAC,IAAI,CAAiB;IAC7B;0EACsE;IACtE,OAAO,CAAC,QAAQ,CAAK;IACrB;iEAC6D;IAC7D,OAAO,CAAC,IAAI,CAAK;IACjB,oEAAoE;IACpE,OAAO,CAAC,GAAG,CAAK;IAChB,wEAAwE;IACxE,OAAO,CAAC,KAAK,CAAK;IAClB;uEACmE;IACnE,OAAO,CAAC,KAAK,CAAS;IAEtB,YAAY,QAAQ,EAAE,MAAM,EAG3B;IAED,OAAO,CAAC,QAAQ;IAKhB;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAanD;IAED,uEAAuE;IACvE,OAAO,CAAC,OAAO;IAgBf;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAmB1D;IAED,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9B;IAED,uEAAuE;IACvE,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGjC;IAED,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAU9B;IAED,gEAAgE;IAChE,KAAK,IAAI,MAAM,CAEd;IAED;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAa9B;IAED;;;;;OAKG;IACH,eAAe,IAAI,OAAO,CAEzB;IAED,4DAA4D;IAC5D,aAAa,IAAI,MAAM,CAItB;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,IAAI,OAAO,CAUf;IAED;;;;;;;;OAQG;IACH,KAAK,IAAI,IAAI,CAMZ;CACF"}
|
package/dist/internal/heights.js
CHANGED
|
@@ -55,15 +55,22 @@ export class RowHeights {
|
|
|
55
55
|
rows = [];
|
|
56
56
|
/** Fenwick tree over the heights, 1-based. */
|
|
57
57
|
tree = [0];
|
|
58
|
-
/** What an unmeasured row is assumed to be
|
|
58
|
+
/** What an unmeasured row is assumed to be, effectively: the caller's
|
|
59
|
+
* `base`, until `adapt` has seen enough real rows to know better. */
|
|
59
60
|
estimate = 1;
|
|
61
|
+
/** The estimate the caller declared. A caller changing it is a caller
|
|
62
|
+
* changing their mind, and it wins back over adaptation. */
|
|
63
|
+
base = 1;
|
|
64
|
+
/** Running sum of the measured map's values, so `adapt` is O(1). */
|
|
65
|
+
sum = 0;
|
|
60
66
|
/** Largest power of two <= n, for the O(log n) descent in `indexAt`. */
|
|
61
67
|
power = 0;
|
|
62
68
|
/** Set when a measurement could not be applied in place, so the next
|
|
63
69
|
* `sync` must rebuild even though the row list did not change. */
|
|
64
70
|
dirty = false;
|
|
65
71
|
constructor(estimate) {
|
|
66
|
-
this.
|
|
72
|
+
this.base = Math.max(1, estimate);
|
|
73
|
+
this.estimate = this.base;
|
|
67
74
|
}
|
|
68
75
|
heightOf(index) {
|
|
69
76
|
const measured = this.measured.get(this.rows[index].id);
|
|
@@ -79,12 +86,23 @@ export class RowHeights {
|
|
|
79
86
|
*/
|
|
80
87
|
sync(rows, estimate) {
|
|
81
88
|
const next = Math.max(1, estimate);
|
|
82
|
-
if (
|
|
89
|
+
if (next !== this.base) {
|
|
90
|
+
// The caller changed their declared estimate: that wins back over
|
|
91
|
+
// whatever `adapt` had learnt — it is the same caller telling us the
|
|
92
|
+
// rows changed character.
|
|
93
|
+
this.base = next;
|
|
94
|
+
this.estimate = next;
|
|
95
|
+
this.dirty = true;
|
|
96
|
+
}
|
|
97
|
+
if (!this.dirty && this.rows === rows)
|
|
83
98
|
return;
|
|
84
|
-
this.dirty = false;
|
|
85
99
|
this.rows = rows;
|
|
86
|
-
this.
|
|
87
|
-
|
|
100
|
+
this.rebuild();
|
|
101
|
+
}
|
|
102
|
+
/** Rebuild the tree from the measured map and the current estimate. */
|
|
103
|
+
rebuild() {
|
|
104
|
+
this.dirty = false;
|
|
105
|
+
const n = this.rows.length;
|
|
88
106
|
// Build in O(n): write each height at its own slot, then push every slot
|
|
89
107
|
// into its parent. The textbook loop of point-updates is O(n log n) and
|
|
90
108
|
// arrives at the same tree.
|
|
@@ -111,6 +129,7 @@ export class RowHeights {
|
|
|
111
129
|
if (before === height)
|
|
112
130
|
return false;
|
|
113
131
|
this.measured.set(id, height);
|
|
132
|
+
this.sum += height - (before ?? 0);
|
|
114
133
|
if (this.rows[index]?.id !== id) {
|
|
115
134
|
// The caller's index is stale — the rows moved under a measurement
|
|
116
135
|
// that was already in flight. Applying a delta at the wrong slot would
|
|
@@ -186,6 +205,35 @@ export class RowHeights {
|
|
|
186
205
|
count++;
|
|
187
206
|
return count;
|
|
188
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Let the estimate learn from the rows that have been measured.
|
|
210
|
+
*
|
|
211
|
+
* The fixed guess is why a measured list converges slowly: every row not
|
|
212
|
+
* yet seen is assumed `estimate`, the scrollbar believes the sum, and each
|
|
213
|
+
* newly measured row moves everything. Once enough rows have real numbers,
|
|
214
|
+
* their mean is a far better guess for the rest — one O(n) rebuild brings
|
|
215
|
+
* every unmeasured offset close to where measuring will find it, so the
|
|
216
|
+
* corrections that follow are small.
|
|
217
|
+
*
|
|
218
|
+
* Returns whether anything changed. **Every offset of every unmeasured row
|
|
219
|
+
* moves when it does** — the caller owns keeping what is on screen still,
|
|
220
|
+
* the same anchor arithmetic a measurement pass does. Deliberately not
|
|
221
|
+
* called from `measure`: the caller decides when a wholesale move is safe
|
|
222
|
+
* to make, which is while nothing is scrolling.
|
|
223
|
+
*/
|
|
224
|
+
adapt() {
|
|
225
|
+
const n = this.measured.size;
|
|
226
|
+
if (n < 8)
|
|
227
|
+
return false; // too few rows to say anything about the rest
|
|
228
|
+
const mean = Math.round(this.sum / n);
|
|
229
|
+
// ±1 is noise — the mean drifts by that much as single rows arrive, and
|
|
230
|
+
// a rebuild per drift would run at the measure rate for no visible gain.
|
|
231
|
+
if (Math.abs(mean - this.estimate) <= 1)
|
|
232
|
+
return false;
|
|
233
|
+
this.estimate = Math.max(1, mean);
|
|
234
|
+
this.rebuild();
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
189
237
|
/**
|
|
190
238
|
* Forget every measurement, keeping the row list.
|
|
191
239
|
*
|
|
@@ -197,6 +245,9 @@ export class RowHeights {
|
|
|
197
245
|
*/
|
|
198
246
|
reset() {
|
|
199
247
|
this.measured.clear();
|
|
248
|
+
this.sum = 0;
|
|
249
|
+
// adaptation came from the measurements just forgotten
|
|
250
|
+
this.estimate = this.base;
|
|
200
251
|
this.dirty = true;
|
|
201
252
|
}
|
|
202
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heights.js","sourceRoot":"","sources":["../../src/internal/heights.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,MAAM;AACN,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,kEAAkE;AAClE,wEAAwE;AACxE,yEAAyE;AACzE,0EAA0E;AAC1E,gEAAgE;AAChE,EAAE;AACF,qEAAqE;AACrE,oEAAoE;AACpE,uEAAuE;AACvE,cAAc;AACd,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,uEAAuE;AACvE,2EAA2E;AAC3E,uEAAuE;AACvE,iEAAiE;AACjE,EAAE;AACF,yEAAyE;AACzE,iDAAiD;AACjD,EAAE;AACF,qDAAqD;AACrD,oDAAoD;AACpD,kDAAkD;AAClD,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,8EAA8E;AAC9E,0EAA0E;AAC1E,8DAA8D;AAc9D;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IACrB,oDAAoD;IACnC,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtD,iDAAiD;IACzC,IAAI,GAAqB,EAAE,CAAC;IACpC,8CAA8C;IACtC,IAAI,GAAa,CAAC,CAAC,CAAC,CAAC;IAC7B
|
|
1
|
+
{"version":3,"file":"heights.js","sourceRoot":"","sources":["../../src/internal/heights.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,MAAM;AACN,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,kEAAkE;AAClE,wEAAwE;AACxE,yEAAyE;AACzE,0EAA0E;AAC1E,gEAAgE;AAChE,EAAE;AACF,qEAAqE;AACrE,oEAAoE;AACpE,uEAAuE;AACvE,cAAc;AACd,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACz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EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,uDAAuD;QACvD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -32,6 +32,17 @@ export interface RevealSources {
|
|
|
32
32
|
export interface Reveal {
|
|
33
33
|
/** Owe a scroll to this row, and try to pay it now. */
|
|
34
34
|
to(id: RowKey): void;
|
|
35
|
+
/**
|
|
36
|
+
* The content above the viewport just changed size by `px` — measurements
|
|
37
|
+
* came in — and the offset must absorb the difference or what is on screen
|
|
38
|
+
* jumps. A debt rather than a one-shot for the same reason a reveal is:
|
|
39
|
+
* the pane clamps against the content height of the *last* layout, so a
|
|
40
|
+
* nudge made just after rows above grew taller lands short — near the
|
|
41
|
+
* bottom of the list, all of it lands short — and the remainder must be
|
|
42
|
+
* re-tried once the layout that admits the growth has run. Retried by
|
|
43
|
+
* `retry`, dropped by `heard`: a user mid-scroll keeps the pane.
|
|
44
|
+
*/
|
|
45
|
+
nudge(px: number): void;
|
|
35
46
|
/**
|
|
36
47
|
* Try again: after a layout, or when the content changed size.
|
|
37
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../src/internal/scroll.ts"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAIvD,+EAA+E;AAC/E,UAAU,KAAK;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED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AS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;6EAC6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,GAAG,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,CAAC;IACjD,iCAAiC;IACjC,IAAI,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAA;KAAE,CAAC;IAC7C,iCAAiC;IACjC,KAAK,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;KAAE,CAAC;IACxD;iDAC6C;IAC7C,OAAO,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,MAAM;IACrB,uDAAuD;IACvD,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;yDACqD;IACrD,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAsOxD"}
|
package/dist/internal/scroll.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
// `useReveal` does not do that itself, because what a component *does* with
|
|
38
38
|
// the offset differs (a slice to rebuild, a header to shift), but it is the
|
|
39
39
|
// other half of the same fix and both components run it on the same tick.
|
|
40
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
40
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
41
41
|
import { afterLayout, cancelAfterLayout } from './timers.js';
|
|
42
42
|
/**
|
|
43
43
|
* The scroll a component owes a row, and the bookkeeping that pays it.
|
|
@@ -76,6 +76,9 @@ export function useReveal(sources) {
|
|
|
76
76
|
const stuck = useRef(null);
|
|
77
77
|
const look = useRef(null);
|
|
78
78
|
useEffect(() => () => cancelAfterLayout(look.current), []);
|
|
79
|
+
/** Pixels the pane still owes the content that grew or shrank above the
|
|
80
|
+
* viewport — the unpaid remainder of `nudge`. */
|
|
81
|
+
const owedShift = useRef(0);
|
|
79
82
|
const scrollTo = useCallback((y) => {
|
|
80
83
|
const box = src.current.box.current;
|
|
81
84
|
if (!box)
|
|
@@ -88,9 +91,38 @@ export function useReveal(sources) {
|
|
|
88
91
|
asked.current = to;
|
|
89
92
|
box.scrollTo({ y: to });
|
|
90
93
|
}, []);
|
|
94
|
+
/** Pay as much of the owed shift as the pane will take right now. What it
|
|
95
|
+
* refuses — a clamp still measuring the last layout's content — stays
|
|
96
|
+
* owed, and the `retry` after the next layout tries again. */
|
|
97
|
+
const payShift = useCallback(() => {
|
|
98
|
+
const box = src.current.box.current;
|
|
99
|
+
const want = owedShift.current;
|
|
100
|
+
if (!box || want === 0)
|
|
101
|
+
return;
|
|
102
|
+
const was = box.scrollY;
|
|
103
|
+
scrollTo(was + want);
|
|
104
|
+
owedShift.current = want - (box.scrollY - was);
|
|
105
|
+
}, [scrollTo]);
|
|
106
|
+
const nudge = useCallback((px) => {
|
|
107
|
+
// Either the reveal owns the pane or the anchor does. While a row is
|
|
108
|
+
// owed — or settled and still being confirmed — the reveal re-places
|
|
109
|
+
// it against the heights as they settle, so preserving the anchor
|
|
110
|
+
// would fight it: a remainder paid out after the reveal has already
|
|
111
|
+
// put its row where it belongs scrolls straight past it.
|
|
112
|
+
if (owed.current !== null || settled.current !== null)
|
|
113
|
+
return;
|
|
114
|
+
if (px === 0)
|
|
115
|
+
return;
|
|
116
|
+
owedShift.current += px;
|
|
117
|
+
payShift();
|
|
118
|
+
}, [payShift]);
|
|
91
119
|
const retry = useCallback((provisional) => {
|
|
92
120
|
const { box: boxRef, rows: rowsRef, nodes, heights } = src.current;
|
|
93
121
|
const box = boxRef.current;
|
|
122
|
+
// The shift first: the reveal below judges placement from the offset,
|
|
123
|
+
// and an offset still owing the content above it is the wrong one to
|
|
124
|
+
// judge anything from.
|
|
125
|
+
payShift();
|
|
94
126
|
// The heights just moved, so what the last reveal settled on was settled
|
|
95
127
|
// against numbers that have changed: owe it again until it can be
|
|
96
128
|
// confirmed at the new ones.
|
|
@@ -197,7 +229,7 @@ export function useReveal(sources) {
|
|
|
197
229
|
look.current = null;
|
|
198
230
|
retryRef.current?.();
|
|
199
231
|
});
|
|
200
|
-
}, [scrollTo]);
|
|
232
|
+
}, [scrollTo, payShift]);
|
|
201
233
|
/** `retry` referring to itself through a ref, so the queued look calls the
|
|
202
234
|
* current one rather than closing over the render that queued it. */
|
|
203
235
|
const retryRef = useRef(null);
|
|
@@ -208,6 +240,8 @@ export function useReveal(sources) {
|
|
|
208
240
|
owed.current = id;
|
|
209
241
|
settled.current = null;
|
|
210
242
|
stuck.current = null;
|
|
243
|
+
// the reveal owns the pane now — see `nudge`
|
|
244
|
+
owedShift.current = 0;
|
|
211
245
|
retry();
|
|
212
246
|
}, [retry]);
|
|
213
247
|
const heard = useCallback((scrollY) => {
|
|
@@ -216,9 +250,15 @@ export function useReveal(sources) {
|
|
|
216
250
|
if (scrollY !== asked.current) {
|
|
217
251
|
owed.current = null;
|
|
218
252
|
settled.current = null;
|
|
253
|
+
owedShift.current = 0;
|
|
219
254
|
}
|
|
220
255
|
asked.current = null;
|
|
221
256
|
}, []);
|
|
222
|
-
|
|
257
|
+
// One stable object, not a fresh literal per render: callbacks built on
|
|
258
|
+
// this handle (`revealAt`, and the row handlers behind it) keep their
|
|
259
|
+
// identity, which is what lets a memoized row bail out of a scroll
|
|
260
|
+
// render. A literal here made every row re-render on every notch — the
|
|
261
|
+
// exact cost the memo exists to remove — with nothing anywhere naming it.
|
|
262
|
+
return useMemo(() => ({ to, retry, scrollTo, nudge, heard }), [to, retry, scrollTo, nudge, heard]);
|
|
223
263
|
}
|
|
224
264
|
//# sourceMappingURL=scroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../src/internal/scroll.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yBAAyB;AACzB,EAAE;AACF,mEAAmE;AACnE,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AACtE,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,8EAA8E;AAC9E,EAAE;AACF,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,0EAA0E;AAC1E,kEAAkE;AAClE,EAAE;AACF,kEAAkE;AAClE,sEAAsE;AACtE,kEAAkE;AAClE,2EAA2E;AAC3E,wEAAwE;AACxE,2EAA2E;AAC3E,uEAAuE;AACvE,iBAAiB;AACjB,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,yEAAyE;AACzE,6EAA6E;AAC7E,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAE1E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../src/internal/scroll.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yBAAyB;AACzB,EAAE;AACF,mEAAmE;AACnE,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AACtE,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,8EAA8E;AAC9E,EAAE;AACF,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,0EAA0E;AAC1E,kEAAkE;AAClE,EAAE;AACF,kEAAkE;AAClE,sEAAsE;AACtE,k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,IAAI,CAAC;YACvB,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,wEAAwE;IACxE,sEAAsE;IACtE,mEAAmE;IACnE,uEAAuE;IACvE,0EAA0E;IAC1E,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAC7C,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CACpC,CAAC;AACJ,CAAC"}
|
|
@@ -5,4 +5,12 @@ export type LayoutTick = {
|
|
|
5
5
|
/** Run `fn` after the layout pass this commit will cause. */
|
|
6
6
|
export declare function afterLayout(fn: () => void): LayoutTick;
|
|
7
7
|
export declare function cancelAfterLayout(tick: LayoutTick): void;
|
|
8
|
+
export type DelayTick = {
|
|
9
|
+
id: unknown;
|
|
10
|
+
} | null;
|
|
11
|
+
/** Run `fn` after `ms` — the idle clock prefetch paces itself on. Typed here
|
|
12
|
+
* for the same reason `afterLayout` is: `src/` compiles with `types: []`,
|
|
13
|
+
* and a bare `setTimeout` would demand `@types/node`. */
|
|
14
|
+
export declare function later(fn: () => void, ms: number): DelayTick;
|
|
15
|
+
export declare function cancelLater(tick: DelayTick): void;
|
|
8
16
|
//# sourceMappingURL=timers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timers.d.ts","sourceRoot":"","sources":["../../src/internal/timers.ts"],"names":[],"mappings":"AA0BA,MAAM,MAAM,UAAU,GAAG;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAEpE,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,UAAU,CAQtD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAIxD"}
|
|
1
|
+
{"version":3,"file":"timers.d.ts","sourceRoot":"","sources":["../../src/internal/timers.ts"],"names":[],"mappings":"AA0BA,MAAM,MAAM,UAAU,GAAG;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAEpE,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,UAAU,CAQtD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAIxD;AAED,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE/C;;0DAE0D;AAC1D,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAE3D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAEjD"}
|
package/dist/internal/timers.js
CHANGED
|
@@ -19,4 +19,14 @@ export function cancelAfterLayout(tick) {
|
|
|
19
19
|
else
|
|
20
20
|
g.clearTimeout?.(tick.id);
|
|
21
21
|
}
|
|
22
|
+
/** Run `fn` after `ms` — the idle clock prefetch paces itself on. Typed here
|
|
23
|
+
* for the same reason `afterLayout` is: `src/` compiles with `types: []`,
|
|
24
|
+
* and a bare `setTimeout` would demand `@types/node`. */
|
|
25
|
+
export function later(fn, ms) {
|
|
26
|
+
return g.setTimeout ? { id: g.setTimeout(fn, ms) } : null;
|
|
27
|
+
}
|
|
28
|
+
export function cancelLater(tick) {
|
|
29
|
+
if (tick)
|
|
30
|
+
g.clearTimeout?.(tick.id);
|
|
31
|
+
}
|
|
22
32
|
//# sourceMappingURL=timers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../../src/internal/timers.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,GAAG,UAAsB,CAAC;AAIjC,6DAA6D;AAC7D,MAAM,UAAU,WAAW,CAAC,EAAc;IACxC,yEAAyE;IACzE,2EAA2E;IAC3E,oEAAoE;IACpE,wEAAwE;IACxE,IAAI,CAAC,CAAC,YAAY;QAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;IACvE,IAAI,CAAC,CAAC,UAAU;QAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAgB;IAChD,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,IAAI,CAAC,SAAS;QAAE,CAAC,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;QAC3C,CAAC,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC"}
|
|
1
|
+
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../../src/internal/timers.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,GAAG,UAAsB,CAAC;AAIjC,6DAA6D;AAC7D,MAAM,UAAU,WAAW,CAAC,EAAc;IACxC,yEAAyE;IACzE,2EAA2E;IAC3E,oEAAoE;IACpE,wEAAwE;IACxE,IAAI,CAAC,CAAC,YAAY;QAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;IACvE,IAAI,CAAC,CAAC,UAAU;QAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAgB;IAChD,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,IAAI,CAAC,SAAS;QAAE,CAAC,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;QAC3C,CAAC,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC;AAID;;0DAE0D;AAC1D,MAAM,UAAU,KAAK,CAAC,EAAc,EAAE,EAAU;IAC9C,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,IAAI,IAAI;QAAE,CAAC,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { ScrollableNode } from 'react-x11';
|
|
2
|
+
import type { RowHeights, RowKey } from './heights.js';
|
|
3
|
+
/** All this needs of a row — `TreeRow` and `TableRow` are both this. */
|
|
4
|
+
interface Keyed {
|
|
5
|
+
id: RowKey;
|
|
6
|
+
}
|
|
7
|
+
/** Rows kept either side of the viewport, so a fast scroll does not show a
|
|
8
|
+
* gap before the next frame catches up. The components' default. */
|
|
9
|
+
export declare const DEFAULT_OVERSCAN = 6;
|
|
10
|
+
/** How long the viewport must have been showing unresolved content before
|
|
11
|
+
* the fast-scroll pill appears. A catch-up the next few frames absorb is
|
|
12
|
+
* not worth announcing — the pill is for the delay you can feel. */
|
|
13
|
+
export declare const SCROLL_HINT_DELAY_MS = 250;
|
|
14
|
+
/** How far past the overscan the idle band grows, rows per side — the
|
|
15
|
+
* components' default for their `prefetch` prop. Roughly two viewports of
|
|
16
|
+
* ordinary rows: enough that a flick lands inside it, small enough that
|
|
17
|
+
* holding it is never felt. */
|
|
18
|
+
export declare const DEFAULT_PREFETCH = 40;
|
|
19
|
+
/** More rows than this entering the window in one render is a flood — a
|
|
20
|
+
* teleport or a hard flick — and floods build skeletons first. An ordinary
|
|
21
|
+
* notch brings in a handful and never trips this. */
|
|
22
|
+
export declare const SKELETON_THRESHOLD = 16;
|
|
23
|
+
/** New full rows built per render while a flood is being caught up with.
|
|
24
|
+
* Measured (rowcost probe, 300-row commits, warm caches): a default-shape
|
|
25
|
+
* row costs ~0.11ms against a skeleton's ~0.06ms — about 2×, not the 10×
|
|
26
|
+
* the original pacing assumed — so the budgets lean generous and the
|
|
27
|
+
* skeleton tier is there for heavy `render` seams and for the look of
|
|
28
|
+
* rows arriving, not because full rows are ruinous. */
|
|
29
|
+
export declare const BURST_BUDGET = 24;
|
|
30
|
+
/** The same, once the scroll has stopped: bigger steps, still paced, so a
|
|
31
|
+
* settle after a long flood is a few quick commits rather than one big
|
|
32
|
+
* one. */
|
|
33
|
+
export declare const SETTLE_BUDGET = 48;
|
|
34
|
+
export interface VirtualViewport {
|
|
35
|
+
/** The pane's vertical offset. */
|
|
36
|
+
top: number;
|
|
37
|
+
height: number;
|
|
38
|
+
width: number;
|
|
39
|
+
}
|
|
40
|
+
/** The rows worth building this render, and the two spacer heights that keep
|
|
41
|
+
* the scrollbar measuring the whole list. `last` is exclusive. */
|
|
42
|
+
export interface WindowSlice {
|
|
43
|
+
first: number;
|
|
44
|
+
last: number;
|
|
45
|
+
above: number;
|
|
46
|
+
below: number;
|
|
47
|
+
}
|
|
48
|
+
/** What the hook reads of its component, re-supplied every render so none of
|
|
49
|
+
* it goes stale inside the stable callbacks. */
|
|
50
|
+
export interface VirtualWindowInputs {
|
|
51
|
+
/** The scroll pane. `<Table>`'s body; `<Tree>`'s own root. */
|
|
52
|
+
box: {
|
|
53
|
+
readonly current: ScrollableNode | null;
|
|
54
|
+
};
|
|
55
|
+
/** The height index, already `sync`ed to the rows this render draws. */
|
|
56
|
+
heights: RowHeights;
|
|
57
|
+
/** The rows in display order — the same list the component draws from. */
|
|
58
|
+
rows: readonly Keyed[];
|
|
59
|
+
/**
|
|
60
|
+
* Every height in the index is exact — the table's declared-uniform model.
|
|
61
|
+
* What it buys here: the idle band may grow *upward* freely. A measured
|
|
62
|
+
* component may only grow upward over rows the index has real numbers
|
|
63
|
+
* for: an unmeasured row laid out above the viewport lands at a height
|
|
64
|
+
* the spacer did not anticipate, and everything on screen jumps by the
|
|
65
|
+
* difference until the measure tick pays it back — a wobble that is
|
|
66
|
+
* masked while scrolling and glaring while idle. Unmeasured territory
|
|
67
|
+
* above is left to the overscan, which meets it during a scroll.
|
|
68
|
+
*/
|
|
69
|
+
exact: boolean;
|
|
70
|
+
virtualizing: boolean;
|
|
71
|
+
overscan: number;
|
|
72
|
+
/** The idle band's target, rows beyond the overscan each side. `0` turns
|
|
73
|
+
* prefetch and the retained band off — the slice is exactly
|
|
74
|
+
* viewport-plus-overscan again. */
|
|
75
|
+
prefetch: number;
|
|
76
|
+
/** Rows entering the window in one render that count as a flood — below
|
|
77
|
+
* it everything builds in full. The component resolves it from its
|
|
78
|
+
* `catchup` prop; `SKELETON_THRESHOLD` is the default. */
|
|
79
|
+
threshold: number;
|
|
80
|
+
/** Full rows built per render while a flood is in flight / once it has
|
|
81
|
+
* settled. `BURST_BUDGET` / `SETTLE_BUDGET` are the defaults. */
|
|
82
|
+
burstBudget: number;
|
|
83
|
+
settleBudget: number;
|
|
84
|
+
}
|
|
85
|
+
export interface VirtualWindow {
|
|
86
|
+
view: VirtualViewport;
|
|
87
|
+
/** The viewport as of the last event, ahead of the state between an
|
|
88
|
+
* `onViewport` and the re-render it causes — what a measure tick reads. */
|
|
89
|
+
viewRef: {
|
|
90
|
+
readonly current: VirtualViewport;
|
|
91
|
+
};
|
|
92
|
+
slice: WindowSlice;
|
|
93
|
+
/**
|
|
94
|
+
* Rows in the slice to draw as skeletons this render — the box at its
|
|
95
|
+
* indexed height, no content, `aria-hidden`, and **not registered as a
|
|
96
|
+
* mounted row**: a skeleton must not be measured into the height index or
|
|
97
|
+
* satisfy a reveal. Empty except while a flood is being caught up with.
|
|
98
|
+
*/
|
|
99
|
+
skeletons: ReadonlySet<RowKey>;
|
|
100
|
+
/**
|
|
101
|
+
* The window teleported this render: nothing it had built overlaps where
|
|
102
|
+
* the viewport is now. One jump is a scrollbar page; a *run* of them
|
|
103
|
+
* while a burst is in flight is a thumb scrub, where every commit chases
|
|
104
|
+
* a viewport that has already left — the case a scroll-position overlay
|
|
105
|
+
* exists for, because nothing else useful can be on screen.
|
|
106
|
+
*/
|
|
107
|
+
jumped: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* When the viewport first stopped being whole — placeholders on screen,
|
|
110
|
+
* or a scrub outrunning the built rows — epoch milliseconds, `null` while
|
|
111
|
+
* everything in view is real. What a hint's show-delay is measured from,
|
|
112
|
+
* and cleared the moment the catch-up ends.
|
|
113
|
+
*/
|
|
114
|
+
catchupSince: number | null;
|
|
115
|
+
/**
|
|
116
|
+
* How many of the rows **on screen** are skeletons this render — the
|
|
117
|
+
* measure of "the user is looking at rows that have no content yet".
|
|
118
|
+
* `0` the moment the viewport is fully real again, even while the band
|
|
119
|
+
* beyond it is still catching up: it is the signal a scroll-position
|
|
120
|
+
* overlay shows on, and an overlay that lingered past the last visible
|
|
121
|
+
* skeleton would be announcing a delay nobody can see.
|
|
122
|
+
*/
|
|
123
|
+
pending: number;
|
|
124
|
+
/** An `onScroll` arrived. */
|
|
125
|
+
scrolled(top: number): void;
|
|
126
|
+
/** An `onViewport` arrived. The ref is updated at event time — the measure
|
|
127
|
+
* tick runs before the re-render this causes, and must see this size. */
|
|
128
|
+
sized(width: number, height: number): void;
|
|
129
|
+
/**
|
|
130
|
+
* Re-read the offset the pane is *actually* at.
|
|
131
|
+
*
|
|
132
|
+
* The pane moves silently — it resolves a queued reveal during layout, and
|
|
133
|
+
* re-clamps an offset the content outgrew or outshrank — and a slice built
|
|
134
|
+
* from the offset before those is drawn where the viewport is not: a blank
|
|
135
|
+
* band where the rows should be, and no way back until a scroll of your
|
|
136
|
+
* own re-syncs it by accident.
|
|
137
|
+
*/
|
|
138
|
+
sync(): void;
|
|
139
|
+
/** Whether a scroll is in flight — an event arrived and the idle clock has
|
|
140
|
+
* not run out since. What the growth pauses on, and what a component may
|
|
141
|
+
* defer non-urgent per-render work on. */
|
|
142
|
+
scrolling(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Scrolling, and too fast to be reading: work whose payoff is precision —
|
|
145
|
+
* measuring rows, adapting estimates — is churn at this speed, every
|
|
146
|
+
* correction invalidated by the next event. The settle tick that follows
|
|
147
|
+
* any burst is where deferred work catches up.
|
|
148
|
+
*/
|
|
149
|
+
fast(): boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The window a virtualizing component builds its rows from.
|
|
153
|
+
*
|
|
154
|
+
* Owns the viewport state and the slice; the component keeps everything the
|
|
155
|
+
* two virtualizers genuinely differ on — what a row *is*, measuring it,
|
|
156
|
+
* revealing it. Call after `heights.sync`, so the slice is computed against
|
|
157
|
+
* the rows this render is about to draw.
|
|
158
|
+
*/
|
|
159
|
+
export declare function useVirtualWindow(inputs: VirtualWindowInputs): VirtualWindow;
|
|
160
|
+
export {};
|
|
161
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../src/internal/window.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAIvD,wEAAwE;AACxE,UAAU,KAAK;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAID;qEACqE;AACrE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;qEAEqE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