@alchemy.run/sigil 0.0.0-alpha.8 → 0.1.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/README.md +176 -0
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/dist/ansi.d.ts +53 -53
- package/dist/capabilities.js +1 -1
- package/dist/{color-policy-DlrZXC0f.js → color-policy-BAC9-TZX.js} +15 -1
- package/dist/color.d.ts +8 -8
- package/dist/{devtools-DbthxoD1.js → devtools-B_2SDRaO.js} +3 -0
- package/dist/index.d.ts +209 -42
- package/dist/index.js +354 -171
- package/dist/jsx-dev-runtime.d.ts +3 -0
- package/dist/jsx-dev-runtime.js +7 -0
- package/dist/jsx-runtime-BS_OosoY.js +42 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +8 -0
- package/dist/react-CeO3oT_g.js +394 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +50 -0
- package/dist/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/router.d.ts +26 -26
- package/dist/router.js +45 -42
- package/dist/{session-Cg6STjFV.js → session-DDQ5V300.js} +34 -11
- package/dist/terminal.d.ts +9 -10
- package/dist/terminal.js +1 -1
- package/dist/use-focus-B1WVNBQm.js +8383 -0
- package/package.json +27 -15
- package/src/ansi/strip.ts +2 -2
- package/src/capabilities/query.ts +22 -0
- package/src/components/VirtualList.tsx +128 -0
- package/src/devtools.ts +5 -0
- package/src/hooks/use-virtual-scroll.ts +84 -0
- package/src/hooks/use-window-size.ts +10 -3
- package/src/index.ts +8 -0
- package/src/input-parser.ts +31 -11
- package/src/jsx-dev-runtime.ts +3 -0
- package/src/jsx-runtime.ts +6 -0
- package/src/react.ts +53 -0
- package/src/reconciler.ts +51 -0
- package/src/terminal/input.ts +11 -5
- package/src/virtual-scroll.ts +133 -0
- package/dist/use-focus-BNG0xsb7.js +0 -1337
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ import { n as Text, r as Styles, t as Props$8 } from "./Text-DV9CuzAT.js";
|
|
|
8
8
|
import { i as Node } from "./index-DDVME65c.js";
|
|
9
9
|
import { t as CursorPosition } from "./cursor-position-D2LAkRG0.js";
|
|
10
10
|
import { Writable } from "node:stream";
|
|
11
|
-
import { PropsWithChildren, ReactNode, Ref, RefObject } from "react";
|
|
12
11
|
import { EventEmitter } from "node:events";
|
|
12
|
+
import { Key as Key$1, PropsWithChildren, ReactNode, Ref, RefObject } from "react";
|
|
13
13
|
//#region src/kitty-keyboard.d.ts
|
|
14
|
-
declare const kittyFlags: {
|
|
14
|
+
export declare const kittyFlags: {
|
|
15
15
|
readonly disambiguateEscapeCodes: 1;
|
|
16
16
|
readonly reportEventTypes: 2;
|
|
17
17
|
readonly reportAlternateKeys: 4;
|
|
@@ -19,7 +19,7 @@ declare const kittyFlags: {
|
|
|
19
19
|
readonly reportAssociatedText: 16;
|
|
20
20
|
};
|
|
21
21
|
type KittyFlagName = keyof typeof kittyFlags;
|
|
22
|
-
declare const kittyModifiers: {
|
|
22
|
+
export declare const kittyModifiers: {
|
|
23
23
|
readonly shift: 1;
|
|
24
24
|
readonly alt: 2;
|
|
25
25
|
readonly ctrl: 4;
|
|
@@ -263,7 +263,7 @@ type Instance = {
|
|
|
263
263
|
/**
|
|
264
264
|
Mount a component and render the output.
|
|
265
265
|
*/
|
|
266
|
-
declare const render: (node: ReactNode, options?: Writable | RenderOptions) => Instance;
|
|
266
|
+
export declare const render: (node: ReactNode, options?: Writable | RenderOptions) => Instance;
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/render-to-string.d.ts
|
|
269
269
|
type RenderToStringOptions = {
|
|
@@ -306,7 +306,7 @@ const output = renderToString(
|
|
|
306
306
|
console.log(output);
|
|
307
307
|
```
|
|
308
308
|
*/
|
|
309
|
-
declare const renderToString: (node: ReactNode, options?: RenderToStringOptions) => string;
|
|
309
|
+
export declare const renderToString: (node: ReactNode, options?: RenderToStringOptions) => string;
|
|
310
310
|
//#endregion
|
|
311
311
|
//#region src/semantic-text-style.d.ts
|
|
312
312
|
type SemanticTextStyle = {
|
|
@@ -405,7 +405,7 @@ type Props$2 = Omit<Styles, "textWrap"> & {
|
|
|
405
405
|
/**
|
|
406
406
|
`<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
|
|
407
407
|
*/
|
|
408
|
-
declare function Box({ children, ref, backgroundColor, "aria-label": ariaLabel, "aria-hidden": ariaHidden, "aria-role": role, "aria-state": ariaState, ...style }: PropsWithChildren<Props$2> & {
|
|
408
|
+
export declare function Box({ children, ref, backgroundColor, "aria-label": ariaLabel, "aria-hidden": ariaHidden, "aria-role": role, "aria-state": ariaState, ...style }: PropsWithChildren<Props$2> & {
|
|
409
409
|
readonly ref?: Ref<DOMElement>;
|
|
410
410
|
}): import("react").JSX.Element | null;
|
|
411
411
|
//#endregion
|
|
@@ -421,7 +421,7 @@ type Props = {
|
|
|
421
421
|
* Renders explicitly trusted ANSI-styled output as structured terminal cells.
|
|
422
422
|
* Ordinary `Text` continues to strip terminal control sequences.
|
|
423
423
|
*/
|
|
424
|
-
declare function AnsiText({ children, wrap, "aria-label": ariaLabel, "aria-hidden": ariaHidden }: Props): import("react").JSX.Element | null;
|
|
424
|
+
export declare function AnsiText({ children, wrap, "aria-label": ariaLabel, "aria-hidden": ariaHidden }: Props): import("react").JSX.Element | null;
|
|
425
425
|
//#endregion
|
|
426
426
|
//#region src/components/AppContext.d.ts
|
|
427
427
|
/**
|
|
@@ -565,7 +565,7 @@ It's preferred to use `<Static>` for use cases like these when you can't know or
|
|
|
565
565
|
|
|
566
566
|
For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display a list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it to display a list of generated pages while still displaying a live progress bar.
|
|
567
567
|
*/
|
|
568
|
-
declare function Static<T>(props: Props$5<T>): import("react").JSX.Element;
|
|
568
|
+
export declare function Static<T>(props: Props$5<T>): import("react").JSX.Element;
|
|
569
569
|
//#endregion
|
|
570
570
|
//#region src/components/Transform.d.ts
|
|
571
571
|
type Props$9 = {
|
|
@@ -582,7 +582,7 @@ type Props$9 = {
|
|
|
582
582
|
/**
|
|
583
583
|
Transform a string representation of React components before they're written to output. For example, you might want to apply a gradient to text, add a clickable link, or create some text effects. These use cases can't accept React nodes as input; they expect a string. That's what the <Transform> component does: it gives you an output string of its child components and lets you transform it in any way.
|
|
584
584
|
*/
|
|
585
|
-
declare function Transform({ children, transform, accessibilityLabel }: Props$9): import("react").JSX.Element | null;
|
|
585
|
+
export declare function Transform({ children, transform, accessibilityLabel }: Props$9): import("react").JSX.Element | null;
|
|
586
586
|
//#endregion
|
|
587
587
|
//#region src/components/Hyperlink.d.ts
|
|
588
588
|
type Props$3 = Omit<Props$8, "children"> & {
|
|
@@ -609,7 +609,7 @@ back to `text (url)`.
|
|
|
609
609
|
<Hyperlink url="https://example.com">Documentation</Hyperlink>
|
|
610
610
|
```
|
|
611
611
|
*/
|
|
612
|
-
declare function Hyperlink({ url, fallback, children, ...textProps }: Props$3): import("react").JSX.Element;
|
|
612
|
+
export declare function Hyperlink({ url, fallback, children, ...textProps }: Props$3): import("react").JSX.Element;
|
|
613
613
|
//#endregion
|
|
614
614
|
//#region src/components/Newline.d.ts
|
|
615
615
|
/** @jsxImportSource react */
|
|
@@ -624,7 +624,7 @@ type Props$4 = {
|
|
|
624
624
|
/**
|
|
625
625
|
Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
|
|
626
626
|
*/
|
|
627
|
-
declare function Newline({ count }: Props$4): import("react").JSX.Element;
|
|
627
|
+
export declare function Newline({ count }: Props$4): import("react").JSX.Element;
|
|
628
628
|
//#endregion
|
|
629
629
|
//#region src/components/Spacer.d.ts
|
|
630
630
|
/**
|
|
@@ -632,7 +632,49 @@ A flexible space that expands along the major axis of its containing layout.
|
|
|
632
632
|
|
|
633
633
|
It's useful as a shortcut for filling all the available space between elements.
|
|
634
634
|
*/
|
|
635
|
-
declare function Spacer(): import("react").JSX.Element;
|
|
635
|
+
export declare function Spacer(): import("react").JSX.Element;
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/components/VirtualList.d.ts
|
|
638
|
+
type Props$10<Item> = {
|
|
639
|
+
/**
|
|
640
|
+
Items to window over.
|
|
641
|
+
*/
|
|
642
|
+
readonly items: ReadonlyArray<Item>;
|
|
643
|
+
/**
|
|
644
|
+
Height of an item in rows. It must match what `renderItem` produces for it:
|
|
645
|
+
the window is computed from these numbers, never from the rendered output.
|
|
646
|
+
*/
|
|
647
|
+
readonly itemHeight: (item: Item, index: number) => number;
|
|
648
|
+
/**
|
|
649
|
+
Render one item. Only items intersecting the viewport are rendered.
|
|
650
|
+
*/
|
|
651
|
+
readonly renderItem: (item: Item, index: number) => ReactNode;
|
|
652
|
+
/**
|
|
653
|
+
React key for an item. Defaults to its index.
|
|
654
|
+
*/
|
|
655
|
+
readonly getKey?: (item: Item, index: number) => Key$1;
|
|
656
|
+
/**
|
|
657
|
+
Item to keep fully visible. When it changes, the list scrolls as little as
|
|
658
|
+
necessary to show it.
|
|
659
|
+
*/
|
|
660
|
+
readonly focusedIndex?: number;
|
|
661
|
+
/**
|
|
662
|
+
Viewport height in rows. When omitted the list takes the height of its
|
|
663
|
+
content and shrinks to whatever space its container leaves: bound an
|
|
664
|
+
ancestor (`height` or `maxHeight`) and give the siblings that must keep
|
|
665
|
+
their size `flexShrink={0}`.
|
|
666
|
+
*/
|
|
667
|
+
readonly height?: number;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
A vertically windowed list: only the items intersecting the viewport are
|
|
671
|
+
rendered, inside a clipped box that scrolls by whole rows. Items may have
|
|
672
|
+
different heights, and the item at the top edge may be partially visible.
|
|
673
|
+
|
|
674
|
+
Until the first layout pass has measured the viewport, every item is rendered
|
|
675
|
+
inside the clipped box so the first frame already looks right.
|
|
676
|
+
*/
|
|
677
|
+
export declare function VirtualList<Item>({ items, itemHeight, renderItem, getKey, focusedIndex, height }: Props$10<Item>): import("react").JSX.Element;
|
|
636
678
|
//#endregion
|
|
637
679
|
//#region src/hooks/use-capabilities.d.ts
|
|
638
680
|
/**
|
|
@@ -645,7 +687,7 @@ itself can answer fill in after a lazy one-time query, and re-mounting
|
|
|
645
687
|
consumers refreshes the dynamic facts (theme colors, pixel geometry).
|
|
646
688
|
Re-renders on terminal resize and whenever query answers arrive.
|
|
647
689
|
*/
|
|
648
|
-
declare const useCapabilities: () => Capabilities;
|
|
690
|
+
export declare const useCapabilities: () => Capabilities;
|
|
649
691
|
/**
|
|
650
692
|
Calls `onChange` whenever the terminal changes: resizes (including in-band
|
|
651
693
|
pixel geometry), color scheme switches, window focus, and query answers
|
|
@@ -664,7 +706,7 @@ useCapabilitiesChange((next, previous) => {
|
|
|
664
706
|
});
|
|
665
707
|
```
|
|
666
708
|
*/
|
|
667
|
-
declare const useCapabilitiesChange: (onChange: (capabilities: Capabilities, previous: Capabilities) => void) => void;
|
|
709
|
+
export declare const useCapabilitiesChange: (onChange: (capabilities: Capabilities, previous: Capabilities) => void) => void;
|
|
668
710
|
//#endregion
|
|
669
711
|
//#region src/hooks/use-input.d.ts
|
|
670
712
|
/**
|
|
@@ -797,7 +839,7 @@ const UserInput = () => {
|
|
|
797
839
|
};
|
|
798
840
|
```
|
|
799
841
|
*/
|
|
800
|
-
declare const useInput: (inputHandler: Handler, options?: Options$2) => void;
|
|
842
|
+
export declare const useInput: (inputHandler: Handler, options?: Options$2) => void;
|
|
801
843
|
//#endregion
|
|
802
844
|
//#region src/hooks/use-paste.d.ts
|
|
803
845
|
type Options$1 = {
|
|
@@ -833,31 +875,31 @@ const MyInput = () => {
|
|
|
833
875
|
};
|
|
834
876
|
```
|
|
835
877
|
*/
|
|
836
|
-
declare const usePaste: (handler: (text: string) => void, options?: Options$1) => void;
|
|
878
|
+
export declare const usePaste: (handler: (text: string) => void, options?: Options$1) => void;
|
|
837
879
|
//#endregion
|
|
838
880
|
//#region src/hooks/use-app.d.ts
|
|
839
881
|
/**
|
|
840
882
|
A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
|
|
841
883
|
*/
|
|
842
|
-
declare const useApp: () => Props$1;
|
|
884
|
+
export declare const useApp: () => Props$1;
|
|
843
885
|
//#endregion
|
|
844
886
|
//#region src/hooks/use-stdin.d.ts
|
|
845
887
|
/**
|
|
846
888
|
A React hook that returns the stdin stream and stdin-related utilities.
|
|
847
889
|
*/
|
|
848
|
-
declare const useStdin: () => PublicProps;
|
|
890
|
+
export declare const useStdin: () => PublicProps;
|
|
849
891
|
//#endregion
|
|
850
892
|
//#region src/hooks/use-stdout.d.ts
|
|
851
893
|
/**
|
|
852
894
|
A React hook that returns the stdout stream where Ink renders your app.
|
|
853
895
|
*/
|
|
854
|
-
declare const useStdout: () => Props$7;
|
|
896
|
+
export declare const useStdout: () => Props$7;
|
|
855
897
|
//#endregion
|
|
856
898
|
//#region src/hooks/use-stderr.d.ts
|
|
857
899
|
/**
|
|
858
900
|
A React hook that returns the stderr stream.
|
|
859
901
|
*/
|
|
860
|
-
declare const useStderr: () => Props$6;
|
|
902
|
+
export declare const useStderr: () => Props$6;
|
|
861
903
|
//#endregion
|
|
862
904
|
//#region src/hooks/use-focus.d.ts
|
|
863
905
|
type Input = {
|
|
@@ -888,10 +930,10 @@ type Output$2 = {
|
|
|
888
930
|
A React hook that returns focus state and focus controls for the current component.
|
|
889
931
|
A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
|
|
890
932
|
*/
|
|
891
|
-
declare const useFocus: ({ isActive, autoFocus, id: customId }?: Input) => Output$2;
|
|
933
|
+
export declare const useFocus: ({ isActive, autoFocus, id: customId }?: Input) => Output$2;
|
|
892
934
|
//#endregion
|
|
893
935
|
//#region src/components/FocusContext.d.ts
|
|
894
|
-
type Props$
|
|
936
|
+
type Props$11 = {
|
|
895
937
|
readonly activeId?: string;
|
|
896
938
|
readonly add: (id: string, options: {
|
|
897
939
|
autoFocus: boolean;
|
|
@@ -911,23 +953,23 @@ type Output$1 = {
|
|
|
911
953
|
/**
|
|
912
954
|
Enable focus management for all components.
|
|
913
955
|
*/
|
|
914
|
-
enableFocus: Props$
|
|
956
|
+
enableFocus: Props$11["enableFocus"];
|
|
915
957
|
/**
|
|
916
958
|
Disable focus management for all components. The currently active component (if there's one) will lose its focus.
|
|
917
959
|
*/
|
|
918
|
-
disableFocus: Props$
|
|
960
|
+
disableFocus: Props$11["disableFocus"];
|
|
919
961
|
/**
|
|
920
962
|
Switch focus to the next focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
|
|
921
963
|
*/
|
|
922
|
-
focusNext: Props$
|
|
964
|
+
focusNext: Props$11["focusNext"];
|
|
923
965
|
/**
|
|
924
966
|
Switch focus to the previous focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
|
|
925
967
|
*/
|
|
926
|
-
focusPrevious: Props$
|
|
968
|
+
focusPrevious: Props$11["focusPrevious"];
|
|
927
969
|
/**
|
|
928
970
|
Switch focus to the element with provided `id`. If there's no element with that `id`, focus is not changed.
|
|
929
971
|
*/
|
|
930
|
-
focus: Props$
|
|
972
|
+
focus: Props$11["focus"];
|
|
931
973
|
/**
|
|
932
974
|
The ID of the currently focused component, or `undefined` if no component is focused.
|
|
933
975
|
|
|
@@ -942,19 +984,19 @@ type Output$1 = {
|
|
|
942
984
|
};
|
|
943
985
|
```
|
|
944
986
|
*/
|
|
945
|
-
activeId: Props$
|
|
987
|
+
activeId: Props$11["activeId"];
|
|
946
988
|
};
|
|
947
989
|
/**
|
|
948
990
|
A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
|
|
949
991
|
*/
|
|
950
|
-
declare const useFocusManager: () => Output$1;
|
|
992
|
+
export declare const useFocusManager: () => Output$1;
|
|
951
993
|
//#endregion
|
|
952
994
|
//#region src/hooks/use-is-screen-reader-enabled.d.ts
|
|
953
995
|
/**
|
|
954
996
|
A React hook that returns whether a screen reader is enabled.
|
|
955
997
|
This is useful when you want to render different output for screen readers.
|
|
956
998
|
*/
|
|
957
|
-
declare const useIsScreenReaderEnabled: () => boolean;
|
|
999
|
+
export declare const useIsScreenReaderEnabled: () => boolean;
|
|
958
1000
|
//#endregion
|
|
959
1001
|
//#region src/hooks/use-cursor.d.ts
|
|
960
1002
|
/**
|
|
@@ -964,7 +1006,7 @@ Setting a cursor position makes the cursor visible at the specified coordinates
|
|
|
964
1006
|
|
|
965
1007
|
Pass `undefined` to hide the cursor.
|
|
966
1008
|
*/
|
|
967
|
-
declare const useCursor: () => {
|
|
1009
|
+
export declare const useCursor: () => {
|
|
968
1010
|
setCursorPosition: (position: CursorPosition | undefined) => void;
|
|
969
1011
|
};
|
|
970
1012
|
//#endregion
|
|
@@ -1016,19 +1058,19 @@ const Spinner = () => {
|
|
|
1016
1058
|
};
|
|
1017
1059
|
```
|
|
1018
1060
|
*/
|
|
1019
|
-
declare function useAnimation(options?: Options): AnimationResult;
|
|
1061
|
+
export declare function useAnimation(options?: Options): AnimationResult;
|
|
1020
1062
|
//#endregion
|
|
1021
1063
|
//#region src/hooks/use-terminal-osc.d.ts
|
|
1022
1064
|
type ProgressOptions = {
|
|
1023
1065
|
readonly state: TerminalProgressState;
|
|
1024
1066
|
readonly value?: number;
|
|
1025
1067
|
};
|
|
1026
|
-
declare const useProgress: ({ state, value }: ProgressOptions) => void;
|
|
1027
|
-
declare const useClipboard: () => ((text: string, selection?: ClipboardSelection) => void);
|
|
1028
|
-
declare const useTitle: (title?: string) => void;
|
|
1029
|
-
declare const useWorkingDirectory: (directory: URL | string) => void;
|
|
1030
|
-
declare const useNotification: () => ((title: string) => void);
|
|
1031
|
-
declare const usePointerShape: (shape: string) => void;
|
|
1068
|
+
export declare const useProgress: ({ state, value }: ProgressOptions) => void;
|
|
1069
|
+
export declare const useClipboard: () => ((text: string, selection?: ClipboardSelection) => void);
|
|
1070
|
+
export declare const useTitle: (title?: string) => void;
|
|
1071
|
+
export declare const useWorkingDirectory: (directory: URL | string) => void;
|
|
1072
|
+
export declare const useNotification: () => ((title: string) => void);
|
|
1073
|
+
export declare const usePointerShape: (shape: string) => void;
|
|
1032
1074
|
//#endregion
|
|
1033
1075
|
//#region src/hooks/use-window-size.d.ts
|
|
1034
1076
|
/**
|
|
@@ -1050,8 +1092,10 @@ A React hook that returns the current terminal window dimensions and re-renders
|
|
|
1050
1092
|
Reads the capabilities store, so on terminals that send in-band size reports
|
|
1051
1093
|
(mode 2048) the dimensions are the emulator's own, arriving after it has
|
|
1052
1094
|
rewrapped its screen; elsewhere they are the stream's `columns`/`rows`.
|
|
1095
|
+
Subscribing to dimensions does not initiate capability queries. In-band reports
|
|
1096
|
+
are used when another consumer has explicitly enabled capability discovery.
|
|
1053
1097
|
*/
|
|
1054
|
-
declare const useWindowSize: () => WindowSize;
|
|
1098
|
+
export declare const useWindowSize: () => WindowSize;
|
|
1055
1099
|
//#endregion
|
|
1056
1100
|
//#region src/hooks/use-box-metrics.d.ts
|
|
1057
1101
|
/**
|
|
@@ -1109,7 +1153,130 @@ const Example = () => {
|
|
|
1109
1153
|
};
|
|
1110
1154
|
```
|
|
1111
1155
|
*/
|
|
1112
|
-
declare const useBoxMetrics: (ref: RefObject<DOMElement | null>) => UseBoxMetricsResult;
|
|
1156
|
+
export declare const useBoxMetrics: (ref: RefObject<DOMElement | null>) => UseBoxMetricsResult;
|
|
1157
|
+
//#endregion
|
|
1158
|
+
//#region src/virtual-scroll.d.ts
|
|
1159
|
+
/**
|
|
1160
|
+
Windowing math shared by `useVirtualScroll` and `<VirtualList>`.
|
|
1161
|
+
|
|
1162
|
+
Items are stacked vertically and measured in terminal rows. The viewport shows
|
|
1163
|
+
`viewportHeight` rows of that stack starting `scrollTop` rows from the top.
|
|
1164
|
+
*/
|
|
1165
|
+
type VirtualScrollOptions = {
|
|
1166
|
+
/**
|
|
1167
|
+
Number of items in the list.
|
|
1168
|
+
*/
|
|
1169
|
+
readonly count: number;
|
|
1170
|
+
/**
|
|
1171
|
+
Height of the item at `index` in rows. It must match what the item renders:
|
|
1172
|
+
the window is computed from these numbers, never from the rendered output.
|
|
1173
|
+
*/
|
|
1174
|
+
readonly itemHeight: (index: number) => number;
|
|
1175
|
+
/**
|
|
1176
|
+
Rows available to show items.
|
|
1177
|
+
*/
|
|
1178
|
+
readonly viewportHeight: number;
|
|
1179
|
+
/**
|
|
1180
|
+
Requested distance of the viewport from the top of the list in rows. It is
|
|
1181
|
+
clamped to the scrollable range and then moved as little as necessary to keep
|
|
1182
|
+
`focusedIndex` fully visible.
|
|
1183
|
+
*/
|
|
1184
|
+
readonly scrollTop: number;
|
|
1185
|
+
/**
|
|
1186
|
+
Item that must stay fully visible. An item taller than the viewport is aligned
|
|
1187
|
+
to the top. Out-of-range values are ignored.
|
|
1188
|
+
*/
|
|
1189
|
+
readonly focusedIndex?: number;
|
|
1190
|
+
};
|
|
1191
|
+
type VirtualScrollWindow = {
|
|
1192
|
+
/**
|
|
1193
|
+
Index of the first item that intersects the viewport.
|
|
1194
|
+
*/
|
|
1195
|
+
readonly start: number;
|
|
1196
|
+
/**
|
|
1197
|
+
Index after the last item that intersects the viewport.
|
|
1198
|
+
*/
|
|
1199
|
+
readonly end: number;
|
|
1200
|
+
/**
|
|
1201
|
+
Effective distance of the viewport from the top of the list in rows.
|
|
1202
|
+
*/
|
|
1203
|
+
readonly scrollTop: number;
|
|
1204
|
+
/**
|
|
1205
|
+
Largest `scrollTop` that still fills the viewport.
|
|
1206
|
+
*/
|
|
1207
|
+
readonly maxScrollTop: number;
|
|
1208
|
+
/**
|
|
1209
|
+
Height of every item combined in rows.
|
|
1210
|
+
*/
|
|
1211
|
+
readonly totalHeight: number;
|
|
1212
|
+
/**
|
|
1213
|
+
Position of the `start` item relative to the top of the viewport. Zero or
|
|
1214
|
+
negative: a negative value means the item is partially scrolled out above.
|
|
1215
|
+
*/
|
|
1216
|
+
readonly offset: number;
|
|
1217
|
+
/**
|
|
1218
|
+
Rows scrolled out above the viewport.
|
|
1219
|
+
*/
|
|
1220
|
+
readonly hiddenAbove: number;
|
|
1221
|
+
/**
|
|
1222
|
+
Rows left below the viewport.
|
|
1223
|
+
*/
|
|
1224
|
+
readonly hiddenBelow: number;
|
|
1225
|
+
};
|
|
1226
|
+
//#endregion
|
|
1227
|
+
//#region src/hooks/use-virtual-scroll.d.ts
|
|
1228
|
+
type UseVirtualScrollOptions = Omit<VirtualScrollOptions, "scrollTop">;
|
|
1229
|
+
type UseVirtualScrollResult = VirtualScrollWindow & {
|
|
1230
|
+
/**
|
|
1231
|
+
Scroll so the viewport starts `top` rows from the top of the list.
|
|
1232
|
+
*/
|
|
1233
|
+
readonly scrollTo: (top: number) => void;
|
|
1234
|
+
/**
|
|
1235
|
+
Scroll by `delta` rows; negative values scroll up.
|
|
1236
|
+
*/
|
|
1237
|
+
readonly scrollBy: (delta: number) => void;
|
|
1238
|
+
};
|
|
1239
|
+
/**
|
|
1240
|
+
A React hook that owns the scroll position of a windowed list and returns which
|
|
1241
|
+
items to render for it. The position is clamped to the scrollable range and,
|
|
1242
|
+
while `focusedIndex` is set, moved as little as necessary to keep that item
|
|
1243
|
+
fully visible. Render the items in `[start, end)` inside an `overflowY="hidden"`
|
|
1244
|
+
box of `viewportHeight` rows, shifted up by `offset` rows.
|
|
1245
|
+
|
|
1246
|
+
`<VirtualList>` wraps this hook; use it directly to draw your own chrome such
|
|
1247
|
+
as overflow markers or a scrollbar around the window.
|
|
1248
|
+
|
|
1249
|
+
@example
|
|
1250
|
+
```tsx
|
|
1251
|
+
import { Box, Text, useVirtualScroll } from "@alchemy.run/sigil";
|
|
1252
|
+
|
|
1253
|
+
const Example = ({ lines, cursor }: { lines: string[]; cursor: number }) => {
|
|
1254
|
+
const { start, end, offset, hiddenAbove, hiddenBelow } = useVirtualScroll({
|
|
1255
|
+
count: lines.length,
|
|
1256
|
+
itemHeight: () => 1,
|
|
1257
|
+
viewportHeight: 10,
|
|
1258
|
+
focusedIndex: cursor,
|
|
1259
|
+
});
|
|
1260
|
+
|
|
1261
|
+
return (
|
|
1262
|
+
<Box flexDirection="column">
|
|
1263
|
+
<Text dimColor>{hiddenAbove > 0 ? `↑ ${hiddenAbove} more` : ""}</Text>
|
|
1264
|
+
<Box flexDirection="column" height={10} overflowY="hidden">
|
|
1265
|
+
<Box flexDirection="column" flexShrink={0} marginTop={offset}>
|
|
1266
|
+
{lines.slice(start, end).map((line, index) => (
|
|
1267
|
+
<Text key={start + index} inverse={start + index === cursor}>
|
|
1268
|
+
{line}
|
|
1269
|
+
</Text>
|
|
1270
|
+
))}
|
|
1271
|
+
</Box>
|
|
1272
|
+
</Box>
|
|
1273
|
+
<Text dimColor>{hiddenBelow > 0 ? `↓ ${hiddenBelow} more` : ""}</Text>
|
|
1274
|
+
</Box>
|
|
1275
|
+
);
|
|
1276
|
+
};
|
|
1277
|
+
```
|
|
1278
|
+
*/
|
|
1279
|
+
export declare const useVirtualScroll: (options: UseVirtualScrollOptions) => UseVirtualScrollResult;
|
|
1113
1280
|
//#endregion
|
|
1114
1281
|
//#region src/measure-element.d.ts
|
|
1115
1282
|
type Output = {
|
|
@@ -1138,6 +1305,6 @@ Returns an object with `x`, `y`, `width`, and `height` properties.
|
|
|
1138
1305
|
|
|
1139
1306
|
Note: `measureElement()` returns `{x: 0, y: 0, width: 0, height: 0}` when called during render (before layout is calculated). Call it from post-render code, such as `useEffect`, `useLayoutEffect`, input handlers, or timer callbacks. When content changes, pass the relevant dependency to your effect so it re-measures after each update.
|
|
1140
1307
|
*/
|
|
1141
|
-
declare const measureElement: (node: DOMElement) => Output;
|
|
1308
|
+
export declare const measureElement: (node: DOMElement) => Output;
|
|
1142
1309
|
//#endregion
|
|
1143
|
-
export { type AnimationResult,
|
|
1310
|
+
export { type AnimationResult, type Props as AnsiTextProps, type Props$1 as AppProps, type BoxMetrics, type Props$2 as BoxProps, type Capabilities, type CapabilitiesStore, type CapturedOutputSource, type ColorInfo, type ColorSupport, type ColorSupportLevel, type CursorPosition, type DOMElement, type Output as ElementMetrics, type Props$3 as HyperlinkProps, type Instance, type Key, type KittyFlagName, type KittyKeyboardOptions, type Multiplexer, type Props$4 as NewlineProps, type PixelGeometry, type PixelSize, type ProgressOptions, type RenderOptions, type RenderToStringOptions, type RgbColor, type Props$5 as StaticProps, type Props$6 as StderrProps, type PublicProps as StdinProps, type Props$7 as StdoutProps, type SuspendTerminal, type TerminalAppearance, type TerminalIdentity, type TerminalQueryOptions, type TerminalQueryResult, type TerminalSuspension, Text, type Props$8 as TextProps, type Props$9 as TransformProps, type UseBoxMetricsResult, type UseVirtualScrollOptions, type UseVirtualScrollResult, type Props$10 as VirtualListProps, type VirtualScrollWindow, type WindowSize, applyTerminalQuery, capabilities, createSupportsColor, detectCapabilities, detectColorLevel, detectHyperlinkSupport, detectTerminal, detectUnicodeSupport, getCapabilities, getTerminalQuery, queryTerminal, refreshTerminalQuery };
|